Initial MCMP support!
This commit is contained in:
@@ -17,7 +17,7 @@ group = "refinedstorage"
|
|||||||
archivesBaseName = "refinedstorage"
|
archivesBaseName = "refinedstorage"
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.10.2-12.18.1.2045"
|
version = "1.10.2-12.18.1.2046"
|
||||||
runDir = "run"
|
runDir = "run"
|
||||||
useDepAts = true
|
useDepAts = true
|
||||||
mappings = "snapshot_20160518"
|
mappings = "snapshot_20160518"
|
||||||
@@ -34,12 +34,16 @@ repositories {
|
|||||||
name = "ic2"
|
name = "ic2"
|
||||||
url = "http://maven.ic2.player.to/"
|
url = "http://maven.ic2.player.to/"
|
||||||
}
|
}
|
||||||
|
maven {
|
||||||
|
url "http://maven.amadornes.com/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
deobfCompile "mezz.jei:jei_1.10.2:3.7.+"
|
deobfCompile "mezz.jei:jei_1.10.2:3.7.+"
|
||||||
compile "net.darkhax.tesla:Tesla:1.10-1.2.+"
|
compile "net.darkhax.tesla:Tesla:1.10-1.2.+"
|
||||||
compile "net.industrial-craft:industrialcraft-2:2.6.27-ex110:api"
|
compile "net.industrial-craft:industrialcraft-2:2.6.27-ex110:api"
|
||||||
|
deobfCompile "MCMultiPart:MCMultiPart:1.2.+:universal"
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
|
@@ -1,19 +1,36 @@
|
|||||||
package refinedstorage.block;
|
package refinedstorage.block;
|
||||||
|
|
||||||
|
import mcmultipart.block.BlockCoverable;
|
||||||
|
import mcmultipart.block.BlockMultipartContainer;
|
||||||
|
import mcmultipart.microblock.IMicroblock;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.properties.PropertyBool;
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
import net.minecraft.block.state.BlockStateContainer;
|
import net.minecraft.block.state.BlockStateContainer;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.inventory.InventoryHelper;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.api.network.INetworkMaster;
|
import refinedstorage.api.network.INetworkMaster;
|
||||||
import refinedstorage.api.network.INetworkNode;
|
import refinedstorage.api.network.INetworkNode;
|
||||||
|
import refinedstorage.api.network.NetworkUtils;
|
||||||
import refinedstorage.tile.TileBase;
|
import refinedstorage.tile.TileBase;
|
||||||
import refinedstorage.tile.TileCable;
|
import refinedstorage.tile.TileCable;
|
||||||
|
import refinedstorage.tile.TileMultipartNode;
|
||||||
|
import refinedstorage.tile.TileNode;
|
||||||
|
|
||||||
|
public class BlockCable extends BlockCoverable {
|
||||||
|
private static final PropertyDirection DIRECTION = PropertyDirection.create("direction");
|
||||||
|
|
||||||
public class BlockCable extends BlockNode {
|
|
||||||
private static final AxisAlignedBB CABLE_AABB = new AxisAlignedBB(4 * (1F / 16F), 4 * (1F / 16F), 4 * (1F / 16F), 1 - 4 * (1F / 16F), 1 - 4 * (1F / 16F), 1 - 4 * (1F / 16F));
|
private static final AxisAlignedBB CABLE_AABB = new AxisAlignedBB(4 * (1F / 16F), 4 * (1F / 16F), 4 * (1F / 16F), 1 - 4 * (1F / 16F), 1 - 4 * (1F / 16F), 1 - 4 * (1F / 16F));
|
||||||
|
|
||||||
private static final PropertyBool NORTH = PropertyBool.create("north");
|
private static final PropertyBool NORTH = PropertyBool.create("north");
|
||||||
@@ -23,50 +40,91 @@ public class BlockCable extends BlockNode {
|
|||||||
private static final PropertyBool UP = PropertyBool.create("up");
|
private static final PropertyBool UP = PropertyBool.create("up");
|
||||||
private static final PropertyBool DOWN = PropertyBool.create("down");
|
private static final PropertyBool DOWN = PropertyBool.create("down");
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
public BlockCable(String name) {
|
public BlockCable(String name) {
|
||||||
super(name);
|
super(Material.ROCK);
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
|
||||||
setHardness(0.6F);
|
setHardness(0.6F);
|
||||||
|
setRegistryName(RefinedStorage.ID, name);
|
||||||
|
setCreativeTab(RefinedStorage.INSTANCE.tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnlocalizedName() {
|
||||||
|
return "block." + RefinedStorage.ID + ":" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockCable() {
|
public BlockCable() {
|
||||||
this("cable");
|
this("cable");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTileEntity(IBlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||||
return new TileCable();
|
return new TileCable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected BlockStateContainer createBlockState() {
|
||||||
protected BlockStateContainer.Builder createBlockStateBuilder() {
|
BlockStateContainer.Builder builder = new BlockStateContainer.Builder(this);
|
||||||
return super.createBlockStateBuilder()
|
|
||||||
.add(NORTH)
|
builder.add(NORTH)
|
||||||
.add(EAST)
|
.add(EAST)
|
||||||
.add(SOUTH)
|
.add(SOUTH)
|
||||||
.add(WEST)
|
.add(WEST)
|
||||||
.add(UP)
|
.add(UP)
|
||||||
.add(DOWN);
|
.add(DOWN)
|
||||||
|
.add(BlockMultipartContainer.PROPERTY_MULTIPART_CONTAINER);
|
||||||
|
|
||||||
|
if (getPlacementType() != null) {
|
||||||
|
builder.add(DIRECTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||||
return super.getActualState(state, world, pos)
|
state = super.getActualState(state, world, pos)
|
||||||
.withProperty(NORTH, hasConnectionWith(world, pos, pos.north()))
|
.withProperty(NORTH, hasConnectionWith(world, pos, pos.north()))
|
||||||
.withProperty(EAST, hasConnectionWith(world, pos, pos.east()))
|
.withProperty(EAST, hasConnectionWith(world, pos, pos.east()))
|
||||||
.withProperty(SOUTH, hasConnectionWith(world, pos, pos.south()))
|
.withProperty(SOUTH, hasConnectionWith(world, pos, pos.south()))
|
||||||
.withProperty(WEST, hasConnectionWith(world, pos, pos.west()))
|
.withProperty(WEST, hasConnectionWith(world, pos, pos.west()))
|
||||||
.withProperty(UP, hasConnectionWith(world, pos, pos.up()))
|
.withProperty(UP, hasConnectionWith(world, pos, pos.up()))
|
||||||
.withProperty(DOWN, hasConnectionWith(world, pos, pos.down()));
|
.withProperty(DOWN, hasConnectionWith(world, pos, pos.down()));
|
||||||
|
|
||||||
|
if (getPlacementType() != null) {
|
||||||
|
state = state.withProperty(DIRECTION, ((TileNode) world.getTileEntity(pos)).getDirection());
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasConnectionWith(IBlockAccess world, BlockPos basePos, BlockPos pos) {
|
private boolean hasConnectionWith(IBlockAccess world, BlockPos basePos, BlockPos pos) {
|
||||||
|
TileMultipartNode baseTile = (TileMultipartNode) world.getTileEntity(basePos);
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
|
||||||
if (tile instanceof INetworkMaster || tile instanceof INetworkNode) {
|
if (tile instanceof INetworkMaster || tile instanceof INetworkNode) {
|
||||||
|
// Do not render a cable extension if the tile is blocked by a multipart
|
||||||
|
for (IMicroblock microblock : baseTile.getMicroblockContainer().getParts()) {
|
||||||
|
if (microblock instanceof IMicroblock.IFaceMicroblock && baseTile.getPos().offset(((IMicroblock.IFaceMicroblock) microblock).getFace()).equals(pos)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do not render a cable extension to on this position when we have a direction (like an exporter, importer or external storage)
|
// Do not render a cable extension to on this position when we have a direction (like an exporter, importer or external storage)
|
||||||
if (getPlacementType() != null) {
|
if (getPlacementType() != null) {
|
||||||
return ((TileBase) world.getTileEntity(basePos)).getFacingTile() != tile;
|
return baseTile.getFacingTile() != tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -90,8 +148,94 @@ public class BlockCable extends BlockNode {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected EnumPlacementType getPlacementType() {
|
protected EnumPlacementType getPlacementType() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase entity) {
|
||||||
|
IBlockState state = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, entity);
|
||||||
|
|
||||||
|
if (getPlacementType() != null) {
|
||||||
|
return state.withProperty(DIRECTION, getPlacementType().getFrom(facing, entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack) {
|
||||||
|
super.onBlockPlacedBy(world, pos, state, player, stack);
|
||||||
|
|
||||||
|
if (getPlacementType() != null) {
|
||||||
|
((TileBase) world.getTileEntity(pos)).setDirection(state.getValue(DIRECTION));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
|
for (EnumFacing facing : EnumFacing.VALUES) {
|
||||||
|
TileEntity tile = world.getTileEntity(pos.offset(facing));
|
||||||
|
|
||||||
|
if (tile instanceof TileNode && ((TileNode) tile).isConnected()) {
|
||||||
|
NetworkUtils.rebuildGraph(((TileNode) tile).getNetwork());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World world, BlockPos pos, IBlockState state) {
|
||||||
|
INetworkMaster network = null;
|
||||||
|
|
||||||
|
if (!world.isRemote) {
|
||||||
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
|
|
||||||
|
if (tile instanceof TileNode) {
|
||||||
|
network = ((TileNode) tile).getNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tile instanceof TileBase && ((TileBase) tile).getDroppedItems() != null) {
|
||||||
|
IItemHandler handler = ((TileBase) tile).getDroppedItems();
|
||||||
|
|
||||||
|
for (int i = 0; i < handler.getSlots(); ++i) {
|
||||||
|
if (handler.getStackInSlot(i) != null) {
|
||||||
|
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), handler.getStackInSlot(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.breakBlock(world, pos, state);
|
||||||
|
|
||||||
|
if (network != null) {
|
||||||
|
NetworkUtils.rebuildGraph(network);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removedByPlayerDefault(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
|
||||||
|
return willHarvest ? true : super.removedByPlayerDefault(state, world, pos, player, willHarvest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void harvestBlockDefault(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tile, ItemStack stack) {
|
||||||
|
super.harvestBlockDefault(world, player, pos, state, tile, stack);
|
||||||
|
|
||||||
|
world.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean rotateBlock(World world, BlockPos pos, EnumFacing axis) {
|
||||||
|
if (!world.isRemote && getPlacementType() != null) {
|
||||||
|
TileBase tile = (TileBase) world.getTileEntity(pos);
|
||||||
|
|
||||||
|
tile.setDirection(getPlacementType().getNext(tile.getDirection()));
|
||||||
|
|
||||||
|
tile.updateBlock();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ public class BlockConstructor extends BlockCable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
|
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.CONSTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ public class BlockDestructor extends BlockCable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
|
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.DESTRUCTOR, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ public class BlockExporter extends BlockCable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ());
|
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.EXPORTER, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ public class BlockExternalStorage extends BlockCable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
|
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.STORAGE, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,8 @@ public class BlockExternalStorage extends BlockCable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block) {
|
public void onNeighborBlockChangeDefault(World world, BlockPos pos, IBlockState state, Block neighborBlock) {
|
||||||
super.neighborChanged(state, world, pos, block);
|
super.onNeighborBlockChangeDefault(world, pos, state, neighborBlock);
|
||||||
|
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
TileExternalStorage externalStorage = (TileExternalStorage) world.getTileEntity(pos);
|
TileExternalStorage externalStorage = (TileExternalStorage) world.getTileEntity(pos);
|
||||||
|
@@ -23,7 +23,7 @@ public class BlockImporter extends BlockCable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
public boolean onBlockActivatedDefault(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ());
|
player.openGui(RefinedStorage.INSTANCE, RefinedStorageGui.IMPORTER, world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
}
|
}
|
||||||
|
@@ -398,6 +398,7 @@ public class GuiGrid extends GuiBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @TODO: This is buggy...
|
||||||
public static void updateSearchFieldFocus(int mode) {
|
public static void updateSearchFieldFocus(int mode) {
|
||||||
SEARCH_FIELD.setCanLoseFocus(!TileGrid.isSearchBoxModeWithAutoselection(mode));
|
SEARCH_FIELD.setCanLoseFocus(!TileGrid.isSearchBoxModeWithAutoselection(mode));
|
||||||
SEARCH_FIELD.setFocused(TileGrid.isSearchBoxModeWithAutoselection(mode));
|
SEARCH_FIELD.setFocused(TileGrid.isSearchBoxModeWithAutoselection(mode));
|
||||||
|
@@ -1,30 +1,53 @@
|
|||||||
package refinedstorage.proxy;
|
package refinedstorage.proxy;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import com.google.common.base.Predicate;
|
||||||
|
import mcmultipart.client.multipart.ModelMultipartContainer;
|
||||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.util.BlockRenderLayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||||
import net.minecraftforge.client.model.ModelLoader;
|
import net.minecraftforge.client.model.ModelLoader;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import refinedstorage.RefinedStorage;
|
||||||
import refinedstorage.RefinedStorageBlocks;
|
import refinedstorage.RefinedStorageBlocks;
|
||||||
import refinedstorage.RefinedStorageItems;
|
import refinedstorage.RefinedStorageItems;
|
||||||
|
import refinedstorage.block.BlockCable;
|
||||||
import refinedstorage.block.EnumControllerType;
|
import refinedstorage.block.EnumControllerType;
|
||||||
import refinedstorage.block.EnumGridType;
|
import refinedstorage.block.EnumGridType;
|
||||||
import refinedstorage.block.EnumStorageType;
|
import refinedstorage.block.EnumStorageType;
|
||||||
import refinedstorage.item.*;
|
import refinedstorage.item.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy {
|
public class ClientProxy extends CommonProxy {
|
||||||
public static World getWorld() {
|
@SubscribeEvent
|
||||||
return Minecraft.getMinecraft().theWorld;
|
public void onModelBake(ModelBakeEvent e) {
|
||||||
|
System.out.println("Model bake event called.");
|
||||||
|
for (ModelResourceLocation model : e.getModelRegistry().getKeys()) {
|
||||||
|
for (BlockCable cable : cables) {
|
||||||
|
if (model.getResourceDomain().equals(RefinedStorage.ID) && model.getResourcePath().equals(cable.getName()) && !model.getVariant().equals("inventory")) {
|
||||||
|
e.getModelRegistry().putObject(model, new ModelMultipartContainer(e.getModelRegistry().getObject(model), new Predicate<BlockRenderLayer>() {
|
||||||
|
@Override
|
||||||
|
public boolean apply(@Nullable BlockRenderLayer input) {
|
||||||
|
return cable.canRenderInLayer(input);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit(FMLPreInitializationEvent e) {
|
public void preInit(FMLPreInitializationEvent e) {
|
||||||
super.preInit(e);
|
super.preInit(e);
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
|
|
||||||
// Item Variants
|
// Item Variants
|
||||||
ModelBakery.registerItemVariants(RefinedStorageItems.STORAGE_DISK,
|
ModelBakery.registerItemVariants(RefinedStorageItems.STORAGE_DISK,
|
||||||
new ResourceLocation("refinedstorage:1k_storage_disk"),
|
new ResourceLocation("refinedstorage:1k_storage_disk"),
|
||||||
|
@@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
@@ -20,10 +21,7 @@ import refinedstorage.RefinedStorageItems;
|
|||||||
import refinedstorage.api.RefinedStorageAPI;
|
import refinedstorage.api.RefinedStorageAPI;
|
||||||
import refinedstorage.apiimpl.solderer.*;
|
import refinedstorage.apiimpl.solderer.*;
|
||||||
import refinedstorage.apiimpl.storage.NBTStorage;
|
import refinedstorage.apiimpl.storage.NBTStorage;
|
||||||
import refinedstorage.block.BlockBase;
|
import refinedstorage.block.*;
|
||||||
import refinedstorage.block.EnumControllerType;
|
|
||||||
import refinedstorage.block.EnumGridType;
|
|
||||||
import refinedstorage.block.EnumStorageType;
|
|
||||||
import refinedstorage.gui.GuiHandler;
|
import refinedstorage.gui.GuiHandler;
|
||||||
import refinedstorage.item.*;
|
import refinedstorage.item.*;
|
||||||
import refinedstorage.network.*;
|
import refinedstorage.network.*;
|
||||||
@@ -32,9 +30,14 @@ import refinedstorage.tile.data.ContainerListener;
|
|||||||
import refinedstorage.tile.externalstorage.TileExternalStorage;
|
import refinedstorage.tile.externalstorage.TileExternalStorage;
|
||||||
import refinedstorage.tile.grid.TileGrid;
|
import refinedstorage.tile.grid.TileGrid;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static refinedstorage.RefinedStorage.ID;
|
import static refinedstorage.RefinedStorage.ID;
|
||||||
|
|
||||||
public class CommonProxy {
|
public class CommonProxy {
|
||||||
|
protected List<BlockCable> cables = new ArrayList<>();
|
||||||
|
|
||||||
public void preInit(FMLPreInitializationEvent e) {
|
public void preInit(FMLPreInitializationEvent e) {
|
||||||
RefinedStorageAPI.SOLDERER_REGISTRY = new SoldererRegistry();
|
RefinedStorageAPI.SOLDERER_REGISTRY = new SoldererRegistry();
|
||||||
|
|
||||||
@@ -528,6 +531,13 @@ public class CommonProxy {
|
|||||||
GameRegistry.register(block.createItem());
|
GameRegistry.register(block.createItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void registerBlock(BlockCable cable) {
|
||||||
|
GameRegistry.<Block>register(cable);
|
||||||
|
GameRegistry.register(new ItemBlock(cable).setRegistryName(cable.getRegistryName()));
|
||||||
|
|
||||||
|
cables.add(cable);
|
||||||
|
}
|
||||||
|
|
||||||
private void registerItem(Item item) {
|
private void registerItem(Item item) {
|
||||||
GameRegistry.register(item);
|
GameRegistry.register(item);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ package refinedstorage.tile;
|
|||||||
|
|
||||||
import refinedstorage.RefinedStorage;
|
import refinedstorage.RefinedStorage;
|
||||||
|
|
||||||
public class TileCable extends TileNode {
|
public class TileCable extends TileMultipartNode {
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
return RefinedStorage.INSTANCE.cableUsage;
|
return RefinedStorage.INSTANCE.cableUsage;
|
||||||
|
@@ -19,7 +19,7 @@ import refinedstorage.item.ItemUpgrade;
|
|||||||
import refinedstorage.tile.config.IComparable;
|
import refinedstorage.tile.config.IComparable;
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
|
|
||||||
public class TileConstructor extends TileNode implements IComparable {
|
public class TileConstructor extends TileMultipartNode implements IComparable {
|
||||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||||
|
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
|
@@ -20,7 +20,7 @@ import refinedstorage.tile.data.TileDataParameter;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileDestructor extends TileNode implements IComparable, IFilterable {
|
public class TileDestructor extends TileMultipartNode implements IComparable, IFilterable {
|
||||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ import refinedstorage.item.ItemUpgrade;
|
|||||||
import refinedstorage.tile.config.IComparable;
|
import refinedstorage.tile.config.IComparable;
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
|
|
||||||
public class TileExporter extends TileNode implements IComparable {
|
public class TileExporter extends TileMultipartNode implements IComparable {
|
||||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||||
|
|
||||||
private static final String NBT_COMPARE = "Compare";
|
private static final String NBT_COMPARE = "Compare";
|
||||||
|
@@ -14,7 +14,7 @@ import refinedstorage.tile.config.IComparable;
|
|||||||
import refinedstorage.tile.config.IFilterable;
|
import refinedstorage.tile.config.IFilterable;
|
||||||
import refinedstorage.tile.data.TileDataParameter;
|
import refinedstorage.tile.data.TileDataParameter;
|
||||||
|
|
||||||
public class TileImporter extends TileNode implements IComparable, IFilterable {
|
public class TileImporter extends TileMultipartNode implements IComparable, IFilterable {
|
||||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||||
|
|
||||||
|
148
src/main/java/refinedstorage/tile/TileMultipartNode.java
Executable file
148
src/main/java/refinedstorage/tile/TileMultipartNode.java
Executable file
@@ -0,0 +1,148 @@
|
|||||||
|
package refinedstorage.tile;
|
||||||
|
|
||||||
|
import mcmultipart.capabilities.ISlottedCapabilityProvider;
|
||||||
|
import mcmultipart.capabilities.MultipartCapabilityHelper;
|
||||||
|
import mcmultipart.microblock.IMicroblock;
|
||||||
|
import mcmultipart.microblock.IMicroblockContainerTile;
|
||||||
|
import mcmultipart.microblock.MicroblockContainer;
|
||||||
|
import mcmultipart.multipart.IMultipart;
|
||||||
|
import mcmultipart.multipart.PartSlot;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
|
||||||
|
public abstract class TileMultipartNode extends TileNode implements IMicroblockContainerTile, ISlottedCapabilityProvider {
|
||||||
|
private MicroblockContainer container;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World getWorldIn() {
|
||||||
|
return getWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockPos getPosIn() {
|
||||||
|
return getPos();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MicroblockContainer getMicroblockContainer() {
|
||||||
|
return container != null ? container : (container = new MicroblockContainer(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAddMicroblock(IMicroblock microblock) {
|
||||||
|
return microblock instanceof IMicroblock.IFaceMicroblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMicroblocksChanged() {
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
|
||||||
|
if (super.hasCapability(capability, facing)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MultipartCapabilityHelper.hasCapability(container, capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
|
||||||
|
T impl = super.getCapability(capability, facing);
|
||||||
|
|
||||||
|
if (impl != null) {
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MultipartCapabilityHelper.getCapability(container, capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCapability(Capability<?> capability, PartSlot slot, EnumFacing facing) {
|
||||||
|
return container.hasCapability(capability, slot, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(Capability<T> capability, PartSlot slot, EnumFacing facing) {
|
||||||
|
return container.getCapability(capability, slot, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
super.onLoad();
|
||||||
|
|
||||||
|
for (IMultipart part : getMicroblockContainer().getParts()) {
|
||||||
|
part.onLoaded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onChunkUnload() {
|
||||||
|
super.onChunkUnload();
|
||||||
|
|
||||||
|
for (IMultipart part : getMicroblockContainer().getParts()) {
|
||||||
|
part.onUnloaded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound write(NBTTagCompound tag) {
|
||||||
|
super.write(tag);
|
||||||
|
|
||||||
|
getMicroblockContainer().getPartContainer().writeToNBT(tag);
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(NBTTagCompound tag) {
|
||||||
|
super.read(tag);
|
||||||
|
|
||||||
|
getMicroblockContainer().getPartContainer().readFromNBT(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound writeUpdate(NBTTagCompound tag) {
|
||||||
|
super.writeUpdate(tag);
|
||||||
|
|
||||||
|
getMicroblockContainer().getPartContainer().writeToNBT(tag);
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readUpdate(NBTTagCompound tag) {
|
||||||
|
getMicroblockContainer().getPartContainer().readFromNBT(tag);
|
||||||
|
|
||||||
|
super.readUpdate(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRenderBreaking() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldRenderInPass(int pass) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AxisAlignedBB getRenderBoundingBox() {
|
||||||
|
AxisAlignedBB bounds = super.getRenderBoundingBox().offset(-getPosIn().getX(), -getPosIn().getY(), -getPosIn().getZ());
|
||||||
|
|
||||||
|
for (IMultipart part : getMicroblockContainer().getParts()) {
|
||||||
|
AxisAlignedBB bb = part.getRenderBoundingBox();
|
||||||
|
if (bb != null) {
|
||||||
|
bounds = bounds.union(bb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bounds.offset(getPosIn().getX(), getPosIn().getY(), getPosIn().getZ());
|
||||||
|
}
|
||||||
|
}
|
@@ -13,7 +13,7 @@ import refinedstorage.api.storage.IStorage;
|
|||||||
import refinedstorage.api.storage.IStorageProvider;
|
import refinedstorage.api.storage.IStorageProvider;
|
||||||
import refinedstorage.inventory.ItemHandlerBasic;
|
import refinedstorage.inventory.ItemHandlerBasic;
|
||||||
import refinedstorage.tile.IStorageGui;
|
import refinedstorage.tile.IStorageGui;
|
||||||
import refinedstorage.tile.TileNode;
|
import refinedstorage.tile.TileMultipartNode;
|
||||||
import refinedstorage.tile.config.IComparable;
|
import refinedstorage.tile.config.IComparable;
|
||||||
import refinedstorage.tile.config.IFilterable;
|
import refinedstorage.tile.config.IFilterable;
|
||||||
import refinedstorage.tile.config.IPrioritizable;
|
import refinedstorage.tile.config.IPrioritizable;
|
||||||
@@ -24,7 +24,7 @@ import refinedstorage.tile.data.TileDataParameter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TileExternalStorage extends TileNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable {
|
public class TileExternalStorage extends TileMultipartNode implements IStorageProvider, IStorageGui, IComparable, IFilterable, IPrioritizable {
|
||||||
public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
|
public static final TileDataParameter<Integer> PRIORITY = IPrioritizable.createParameter();
|
||||||
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
public static final TileDataParameter<Integer> COMPARE = IComparable.createParameter();
|
||||||
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
public static final TileDataParameter<Integer> MODE = IFilterable.createParameter();
|
||||||
|
Reference in New Issue
Block a user