Re-added a single mode Wrench that can rotate blocks and break Refined Storage covers.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
### 1.6.3
|
||||
- Fixed crash with Wireless Fluid Grid (raoulvdberge)
|
||||
- Re-added a single mode Wrench that can rotate blocks and break Refined Storage covers (raoulvdberge)
|
||||
|
||||
### 1.6.2
|
||||
- Fixed Grid searching not working (raoulvdberge)
|
||||
|
||||
@@ -23,4 +23,5 @@ public final class RSItems {
|
||||
public static final ItemCuttingTool CUTTING_TOOL = new ItemCuttingTool();
|
||||
public static final ItemCover COVER = new ItemCover();
|
||||
public static final ItemHollowCover HOLLOW_COVER = new ItemHollowCover();
|
||||
public static final ItemWrench WRENCH = new ItemWrench();
|
||||
}
|
||||
|
||||
@@ -63,13 +63,19 @@ public class CoverManager {
|
||||
return covers.containsKey(facing);
|
||||
}
|
||||
|
||||
public boolean setCover(EnumFacing facing, Cover cover) {
|
||||
if (isValidCover(cover.getStack()) && !hasCover(facing)) {
|
||||
public boolean setCover(EnumFacing facing, @Nullable Cover cover) {
|
||||
if (cover == null || (isValidCover(cover.getStack()) && !hasCover(facing))) {
|
||||
if (cover != null) {
|
||||
if (facing == node.getDirection() && !(node instanceof NetworkNodeCable) && cover.getType() != CoverType.HOLLOW) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (cover == null) {
|
||||
covers.remove(facing);
|
||||
} else {
|
||||
covers.put(facing, cover);
|
||||
}
|
||||
|
||||
node.markDirty();
|
||||
|
||||
@@ -84,6 +90,8 @@ public class CoverManager {
|
||||
}
|
||||
|
||||
public void readFromNbt(NBTTagList list) {
|
||||
covers.clear();
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound tag = list.getCompoundTagAt(i);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -21,7 +20,6 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -130,13 +128,7 @@ public abstract class BlockBase extends Block {
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileBase && ((TileBase) tile).getDrops() != null) {
|
||||
IItemHandler handler = ((TileBase) tile).getDrops();
|
||||
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
if (!handler.getStackInSlot(i).isEmpty()) {
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
WorldUtils.dropInventory(world, pos, ((TileBase) tile).getDrops());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ public class BlockCable extends BlockNode {
|
||||
groups.add(new CollisionGroup().addItem(CollisionUtils.getBounds(
|
||||
coverWest != null ? 2 : 0, coverDown != null ? 2 : 0, 0,
|
||||
coverEast != null ? 14 : 16, coverUp != null ? 14 : 16, 2
|
||||
)));
|
||||
)).setDirection(EnumFacing.NORTH));
|
||||
|
||||
if (coverNorth.getType() != CoverType.HOLLOW) {
|
||||
groups.add(ConstantsCable.HOLDER_NORTH);
|
||||
@@ -261,7 +261,7 @@ public class BlockCable extends BlockNode {
|
||||
groups.add(new CollisionGroup().addItem(CollisionUtils.getBounds(
|
||||
14, coverDown != null ? 2 : 0, 0,
|
||||
16, coverUp != null ? 14 : 16, 16
|
||||
)));
|
||||
)).setDirection(EnumFacing.EAST));
|
||||
|
||||
if (coverEast.getType() != CoverType.HOLLOW) {
|
||||
groups.add(ConstantsCable.HOLDER_EAST);
|
||||
@@ -272,7 +272,7 @@ public class BlockCable extends BlockNode {
|
||||
groups.add(new CollisionGroup().addItem(CollisionUtils.getBounds(
|
||||
coverEast != null ? 14 : 16, coverDown != null ? 2 : 0, 16,
|
||||
coverWest != null ? 2 : 0, coverUp != null ? 14 : 16, 14
|
||||
)));
|
||||
)).setDirection(EnumFacing.SOUTH));
|
||||
|
||||
if (coverSouth.getType() != CoverType.HOLLOW) {
|
||||
groups.add(ConstantsCable.HOLDER_SOUTH);
|
||||
@@ -283,7 +283,7 @@ public class BlockCable extends BlockNode {
|
||||
groups.add(new CollisionGroup().addItem(CollisionUtils.getBounds(
|
||||
0, coverDown != null ? 2 : 0, 0,
|
||||
2, coverUp != null ? 14 : 16, 16
|
||||
)));
|
||||
)).setDirection(EnumFacing.WEST));
|
||||
|
||||
if (coverWest.getType() != CoverType.HOLLOW) {
|
||||
groups.add(ConstantsCable.HOLDER_WEST);
|
||||
@@ -294,7 +294,7 @@ public class BlockCable extends BlockNode {
|
||||
groups.add(new CollisionGroup().addItem(CollisionUtils.getBounds(
|
||||
0, 14, 0,
|
||||
16, 16, 16
|
||||
)));
|
||||
)).setDirection(EnumFacing.UP));
|
||||
|
||||
if (coverUp.getType() != CoverType.HOLLOW) {
|
||||
groups.add(ConstantsCable.HOLDER_UP);
|
||||
@@ -305,7 +305,7 @@ public class BlockCable extends BlockNode {
|
||||
groups.add(new CollisionGroup().addItem(CollisionUtils.getBounds(
|
||||
0, 0, 0,
|
||||
16, 2, 16
|
||||
)));
|
||||
)).setDirection(EnumFacing.DOWN));
|
||||
|
||||
if (coverDown.getType() != CoverType.HOLLOW) {
|
||||
groups.add(ConstantsCable.HOLDER_DOWN);
|
||||
|
||||
@@ -150,6 +150,8 @@ public class ItemCover extends ItemBase {
|
||||
INetworkNode node = ((TileNode) tile).getNode();
|
||||
|
||||
if (node.getNetwork() != null && !node.getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.raoulvdberge.refinedstorage.item;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.api.network.security.Permission;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.ICoverable;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.cover.CoverManager;
|
||||
import com.raoulvdberge.refinedstorage.block.BlockCable;
|
||||
import com.raoulvdberge.refinedstorage.item.info.ItemInfo;
|
||||
import com.raoulvdberge.refinedstorage.render.IModelRegistration;
|
||||
import com.raoulvdberge.refinedstorage.render.collision.AdvancedRayTraceResult;
|
||||
import com.raoulvdberge.refinedstorage.render.collision.AdvancedRayTracer;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileNode;
|
||||
import com.raoulvdberge.refinedstorage.util.WorldUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class ItemWrench extends ItemBase {
|
||||
public ItemWrench() {
|
||||
super(new ItemInfo(RS.ID, "wrench"));
|
||||
|
||||
setMaxStackSize(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerModels(IModelRegistration modelRegistration) {
|
||||
modelRegistration.setModel(this, 0, new ModelResourceLocation(info.getId(), "inventory"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
||||
if (!player.isSneaking()) {
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
if (world.isRemote) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
TileEntity tile = world.getTileEntity(pos);
|
||||
|
||||
if (tile instanceof TileNode && ((TileNode) tile).getNode().getNetwork() != null && !((TileNode) tile).getNode().getNetwork().getSecurityManager().hasPermission(Permission.BUILD, player)) {
|
||||
WorldUtils.sendNoPermissionMessage(player);
|
||||
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
IBlockState state = world.getBlockState(pos);
|
||||
|
||||
Block block = state.getBlock();
|
||||
|
||||
if (block instanceof BlockCable && tile instanceof TileNode && ((TileNode) tile).getNode() instanceof ICoverable) {
|
||||
CoverManager manager = ((ICoverable) ((TileNode) tile).getNode()).getCoverManager();
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
AdvancedRayTraceResult result = AdvancedRayTracer.rayTrace(
|
||||
pos,
|
||||
AdvancedRayTracer.getStart(player),
|
||||
AdvancedRayTracer.getEnd(player),
|
||||
((BlockCable) block).getCollisions(tile, block.getActualState(state, world, pos))
|
||||
);
|
||||
|
||||
if (result != null && result.getGroup().getDirection() != null) {
|
||||
EnumFacing facingSelected = result.getGroup().getDirection();
|
||||
|
||||
if (manager.hasCover(facingSelected)) {
|
||||
ItemStack cover = manager.getCover(facingSelected).getType().createStack();
|
||||
|
||||
ItemCover.setItem(cover, manager.getCover(facingSelected).getStack());
|
||||
|
||||
manager.setCover(facingSelected, null);
|
||||
|
||||
WorldUtils.updateBlock(world, pos);
|
||||
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), cover);
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
block.rotateBlock(world, pos, player.getHorizontalFacing().getOpposite());
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -242,6 +242,7 @@ public class ProxyCommon {
|
||||
registerItem(RSItems.SECURITY_CARD);
|
||||
registerItem(RSItems.COVER);
|
||||
registerItem(RSItems.HOLLOW_COVER);
|
||||
registerItem(RSItems.WRENCH);
|
||||
|
||||
IntegrationInventorySorter.register();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
public final class AdvancedRayTracer {
|
||||
@@ -23,6 +24,7 @@ public final class AdvancedRayTracer {
|
||||
return start.add(lookVec.x * reachDistance, lookVec.y * reachDistance, lookVec.z * reachDistance);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static AdvancedRayTraceResult<RayTraceResult> rayTrace(BlockPos pos, Vec3d start, Vec3d end, Collection<CollisionGroup> groups) {
|
||||
double minDistance = Double.POSITIVE_INFINITY;
|
||||
AdvancedRayTraceResult hit = null;
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.raoulvdberge.refinedstorage.render.collision;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CollisionGroup {
|
||||
private List<AxisAlignedBB> items = new ArrayList<>();
|
||||
private boolean canAccessGui;
|
||||
@Nullable
|
||||
private EnumFacing direction;
|
||||
|
||||
public CollisionGroup addItem(AxisAlignedBB item) {
|
||||
items.add(item);
|
||||
@@ -28,4 +32,15 @@ public class CollisionGroup {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollisionGroup setDirection(EnumFacing direction) {
|
||||
this.direction = direction;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumFacing getDirection() {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -53,4 +54,12 @@ public final class WorldUtils {
|
||||
public static void sendNoPermissionMessage(EntityPlayer player) {
|
||||
player.sendMessage(new TextComponentTranslation("misc.refinedstorage:security.no_permission").setStyle(new Style().setColor(TextFormatting.RED)));
|
||||
}
|
||||
|
||||
public static void dropInventory(World world, BlockPos pos, IItemHandler handler) {
|
||||
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||
if (!handler.getStackInSlot(i).isEmpty()) {
|
||||
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,6 +289,7 @@ item.refinedstorage:upgrade.9.name=Glücksupgrade
|
||||
item.refinedstorage:storage_housing.name=Speichergehäuse
|
||||
item.refinedstorage:filter.name=Filter
|
||||
item.refinedstorage:network_card.name=Netzwerkkarte
|
||||
item.refinedstorage:wrench.name=Schraubenschlüssel
|
||||
item.refinedstorage:security_card.name=Sicherheitskarte
|
||||
item.refinedstorage:security_card.owner=Besitzer: %s
|
||||
item.refinedstorage:cutting_tool.name=Schnittwerkzeug
|
||||
|
||||
@@ -289,6 +289,7 @@ item.refinedstorage:upgrade.9.name=Fortune Upgrade
|
||||
item.refinedstorage:storage_housing.name=Storage Housing
|
||||
item.refinedstorage:filter.name=Filter
|
||||
item.refinedstorage:network_card.name=Network Card
|
||||
item.refinedstorage:wrench.name=Wrench
|
||||
item.refinedstorage:security_card.name=Security Card
|
||||
item.refinedstorage:security_card.owner=Bound to: %s
|
||||
item.refinedstorage:cutting_tool.name=Cutting Tool
|
||||
|
||||
@@ -271,6 +271,7 @@ item.refinedstorage:upgrade.9.name=Mejora de Fortuna
|
||||
item.refinedstorage:storage_housing.name=Carcasa
|
||||
item.refinedstorage:filter.name=Filtro
|
||||
item.refinedstorage:network_card.name=Tarjeta de Red
|
||||
item.refinedstorage:wrench.name=Llave inglesa
|
||||
item.refinedstorage:security_card.name=Tarjeta de Seguridad
|
||||
item.refinedstorage:security_card.owner=Designado a: %s
|
||||
|
||||
|
||||
@@ -246,6 +246,7 @@ item.refinedstorage:upgrade.7.name=Amélioration Fortune
|
||||
item.refinedstorage:storage_housing.name=Boitier de stockage
|
||||
item.refinedstorage:filter.name=Filtre
|
||||
item.refinedstorage:network_card.name=Carte réseau
|
||||
item.refinedstorage:wrench.name=Clé
|
||||
item.refinedstorage:security_card.name=Carte de sécurité
|
||||
item.refinedstorage:security_card.owner=Bound to: %s
|
||||
|
||||
|
||||
@@ -244,5 +244,6 @@ item.refinedstorage:upgrade.7.name=행운 업그레이드
|
||||
item.refinedstorage:storage_housing.name=빈 저장 디스크
|
||||
item.refinedstorage:filter.name=필터
|
||||
item.refinedstorage:network_card.name=네트워크 카드
|
||||
item.refinedstorage:wrench.name=렌치
|
||||
item.refinedstorage:security_card.name=보안 카드
|
||||
item.refinedstorage:security_card.owner=플레이어: %s
|
||||
|
||||
@@ -248,6 +248,7 @@ item.refinedstorage:upgrade.8.name=Aprimoramento de Fortuna
|
||||
item.refinedstorage:upgrade.9.name=Aprimoramento de Fortuna
|
||||
item.refinedstorage:storage_housing.name=Alojamento de Armazenação
|
||||
item.refinedstorage:filter.name=Filtro
|
||||
item.refinedstorage:wrench.name=Chave Inglesa
|
||||
item.refinedstorage:network_card.name=Cartão de Rede
|
||||
item.refinedstorage:security_card.name=Cartão de Segurança
|
||||
item.refinedstorage:security_card.owner=Ligado a: %s
|
||||
|
||||
@@ -282,6 +282,7 @@ item.refinedstorage:upgrade.9.name=Улучшение: "Удача"
|
||||
item.refinedstorage:storage_housing.name=Хранилище корпуса
|
||||
item.refinedstorage:filter.name=Фильтр
|
||||
item.refinedstorage:network_card.name=Сетевая карта
|
||||
item.refinedstorage:wrench.name=Ключ
|
||||
item.refinedstorage:security_card.name=Карточка безопасности
|
||||
item.refinedstorage:security_card.owner=Связано с: %s
|
||||
item.refinedstorage:cutting_tool.name=Режущий инструмент
|
||||
|
||||
@@ -250,5 +250,6 @@ item.refinedstorage:upgrade.9.name=时运升级
|
||||
item.refinedstorage:storage_housing.name=磁盘外壳
|
||||
item.refinedstorage:filter.name=过滤升级
|
||||
item.refinedstorage:network_card.name=网卡
|
||||
item.refinedstorage:wrench.name=扳手
|
||||
item.refinedstorage:security_card.name=权限卡
|
||||
item.refinedstorage:security_card.owner=绑定至:%s
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"parent": "item/generated",
|
||||
"textures": {
|
||||
"layer0": "refinedstorage:items/wrench"
|
||||
}
|
||||
}
|
||||
19
src/main/resources/assets/refinedstorage/recipes/wrench.json
Normal file
19
src/main/resources/assets/refinedstorage/recipes/wrench.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"type": "minecraft:crafting_shaped",
|
||||
"pattern": [
|
||||
"EPE",
|
||||
"EEE",
|
||||
" E "
|
||||
],
|
||||
"key": {
|
||||
"E": {
|
||||
"item": "refinedstorage:quartz_enriched_iron"
|
||||
},
|
||||
"P": {
|
||||
"item": "#basic_processor"
|
||||
}
|
||||
},
|
||||
"result": {
|
||||
"item": "refinedstorage:wrench"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Reference in New Issue
Block a user