remove sensitive cable
This commit is contained in:
@@ -1,12 +1,6 @@
|
|||||||
package storagecraft.block;
|
package storagecraft.block;
|
||||||
|
|
||||||
import net.minecraft.block.properties.IProperty;
|
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
|
||||||
import net.minecraft.block.state.BlockState;
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.creativetab.CreativeTabs;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import storagecraft.tile.TileCable;
|
import storagecraft.tile.TileCable;
|
||||||
@@ -15,35 +9,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class BlockCable extends BlockBase
|
public class BlockCable extends BlockBase
|
||||||
{
|
{
|
||||||
public static final PropertyBool SENSITIVE = PropertyBool.create("sensitive");
|
|
||||||
|
|
||||||
public BlockCable()
|
public BlockCable()
|
||||||
{
|
{
|
||||||
super("cable");
|
super("cable");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected BlockState createBlockState()
|
|
||||||
{
|
|
||||||
return new BlockState(this, new IProperty[]
|
|
||||||
{
|
|
||||||
DIRECTION,
|
|
||||||
SENSITIVE
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IBlockState getStateFromMeta(int meta)
|
|
||||||
{
|
|
||||||
return getDefaultState().withProperty(SENSITIVE, meta == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetaFromState(IBlockState state)
|
|
||||||
{
|
|
||||||
return ((Boolean) state.getValue(SENSITIVE)) ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasTileEntity(IBlockState state)
|
public boolean hasTileEntity(IBlockState state)
|
||||||
{
|
{
|
||||||
@@ -56,15 +26,6 @@ public class BlockCable extends BlockBase
|
|||||||
return new TileCable();
|
return new TileCable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getSubBlocks(Item item, CreativeTabs tab, List subItems)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
subItems.add(new ItemStack(item, 1, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRenderType()
|
public int getRenderType()
|
||||||
{
|
{
|
||||||
@@ -76,4 +37,10 @@ public class BlockCable extends BlockBase
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFullCube() { return false; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVisuallyOpaque() { return false; }
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
package storagecraft.item;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
|
|
||||||
public class ItemBlockCable extends ItemBlockBase
|
|
||||||
{
|
|
||||||
public ItemBlockCable(Block block)
|
|
||||||
{
|
|
||||||
super(block);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -7,10 +7,16 @@ import net.minecraft.client.resources.model.ModelBakery;
|
|||||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
import net.minecraftforge.client.MinecraftForgeClient;
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import storagecraft.StorageCraft;
|
||||||
import storagecraft.StorageCraftBlocks;
|
import storagecraft.StorageCraftBlocks;
|
||||||
import storagecraft.StorageCraftItems;
|
import storagecraft.StorageCraftItems;
|
||||||
import storagecraft.block.EnumControllerType;
|
import storagecraft.block.EnumControllerType;
|
||||||
@@ -61,12 +67,22 @@ public class ClientProxy extends CommonProxy
|
|||||||
"storagecraft:wireless_grid_disconnected"
|
"storagecraft:wireless_grid_disconnected"
|
||||||
);
|
);
|
||||||
|
|
||||||
ModelBakery.addVariantName(Item.getItemFromBlock(StorageCraftBlocks.CABLE),
|
ForgeHooksClient.registerTESRItemStack(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, TileCable.class);
|
||||||
"storagecraft:cable",
|
ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, new ModelResourceLocation("storagecraft:cable", "inventory"));
|
||||||
"storagecraft:cable_sensitive"
|
MinecraftForge.EVENT_BUS.register(BakeEventHandler.instance);
|
||||||
);
|
}
|
||||||
|
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCable.class, new BlockCableRenderer());
|
public static class BakeEventHandler
|
||||||
|
{
|
||||||
|
public static final BakeEventHandler instance = new BakeEventHandler();
|
||||||
|
|
||||||
|
public BakeEventHandler() {}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onModelBakeEvent(ModelBakeEvent event)
|
||||||
|
{
|
||||||
|
event.modelManager.getBlockModelShapes().registerBuiltInBlocks(StorageCraftBlocks.CABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,6 +90,8 @@ public class ClientProxy extends CommonProxy
|
|||||||
{
|
{
|
||||||
super.init(e);
|
super.init(e);
|
||||||
|
|
||||||
|
ClientRegistry.bindTileEntitySpecialRenderer(TileCable.class, new BlockCableRenderer());
|
||||||
|
|
||||||
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
|
||||||
|
|
||||||
// Items
|
// Items
|
||||||
@@ -128,7 +146,5 @@ public class ClientProxy extends CommonProxy
|
|||||||
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.SOLDERER), 0, new ModelResourceLocation("storagecraft:solderer", "inventory"));
|
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.SOLDERER), 0, new ModelResourceLocation("storagecraft:solderer", "inventory"));
|
||||||
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.WIRELESS_TRANSMITTER), 0, new ModelResourceLocation("storagecraft:wireless_transmitter", "inventory"));
|
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.WIRELESS_TRANSMITTER), 0, new ModelResourceLocation("storagecraft:wireless_transmitter", "inventory"));
|
||||||
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.DETECTOR), 0, new ModelResourceLocation("storagecraft:detector", "inventory"));
|
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.DETECTOR), 0, new ModelResourceLocation("storagecraft:detector", "inventory"));
|
||||||
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 0, new ModelResourceLocation("storagecraft:cable", "inventory"));
|
|
||||||
mesher.register(Item.getItemFromBlock(StorageCraftBlocks.CABLE), 1, new ModelResourceLocation("storagecraft:cable_sensitive", "inventory"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ public class CommonProxy
|
|||||||
GameRegistry.registerTileEntity(TileConstructor.class, "constructor");
|
GameRegistry.registerTileEntity(TileConstructor.class, "constructor");
|
||||||
|
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, ItemBlockController.class, "controller");
|
GameRegistry.registerBlock(StorageCraftBlocks.CONTROLLER, ItemBlockController.class, "controller");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, ItemBlockCable.class, "cable");
|
GameRegistry.registerBlock(StorageCraftBlocks.CABLE, "cable");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.GRID, ItemBlockGrid.class, "grid");
|
GameRegistry.registerBlock(StorageCraftBlocks.GRID, ItemBlockGrid.class, "grid");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.DRIVE, "drive");
|
GameRegistry.registerBlock(StorageCraftBlocks.DRIVE, "drive");
|
||||||
GameRegistry.registerBlock(StorageCraftBlocks.EXTERNAL_STORAGE, "external_storage");
|
GameRegistry.registerBlock(StorageCraftBlocks.EXTERNAL_STORAGE, "external_storage");
|
||||||
@@ -140,7 +140,7 @@ public class CommonProxy
|
|||||||
SoldererRegistry.addRecipe(new SoldererRecipeDrive());
|
SoldererRegistry.addRecipe(new SoldererRecipeDrive());
|
||||||
|
|
||||||
// Cable
|
// Cable
|
||||||
GameRegistry.addRecipe(new ItemStack(StorageCraftBlocks.CABLE, 6, 0),
|
GameRegistry.addRecipe(new ItemStack(StorageCraftBlocks.CABLE, 6),
|
||||||
"EEE",
|
"EEE",
|
||||||
"GRG",
|
"GRG",
|
||||||
"EEE",
|
"EEE",
|
||||||
@@ -149,12 +149,6 @@ public class CommonProxy
|
|||||||
'R', new ItemStack(Items.redstone)
|
'R', new ItemStack(Items.redstone)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Sensitive Cable
|
|
||||||
GameRegistry.addShapelessRecipe(new ItemStack(StorageCraftBlocks.CABLE, 1, 1),
|
|
||||||
new ItemStack(StorageCraftBlocks.CABLE, 1, 0),
|
|
||||||
new ItemStack(Items.redstone)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Grid
|
// Grid
|
||||||
GameRegistry.addRecipe(new ItemStack(StorageCraftBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
GameRegistry.addRecipe(new ItemStack(StorageCraftBlocks.GRID, 1, EnumGridType.NORMAL.getId()),
|
||||||
"ECE",
|
"ECE",
|
||||||
|
@@ -16,7 +16,7 @@ public class BlockCableRenderer extends TileEntitySpecialRenderer
|
|||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef((float) x, (float) y, (float) z);
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
|
|
||||||
CABLE_MODEL.render((TileCable) tile, 0.0625F);
|
CABLE_MODEL.render(tile);
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
|
|||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import storagecraft.tile.TileCable;
|
import storagecraft.tile.TileCable;
|
||||||
@@ -11,8 +12,6 @@ import storagecraft.tile.TileCable;
|
|||||||
public class CableModel extends ModelBase
|
public class CableModel extends ModelBase
|
||||||
{
|
{
|
||||||
public static final ResourceLocation CABLE_RESOURCE = new ResourceLocation("storagecraft:textures/blocks/cable.png");
|
public static final ResourceLocation CABLE_RESOURCE = new ResourceLocation("storagecraft:textures/blocks/cable.png");
|
||||||
public static final ResourceLocation CABLE_UNPOWERED_RESOURCE = new ResourceLocation("storagecraft:textures/blocks/cable_sensitive_unpowered.png");
|
|
||||||
public static final ResourceLocation CABLE_POWERED_RESOURCE = new ResourceLocation("storagecraft:textures/blocks/cable_sensitive_powered.png");
|
|
||||||
|
|
||||||
private ModelRenderer core;
|
private ModelRenderer core;
|
||||||
private ModelRenderer up;
|
private ModelRenderer up;
|
||||||
@@ -53,59 +52,45 @@ public class CableModel extends ModelBase
|
|||||||
west.setTextureSize(16, 16);
|
west.setTextureSize(16, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(TileCable cable, float x)
|
public void render(TileEntity tile)
|
||||||
{
|
|
||||||
if (cable.isSensitiveCable())
|
|
||||||
{
|
|
||||||
if (cable.isPowered())
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(CABLE_POWERED_RESOURCE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(CABLE_UNPOWERED_RESOURCE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(CABLE_RESOURCE);
|
Minecraft.getMinecraft().renderEngine.bindTexture(CABLE_RESOURCE);
|
||||||
}
|
|
||||||
|
|
||||||
core.render(x);
|
core.render(0.0625F);
|
||||||
|
|
||||||
if (cable.isSensitiveCable())
|
if (tile != null)
|
||||||
{
|
{
|
||||||
Minecraft.getMinecraft().renderEngine.bindTexture(CABLE_RESOURCE);
|
TileCable cable = (TileCable) tile;
|
||||||
}
|
|
||||||
|
|
||||||
if (cable.hasConnection(EnumFacing.UP))
|
if (cable.hasConnection(EnumFacing.UP))
|
||||||
{
|
{
|
||||||
up.render(x);
|
up.render(0.0625F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cable.hasConnection(EnumFacing.DOWN))
|
if (cable.hasConnection(EnumFacing.DOWN))
|
||||||
{
|
{
|
||||||
down.render(x);
|
down.render(0.0625F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cable.hasConnection(EnumFacing.NORTH))
|
if (cable.hasConnection(EnumFacing.NORTH))
|
||||||
{
|
{
|
||||||
north.render(x);
|
north.render(0.0625F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cable.hasConnection(EnumFacing.EAST))
|
if (cable.hasConnection(EnumFacing.EAST))
|
||||||
{
|
{
|
||||||
east.render(x);
|
east.render(0.0625F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cable.hasConnection(EnumFacing.SOUTH))
|
if (cable.hasConnection(EnumFacing.SOUTH))
|
||||||
{
|
{
|
||||||
south.render(x);
|
south.render(0.0625F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cable.hasConnection(EnumFacing.WEST))
|
if (cable.hasConnection(EnumFacing.WEST))
|
||||||
{
|
{
|
||||||
west.render(x);
|
west.render(0.0625F);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,39 +18,24 @@ public class TileCable extends TileBase
|
|||||||
|
|
||||||
public boolean hasConnection(EnumFacing dir)
|
public boolean hasConnection(EnumFacing dir)
|
||||||
{
|
{
|
||||||
if (!isCable(worldObj, pos.offset(dir)))
|
if (!isEnabled())
|
||||||
{
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isCable(worldObj, pos.offset(dir)))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TileEntity tile = worldObj.getTileEntity(pos.offset(dir));
|
TileEntity tile = worldObj.getTileEntity(pos.offset(dir));
|
||||||
|
|
||||||
return tile instanceof TileMachine || tile instanceof TileController;
|
return tile instanceof TileMachine || tile instanceof TileController;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPowered()
|
|
||||||
{
|
|
||||||
return worldObj.isBlockPowered(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSensitiveCable()
|
|
||||||
{
|
|
||||||
if (worldObj.getBlockState(pos).getBlock() == StorageCraftBlocks.CABLE)
|
|
||||||
{
|
|
||||||
return (Boolean) worldObj.getBlockState(pos).getValue(BlockCable.SENSITIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
if (isSensitiveCable())
|
return !worldObj.isBlockPowered(pos);
|
||||||
{
|
|
||||||
return !isPowered();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMachines(List<BlockPos> visited, List<TileMachine> machines, TileController controller)
|
public void addMachines(List<BlockPos> visited, List<TileMachine> machines, TileController controller)
|
||||||
|
@@ -59,8 +59,7 @@ sidebutton.storagecraft:detector.mode.2=Above the amount
|
|||||||
|
|
||||||
block.storagecraft:controller.0.name=Controller
|
block.storagecraft:controller.0.name=Controller
|
||||||
block.storagecraft:controller.1.name=Creative Controller
|
block.storagecraft:controller.1.name=Creative Controller
|
||||||
block.storagecraft:cable.0.name=Cable
|
block.storagecraft:cable.name=Cable
|
||||||
block.storagecraft:cable.1.name=Sensitive Cable
|
|
||||||
block.storagecraft:grid.0.name=Grid
|
block.storagecraft:grid.0.name=Grid
|
||||||
block.storagecraft:grid.1.name=Crafting Grid
|
block.storagecraft:grid.1.name=Crafting Grid
|
||||||
block.storagecraft:drive.name=Drive
|
block.storagecraft:drive.name=Drive
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "builtin/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "storagecraft:items/cable"
|
|
||||||
},
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [-90, 0, 0],
|
|
||||||
"translation": [0, 1, -3],
|
|
||||||
"scale": [0.55, 0.55, 0.55]
|
|
||||||
},
|
|
||||||
"firstperson": {
|
|
||||||
"rotation": [0, -135, 25],
|
|
||||||
"translation": [0, 4, 2],
|
|
||||||
"scale": [1.7, 1.7, 1.7]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"parent": "builtin/generated",
|
|
||||||
"textures": {
|
|
||||||
"layer0": "storagecraft:items/cable_sensitive"
|
|
||||||
},
|
|
||||||
"display": {
|
|
||||||
"thirdperson": {
|
|
||||||
"rotation": [-90, 0, 0],
|
|
||||||
"translation": [0, 1, -3],
|
|
||||||
"scale": [0.55, 0.55, 0.55]
|
|
||||||
},
|
|
||||||
"firstperson": {
|
|
||||||
"rotation": [0, -135, 25],
|
|
||||||
"translation": [0, 4, 2],
|
|
||||||
"scale": [1.7, 1.7, 1.7]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 183 B |
Binary file not shown.
Before Width: | Height: | Size: 199 B |
Reference in New Issue
Block a user