From 0ed369c0e45e3da6f470f60618dad8af3abc387d Mon Sep 17 00:00:00 2001 From: Lignum Date: Tue, 28 Mar 2017 19:25:45 +0200 Subject: [PATCH 01/36] Replace 'toRemove' pattern with Iterator.remove() calls --- .../common/tile/TileEntityDigitalMiner.java | 26 ++++++------------- .../tile/TileEntityFluidicPlenisher.java | 9 +++---- .../java/mekanism/common/util/CableUtils.java | 21 +++++---------- .../mekanism/common/util/MekanismUtils.java | 6 +---- .../java/mekanism/common/util/MinerUtils.java | 7 ++--- 5 files changed, 23 insertions(+), 46 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index a35e517ab..38a0eb191 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -188,22 +188,22 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(delay == 0) { - Set toRemove = new HashSet(); boolean did = false; - for(Chunk3D chunk : oresToMine.keySet()) + for(Iterator it = oresToMine.keySet().iterator(); it.hasNext();) { + Chunk3D chunk = it.next(); BitSet set = oresToMine.get(chunk); int next = 0; - while(true) + while(!did) { int index = set.nextSetBit(next); Coord4D coord = getCoordFromIndex(index); if(index == -1) { - toRemove.add(chunk); + it.remove(); break; } @@ -213,7 +213,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(set.cardinality() == 0) { - toRemove.add(chunk); + it.remove(); } next = index + 1; @@ -230,7 +230,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(set.cardinality() == 0) { - toRemove.add(chunk); + it.remove(); } next = index + 1; @@ -254,7 +254,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(set.cardinality() == 0) { - toRemove.add(chunk); + it.remove(); break; } @@ -272,7 +272,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I if(set.cardinality() == 0) { - toRemove.add(chunk); + it.remove(); } worldObj.playEvent(null, 2001, coord.getPos(), Block.getStateId(state)); @@ -282,16 +282,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I break; } - - if(did) - { - break; - } - } - - for(Chunk3D chunk : toRemove) - { - oresToMine.remove(chunk); } delay = getDelay(); diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java index 0a5664592..735e175c7 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java @@ -197,12 +197,9 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen toRemove.add(coord); } } - - for(Coord4D coord : toRemove) - { - activeNodes.remove(coord); - usedNodes.add(coord); - } + + usedNodes.addAll(toRemove); + activeNodes.removeAll(toRemove); } public boolean canReplace(Coord4D coord, boolean checkNodes, boolean isPathfinding) diff --git a/src/main/java/mekanism/common/util/CableUtils.java b/src/main/java/mekanism/common/util/CableUtils.java index 804417a76..f29646622 100644 --- a/src/main/java/mekanism/common/util/CableUtils.java +++ b/src/main/java/mekanism/common/util/CableUtils.java @@ -1,8 +1,6 @@ package mekanism.common.util; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; +import java.util.*; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; @@ -176,7 +174,7 @@ public final class CableUtils if(energyToSend > 0) { - List outputtingSides = new ArrayList(); + List outputtingSides = new LinkedList<>(); boolean[] connectable = getConnections((TileEntity)emitter, emitter.getOutputtingSides()); for(EnumFacing side : emitter.getOutputtingSides()) @@ -187,7 +185,7 @@ public final class CableUtils } } - if(outputtingSides.size() > 0) + if(!outputtingSides.isEmpty()) { double sent = 0; boolean tryAgain = false; @@ -214,10 +212,10 @@ public final class CableUtils double splitSend = (totalToSend-remains)/outputtingSides.size(); double sent = 0; - List toRemove = new ArrayList(); - - for(EnumFacing side : outputtingSides) + for(Iterator it = outputtingSides.iterator(); it.hasNext();) { + EnumFacing side = it.next(); + TileEntity tileEntity = Coord4D.get((TileEntity)emitter).offset(side).getTileEntity(((TileEntity)emitter).getWorld()); double toSend = splitSend+remains; remains = 0; @@ -227,15 +225,10 @@ public final class CableUtils if(sent-prev == 0) { - toRemove.add(side); + it.remove(); } } - for(EnumFacing side : toRemove) - { - outputtingSides.remove(side); - } - return sent; } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 11356f648..74e4ba3bc 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -167,11 +167,7 @@ public final class MekanismUtils public static void updateDonators() { Mekanism.donators.clear(); - - for(String s : getHTML("https://dl.dropbox.com/u/90411166/Donators/Mekanism.txt")) - { - Mekanism.donators.add(s); - } + Mekanism.donators.addAll(getHTML("https://dl.dropbox.com/u/90411166/Donators/Mekanism.txt")); } /** diff --git a/src/main/java/mekanism/common/util/MinerUtils.java b/src/main/java/mekanism/common/util/MinerUtils.java index a59de1d3f..6923c46c9 100644 --- a/src/main/java/mekanism/common/util/MinerUtils.java +++ b/src/main/java/mekanism/common/util/MinerUtils.java @@ -1,6 +1,7 @@ package mekanism.common.util; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import mekanism.api.Coord4D; @@ -22,7 +23,7 @@ public final class MinerUtils if(block == null || block.isAir(state, world, obj.getPos())) { - return new ArrayList(); + return new LinkedList<>(); } if(!silk) @@ -30,7 +31,7 @@ public final class MinerUtils return block.getDrops(world, obj.getPos(), state, 0); } else { - List ret = new ArrayList(); + List ret = new LinkedList<>(); ret.add(new ItemStack(block, 1, block.getMetaFromState(state))); if(specialSilkIDs.contains(block) || (block.getDrops(world, obj.getPos(), state, 0) != null && block.getDrops(world, obj.getPos(), state, 0).size() > 0)) @@ -39,6 +40,6 @@ public final class MinerUtils } } - return new ArrayList(); + return new LinkedList<>(); } } From b0d211582c9eb29a80b2bdb46c60064ff337ea81 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Wed, 28 Jun 2017 16:20:08 -0600 Subject: [PATCH 02/36] Fix MCMP ClassCastException and usability Fixes #4492 --- .../common/block/BlockTransmitter.java | 104 ++++++++++++------ .../multipart/MultipartGlowPanel.java | 7 ++ .../multipart/MultipartMekanism.java | 22 ++++ .../multipart/MultipartTransmitter.java | 40 +++++++ .../tile/transmitter/TileEntitySidedPipe.java | 7 ++ .../transmitter/TileEntityTransmitter.java | 7 ++ 6 files changed, 154 insertions(+), 33 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index 7b094a3fd..0419b9011 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -2,6 +2,7 @@ package mekanism.common.block; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.Random; import javax.annotation.Nullable; @@ -14,6 +15,7 @@ import mekanism.common.block.property.PropertyConnection; import mekanism.common.block.states.BlockStateTransmitter; import mekanism.common.block.states.BlockStateTransmitter.TransmitterType; import mekanism.common.block.states.BlockStateTransmitter.TransmitterType.Size; +import mekanism.common.integration.multipart.MultipartMekanism; import mekanism.common.tile.transmitter.TileEntityDiversionTransporter; import mekanism.common.tile.transmitter.TileEntityLogisticalTransporter; import mekanism.common.tile.transmitter.TileEntityMechanicalPipe; @@ -95,11 +97,10 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); - - if(tile instanceof TileEntitySidedPipe) + Optional tile = getTileEntitySidedPipe(worldIn.getTileEntity(pos)); + if(tile.isPresent()) { - state = state.withProperty(BlockStateTransmitter.tierProperty, ((TileEntitySidedPipe)tile).getBaseTier()); + state = state.withProperty(BlockStateTransmitter.tierProperty, tile.get().getBaseTier()); } return state; @@ -129,11 +130,11 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)w.getTileEntity(pos); + Optional tile = getTileEntitySidedPipe(w.getTileEntity(pos)); - if(tile != null) + if(tile.isPresent()) { - return tile.getExtendedState(state); + return tile.get().getExtendedState(state); } else { ConnectionType[] typeArray = new ConnectionType[] {ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, @@ -147,9 +148,9 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); + Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile instanceof TileEntitySidedPipe && ((TileEntitySidedPipe)tile).getTransmitterType().getSize() == Size.SMALL) + if(tile.isPresent() && tile.get().getTransmitterType().getSize() == Size.SMALL) { return smallSides[6]; } @@ -160,11 +161,11 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean b) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos); + Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile != null) + if(tile.isPresent()) { - List boxes = tile.getCollisionBoxes(entityBox.offset(-pos.getX(), -pos.getY(), -pos.getZ())); + List boxes = tile.get().getCollisionBoxes(entityBox.offset(-pos.getX(), -pos.getY(), -pos.getZ())); for(AxisAlignedBB box : boxes) { @@ -176,25 +177,25 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { - return getDefaultForTile((TileEntitySidedPipe)world.getTileEntity(pos)).offset(pos); + return getDefaultForTile(getTileEntitySidedPipe(world.getTileEntity(pos)).orElse(null)).offset(pos); } @Override public RayTraceResult collisionRayTrace(IBlockState blockState, World world, BlockPos pos, Vec3d start, Vec3d end) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos); + Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile == null) + if(!tile.isPresent()) { return null; } - List boxes = tile.getCollisionBoxes(); + List boxes = tile.get().getCollisionBoxes(); AdvancedRayTraceResult result = MultipartUtils.collisionRayTrace(pos, start, end, boxes); if(result != null && result.valid()) { - setDefaultForTile(tile, result.bounds); + setDefaultForTile(tile.get(), result.bounds); } return result != null ? result.hit : null; @@ -226,16 +227,24 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { - TileEntitySidedPipe tileEntity = (TileEntitySidedPipe)world.getTileEntity(pos); - ItemStack itemStack = new ItemStack(MekanismBlocks.Transmitter, 1, tileEntity.getTransmitterType().ordinal()); - - if(!itemStack.hasTagCompound()) + ItemStack itemStack; + Optional tileEntity = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(!tileEntity.isPresent()) { - itemStack.setTagCompound(new NBTTagCompound()); + itemStack = ItemStack.EMPTY; + } + else + { + itemStack = new ItemStack(MekanismBlocks.Transmitter, 1, tileEntity.get().getTransmitterType().ordinal()); + + if(!itemStack.hasTagCompound()) + { + itemStack.setTagCompound(new NBTTagCompound()); + } + + ITierItem tierItem = (ITierItem)itemStack.getItem(); + tierItem.setBaseTier(itemStack, tileEntity.get().getBaseTier()); } - - ITierItem tierItem = (ITierItem)itemStack.getItem(); - tierItem.setBaseTier(itemStack, tileEntity.getBaseTier()); return itemStack; } @@ -286,24 +295,33 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos); - tile.onAdded(); + Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tile.isPresent()) + { + tile.get().onAdded(); + } } @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neighbor) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos); - EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); - tile.onNeighborBlockChange(side); + Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tile.isPresent()) + { + EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); + tile.get().onNeighborBlockChange(side); + } } @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos); - EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); - tile.onNeighborTileChange(side); + Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tile.isPresent()) + { + EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); + tile.get().onNeighborTileChange(side); + } } @Override @@ -424,4 +442,24 @@ public class BlockTransmitter extends Block implements ITileEntityProvider return null; } + + private Optional getTileEntitySidedPipe(TileEntity entity) + { + if(entity instanceof TileEntitySidedPipe) + { + return Optional.of((TileEntitySidedPipe)entity); + } + else if(Mekanism.hooks.MCMPLoaded && MultipartMekanism.isMultiPartContainer(entity)) + { + for(TileEntity childEntity : MultipartMekanism.getTileEntities(entity)) + { + if(childEntity instanceof TileEntitySidedPipe) + { + return Optional.of((TileEntitySidedPipe)childEntity); + } + } + } + + return Optional.empty(); + } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java b/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java index 415a7e9aa..7a41b2b8a 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java @@ -3,7 +3,9 @@ package mekanism.common.integration.multipart; import mcmultipart.api.multipart.IMultipart; import mcmultipart.api.slot.EnumFaceSlot; import mcmultipart.api.slot.IPartSlot; +import mekanism.common.MekanismBlocks; import mekanism.common.block.states.BlockStateFacing; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.EnumFacing; @@ -24,4 +26,9 @@ public class MultipartGlowPanel implements IMultipart { return EnumFaceSlot.values()[state.getValue(BlockStateFacing.facingProperty).ordinal()]; } + + @Override + public Block getBlock() { + return MekanismBlocks.GlowPanel; + } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java index 748b72089..b88c945ce 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java @@ -3,14 +3,17 @@ package mekanism.common.integration.multipart; import static mekanism.common.block.states.BlockStateMachine.MachineBlock.MACHINE_BLOCK_1; import static mekanism.common.block.states.BlockStateMachine.MachineBlock.MACHINE_BLOCK_2; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; import mcmultipart.api.addon.IMCMPAddon; import mcmultipart.api.addon.MCMPAddon; +import mcmultipart.api.container.IMultipartContainer; import mcmultipart.api.container.IPartInfo; import mcmultipart.api.multipart.IMultipart; import mcmultipart.api.multipart.IMultipartRegistry; @@ -162,4 +165,23 @@ public class MultipartMekanism implements IMCMPAddon return Collections.emptyList(); } + + public static boolean isMultiPartContainer(TileEntity entity) + { + return entity instanceof IMultipartContainer; + } + + public static Collection getTileEntities(TileEntity container) + { + if(container instanceof IMultipartContainer) + { + return ((IMultipartContainer)container).getParts().values().stream() + .map(partInfo -> partInfo.getPart()) + .filter(part -> part instanceof MultipartTile) + .map(part -> ((MultipartTile)part).getTileEntity()) + .collect(Collectors.toList()); + } + + return new ArrayList(); + } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java index 947af9bbf..94b0beeaf 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java @@ -4,7 +4,9 @@ import mcmultipart.api.container.IPartInfo; import mcmultipart.api.multipart.IMultipart; import mcmultipart.api.slot.EnumCenterSlot; import mcmultipart.api.slot.IPartSlot; +import mekanism.common.MekanismBlocks; import mekanism.common.tile.transmitter.TileEntitySidedPipe; +import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.tileentity.TileEntity; @@ -27,6 +29,28 @@ public class MultipartTransmitter implements IMultipart return EnumCenterSlot.CENTER; } + @Override + public void onAdded(IPartInfo part) + { + TileEntity tile = part.getTile().getTileEntity(); + + if(tile instanceof TileEntitySidedPipe) + { + ((TileEntitySidedPipe)tile).onPartChanged(null); + } + } + + @Override + public void onPartAdded(IPartInfo part, IPartInfo otherPart) + { + TileEntity tile = part.getTile().getTileEntity(); + + if(tile instanceof TileEntitySidedPipe) + { + tile.validate(); + } + } + @Override public void onPartChanged(IPartInfo part, IPartInfo otherPart) { @@ -37,4 +61,20 @@ public class MultipartTransmitter implements IMultipart ((TileEntitySidedPipe)tile).onPartChanged(otherPart.getPart()); } } + + @Override + public void onPartRemoved(IPartInfo part, IPartInfo otherPart) + { + TileEntity tile = part.getTile().getTileEntity(); + + if(tile instanceof TileEntitySidedPipe) + { + ((TileEntitySidedPipe)tile).onPartChanged(otherPart.getPart()); + } + } + + @Override + public Block getBlock() { + return MekanismBlocks.Transmitter; + } } diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java b/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java index 261fd2c3d..a12465463 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java @@ -481,6 +481,13 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet super.invalidate(); } + @Override + public void validate() + { + onWorldJoin(); + super.validate(); + } + @Override public void onChunkUnload() { diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityTransmitter.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityTransmitter.java index 0b30468c7..b3f4bc1f1 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityTransmitter.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityTransmitter.java @@ -28,6 +28,8 @@ public abstract class TileEntityTransmitter> e public boolean unloaded = true; public boolean dataRequest = false; + + private N lastClientNetwork = null; public TileEntityTransmitter() { @@ -50,6 +52,10 @@ public abstract class TileEntityTransmitter> e { TransmitterNetworkRegistry.registerOrphanTransmitter(getTransmitter()); } + else if(lastClientNetwork != null) + { + getTransmitter().setTransmitterNetwork(lastClientNetwork); + } unloaded = false; } @@ -90,6 +96,7 @@ public abstract class TileEntityTransmitter> e TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); } else { + lastClientNetwork = getTransmitter().getTransmitterNetwork(); getTransmitter().setTransmitterNetwork(null); } } From 0a519ca1e7c46af911595c13a283a6e0a6ffd1df Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sun, 2 Jul 2017 17:04:02 -0600 Subject: [PATCH 03/36] Fix issue with transmitters in multiparts not dropping items when harvested --- .../integration/multipart/MultipartTransmitter.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java index 94b0beeaf..4f48cf92c 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java @@ -9,6 +9,7 @@ import mekanism.common.tile.transmitter.TileEntitySidedPipe; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -63,14 +64,18 @@ public class MultipartTransmitter implements IMultipart } @Override - public void onPartRemoved(IPartInfo part, IPartInfo otherPart) + public void onPartHarvested(IPartInfo part, EntityPlayer player) { TileEntity tile = part.getTile().getTileEntity(); if(tile instanceof TileEntitySidedPipe) { - ((TileEntitySidedPipe)tile).onPartChanged(otherPart.getPart()); + IBlockState partState = part.getState(); + partState.getBlock().removedByPlayer(partState, part.getPartWorld(), + part.getContainer().getPartPos(), player, true); } + + IMultipart.super.onPartHarvested(part, player); } @Override From e860089535a995c56dacda5225cdacc7745d4278 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 10 Jul 2017 18:19:00 +0200 Subject: [PATCH 04/36] Update BuildCraft API to 218FB4A --- src/api/java/buildcraft/api/BCBlocks.java | 122 +++++ src/api/java/buildcraft/api/BCItems.java | 167 +++++++ src/api/java/buildcraft/api/BCModules.java | 67 +++ .../api/blueprints/BlueprintDeployer.java | 30 -- .../buildcraft/api/blueprints/BuilderAPI.java | 16 - .../api/blueprints/BuildingPermission.java | 21 - .../api/blueprints/IBuilderContext.java | 22 - .../api/blueprints/ISchematicHelper.java | 7 - .../api/blueprints/ISchematicRegistry.java | 19 - .../api/blueprints/ITileBuilder.java | 13 - .../blueprints/MappingNotFoundException.java | 13 - .../api/blueprints/MappingRegistry.java | 422 ------------------ .../buildcraft/api/blueprints/Schematic.java | 196 -------- .../api/blueprints/SchematicBlock.java | 193 -------- .../api/blueprints/SchematicBlockBase.java | 9 - .../api/blueprints/SchematicEntity.java | 193 -------- .../api/blueprints/SchematicFactory.java | 51 --- .../api/blueprints/SchematicFluid.java | 83 ---- .../api/blueprints/SchematicMask.java | 83 ---- .../api/blueprints/SchematicTile.java | 109 ----- .../api/blueprints/package-info.java | 8 - .../java/buildcraft/api/core/APIHelper.java | 81 ---- .../java/buildcraft/api/core/BCDebugging.java | 4 +- .../buildcraft/api/core/BuildCraftAPI.java | 29 +- .../api/core/CapabilitiesHelper.java | 37 ++ .../buildcraft/api/core/ConfigAccessor.java | 48 -- .../api/core/EnumHandlerPriority.java | 17 + .../buildcraft/api/core/EnumPipePart.java | 53 ++- .../buildcraft/api/core/IBCFakePlayer.java | 25 -- .../buildcraft/api/core/IBuildCraftMod.java | 8 - .../java/buildcraft/api/core/IEngineType.java | 5 + .../api/core/IFakePlayerProvider.java | 40 ++ .../buildcraft/api/core/INBTLoadable_BC8.java | 14 - .../buildcraft/api/core/INBTStoreable.java | 12 - .../api/core/INetworkLoadable_BC8.java | 10 - .../{permission => core}/IPlayerOwned.java | 2 +- .../buildcraft/api/core/ISerializable.java | 21 - .../buildcraft/api/core/IStackFilter.java | 8 + .../api/core/InvalidInputDataException.java | 29 ++ .../buildcraft/api/core/render/ICullable.java | 27 -- .../api/core/render/ITextureStateManager.java | 7 - .../api/core/render/ITextureStates.java | 18 - .../buildcraft/api/crops/CropManager.java | 2 +- .../buildcraft/api/crops/ICropHandler.java | 2 - .../api/data/NbtSquishConstants.java | 50 +++ .../api/enums/EnumBlueprintType.java | 29 -- .../api/enums/EnumDecoratedBlock.java | 2 +- .../buildcraft/api/enums/EnumEngineType.java | 11 +- .../api/enums/EnumMachineState.java | 2 +- .../api/enums/EnumOptionalSnapshotType.java | 36 ++ .../api/enums/EnumRedstoneChipset.java | 23 +- .../api/enums/EnumSnapshotType.java | 12 + .../java/buildcraft/api/enums/EnumSpring.java | 9 +- .../buildcraft/api/facades/FacadeAPI.java | 26 ++ .../buildcraft/api/facades/IFacadeItem.java | 7 +- .../java/buildcraft/api/fuels/ICoolant.java | 9 +- .../buildcraft/api/fuels/ICoolantManager.java | 12 +- src/api/java/buildcraft/api/fuels/IFuel.java | 5 +- .../buildcraft/api/fuels/IFuelManager.java | 20 +- .../api/inventory/IItemTransactor.java | 72 +++ .../buildcraft/api/items/IBlueprintItem.java | 9 - .../buildcraft/api/items/IMapLocation.java | 2 +- .../buildcraft/api/library/LibraryAPI.java | 2 +- .../buildcraft/api/lists/ListRegistry.java | 4 +- .../java/buildcraft/api/mj/ILaserTarget.java | 11 +- .../java/buildcraft/api/mj/IMjReceiver.java | 11 + src/api/java/buildcraft/api/mj/MjAPI.java | 149 ++----- src/api/java/buildcraft/api/mj/MjBattery.java | 4 +- .../buildcraft/api/mj/MjCapabilityHelper.java | 32 +- .../java/buildcraft/api/mj/package-info.java | 4 +- .../buildcraft/api/permission/IOwner.java | 24 - .../BuildCraftExtendedProperty.java | 65 --- .../api/properties/BuildCraftProperties.java | 72 +-- .../api/properties/BuildCraftProperty.java | 147 ------ .../api/recipes/AssemblyRecipe.java | 107 ++--- .../api/recipes/BuildcraftRecipeRegistry.java | 2 +- .../api/recipes/IAssemblyRecipeProvider.java | 16 +- .../IComplexRefineryRecipeManager.java | 66 --- .../recipes/IIntegrationRecipeProvider.java | 12 + .../api/recipes/IRefineryRecipeManager.java | 81 ++++ .../api/recipes/IntegrationRecipe.java | 108 ++--- .../api/recipes/StackDefinition.java | 20 + .../buildcraft/api/robots/DockingStation.java | 4 +- .../buildcraft/api/robots/RobotManager.java | 24 +- .../api/schematics/ISchematicBlock.java | 46 ++ .../api/schematics/ISchematicEntity.java | 40 ++ .../api/schematics/SchematicBlockContext.java | 33 ++ .../api/schematics/SchematicBlockFactory.java | 39 ++ .../SchematicBlockFactoryRegistry.java | 65 +++ .../schematics/SchematicEntityContext.java | 24 + .../schematics/SchematicEntityFactory.java | 39 ++ .../SchematicEntityFactoryRegistry.java | 65 +++ .../buildcraft/api/statements/IGuiSlot.java | 3 +- .../api/statements/IStatementContainer.java | 3 + .../statements/ITriggerExternalOverride.java | 2 +- .../api/statements/StatementManager.java | 43 +- .../StatementParameterItemStack.java | 1 + .../java/buildcraft/api/tablet/TabletAPI.java | 2 +- .../api/template/ITemplateHandler.java | 16 + .../api/template/ITemplateRegistry.java | 25 ++ .../buildcraft/api/template/TemplateApi.java | 11 + .../buildcraft/api/tiles/IControllable.java | 21 +- .../java/buildcraft/api/tiles/IHeatable.java | 2 +- .../java/buildcraft/api/tiles/TilesAPI.java | 46 ++ .../api/transport/EnumWirePart.java | 15 +- .../buildcraft/api/transport/IInjectable.java | 1 - .../api/transport/IItemPluggable.java | 6 +- .../api/transport/IStripesRegistry.java | 41 +- .../transport/pipe/ICustomPipeConnection.java | 6 +- .../api/transport/pipe/IFlowFluid.java | 11 +- .../api/transport/pipe/IItemPipe.java | 2 +- .../buildcraft/api/transport/pipe/IPipe.java | 4 +- .../api/transport/pipe/IPipeHolder.java | 21 +- .../api/transport/pipe/PipeApi.java | 103 ++++- .../api/transport/pipe/PipeBehaviour.java | 11 +- .../api/transport/pipe/PipeConnectionAPI.java | 11 +- .../api/transport/pipe/PipeDefinition.java | 2 +- .../api/transport/pipe/PipeEvent.java | 15 +- .../api/transport/pipe/PipeEventFluid.java | 97 +++- .../api/transport/pipe/PipeEventHandler.java | 11 +- .../api/transport/pipe/PipeEventItem.java | 38 +- .../api/transport/pipe/PipeEventPriority.java | 2 +- .../api/transport/pipe/PipeFlow.java | 17 +- .../transport/pluggable/PipePluggable.java | 51 ++- .../pluggable/PluggableDefinition.java | 2 +- .../java/mekanism/common/FuelHandler.java | 6 +- .../generators/common/MekanismGenerators.java | 6 +- 127 files changed, 2015 insertions(+), 2634 deletions(-) create mode 100644 src/api/java/buildcraft/api/BCBlocks.java create mode 100644 src/api/java/buildcraft/api/BCItems.java create mode 100644 src/api/java/buildcraft/api/BCModules.java delete mode 100755 src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java delete mode 100755 src/api/java/buildcraft/api/blueprints/BuilderAPI.java delete mode 100755 src/api/java/buildcraft/api/blueprints/BuildingPermission.java delete mode 100755 src/api/java/buildcraft/api/blueprints/IBuilderContext.java delete mode 100755 src/api/java/buildcraft/api/blueprints/ISchematicHelper.java delete mode 100755 src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java delete mode 100755 src/api/java/buildcraft/api/blueprints/ITileBuilder.java delete mode 100755 src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java delete mode 100755 src/api/java/buildcraft/api/blueprints/MappingRegistry.java delete mode 100755 src/api/java/buildcraft/api/blueprints/Schematic.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicBlock.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicEntity.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicFactory.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicFluid.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicMask.java delete mode 100755 src/api/java/buildcraft/api/blueprints/SchematicTile.java delete mode 100755 src/api/java/buildcraft/api/blueprints/package-info.java delete mode 100755 src/api/java/buildcraft/api/core/APIHelper.java create mode 100644 src/api/java/buildcraft/api/core/CapabilitiesHelper.java delete mode 100755 src/api/java/buildcraft/api/core/ConfigAccessor.java create mode 100644 src/api/java/buildcraft/api/core/EnumHandlerPriority.java delete mode 100755 src/api/java/buildcraft/api/core/IBCFakePlayer.java delete mode 100755 src/api/java/buildcraft/api/core/IBuildCraftMod.java create mode 100644 src/api/java/buildcraft/api/core/IEngineType.java create mode 100644 src/api/java/buildcraft/api/core/IFakePlayerProvider.java delete mode 100755 src/api/java/buildcraft/api/core/INBTLoadable_BC8.java delete mode 100755 src/api/java/buildcraft/api/core/INBTStoreable.java delete mode 100755 src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java rename src/api/java/buildcraft/api/{permission => core}/IPlayerOwned.java (83%) mode change 100755 => 100644 delete mode 100755 src/api/java/buildcraft/api/core/ISerializable.java create mode 100644 src/api/java/buildcraft/api/core/InvalidInputDataException.java delete mode 100755 src/api/java/buildcraft/api/core/render/ICullable.java delete mode 100755 src/api/java/buildcraft/api/core/render/ITextureStateManager.java delete mode 100755 src/api/java/buildcraft/api/core/render/ITextureStates.java create mode 100644 src/api/java/buildcraft/api/data/NbtSquishConstants.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumBlueprintType.java create mode 100644 src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java create mode 100644 src/api/java/buildcraft/api/enums/EnumSnapshotType.java create mode 100644 src/api/java/buildcraft/api/inventory/IItemTransactor.java delete mode 100755 src/api/java/buildcraft/api/items/IBlueprintItem.java delete mode 100755 src/api/java/buildcraft/api/permission/IOwner.java delete mode 100755 src/api/java/buildcraft/api/properties/BuildCraftExtendedProperty.java delete mode 100755 src/api/java/buildcraft/api/properties/BuildCraftProperty.java delete mode 100755 src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java create mode 100644 src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java create mode 100644 src/api/java/buildcraft/api/recipes/StackDefinition.java create mode 100644 src/api/java/buildcraft/api/schematics/ISchematicBlock.java create mode 100644 src/api/java/buildcraft/api/schematics/ISchematicEntity.java create mode 100644 src/api/java/buildcraft/api/schematics/SchematicBlockContext.java create mode 100644 src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java create mode 100644 src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java create mode 100644 src/api/java/buildcraft/api/schematics/SchematicEntityContext.java create mode 100644 src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java create mode 100644 src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java create mode 100644 src/api/java/buildcraft/api/template/ITemplateHandler.java create mode 100644 src/api/java/buildcraft/api/template/ITemplateRegistry.java create mode 100644 src/api/java/buildcraft/api/template/TemplateApi.java create mode 100644 src/api/java/buildcraft/api/tiles/TilesAPI.java diff --git a/src/api/java/buildcraft/api/BCBlocks.java b/src/api/java/buildcraft/api/BCBlocks.java new file mode 100644 index 000000000..c864fd797 --- /dev/null +++ b/src/api/java/buildcraft/api/BCBlocks.java @@ -0,0 +1,122 @@ +package buildcraft.api; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.LoaderState; + +import buildcraft.api.core.BCDebugging; +import buildcraft.api.core.BCLog; + +/** Stores all of BuildCraft's blocks, from all of its modules. If any of them have been disabled by the user (or it the + * module is not installed) then they will be null. This is the equivalent of {@link Blocks} */ +public class BCBlocks { + private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.blocks"); + + // BC Core + public static final Block CORE_DECORATED; + public static final Block CORE_ENGINE; + public static final Block CORE_MARKER_VOLUME; + public static final Block CORE_MARKER_PATH; + + // BC Builders + + // BC Energy + + // BC Factory + public static final Block FACTORY_TANK; + public static final Block FACTORY_PUMP; + public static final Block FACTORY_CHUTE; + public static final Block FACTORY_FLOOD_GATE; + public static final Block FACTORY_MINING_WELL; + public static final Block FACTORY_AUTOWORKBENCH_ITEM; + public static final Block FACTORY_DISTILLER; + public static final Block FACTORY_HEAT_EXCHANGE_START; + public static final Block FACTORY_HEAT_EXCHANGE_MIDDLE; + public static final Block FACTORY_HEAT_EXCHANGE_END; + + // BC Robotics + + // BC Silicon + public static final Block SILICON_LASER; + public static final Block SILICON_TABLE_ASSEMBLY; + public static final Block SILICON_TABLE_INTEGRATION; + public static final Block SILICON_TABLE_ADV_CRAFT; + public static final Block SILICON_TABLE_CHARGING; + public static final Block SILICON_TABLE_PROGRAMMING; + + // BC Transport + + // Set of items scanned + private static final Set SCANNED = DEBUG ? new HashSet<>() : null; + + static { + if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) { + throw new RuntimeException("Accessed BC blocks too early! You can only use them from init onwards!"); + } + String core = "core"; + CORE_DECORATED = getRegisteredBlock(core, "decorated"); + CORE_ENGINE = getRegisteredBlock(core, "engine"); + CORE_MARKER_VOLUME = getRegisteredBlock(core, "marker_volume"); + CORE_MARKER_PATH = getRegisteredBlock(core, "marker_path"); + + String energy = "energy"; + + String factory = "factory"; + FACTORY_TANK = getRegisteredBlock(factory, "tank"); + FACTORY_PUMP = getRegisteredBlock(factory, "pump"); + FACTORY_CHUTE = getRegisteredBlock(factory, "chute"); + FACTORY_FLOOD_GATE = getRegisteredBlock(factory, "flood_gate"); + FACTORY_MINING_WELL = getRegisteredBlock(factory, "mining_well"); + FACTORY_AUTOWORKBENCH_ITEM = getRegisteredBlock(factory, "autoworkbench_item"); + FACTORY_DISTILLER = getRegisteredBlock(factory, "distiller"); + FACTORY_HEAT_EXCHANGE_START = getRegisteredBlock(factory, "heat_exchange_start"); + FACTORY_HEAT_EXCHANGE_MIDDLE = getRegisteredBlock(factory, "heat_exchange_middle"); + FACTORY_HEAT_EXCHANGE_END = getRegisteredBlock(factory, "heat_exchange_end"); + + String silicon = "silicon"; + SILICON_LASER = getRegisteredBlock(silicon, "laser"); + SILICON_TABLE_ASSEMBLY = getRegisteredBlock(silicon, "assembly_table"); + SILICON_TABLE_INTEGRATION = getRegisteredBlock(silicon, "integration_table"); + SILICON_TABLE_ADV_CRAFT = getRegisteredBlock(silicon, "advanced_crafting_table"); + SILICON_TABLE_CHARGING = getRegisteredBlock(silicon, "charging_table"); + SILICON_TABLE_PROGRAMMING = getRegisteredBlock(silicon, "programming_table"); + + if (DEBUG) { + for (Block block : Block.REGISTRY) { + ResourceLocation id = block.getRegistryName(); + if (id.getResourceDomain().startsWith("buildcraft")) { + if (!SCANNED.contains(id.toString())) { + BCLog.logger.warn("[api.blocks] Found a block " + id.toString() + " that was not registered with the API! Is this a bug?"); + } + } + } + } + } + + private static Block getRegisteredBlock(String module, String regName) { + String modid = "buildcraft" + module; + Block block = Block.REGISTRY.getObject(new ResourceLocation(modid, regName)); + + if (block != Blocks.AIR) { + if (DEBUG) { + BCLog.logger.info("[api.blocks] Found the block " + regName + " from the module " + module); + SCANNED.add(modid + ":" + regName); + } + return block; + } + if (DEBUG) { + if (Loader.isModLoaded(modid)) { + BCLog.logger.info("[api.blocks] Did not find the block " + regName + " despite the appropriate mod being loaded (" + modid + ")"); + } else { + BCLog.logger.info("[api.blocks] Did not find the block " + regName + " probably because the mod is not loaded (" + modid + ")"); + } + } + return null; + } +} diff --git a/src/api/java/buildcraft/api/BCItems.java b/src/api/java/buildcraft/api/BCItems.java new file mode 100644 index 000000000..2497aff15 --- /dev/null +++ b/src/api/java/buildcraft/api/BCItems.java @@ -0,0 +1,167 @@ +package buildcraft.api; + +import java.util.HashSet; +import java.util.Set; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.LoaderState; + +import buildcraft.api.core.BCDebugging; +import buildcraft.api.core.BCLog; + +/** Stores all of BuildCraft's items, from all of its modules. If any of them have been disabled by the user (or it the + * module is not installed) then they will be null. This is the equivalent of {@link Items} */ +public class BCItems { + private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.items"); + + // The (optional) items in BC LIB, and has other rules for when they are enabled. + public static final Item LIB_GUIDE; + public static final Item LIB_DEBUGGER; + + // BC Core + public static final Item CORE_WRENCH; + public static final Item CORE_DIAMOND_SHARD; + public static final Item CORE_LIST; + public static final Item CORE_MAP_LOCATION; + public static final Item CORE_PAINTBRUSH; + public static final Item CORE_GEAR_WOOD; + public static final Item CORE_GEAR_STONE; + public static final Item CORE_GEAR_IRON; + public static final Item CORE_GEAR_GOLD; + public static final Item CORE_GEAR_DIAMOND; + public static final Item CORE_MARKER_CONNECTOR; + public static final Item CORE_GOGGLES; + + // BC Builders + public static final Item BUILDERS_SINGLE_SCHEMATIC; + public static final Item BUILDERS_SNAPSHOT; + + // BC Energy + public static final Item ENERGY_GLOB_OF_OIL; + + // BC Factory + public static final Item FACTORY_PLASTIC_SHEET; + + // BC Robotics + public static final Item ROBOTICS_REDSTONE_BOARD; + public static final Item ROBOTICS_ROBOT; + public static final Item ROBOTICS_ROBOT_GOGGLES; + public static final Item ROBOTICS_PLUGGABLE_ROBOT_STATION; + + // BC Silicon + public static final Item SILICON_REDSTONE_CHIPSET; + + // BC Transport + public static final Item TRANSPORT_WATERPROOF; + public static final Item TRANSPORT_GATE_COPIER; + public static final Item TRANSPORT_PLUGGABLE_GATE; + public static final Item TRANSPORT_PLUGGABLE_WIRE; + public static final Item TRANSPORT_PLUGGABLE_BLOCKER; + public static final Item TRANSPORT_PLUGGABLE_LENS; + public static final Item TRANSPORT_PLUGGABLE_POWER_ADAPTOR; + public static final Item TRANSPORT_PLUGGABLE_FACADE; + + public static final Item TRANSPORT_PIPE_WOOD_ITEM; + public static final Item TRANSPORT_PIPE_WOOD_FLUID; + public static final Item TRANSPORT_PIPE_WOOD_POWER; + + // ... a few more needed... + + public static final Item TRANSPORT_PIPE_DIAMOND_ITEM; + + // Set of items scanned + private static final Set SCANNED = DEBUG ? new HashSet<>() : null; + + static { + if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) { + throw new RuntimeException("Accessed BC items too early! You can only use them from init onwards!"); + } + final String lib = "lib"; + LIB_GUIDE = getRegisteredItem(lib, "guide"); + LIB_DEBUGGER = getRegisteredItem(lib, "debugger"); + + final String core = "core"; + CORE_WRENCH = getRegisteredItem(core, "wrench"); + CORE_DIAMOND_SHARD = getRegisteredItem(core, "diamond_shard"); + CORE_LIST = getRegisteredItem(core, "list"); + CORE_MAP_LOCATION = getRegisteredItem(core, "map_location"); + CORE_PAINTBRUSH = getRegisteredItem(core, "paintbrush"); + CORE_GEAR_WOOD = getRegisteredItem(core, "gear_wood"); + CORE_GEAR_STONE = getRegisteredItem(core, "gear_stone"); + CORE_GEAR_IRON = getRegisteredItem(core, "gear_iron"); + CORE_GEAR_GOLD = getRegisteredItem(core, "gear_gold"); + CORE_GEAR_DIAMOND = getRegisteredItem(core, "gear_diamond"); + CORE_MARKER_CONNECTOR = getRegisteredItem(core, "marker_connector"); + CORE_GOGGLES = getRegisteredItem(core, "goggles"); + + final String builders = "builders"; + BUILDERS_SINGLE_SCHEMATIC = getRegisteredItem(builders, "single_schematic"); + BUILDERS_SNAPSHOT = getRegisteredItem(builders, "snapshot"); + + final String energy = "energy"; + ENERGY_GLOB_OF_OIL = getRegisteredItem(energy, "glob_oil"); + + final String factory = "factory"; + FACTORY_PLASTIC_SHEET = getRegisteredItem(factory, "plastic_sheet"); + + final String robotics = "robotics"; + ROBOTICS_REDSTONE_BOARD = getRegisteredItem(robotics, "redstone_board"); + ROBOTICS_ROBOT = getRegisteredItem(robotics, "robot"); + ROBOTICS_PLUGGABLE_ROBOT_STATION = getRegisteredItem(robotics, "robot_station"); + ROBOTICS_ROBOT_GOGGLES = getRegisteredItem(robotics, "robot_goggles"); + + final String silicon = "silicon"; + SILICON_REDSTONE_CHIPSET = getRegisteredItem(silicon, "redstone_chipset"); + + final String transport = "transport"; + TRANSPORT_WATERPROOF = getRegisteredItem(transport, "waterproof"); + TRANSPORT_GATE_COPIER = getRegisteredItem(transport, "gate_copier"); + TRANSPORT_PLUGGABLE_GATE = getRegisteredItem(transport, "plug_gate"); + TRANSPORT_PLUGGABLE_WIRE = getRegisteredItem(transport, "plug_wire"); + TRANSPORT_PLUGGABLE_BLOCKER = getRegisteredItem(transport, "plug_blocker"); + TRANSPORT_PLUGGABLE_LENS = getRegisteredItem(transport, "plug_lens"); + TRANSPORT_PLUGGABLE_FACADE = getRegisteredItem(transport, "plug_facade"); + TRANSPORT_PLUGGABLE_POWER_ADAPTOR = getRegisteredItem(transport, "plug_power_adapter"); + TRANSPORT_PIPE_WOOD_ITEM = getRegisteredItem(transport, "pipe_wood_item"); + TRANSPORT_PIPE_WOOD_FLUID = getRegisteredItem(transport, "pipe_wood_fluid"); + TRANSPORT_PIPE_WOOD_POWER = getRegisteredItem(transport, "pipe_wood_power"); + + TRANSPORT_PIPE_DIAMOND_ITEM = getRegisteredItem(transport, "pipe_diamond_item"); + + if (DEBUG) { + for (Item item : Item.REGISTRY) { + ResourceLocation id = item.getRegistryName(); + if (id.getResourceDomain().startsWith("buildcraft")) { + if (!SCANNED.contains(id.toString())) { + BCLog.logger.warn("[api.items] Found an item " + id.toString() + " that was not registered with the API! Is this a bug?"); + } + } + } + } + } + + private static Item getRegisteredItem(String module, String regName) { + String modid = "buildcraft" + module; + Item item = Item.REGISTRY.getObject(new ResourceLocation(modid, regName)); + if (item != null) { + if (DEBUG) { + BCLog.logger.info("[api.items] Found the item " + regName + " from the module " + module); + SCANNED.add(modid + ":" + regName); + } + return item; + } + if (DEBUG) { + if (Loader.isModLoaded(modid)) { + BCLog.logger.info("[api.items] Did not find the item " + regName + " despite the appropriate mod being loaded (" + modid + ")"); + } else { + BCLog.logger.info("[api.items] Did not find the item " + regName + " probably because the mod is not loaded (" + modid + ")"); + } + } + + return null; + } +} diff --git a/src/api/java/buildcraft/api/BCModules.java b/src/api/java/buildcraft/api/BCModules.java new file mode 100644 index 000000000..73e769690 --- /dev/null +++ b/src/api/java/buildcraft/api/BCModules.java @@ -0,0 +1,67 @@ +package buildcraft.api; + +import java.util.Locale; + +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.LoaderState; + +import buildcraft.api.core.BCLog; + +public enum BCModules { + LIB, + // Base module for all BC. + CORE, + // Potentially optional modules for adding more BC functionality + BUILDERS, + ENERGY, + FACTORY, + ROBOTICS, + SILICON, + TRANSPORT, + // Optional module for compatibility with other mods + COMPAT; + + public static final BCModules[] VALUES = values(); + + private static final String MODID_START = "buildcraft"; + private final String modid, part; + + BCModules() { + part = name().toLowerCase(Locale.ROOT); + this.modid = MODID_START + part; + } + + public static void fmlPreInit() {} + + public static boolean isBcMod(String modid) { + if (!modid.startsWith(MODID_START)) return false; + String post = modid.substring(MODID_START.length()); + for (BCModules module : VALUES) { + if (post.equals(module.part)) { + return true; + } + } + return false; + } + + public boolean isLoaded() { + return Loader.isModLoaded(modid); + } + + public String getModId() { + return modid; + } + + static { + if (!Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { + throw new RuntimeException("Accessed BC modules too early! You can only use them from construction onwards!"); + } + for (BCModules module : values()) { + if (module.isLoaded()) { + BCLog.logger.info("[api.modules] Module " + module.name().toLowerCase(Locale.ROOT) + " is loaded!"); + } else { + BCLog.logger.warn("[api.modules] Module " + module.name().toLowerCase(Locale.ROOT) + " is NOT loaded!"); + } + } + } +} diff --git a/src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java b/src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java deleted file mode 100755 index dad91b98f..000000000 --- a/src/api/java/buildcraft/api/blueprints/BlueprintDeployer.java +++ /dev/null @@ -1,30 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import java.io.File; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -/** This class is provided as a utility class for third-party mods that would like to easily deploy structures that are - * written in blueprints. It does not offer control on material that needs to get in, or how the structure is deployed, - * but allows to create contents of a blueprint in one cycle. Note that these functionalities will only work if - * BuildCraft is installed. */ -public abstract class BlueprintDeployer { - - /** The deployed instantiated by BuildCraft. This is set by the BuildCraft builder mod. Mods that want to work with - * BuildCraft not installed should check for this value to be not null. */ - public static BlueprintDeployer instance; - - /** Deploy the contents of the blueprints as if the builder was located at {pos} facing the direction dir. */ - public abstract void deployBlueprint(World world, BlockPos pos, EnumFacing facing, File file); - - /** Deploy the contents of the byte array as if the builder was located at {pos} facing the direction dir. */ - - public abstract void deployBlueprintFromFileStream(World world, BlockPos pos, EnumFacing dir, byte[] data); - -} diff --git a/src/api/java/buildcraft/api/blueprints/BuilderAPI.java b/src/api/java/buildcraft/api/blueprints/BuilderAPI.java deleted file mode 100755 index ac15b474b..000000000 --- a/src/api/java/buildcraft/api/blueprints/BuilderAPI.java +++ /dev/null @@ -1,16 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -public final class BuilderAPI { - public static ISchematicRegistry schematicRegistry; - public static ISchematicHelper schematicHelper; - - private static final long MJ = 1000 * 1000; - public static final long BREAK_POWER = 16 * MJ;// micro Mj - public static final long BUILD_POWER = 24 * MJ;// micro Mj - - private BuilderAPI() {} -} diff --git a/src/api/java/buildcraft/api/blueprints/BuildingPermission.java b/src/api/java/buildcraft/api/blueprints/BuildingPermission.java deleted file mode 100755 index 8661240c4..000000000 --- a/src/api/java/buildcraft/api/blueprints/BuildingPermission.java +++ /dev/null @@ -1,21 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -/** Schematics recorded in the blueprints can restrict situations where a blueprint can be used. A same schematic class - * can have different permissions depending on its contents. It's particularly useful when fixing a schematic, if - * blueprints that saved the previous version should not be built because of a bug (such as dupe bug on inventories). */ -public enum BuildingPermission { - /** No restrictions, blueprints using this schematic are good in all contexts. */ - ALL, - - /** This blueprints containing this schematic can only be used in creative. Maybe the block can't be crafted in - * survival in the first place, or the content of the schematic is known to have dupe bugs. */ - CREATIVE_ONLY, - - /** Blueprints containing this schematic should not be built. This is typically used when a critical problems have - * been fixed, but older versions of the schematic are too badly broken to be retreived. */ - NONE, -} diff --git a/src/api/java/buildcraft/api/blueprints/IBuilderContext.java b/src/api/java/buildcraft/api/blueprints/IBuilderContext.java deleted file mode 100755 index e5eb8900b..000000000 --- a/src/api/java/buildcraft/api/blueprints/IBuilderContext.java +++ /dev/null @@ -1,22 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -import buildcraft.api.core.IBox; - -/** This interface provide contextual information when building or initializing blueprint slots. */ -public interface IBuilderContext { - - Vec3d rotatePositionLeft(Vec3d pos); - - IBox surroundingBox(); - - World world(); - - MappingRegistry getMappingRegistry(); -} diff --git a/src/api/java/buildcraft/api/blueprints/ISchematicHelper.java b/src/api/java/buildcraft/api/blueprints/ISchematicHelper.java deleted file mode 100755 index 7327f2e20..000000000 --- a/src/api/java/buildcraft/api/blueprints/ISchematicHelper.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.blueprints; - -import net.minecraft.item.ItemStack; - -public interface ISchematicHelper { - boolean isEqualItem(ItemStack a, ItemStack b); -} diff --git a/src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java b/src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java deleted file mode 100755 index 503c315d5..000000000 --- a/src/api/java/buildcraft/api/blueprints/ISchematicRegistry.java +++ /dev/null @@ -1,19 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.Entity; - -public interface ISchematicRegistry { - void registerSchematicBlock(Block block, Class clazz, Object... params); - - void registerSchematicBlock(IBlockState state, Class clazz, Object... params); - - void registerSchematicEntity(Class entityClass, Class schematicClass, Object... params); - - boolean isSupported(IBlockState state); -} diff --git a/src/api/java/buildcraft/api/blueprints/ITileBuilder.java b/src/api/java/buildcraft/api/blueprints/ITileBuilder.java deleted file mode 100755 index 2c06f64c3..000000000 --- a/src/api/java/buildcraft/api/blueprints/ITileBuilder.java +++ /dev/null @@ -1,13 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.inventory.IInventory; - -public interface ITileBuilder extends IInventory { - - boolean isBuildingMaterialSlot(int i); - -} diff --git a/src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java b/src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java deleted file mode 100755 index f84cee627..000000000 --- a/src/api/java/buildcraft/api/blueprints/MappingNotFoundException.java +++ /dev/null @@ -1,13 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -public class MappingNotFoundException extends Exception { - private static final long serialVersionUID = 1L; - - public MappingNotFoundException(String msg) { - super(msg); - } -} diff --git a/src/api/java/buildcraft/api/blueprints/MappingRegistry.java b/src/api/java/buildcraft/api/blueprints/MappingRegistry.java deleted file mode 100755 index d2d9b9060..000000000 --- a/src/api/java/buildcraft/api/blueprints/MappingRegistry.java +++ /dev/null @@ -1,422 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map.Entry; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ListMultimap; - -import org.apache.logging.log4j.Level; - -import net.minecraft.block.Block; -import net.minecraft.crash.CrashReportCategory; -import net.minecraft.entity.Entity; -import net.minecraft.item.Item; -import net.minecraft.nbt.NBTTagByte; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.nbt.NBTTagShort; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fml.common.FMLModContainer; -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; -import net.minecraftforge.fml.common.event.FMLMissingMappingsEvent; -import net.minecraftforge.fml.common.registry.GameRegistry; - -import buildcraft.api.core.BCLog; - -public class MappingRegistry { - - public HashMap blockToId = new HashMap(); - public ArrayList idToBlock = new ArrayList(); - - public HashMap itemToId = new HashMap(); - public ArrayList idToItem = new ArrayList(); - - public HashMap, Integer> entityToId = new HashMap, Integer>(); - public ArrayList> idToEntity = new ArrayList>(); - - private void registerItem(Item item) { - if (item == null) throw new IllegalArgumentException("Cannot register a null item!"); - if (!itemToId.containsKey(item)) { - idToItem.add(item); - itemToId.put(item, idToItem.size() - 1); - } - } - - private void registerBlock(Block block) { - if (block == null) throw new IllegalArgumentException("Cannot register a null block!"); - if (!blockToId.containsKey(block)) { - idToBlock.add(block); - blockToId.put(block, idToBlock.size() - 1); - } - } - - private void registerEntity(Class entityClass) { - if (entityClass == null) throw new IllegalArgumentException("Cannot register a null entityClass!"); - if (!entityToId.containsKey(entityClass)) { - idToEntity.add(entityClass); - entityToId.put(entityClass, idToEntity.size() - 1); - } - } - - public Item getItemForId(int id) throws MappingNotFoundException { - if (id >= idToItem.size()) { - throw new MappingNotFoundException("no item mapping at position " + id); - } - - Item result = idToItem.get(id); - - if (result == null) { - throw new MappingNotFoundException("no item mapping at position " + id); - } else { - return result; - } - } - - public int getIdForItem(Item item) { - if (item == null) throw new NullPointerException("item"); - if (!itemToId.containsKey(item)) { - registerItem(item); - } - - return itemToId.get(item); - } - - public int itemIdToRegistry(int id) { - Item item = Item.getItemById(id); - - return getIdForItem(item); - } - - public ResourceLocation itemIdToWorld(int id) throws MappingNotFoundException { - Item item = getItemForId(id); - - return Item.REGISTRY.getNameForObject(item); - } - - public Block getBlockForId(int id) throws MappingNotFoundException { - if (id >= idToBlock.size()) { - throw new MappingNotFoundException("no block mapping at position " + id); - } - - Block result = idToBlock.get(id); - - if (result == null) { - throw new MappingNotFoundException("no block mapping at position " + id); - } else { - return result; - } - } - - public int getIdForBlock(Block block) { - if (!blockToId.containsKey(block)) { - registerBlock(block); - } - - return blockToId.get(block); - } - - public int blockIdToRegistry(int id) { - Block block = Block.getBlockById(id); - - return getIdForBlock(block); - } - - public ResourceLocation blockIdToWorld(int id) throws MappingNotFoundException { - Block block = getBlockForId(id); - - return Block.REGISTRY.getNameForObject(block); - } - - public Class getEntityForId(int id) throws MappingNotFoundException { - if (id >= idToEntity.size()) { - throw new MappingNotFoundException("no entity mapping at position " + id); - } - - Class result = idToEntity.get(id); - - if (result == null) { - throw new MappingNotFoundException("no entity mapping at position " + id); - } else { - return result; - } - } - - public int getIdForEntity(Class entity) { - if (!entityToId.containsKey(entity)) { - registerEntity(entity); - } - - return entityToId.get(entity); - } - - /** Relocates a stack nbt from the registry referential to the world referential. */ - public void stackToWorld(NBTTagCompound nbt) throws MappingNotFoundException { - if (nbt.hasKey("id", Constants.NBT.TAG_SHORT)) { - Item item = getItemForId(nbt.getShort("id")); - nbt.setString("id", (item.getRegistryName().toString())); - } - } - - // versions before 1.8 saved stacks with an Item ID as a short - private boolean isOldStackLayout(NBTTagCompound nbt) { - return nbt.hasKey("id") && nbt.hasKey("Count") && nbt.hasKey("Damage") && nbt.getTag("id") instanceof NBTTagShort && nbt.getTag( - "Count") instanceof NBTTagByte && nbt.getTag("Damage") instanceof NBTTagShort; - } - - public void scanAndTranslateStacksToWorld(NBTTagCompound nbt) throws MappingNotFoundException { - // First, check if this nbt is itself a stack - - if (isOldStackLayout(nbt)) { - stackToWorld(nbt); - } - - // Then, look at the nbt compound contained in this nbt (even if it's a - // stack) and checks for stacks in it. - for (String key : (Collection) nbt.getKeySet()) { - if (nbt.getTag(key) instanceof NBTTagCompound) { - try { - scanAndTranslateStacksToWorld(nbt.getCompoundTag(key)); - } catch (MappingNotFoundException e) { - nbt.removeTag(key); - } - } - - if (nbt.getTag(key) instanceof NBTTagList) { - NBTTagList list = (NBTTagList) nbt.getTag(key); - - if (list.getTagType() == Constants.NBT.TAG_COMPOUND) { - for (int i = list.tagCount() - 1; i >= 0; --i) { - try { - scanAndTranslateStacksToWorld(list.getCompoundTagAt(i)); - } catch (MappingNotFoundException e) { - list.removeTag(i); - } - } - } - } - } - } - - public void write(NBTTagCompound nbt) { - NBTTagList blocksMapping = new NBTTagList(); - - for (Block b : idToBlock) { - NBTTagCompound sub = new NBTTagCompound(); - if (b != null) { - Object obj = Block.REGISTRY.getNameForObject(b); - if (obj == null) { - BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() - + ") does not have a registry name! This is a bug!"); - } else { - String name = obj.toString(); - if (name == null || name.length() == 0) { - BCLog.logger.error("Block " + b.getUnlocalizedName() + " (" + b.getClass().getName() - + ") has an empty registry name! This is a bug!"); - } else { - sub.setString("name", name); - } - } - } else { - throw new IllegalArgumentException("Found a null block!"); - } - blocksMapping.appendTag(sub); - } - - nbt.setTag("blocksMapping", blocksMapping); - - NBTTagList itemsMapping = new NBTTagList(); - - for (Item i : idToItem) { - NBTTagCompound sub = new NBTTagCompound(); - if (i != null) { - ResourceLocation obj = Item.REGISTRY.getNameForObject(i); - if (obj == null) { - BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() - + ") does not have a registry name! This is a bug!"); - } else { - String name = obj.toString(); - if (name == null || name.length() == 0) { - BCLog.logger.error("Item " + i.getUnlocalizedName() + " (" + i.getClass().getName() - + ") has an empty registry name! This is a bug!"); - } else { - sub.setString("name", name); - } - } - } else { - throw new IllegalArgumentException("Found a null item!"); - } - itemsMapping.appendTag(sub); - } - - nbt.setTag("itemsMapping", itemsMapping); - - NBTTagList entitiesMapping = new NBTTagList(); - - for (Class e : idToEntity) { - NBTTagCompound sub = new NBTTagCompound(); - sub.setString("name", e.getCanonicalName()); - entitiesMapping.appendTag(sub); - } - - nbt.setTag("entitiesMapping", entitiesMapping); - - // System.out.println("[W] idToItem size : " + idToItem.size()); - // for (Item i : idToItem) { - // System.out.println("- " + (i != null ? i.toString() : "null")); - // } - } - - private Object getMissingMappingFromFML(boolean isBlock, String name, int i) { - ResourceLocation location = new ResourceLocation(name); - String modName = name.split(":")[0]; - if (Loader.isModLoaded(modName)) { - try { - FMLMissingMappingsEvent.MissingMapping mapping = new FMLMissingMappingsEvent.MissingMapping(isBlock ? GameRegistry.Type.BLOCK - : GameRegistry.Type.ITEM, location, i); - ListMultimap missingMapping = ArrayListMultimap.create(); - missingMapping.put(modName, mapping); - FMLMissingMappingsEvent event = new FMLMissingMappingsEvent(missingMapping); - for (ModContainer container : Loader.instance().getModList()) { - if (container instanceof FMLModContainer) { - event.applyModContainer(container); - ((FMLModContainer) container).handleModStateEvent(event); - if (mapping.getAction() != FMLMissingMappingsEvent.Action.DEFAULT) { - break; - } - } - } - if (mapping.getAction() == FMLMissingMappingsEvent.Action.REMAP) { - return mapping.getTarget(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - return null; - } - - public void read(NBTTagCompound nbt) { - NBTTagList blocksMapping = nbt.getTagList("blocksMapping", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < blocksMapping.tagCount(); ++i) { - NBTTagCompound sub = blocksMapping.getCompoundTagAt(i); - if (!sub.hasKey("name")) { - // Keeping the order correct - idToBlock.add(null); - BCLog.logger.log(Level.WARN, "Can't load a block - corrupt blueprint!"); - continue; - } - String name = sub.getString("name"); - ResourceLocation location = new ResourceLocation(name); - Block b = null; - - if (!Block.REGISTRY.containsKey(location) && name.contains(":")) { - b = (Block) getMissingMappingFromFML(true, name, i); - if (b != null) { - BCLog.logger.info("Remapped " + name + " to " + Block.REGISTRY.getNameForObject(b)); - } - } - - if (b == null && Block.REGISTRY.containsKey(location)) { - b = (Block) Block.REGISTRY.getObject(location); - } - - if (b != null) { - registerBlock(b); - } else { - // Keeping the order correct - idToBlock.add(null); - BCLog.logger.log(Level.WARN, "Can't load block " + name); - } - } - - NBTTagList itemsMapping = nbt.getTagList("itemsMapping", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < itemsMapping.tagCount(); ++i) { - NBTTagCompound sub = itemsMapping.getCompoundTagAt(i); - if (!sub.hasKey("name")) { - // Keeping the order correct - idToItem.add(null); - BCLog.logger.log(Level.WARN, "Can't load an item - corrupt blueprint!"); - continue; - } - - String name = sub.getString("name"); - ResourceLocation location = new ResourceLocation(name); - Item item = null; - - if (!Item.REGISTRY.containsKey(location) && name.contains(":")) { - item = (Item) getMissingMappingFromFML(false, name, i); - if (item != null) { - BCLog.logger.info("Remapped " + name + " to " + Item.REGISTRY.getNameForObject(item)); - } - } - - if (item == null && Item.REGISTRY.containsKey(location)) { - item = (Item) Item.REGISTRY.getObject(location); - } - - if (item != null) { - registerItem(item); - } else { - // Keeping the order correct - idToItem.add(null); - BCLog.logger.log(Level.WARN, "Can't load item " + name); - } - } - - NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < entitiesMapping.tagCount(); ++i) { - NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i); - String name = sub.getString("name"); - Class e = null; - - try { - e = (Class) Class.forName(name); - } catch (ClassNotFoundException e1) { - e1.printStackTrace(); - } - - if (e != null) { - registerEntity(e); - } else { - // Keeping the order correct - idToEntity.add(null); - BCLog.logger.log(Level.WARN, "Can't load entity " + name); - } - } - - // System.out.println("[R] idToItem size : " + idToItem.size()); - // for (Item i : idToItem) { - // System.out.println("- " + (i != null ? i.toString() : "null")); - // } - } - - public void addToCrashReport(CrashReportCategory cat) { - cat.addCrashSection("Item Map Count", itemToId.size()); - for (Entry e : itemToId.entrySet()) { - cat.addCrashSection(" - ID " + e.getValue(), Item.REGISTRY.getNameForObject(e.getKey())); - } - - cat.addCrashSection("Block Map Count", blockToId.size()); - for (Entry e : blockToId.entrySet()) { - cat.addCrashSection(" - ID " + e.getValue(), Block.REGISTRY.getNameForObject(e.getKey())); - } - - cat.addCrashSection("Entity Map Count", entityToId.size()); - for (Entry, Integer> e : entityToId.entrySet()) { - cat.addCrashSection(" - ID " + e.getValue(), e.getKey()); - } - } -} diff --git a/src/api/java/buildcraft/api/blueprints/Schematic.java b/src/api/java/buildcraft/api/blueprints/Schematic.java deleted file mode 100755 index a0bb497b9..000000000 --- a/src/api/java/buildcraft/api/blueprints/Schematic.java +++ /dev/null @@ -1,196 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; - -import buildcraft.api.core.IInvSlot; - -/** A schematic is a piece of a blueprint. It allows to stock blocks or entities to blueprints, and can have a state - * that moves from a blueprint referential to a world referential. Although default schematic behavior will be OK for a - * lot of objects, specific blocks and entities may be associated with a dedicated schematic class, which will be - * instantiated automatically. - * - * Schematic perform "id translation" in case the block ids between a blueprint and the world installation are - * different. Mapping is done through the builder context. - * - * Detailed documentation on the schematic behavior can be found on - * http://www.mod-buildcraft.com/wiki/doku.php?id=builder_support - * - * Example of schematics for minecraft blocks are available in the package buildcraft.core.schematics. */ -// is being replaced by a different schematic implementation -// a simalir styled one to this might be made ontop of the other one though -public abstract class Schematic { - /** Blocks are build in various stages, in order to make sure that a block can indeed be placed, and that it's - * unlikely to disturb other blocks. */ - public enum BuildingStage { - /** Standalone blocks do not change once placed. */ - STANDALONE, - - /** Expanding blocks will grow and may disturb other block locations, like liquids. */ - EXPANDING - } - - /** This is called to verify whether the required item is equal to the supplied item. - * - * Primarily rely on this for checking metadata/NBT - the item ID itself might have been filtered out by previously - * running code. */ - public boolean isItemMatchingRequirement(ItemStack suppliedStack, ItemStack requiredStack) { - return BuilderAPI.schematicHelper.isEqualItem(suppliedStack, requiredStack); - } - - /** This is called each time an item matches a requirement. By default, it will increase damage of items that can be - * damaged by the amount of the requirement, and remove the intended amount of items that can't be damaged. - * - * Client may override this behavior. Note that this subprogram may be called twice with the same parameters, once - * with a copy of requirements and stack to check if the entire requirements can be fulfilled, and once with the - * real inventory. Implementer is responsible for updating req (with the remaining requirements if any) and slot - * (after usage). - * - * returns what was used (similar to req, but created from slot, so that any NBT based differences are drawn from - * the correct source) */ - public ItemStack useItem(IBuilderContext context, ItemStack req, IInvSlot slot) { - ItemStack stack = slot.getStackInSlot(); - ItemStack result = stack.copy(); - - if (stack.isItemStackDamageable()) { - if (req.getItemDamage() + stack.getItemDamage() <= stack.getMaxDamage()) { - stack.setItemDamage(req.getItemDamage() + stack.getItemDamage()); - result.setItemDamage(req.getItemDamage()); - req.setCount(0); - } - - if (stack.getItemDamage() >= stack.getMaxDamage()) { - slot.decreaseStackInSlot(1); - } - } else { - if (stack.getCount() >= req.getCount()) { - result.setCount(req.getCount()); - stack.setCount(stack.getCount() - req.getCount()); - req.setCount(0); - } else { - req.setCount(req.getCount() - stack.getCount()); - stack.setCount(0); - } - } - - if (stack.getCount() == 0) { - stack.setCount(1); - if (stack.getItem().hasContainerItem(stack)) { - ItemStack newStack = stack.getItem().getContainerItem(stack); - slot.setStackInSlot(newStack); - } else { - slot.setStackInSlot(null); - } - } - - return result; - } - - /** Perform a 90 degree rotation to the slot. */ - public void rotateLeft(IBuilderContext context) { - - } - - /** Applies translations to all positions in the schematic to center in the blueprint referential */ - public void translateToBlueprint(Vec3d transform) { - - } - - /** Apply translations to all positions in the schematic to center in the builder referential */ - public void translateToWorld(Vec3d transform) {} - - /** Translates blocks and item ids to the blueprint referential */ - public void idsToBlueprint(MappingRegistry registry) {} - - /** Translates blocks and item ids to the world referential */ - public void idsToWorld(MappingRegistry registry) {} - - /** Initializes a schematic for blueprint according to an objet placed on {x, y, z} on the world. For blocks, block - * and meta fields will be initialized automatically. */ - public void initializeFromObjectAt(IBuilderContext context, BlockPos pos) {} - - /** Places the block in the world, at the location specified in the slot, using the stack in parameters */ - public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) {} - - /** Write specific requirements coming from the world to the blueprint. */ - public void storeRequirements(IBuilderContext context, BlockPos pos) {} - - /** Returns the requirements needed to build this block. When the requirements are met, they will be removed all at - * once from the builder, before calling writeToWorld. */ - public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) {} - - /** Returns the amount of energy required to build this slot, depends on the stacks selected for the build. */ - public int getEnergyRequirement(NonNullList stacksUsed) { - int result = 0; - - if (stacksUsed != null) { - for (ItemStack s : stacksUsed) { - result += s.getCount() ;//* BuilderAPI.BUILD_ENERGY; - } - } - - return result; - } - - /** Returns the flying stacks to display in the builder animation. */ - public NonNullList getStacksToDisplay(NonNullList stackConsumed) { - return stackConsumed; - } - - /** Return the stage where this schematic has to be built. */ - public BuildingStage getBuildStage() { - return BuildingStage.STANDALONE; - } - - /** Return true if the block on the world correspond to the block stored in the blueprint at the location given by - * the slot. By default, this subprogram is permissive and doesn't take into account metadata. - * - * Post processing will be called on these blocks. */ - public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { - return true; - } - - /** Return true if the block should not be placed to the world. Requirements will not be asked on such a block, and - * building will not be called. - * - * Post processing will be called on these blocks. */ - public boolean doNotBuild() { - return false; - } - - /** Return true if the schematic should not be used at all. This is computed straight after readFromNBT can be used - * to deactivate schematics in which an inconsistency is detected. It will be considered as a block of air instead. - * - * Post processing will *not* be called on these blocks. */ - public boolean doNotUse() { - return false; - } - - /** Return the maximium building permission for blueprint containing this schematic. */ - public BuildingPermission getBuildingPermission() { - return BuildingPermission.ALL; - } - - /** Called on a block when the blueprint has finished to place all the blocks. This may be useful to adjust variable - * depending on surrounding blocks that may not be there already at initial building. */ - public void postProcessing(IBuilderContext context, BlockPos pos) {} - - /** Saves this schematic to the blueprint NBT. */ - public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) {} - - /** Loads this schematic from the blueprint NBT. */ - public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) {} - - /** Returns the number of cycles to wait after building this schematic. Tiles and entities typically require more - * wait, around 5 cycles. */ - public int buildTime() { - return 1; - } -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicBlock.java b/src/api/java/buildcraft/api/blueprints/SchematicBlock.java deleted file mode 100755 index fe3af0acf..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicBlock.java +++ /dev/null @@ -1,193 +0,0 @@ -/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockFalling; -import net.minecraft.block.BlockLiquid; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.NonNullList; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; - -import net.minecraftforge.common.util.Constants; -import net.minecraftforge.fluids.BlockFluidBase; - -import buildcraft.api.core.BCLog; - -public class SchematicBlock extends SchematicBlockBase { - public IBlockState state = null; - public BuildingPermission defaultPermission = BuildingPermission.ALL; - - /** This field contains requirements for a given block when stored in the blueprint. Modders can either rely on this - * list or compute their own int Schematic. */ - public NonNullList storedRequirements = NonNullList.create(); - - private boolean doNotUse = false; - - @Override - public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) { - if (state != null) { - if (storedRequirements.size() != 0) { - requirements.addAll(storedRequirements); - } else { - requirements.add(getItemStack(state)); - } - } - } - - @Override - public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { - IBlockState placed = context.world().getBlockState(pos); - if (state == placed) return true; - if (state.getBlock() != placed.getBlock()) return false; - // This fixes bugs with blocks like stairs that return extra properties that were not visible from the meta. - if (state.getBlock().getMetaFromState(state) == placed.getBlock().getMetaFromState(placed)) return true; - return false; - } - - @Override - public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { - super.placeInWorld(context, pos, stacks); - - this.setBlockInWorld(context, pos); - } - - @Override - public void storeRequirements(IBuilderContext context, BlockPos pos) { - super.storeRequirements(context, pos); - - if (state != null) { - storedRequirements = NonNullList.create(); - List drops = state.getBlock().getDrops(context.world(), pos, state, 0); - if (drops != null) { - storedRequirements.addAll(drops); - } - } - } - - @Override - public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { - super.writeSchematicToNBT(nbt, registry); - - writeBlockToNBT(nbt, registry); - writeRequirementsToNBT(nbt, registry); - } - - @Override - public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { - super.readSchematicFromNBT(nbt, registry); - - readBlockFromNBT(nbt, registry); - if (!doNotUse()) { - readRequirementsFromNBT(nbt, registry); - } - } - - /** Get a list of relative block coordinates which have to be built before this block can be placed. */ - public Set getPrerequisiteBlocks(IBuilderContext context) { - Set indexes = new HashSet(); - if (state.getBlock() instanceof BlockFalling) { - indexes.add(new BlockPos(0, -1, 0)); - } - return indexes; - } - - @Override - public BuildingStage getBuildStage() { - if (state.getBlock() instanceof BlockFluidBase || state.getBlock() instanceof BlockLiquid) { - return BuildingStage.EXPANDING; - } else { - return BuildingStage.STANDALONE; - } - } - - @Override - public BuildingPermission getBuildingPermission() { - return defaultPermission; - } - - // Utility functions - protected void setBlockInWorld(IBuilderContext context, BlockPos pos) { - context.world().setBlockState(pos, state, 3); - } - - @Override - public boolean doNotUse() { - return doNotUse; - } - - protected void readBlockFromNBT(NBTTagCompound nbt, MappingRegistry registry) { - try { - Block block = registry.getBlockForId(nbt.getInteger("blockId")); - state = block.getStateFromMeta(nbt.getInteger("blockMeta")); - } catch (MappingNotFoundException e) { - BCLog.logger.info(e); - doNotUse = true; - } - } - - protected void readRequirementsFromNBT(NBTTagCompound nbt, MappingRegistry registry) { - storedRequirements = NonNullList.create(); - if (nbt.hasKey("rq")) { - NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < rq.tagCount(); ++i) { - try { - NBTTagCompound sub = rq.getCompoundTagAt(i); - registry.stackToWorld(sub); - storedRequirements.add(new ItemStack(sub)); - } catch (MappingNotFoundException e) { - defaultPermission = BuildingPermission.CREATIVE_ONLY; - } catch (Throwable t) { - t.printStackTrace(); - defaultPermission = BuildingPermission.CREATIVE_ONLY; - } - } - } - } - - protected void writeBlockToNBT(NBTTagCompound nbt, MappingRegistry registry) { - nbt.setInteger("blockId", registry.getIdForBlock(state.getBlock())); - nbt.setInteger("blockMeta", state.getBlock().getMetaFromState(state)); - } - - protected void writeRequirementsToNBT(NBTTagCompound nbt, MappingRegistry registry) { - if (storedRequirements.size() > 0) { - NBTTagList rq = new NBTTagList(); - - for (ItemStack stack : storedRequirements) { - if (stack.isEmpty() || stack.getItem() == null) throw new IllegalStateException("Found a null requirement! " + getClass()); - NBTTagCompound sub = new NBTTagCompound(); - stack.writeToNBT(sub); - rq.appendTag(sub); - } - - nbt.setTag("rq", rq); - } - } - - protected ItemStack getItemStack(IBlockState state, int quantity) { - return new ItemStack(state.getBlock(), quantity, state.getBlock().damageDropped(state)); - } - - protected ItemStack getItemStack(IBlockState state) { - return getItemStack(state, 1); - } - - // Pretty much all blocks (that rotate) rotate this way now - @Override - public void rotateLeft(IBuilderContext context) { - // FIXME: This might be the wrong way - state = state.withRotation(Rotation.CLOCKWISE_90); - } -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java b/src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java deleted file mode 100755 index 69f18a2eb..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicBlockBase.java +++ /dev/null @@ -1,9 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -public abstract class SchematicBlockBase extends Schematic { - -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicEntity.java b/src/api/java/buildcraft/api/blueprints/SchematicEntity.java deleted file mode 100755 index 5d856c71d..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicEntity.java +++ /dev/null @@ -1,193 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import java.util.Collections; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagDouble; -import net.minecraft.nbt.NBTTagFloat; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.Vec3d; - -import net.minecraftforge.common.util.Constants; - -public class SchematicEntity extends Schematic { - public Class entity; - - /** This tree contains additional data to be stored in the blueprint. By default, it will be initialized from - * Schematic.readFromWord with the standard readNBT function of the corresponding tile (if any) and will be loaded - * from BptBlock.writeToWorld using the standard writeNBT function. */ - public NBTTagCompound entityNBT = new NBTTagCompound(); - - /** This field contains requirements for a given block when stored in the blueprint. Modders can either rely on this - * list or compute their own int Schematic. */ - public NonNullList storedRequirements = NonNullList.withSize(0, null); - public BuildingPermission defaultPermission = BuildingPermission.ALL; - - @Override - public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) { - requirements.addAll(storedRequirements); - } - - public void writeToWorld(IBuilderContext context) { - Entity e = EntityList.createEntityFromNBT(entityNBT, context.world()); - context.world().spawnEntity(e); - } - - public void readFromWorld(IBuilderContext context, Entity entity) { - entity.writeToNBTOptional(entityNBT); - } - - @Override - public void translateToBlueprint(Vec3d transform) { - NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); - Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); - pos = pos.add(transform); - entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord)); - } - - @Override - public void translateToWorld(Vec3d transform) { - NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); - Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); - pos = pos.add(transform); - - entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord)); - } - - @Override - public void idsToBlueprint(MappingRegistry registry) {} - - @Override - public void idsToWorld(MappingRegistry registry) { - try { - registry.scanAndTranslateStacksToWorld(entityNBT); - } catch (MappingNotFoundException e) { - entityNBT = new NBTTagCompound(); - } - } - - @Override - public void rotateLeft(IBuilderContext context) { - NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); - Vec3d pos = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); - pos = context.rotatePositionLeft(pos); - entityNBT.setTag("Pos", this.newDoubleNBTList(pos.xCoord, pos.yCoord, pos.zCoord)); - - nbttaglist = entityNBT.getTagList("Rotation", 5); - float yaw = nbttaglist.getFloatAt(0); - yaw += 90; - entityNBT.setTag("Rotation", this.newFloatNBTList(yaw, nbttaglist.getFloatAt(1))); - } - - @Override - public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { - super.writeSchematicToNBT(nbt, registry); - - nbt.setInteger("entityId", registry.getIdForEntity(entity)); - nbt.setTag("entity", entityNBT); - - NBTTagList rq = new NBTTagList(); - - for (ItemStack stack : storedRequirements) { - NBTTagCompound sub = new NBTTagCompound(); - stack.writeToNBT(stack.writeToNBT(sub)); - sub.setInteger("id", registry.getIdForItem(stack.getItem())); - rq.appendTag(sub); - } - - nbt.setTag("rq", rq); - } - - @Override - public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { - super.readSchematicFromNBT(nbt, registry); - - entityNBT = nbt.getCompoundTag("entity"); - - NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND); - - NonNullList rqs = NonNullList.create(); - - for (int i = 0; i < rq.tagCount(); ++i) { - try { - NBTTagCompound sub = rq.getCompoundTagAt(i); - - if (sub.getInteger("id") >= 0) { - // Maps the id in the blueprint to the id in the world - sub.setInteger("id", Item.REGISTRY.getIDForObject(registry.getItemForId(sub.getInteger("id")))); - - rqs.add(new ItemStack(sub)); - } else { - defaultPermission = BuildingPermission.CREATIVE_ONLY; - } - } catch (Throwable t) { - t.printStackTrace(); - defaultPermission = BuildingPermission.CREATIVE_ONLY; - } - } - - storedRequirements = rqs; - } - - protected NBTTagList newDoubleNBTList(double... par1ArrayOfDouble) { - NBTTagList nbttaglist = new NBTTagList(); - double[] adouble = par1ArrayOfDouble; - int i = par1ArrayOfDouble.length; - - for (int j = 0; j < i; ++j) { - double d1 = adouble[j]; - nbttaglist.appendTag(new NBTTagDouble(d1)); - } - - return nbttaglist; - } - - protected NBTTagList newFloatNBTList(float... par1ArrayOfFloat) { - NBTTagList nbttaglist = new NBTTagList(); - float[] afloat = par1ArrayOfFloat; - int i = par1ArrayOfFloat.length; - - for (int j = 0; j < i; ++j) { - float f1 = afloat[j]; - nbttaglist.appendTag(new NBTTagFloat(f1)); - } - - return nbttaglist; - } - - public boolean isAlreadyBuilt(IBuilderContext context) { - NBTTagList nbttaglist = entityNBT.getTagList("Pos", 6); - Vec3d newPosition = new Vec3d(nbttaglist.getDoubleAt(0), nbttaglist.getDoubleAt(1), nbttaglist.getDoubleAt(2)); - - for (Object o : context.world().loadedEntityList) { - Entity e = (Entity) o; - - Vec3d existingPositon = new Vec3d(e.posX, e.posY, e.posZ); - - if (existingPositon.distanceTo(newPosition) <= 0.1) { - return true; - } - } - - return false; - } - - @Override - public int buildTime() { - return 5; - } - - @Override - public BuildingPermission getBuildingPermission() { - return defaultPermission; - } -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicFactory.java b/src/api/java/buildcraft/api/blueprints/SchematicFactory.java deleted file mode 100755 index 878b15714..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicFactory.java +++ /dev/null @@ -1,51 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import java.util.HashMap; - -import net.minecraft.nbt.NBTTagCompound; - -public abstract class SchematicFactory { - - private static final HashMap> factories = new HashMap>(); - - private static final HashMap, SchematicFactory> schematicToFactory = - new HashMap, SchematicFactory>(); - - protected abstract S loadSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry) throws MappingNotFoundException; - - public void saveSchematicToWorldNBT(NBTTagCompound nbt, S object, MappingRegistry registry) { - nbt.setString("factoryID", getClass().getCanonicalName()); - } - - public static Schematic createSchematicFromWorldNBT(NBTTagCompound nbt, MappingRegistry registry) throws MappingNotFoundException { - String factoryName = nbt.getString("factoryID"); - - if (factories.containsKey(factoryName)) { - return factories.get(factoryName).loadSchematicFromWorldNBT(nbt, registry); - } else { - return null; - } - } - - public static void registerSchematicFactory(Class clas, SchematicFactory factory) { - schematicToFactory.put(clas, factory); - factories.put(factory.getClass().getCanonicalName(), factory); - } - - public static SchematicFactory getFactory(Class clas) { - Class superClass = clas.getSuperclass(); - - if (schematicToFactory.containsKey(clas)) { - return schematicToFactory.get(clas); - } else if (superClass != null) { - return getFactory(superClass); - } else { - return null; - } - } - -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicFluid.java b/src/api/java/buildcraft/api/blueprints/SchematicFluid.java deleted file mode 100755 index f044bf021..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicFluid.java +++ /dev/null @@ -1,83 +0,0 @@ -/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.block.BlockLiquid; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; - -import net.minecraftforge.fluids.FluidStack; - -@Deprecated -public class SchematicFluid extends SchematicBlock { - - private final ItemStack fluidItem; - - public SchematicFluid(FluidStack fluidStack) { - this.fluidItem = new ItemStack(fluidStack.getFluid().getBlock(), 1); - } - - @Override - public void getRequirementsForPlacement(IBuilderContext context, NonNullList requirements) { - if (getLevel() == 0) { - requirements.add(fluidItem); - } - } - - @Override - public void storeRequirements(IBuilderContext context, BlockPos pos) { - // cancel requirements reading - } - - @Override - public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { - if (getLevel() == 0) { - return state == context.world().getBlockState(pos) && (context.world().getBlockState(pos).getValue(BlockLiquid.LEVEL)) == 0; - } else { - return state == context.world().getBlockState(pos); - } - } - - @Override - public void rotateLeft(IBuilderContext context) { - - } - - @Override - public boolean doNotBuild() { - return getLevel() != 0; - } - - @Override - public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { - if (getLevel() == 0) { - context.world().setBlockState(pos, state, 3); - } - } - - @Override - public void postProcessing(IBuilderContext context, BlockPos pos) { - if (getLevel() != 0) { - context.world().setBlockState(pos, state, 3); - } - } - - @Override - public NonNullList getStacksToDisplay(NonNullList stackConsumed) { - NonNullList result = NonNullList.create(); - result.add(fluidItem); - return result; - } - - @Override - public int getEnergyRequirement(NonNullList stacksUsed) { - return 1;// * BuilderAPI.BUILD_ENERGY; - } - - public int getLevel() { - return state.getValue(BlockLiquid.LEVEL); - } -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicMask.java b/src/api/java/buildcraft/api/blueprints/SchematicMask.java deleted file mode 100755 index 3d811bce4..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicMask.java +++ /dev/null @@ -1,83 +0,0 @@ -/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; - -import buildcraft.api.core.BuildCraftAPI; - -public class SchematicMask extends SchematicBlockBase { - /** True of the block should be a solid block (stone, grass or a furnace) and false if it shouldn't (flowers, air or - * vines) */ - public boolean isConcrete = true; - - public SchematicMask() { - - } - - public SchematicMask(boolean isConcrete) { - this.isConcrete = isConcrete; - } - - @Override - public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { - if (isConcrete) { - if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), pos)) { - return; - } else { - ItemStack stack = stacks.get(0); - EntityPlayer player = BuildCraftAPI.fakePlayerProvider.getBuildCraftPlayer((WorldServer) context.world()); - - // force the block to be air block, in case it's just a soft - // block which replacement is not straightforward - context.world().setBlockToAir(pos); - - // Find nearest solid surface to place on - EnumFacing solidFace = null; - for (EnumFacing face : EnumFacing.values()) { - BlockPos offset = pos.offset(face); - if (!BuildCraftAPI.isSoftBlock(context.world(), offset)) { - solidFace = face; - break; - } - } - ItemBlock itemBlock = (ItemBlock) stack.getItem(); - - IBlockState state = itemBlock.block.getStateForPlacement(context.world(), pos, solidFace, 0, 0, 0, stack.getMetadata(), player, EnumHand.MAIN_HAND); - itemBlock.placeBlockAt(stack, player, context.world(), pos, solidFace, 0, 0, 0, state); - } - } else { - context.world().setBlockToAir(pos); - } - } - - @Override - public boolean isAlreadyBuilt(IBuilderContext context, BlockPos pos) { - if (isConcrete) { - return !BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), pos); - } else { - return BuildCraftAPI.getWorldProperty("replaceable").get(context.world(), pos); - } - } - - @Override - public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { - nbt.setBoolean("isConcrete", isConcrete); - } - - @Override - public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { - isConcrete = nbt.getBoolean("isConcrete"); - } -} diff --git a/src/api/java/buildcraft/api/blueprints/SchematicTile.java b/src/api/java/buildcraft/api/blueprints/SchematicTile.java deleted file mode 100755 index 318e27eb3..000000000 --- a/src/api/java/buildcraft/api/blueprints/SchematicTile.java +++ /dev/null @@ -1,109 +0,0 @@ -/** Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.blueprints; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; - -public class SchematicTile extends SchematicBlock { - - /** This tree contains additional data to be stored in the blueprint. By default, it will be initialized from - * Schematic.readFromWord with the standard readNBT function of the corresponding tile (if any) and will be loaded - * from BptBlock.writeToWorld using the standard writeNBT function. */ - public NBTTagCompound tileNBT = new NBTTagCompound(); - - @Override - public void idsToBlueprint(MappingRegistry registry) {} - - @Override - public void idsToWorld(MappingRegistry registry) { - try { - registry.scanAndTranslateStacksToWorld(tileNBT); - } catch (MappingNotFoundException e) { - tileNBT = new NBTTagCompound(); - } - } - - public void onNBTLoaded() { - - } - - /** Places the block in the world, at the location specified in the slot. */ - @Override - public void placeInWorld(IBuilderContext context, BlockPos pos, NonNullList stacks) { - super.placeInWorld(context, pos, stacks); - - if (state.getBlock().hasTileEntity(state)) { - tileNBT.setInteger("x", pos.getX()); - tileNBT.setInteger("y", pos.getY()); - tileNBT.setInteger("z", pos.getZ()); - TileEntity tile = TileEntity.create(context.world(), tileNBT); - if (tile != null) { - tile.setWorld(context.world()); - context.world().setTileEntity(pos, tile); - } - } - } - - @Override - public void initializeFromObjectAt(IBuilderContext context, BlockPos pos) { - super.initializeFromObjectAt(context, pos); - - if (state.getBlock().hasTileEntity(state)) { - TileEntity tile = context.world().getTileEntity(pos); - - if (tile != null) { - tile.writeToNBT(tileNBT); - } - - tileNBT = tileNBT.copy(); - onNBTLoaded(); - } - } - - @Override - public void storeRequirements(IBuilderContext context, BlockPos pos) { - super.storeRequirements(context, pos); - - if (state.getBlock().hasTileEntity(state)) { - TileEntity tile = context.world().getTileEntity(pos); - - if (tile instanceof IInventory) { - IInventory inv = (IInventory) tile; - - for (int i = 0; i < inv.getSizeInventory(); ++i) { - ItemStack stack = inv.getStackInSlot(i); - if (!stack.isEmpty()) { - storedRequirements.add(stack); - } - } - } - } - } - - @Override - public void writeSchematicToNBT(NBTTagCompound nbt, MappingRegistry registry) { - super.writeSchematicToNBT(nbt, registry); - - nbt.setTag("blockCpt", tileNBT); - } - - @Override - public void readSchematicFromNBT(NBTTagCompound nbt, MappingRegistry registry) { - super.readSchematicFromNBT(nbt, registry); - - tileNBT = nbt.getCompoundTag("blockCpt"); - onNBTLoaded(); - } - - @Override - public int buildTime() { - return 5; - } -} diff --git a/src/api/java/buildcraft/api/blueprints/package-info.java b/src/api/java/buildcraft/api/blueprints/package-info.java deleted file mode 100755 index 3b3632424..000000000 --- a/src/api/java/buildcraft/api/blueprints/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.5", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blueprints") -package buildcraft.api.blueprints; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/core/APIHelper.java b/src/api/java/buildcraft/api/core/APIHelper.java deleted file mode 100755 index 9d8613201..000000000 --- a/src/api/java/buildcraft/api/core/APIHelper.java +++ /dev/null @@ -1,81 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.Arrays; - -import org.apache.commons.lang3.StringUtils; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; - -public class APIHelper { - public static T getInstance(String clsName, Class baseVersion) { - return getNamedInstance(clsName, "INSTANCE", baseVersion); - } - - public static T getInstance(String clsName, Class baseVersion, T nullVersion) { - return getNamedInstance(clsName, "INSTANCE", baseVersion, nullVersion); - } - - @SuppressWarnings("unchecked") - public static T getNamedInstance(String clsName, String enumName, Class baseVersion) { - T instance = getNamedInstance(clsName, enumName, baseVersion, null); - if (instance != null) return instance; - - Class[] types = baseVersion.getClasses(); - Class voidType = null; - for (Class class1 : types) { - if (baseVersion.isAssignableFrom(class1)) voidType = class1; - } - if (voidType != null) { - Object[] arr = voidType.getEnumConstants(); - if (arr == null) return null; - Enum[] eArr = ((Class>) voidType).getEnumConstants(); - for (Enum e : eArr) { - if (e.name().equals(enumName) && baseVersion.isInstance(e)) return (T) e; - } - } - return null; - } - - @SuppressWarnings("unchecked") - public static T getNamedInstance(String clsName, String enumName, Class baseVersion, T nullVersion) { - if (!Loader.instance().hasReachedState(LoaderState.PREINITIALIZATION)) throw new IllegalStateException( - "Called this API too early, you are not allowed to use BC api before pre init!"); - try { - Class cls = Class.forName(clsName); - Object[] arr = cls.getEnumConstants(); - if (arr == null) { - return fail(clsName, nullVersion); - } - Enum[] enumArr = ((Class>) cls).getEnumConstants(); - - for (Enum e : enumArr) { - if (e.name().equals(enumName) && baseVersion.isInstance(e)) return (T) e; - } - return fail(clsName, nullVersion); - } catch (ClassNotFoundException e) { - return fail(clsName, nullVersion); - } - } - - private static M fail(String clsName, M failure) { - String[] split = clsName.split("\\."); - String module; - if (split.length < 2) { - BCLog.logger.warn("Tried and failed to get the module name from " + Arrays.toString(split) + " (" + clsName + ")!"); - module = "invalid"; - } else { - module = split[1]; - } - module = StringUtils.capitalize(module); - String bcMod = "BuildCraft|" + module; - if (Loader.isModLoaded(bcMod)) { - BCLog.logger.warn("Failed to load the " + clsName + " dispite the appropriate buildcraft module being installed (" + module + ")"); - } - return failure; - } -} diff --git a/src/api/java/buildcraft/api/core/BCDebugging.java b/src/api/java/buildcraft/api/core/BCDebugging.java index 3badeb901..732be03d0 100755 --- a/src/api/java/buildcraft/api/core/BCDebugging.java +++ b/src/api/java/buildcraft/api/core/BCDebugging.java @@ -15,7 +15,7 @@ public class BCDebugging { NONE, ENABLE, LOGGING_ONLY, - ALL; + ALL } enum DebugLevel { @@ -100,7 +100,7 @@ public class BCDebugging { log.append(option); log.append(" add the option \"-D"); log.append(prop); - log.append("=true\" to your launch config as a VM argument (" + type + ")."); + log.append("=true\" to your launch config as a VM argument (").append(type).append(")."); BCLog.logger.info(log); } return false; diff --git a/src/api/java/buildcraft/api/core/BuildCraftAPI.java b/src/api/java/buildcraft/api/core/BuildCraftAPI.java index 19e9e9c79..f7f24c0cb 100755 --- a/src/api/java/buildcraft/api/core/BuildCraftAPI.java +++ b/src/api/java/buildcraft/api/core/BuildCraftAPI.java @@ -4,7 +4,6 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.core; -import java.lang.reflect.Method; import java.util.HashMap; import java.util.Set; @@ -12,12 +11,15 @@ import com.google.common.collect.Maps; import com.google.common.collect.Sets; import net.minecraft.block.Block; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -public final class BuildCraftAPI { +import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.ModContainer; - public static IBCFakePlayer fakePlayerProvider; +public final class BuildCraftAPI { + public static IFakePlayerProvider fakePlayerProvider; public static final Set softBlocks = Sets.newHashSet(); public static final HashMap worldProperties = Maps.newHashMap(); @@ -26,13 +28,11 @@ public final class BuildCraftAPI { private BuildCraftAPI() {} public static String getVersion() { - try { - Class clazz = Class.forName("buildcraft.core.Version"); - Method method = clazz.getDeclaredMethod("getVersion"); - return String.valueOf(method.invoke(null)); - } catch (Exception e) { - return "UNKNOWN VERSION"; + ModContainer container = Loader.instance().getIndexedModList().get("buildcraftlib"); + if (container != null) { + return container.getDisplayVersion(); } + return "UNKNOWN VERSION"; } public static IWorldProperty getWorldProperty(String name) { @@ -41,7 +41,7 @@ public final class BuildCraftAPI { public static void registerWorldProperty(String name, IWorldProperty property) { if (worldProperties.containsKey(name)) { - BCLog.logger.warn("The WorldProperty key '" + name + "' is being overidden with " + property.getClass().getSimpleName() + "!"); + BCLog.logger.warn("The WorldProperty key '" + name + "' is being overridden with " + property.getClass().getSimpleName() + "!"); } worldProperties.put(name, property); } @@ -49,4 +49,13 @@ public final class BuildCraftAPI { public static boolean isSoftBlock(World world, BlockPos pos) { return worldProperties.get("soft").get(world, pos); } + + public static ResourceLocation nameToResourceLocation(String name) { + if (name.indexOf(':') > 0) return new ResourceLocation(name); + ModContainer modContainer = Loader.instance().activeModContainer(); + if (modContainer == null) { + throw new IllegalStateException("Illegal recipe name " + name + ". Provide domain id to register it correctly."); + } + return new ResourceLocation(modContainer.getModId(), name); + } } diff --git a/src/api/java/buildcraft/api/core/CapabilitiesHelper.java b/src/api/java/buildcraft/api/core/CapabilitiesHelper.java new file mode 100644 index 000000000..d5795c935 --- /dev/null +++ b/src/api/java/buildcraft/api/core/CapabilitiesHelper.java @@ -0,0 +1,37 @@ +package buildcraft.api.core; + +import javax.annotation.Nonnull; + +import net.minecraft.nbt.NBTBase; +import net.minecraft.util.EnumFacing; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityManager; + +public class CapabilitiesHelper { + public static void registerCapability(Class clazz) { + CapabilityManager.INSTANCE.register(clazz, new VoidStorage<>(), () -> { + throw new IllegalStateException("You must create your own instances!"); + }); + } + + @Nonnull + public static Capability ensureRegistration(Capability cap, Class clazz) { + if (cap == null) { + throw new Error("Capability registration failed for " + clazz); + } + return cap; + } + + public static class VoidStorage implements Capability.IStorage { + @Override + public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { + throw new IllegalStateException("You must create your own instances!"); + } + + @Override + public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { + throw new IllegalStateException("You must create your own instances!"); + } + } +} diff --git a/src/api/java/buildcraft/api/core/ConfigAccessor.java b/src/api/java/buildcraft/api/core/ConfigAccessor.java deleted file mode 100755 index a66346ac5..000000000 --- a/src/api/java/buildcraft/api/core/ConfigAccessor.java +++ /dev/null @@ -1,48 +0,0 @@ -package buildcraft.api.core; - -import java.util.Map; - -import com.google.common.collect.Maps; - -import net.minecraftforge.common.config.Property; - -/** Use this to access the various config options. It is recommended that you use this as opposed to the variables in - * the mod, as users may only install the modules that they want, and not the one you may have refereed to. */ -@Deprecated -public final class ConfigAccessor { - public enum EMod { - CORE, - BUILDERS, - ENERGY, - FACTORY, - ROBITICS, - SILICON, - TRANSPORT - } - - private static Map mods = Maps.newHashMap(); - - private ConfigAccessor() {} - - public static Property getOption(EMod mod, String name) { - if (mods.containsKey(mod)) { - return mods.get(mod).getOption(name); - } else { - return null; - } - } - - public static boolean getBoolean(EMod mod, String name, boolean defaultBoolean) { - Property prop = getOption(mod, name); - if (prop == null) { - return defaultBoolean; - } else { - return prop.getBoolean(defaultBoolean); - } - } - - /** WARNING: INTERNAL USE ONLY! */ - public static void addMod(EMod mod, IBuildCraftMod actual) { - mods.put(mod, actual); - } -} diff --git a/src/api/java/buildcraft/api/core/EnumHandlerPriority.java b/src/api/java/buildcraft/api/core/EnumHandlerPriority.java new file mode 100644 index 000000000..66145a2f5 --- /dev/null +++ b/src/api/java/buildcraft/api/core/EnumHandlerPriority.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2017 SpaceToad and the BuildCraft team + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. + */ + +package buildcraft.api.core; + +public enum EnumHandlerPriority implements Comparable { + HIGHEST, + HIGH, + NORMAL, + LOW, + LOWEST; + + public static final EnumHandlerPriority[] VALUES = values(); +} diff --git a/src/api/java/buildcraft/api/core/EnumPipePart.java b/src/api/java/buildcraft/api/core/EnumPipePart.java index 13b1ffc3f..3eb3731b0 100755 --- a/src/api/java/buildcraft/api/core/EnumPipePart.java +++ b/src/api/java/buildcraft/api/core/EnumPipePart.java @@ -11,9 +11,7 @@ import net.minecraft.nbt.NBTTagString; import net.minecraft.util.EnumFacing; import net.minecraft.util.IStringSerializable; -import io.netty.buffer.ByteBuf; - -public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 { +public enum EnumPipePart implements IStringSerializable { DOWN(EnumFacing.DOWN), UP(EnumFacing.UP), NORTH(EnumFacing.NORTH), @@ -24,7 +22,9 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 facingMap = Maps.newEnumMap(EnumFacing.class); private static final Map nameMap = Maps.newHashMap(); private static final int MAX_VALUES = values().length; @@ -36,6 +36,16 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8= MAX_VALUES) return EnumPipePart.CENTER; + if (meta < 0 || meta >= MAX_VALUES) { + return EnumPipePart.CENTER; + } return VALUES[meta]; } - private EnumPipePart(EnumFacing face) { + EnumPipePart(EnumFacing face) { this.face = face; } @@ -90,19 +104,25 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 6) return CENTER; + if (ord < 0 || ord > 6) { + return CENTER; + } return values()[ord]; } } @@ -110,15 +130,4 @@ public enum EnumPipePart implements IStringSerializable, INetworkLoadable_BC8 + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. + */ +package buildcraft.api.core; + +import com.mojang.authlib.GameProfile; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.WorldServer; + +import net.minecraftforge.common.util.FakePlayer; + +public interface IFakePlayerProvider { + /** + * Returns the generic buildcraft fake player. Note that you shouldn't use this anymore, as you should store the + * UUID of the real player who created the block or entity that calls this. + */ + @Deprecated + FakePlayer getBuildCraftPlayer(WorldServer world); + + /** + * @param world + * @param profile The owner's profile. + * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this + * player is left around as it holds a reference to the world object. + */ + FakePlayer getFakePlayer(WorldServer world, GameProfile profile); + + /** + * @param world + * @param profile The owner's profile. + * @param pos + * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this + * player is left around as it holds a reference to the world object. + */ + FakePlayer getFakePlayer(WorldServer world, GameProfile profile, BlockPos pos); +} diff --git a/src/api/java/buildcraft/api/core/INBTLoadable_BC8.java b/src/api/java/buildcraft/api/core/INBTLoadable_BC8.java deleted file mode 100755 index 8005bcf53..000000000 --- a/src/api/java/buildcraft/api/core/INBTLoadable_BC8.java +++ /dev/null @@ -1,14 +0,0 @@ -package buildcraft.api.core; - -import net.minecraft.nbt.NBTBase; - -/** @param The type that will be loaded from and saved too. This essentially allows Immutable objects to be safely - * loaded without helper methods everywhere. However you are allowed to return this if you are a mutable - * object */ -public interface INBTLoadable_BC8 { - /** @return An object that has the properties loaded. WARNIG! This might be the same object as the one this method - * was called on! (You should always replace the object you have stored with whatever this returns) */ - T readFromNBT(NBTBase nbt); - - NBTBase writeToNBT(); -} diff --git a/src/api/java/buildcraft/api/core/INBTStoreable.java b/src/api/java/buildcraft/api/core/INBTStoreable.java deleted file mode 100755 index c34c134ac..000000000 --- a/src/api/java/buildcraft/api/core/INBTStoreable.java +++ /dev/null @@ -1,12 +0,0 @@ -package buildcraft.api.core; - -import net.minecraft.nbt.NBTTagCompound; - -/** Use {@link INBTLoadable_BC8} instead of this, as this gives you more control over what NBT goes where, and what - * objects are allowed to do. */ -@Deprecated -public interface INBTStoreable { - void readFromNBT(NBTTagCompound tag); - - void writeToNBT(NBTTagCompound tag); -} diff --git a/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java b/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java deleted file mode 100755 index 42d0d2469..000000000 --- a/src/api/java/buildcraft/api/core/INetworkLoadable_BC8.java +++ /dev/null @@ -1,10 +0,0 @@ -package buildcraft.api.core; - -import io.netty.buffer.ByteBuf; - -@Deprecated -public interface INetworkLoadable_BC8 { - T readFromByteBuf(ByteBuf buf); - - void writeToByteBuf(ByteBuf buf); -} diff --git a/src/api/java/buildcraft/api/permission/IPlayerOwned.java b/src/api/java/buildcraft/api/core/IPlayerOwned.java old mode 100755 new mode 100644 similarity index 83% rename from src/api/java/buildcraft/api/permission/IPlayerOwned.java rename to src/api/java/buildcraft/api/core/IPlayerOwned.java index b6c4350bb..8aa80fe4f --- a/src/api/java/buildcraft/api/permission/IPlayerOwned.java +++ b/src/api/java/buildcraft/api/core/IPlayerOwned.java @@ -1,4 +1,4 @@ -package buildcraft.api.permission; +package buildcraft.api.core; import com.mojang.authlib.GameProfile; diff --git a/src/api/java/buildcraft/api/core/ISerializable.java b/src/api/java/buildcraft/api/core/ISerializable.java deleted file mode 100755 index 77d56d541..000000000 --- a/src/api/java/buildcraft/api/core/ISerializable.java +++ /dev/null @@ -1,21 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.core; - -import io.netty.buffer.ByteBuf; - -/** Use {@link INetworkLoadable_BC8} instead, as that gives you more control over how you use objects */ -@Deprecated -public interface ISerializable { - /** Serializes the state to the stream - * - * @param data */ - void writeData(ByteBuf data); - - /** Deserializes the state from the stream - * - * @param data */ - void readData(ByteBuf data); -} diff --git a/src/api/java/buildcraft/api/core/IStackFilter.java b/src/api/java/buildcraft/api/core/IStackFilter.java index 815861c44..2c810c9f6 100755 --- a/src/api/java/buildcraft/api/core/IStackFilter.java +++ b/src/api/java/buildcraft/api/core/IStackFilter.java @@ -7,6 +7,7 @@ package buildcraft.api.core; import javax.annotation.Nonnull; import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; /** This interface provides a convenient means of dealing with entire classes of items without having to specify each * item individually. */ @@ -17,4 +18,11 @@ public interface IStackFilter { * @param stack The stack to test. stack.isEmpty will always return false. * @return True if it does match, false otherwise. */ boolean matches(@Nonnull ItemStack stack); + + /** + * Returns example stack to match this filter + */ + default NonNullList getExamples() { + return NonNullList.withSize(0, ItemStack.EMPTY); + } } diff --git a/src/api/java/buildcraft/api/core/InvalidInputDataException.java b/src/api/java/buildcraft/api/core/InvalidInputDataException.java new file mode 100644 index 000000000..866c36cb1 --- /dev/null +++ b/src/api/java/buildcraft/api/core/InvalidInputDataException.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017 SpaceToad and the BuildCraft team + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not + * distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/ + */ + +package buildcraft.api.core; + +import java.io.IOException; + +/** + * Indicates that we failed to load from NBT or some other file. + */ +public class InvalidInputDataException extends IOException { + public InvalidInputDataException() { + } + + public InvalidInputDataException(String message) { + super(message); + } + + public InvalidInputDataException(Throwable cause) { + super(cause); + } + + public InvalidInputDataException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/src/api/java/buildcraft/api/core/render/ICullable.java b/src/api/java/buildcraft/api/core/render/ICullable.java deleted file mode 100755 index 2399a6927..000000000 --- a/src/api/java/buildcraft/api/core/render/ICullable.java +++ /dev/null @@ -1,27 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.core.render; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; - -/* This interface designates a block as a state machine responsible for culling For implementation details look into - * FakeBlock implementation */ -public interface ICullable { - - // Side Rendering States - // They are used to effectively cull obstructed sides while processing facades. - // Make sure your implementation is correct otherwise expect FPS drop - - void setRenderSide(EnumFacing side, boolean render); - - void setRenderAllSides(); - - boolean shouldSideBeRendered(IBlockAccess blockAccess, BlockPos pos, int side); - - void setRenderMask(int mask); - -} diff --git a/src/api/java/buildcraft/api/core/render/ITextureStateManager.java b/src/api/java/buildcraft/api/core/render/ITextureStateManager.java deleted file mode 100755 index e401b3e2e..000000000 --- a/src/api/java/buildcraft/api/core/render/ITextureStateManager.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.core.render; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; - -public interface ITextureStateManager { - void set(TextureAtlasSprite icon); -} diff --git a/src/api/java/buildcraft/api/core/render/ITextureStates.java b/src/api/java/buildcraft/api/core/render/ITextureStates.java deleted file mode 100755 index 593534f6c..000000000 --- a/src/api/java/buildcraft/api/core/render/ITextureStates.java +++ /dev/null @@ -1,18 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.core.render; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; - -public interface ITextureStates extends ICullable { - - ITextureStateManager getTextureState(); - - TextureAtlasSprite getIcon(int side, int meta); - - Block getBlock(); - -} diff --git a/src/api/java/buildcraft/api/crops/CropManager.java b/src/api/java/buildcraft/api/crops/CropManager.java index 97879829f..68a430201 100755 --- a/src/api/java/buildcraft/api/crops/CropManager.java +++ b/src/api/java/buildcraft/api/crops/CropManager.java @@ -12,7 +12,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public final class CropManager { - private static List handlers = new ArrayList(); + private static List handlers = new ArrayList<>(); private static ICropHandler defaultHandler; private CropManager() { diff --git a/src/api/java/buildcraft/api/crops/ICropHandler.java b/src/api/java/buildcraft/api/crops/ICropHandler.java index 6b2324ac8..845108fe0 100755 --- a/src/api/java/buildcraft/api/crops/ICropHandler.java +++ b/src/api/java/buildcraft/api/crops/ICropHandler.java @@ -1,7 +1,5 @@ package buildcraft.api.crops; -import com.mojang.authlib.GameProfile; - import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; diff --git a/src/api/java/buildcraft/api/data/NbtSquishConstants.java b/src/api/java/buildcraft/api/data/NbtSquishConstants.java new file mode 100644 index 000000000..942f0a8e4 --- /dev/null +++ b/src/api/java/buildcraft/api/data/NbtSquishConstants.java @@ -0,0 +1,50 @@ +package buildcraft.api.data; + +import java.util.zip.GZIPInputStream; + +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; + +public class NbtSquishConstants { + /** Default written NBT Tag type- this is provided by + * {@link CompressedStreamTools#write(NBTTagCompound, java.io.DataOutput)} and + * {@link CompressedStreamTools#read(java.io.DataInput, net.minecraft.nbt.NBTSizeTracker)}. + * + * Generally more suited to smaller NBT tags, and it writes fairly quickly. Can quickly use up a lot of space for + * larger/more complex tags so it is recommended that you also pass it through a GZIP compressor to take up a much + * smaller space. */ + public static final int VANILLA = 0; + public static final int VANILLA_COMPRESSED = 1; + /** Buildcraft provided NBT compressor - puts every tag type into a dictionary and then refers to the dictionary for + * every tag which is written out. Can get much better space usage than {@link #VANILLA}, but at the cost of + * time. */ + public static final int BUILDCRAFT_V1 = 2; + public static final int BUILDCRAFT_V1_COMPRESSED = 3; + + public static final int BUILDCRAFT_MAGIC_1 = 0xbc; + public static final int BUILDCRAFT_MAGIC_2 = 0xa1; + /** The magic identifier for this type of file. First byte is BC, second is A1. */ + public static final int BUILDCRAFT_MAGIC = (BUILDCRAFT_MAGIC_1 << 8) | BUILDCRAFT_MAGIC_2; + + // GZIP uses the opposite byte order to us, so swap it around for us + public static final int GZIP_MAGIC_1 = GZIPInputStream.GZIP_MAGIC & 0xff; + public static final int GZIP_MAGIC_2 = GZIPInputStream.GZIP_MAGIC >> 8; + public static final int GZIP_MAGIC = (GZIP_MAGIC_1 << 8) | GZIP_MAGIC_2; + + // The flags used by BUILDCRAFT_V1 to check the existence of each dictionary + public static final int FLAG_HAS_BYTES = 1 << 0; + public static final int FLAG_HAS_SHORTS = 1 << 1; + public static final int FLAG_HAS_INTS = 1 << 2; + public static final int FLAG_HAS_LONGS = 1 << 3; + public static final int FLAG_HAS_FLOATS = 1 << 4; + public static final int FLAG_HAS_DOUBLES = 1 << 5; + public static final int FLAG_HAS_BYTE_ARRAYS = 1 << 6; + public static final int FLAG_HAS_INT_ARRAYS = 1 << 7; + public static final int FLAG_HAS_STRINGS = 1 << 8; + public static final int FLAG_HAS_COMPLEX = 1 << 9; + + // Complex types + public static final int COMPLEX_COMPOUND = 0; + public static final int COMPLEX_LIST = 1; + public static final int COMPLEX_LIST_PACKED = 2; +} diff --git a/src/api/java/buildcraft/api/enums/EnumBlueprintType.java b/src/api/java/buildcraft/api/enums/EnumBlueprintType.java deleted file mode 100755 index 8d6217797..000000000 --- a/src/api/java/buildcraft/api/enums/EnumBlueprintType.java +++ /dev/null @@ -1,29 +0,0 @@ -package buildcraft.api.enums; - -import net.minecraft.item.ItemStack; - -import buildcraft.api.items.IBlueprintItem; - -public enum EnumBlueprintType { - NONE, - BLUEPRINT, - TEMPLATE; - - public static EnumBlueprintType valueOf(int index) { - if (index <= 0 || index >= values().length) { - return NONE; - } else { - return values()[index]; - } - } - - public static EnumBlueprintType getType(ItemStack item) { - if (item == null) { - return NONE; - } else if (item.getItem() instanceof IBlueprintItem) { - return ((IBlueprintItem) item.getItem()).getType(item); - } else { - return NONE; - } - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java b/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java index f161e2ba8..0a6b53feb 100755 --- a/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java +++ b/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java @@ -16,7 +16,7 @@ public enum EnumDecoratedBlock implements IStringSerializable { public final int lightValue; - private EnumDecoratedBlock(int lightValue) { + EnumDecoratedBlock(int lightValue) { this.lightValue = lightValue; } diff --git a/src/api/java/buildcraft/api/enums/EnumEngineType.java b/src/api/java/buildcraft/api/enums/EnumEngineType.java index 16e2714b7..38cdc62f7 100755 --- a/src/api/java/buildcraft/api/enums/EnumEngineType.java +++ b/src/api/java/buildcraft/api/enums/EnumEngineType.java @@ -2,7 +2,9 @@ package buildcraft.api.enums; import net.minecraft.util.IStringSerializable; -public enum EnumEngineType implements IStringSerializable { +import buildcraft.api.core.IEngineType; + +public enum EnumEngineType implements IStringSerializable, IEngineType { WOOD("core", "wood"), STONE("energy", "stone"), IRON("energy", "iron"), @@ -15,7 +17,12 @@ public enum EnumEngineType implements IStringSerializable { EnumEngineType(String mod, String loc) { unlocalizedTag = loc; - resourceLocation = "buildcraft" + mod + ":blocks/engine/inv/" + loc + "/"; + resourceLocation = "buildcraft" + mod + ":blocks/engine/inv/" + loc; + } + + @Override + public String getItemModelLocation() { + return resourceLocation; } @Override diff --git a/src/api/java/buildcraft/api/enums/EnumMachineState.java b/src/api/java/buildcraft/api/enums/EnumMachineState.java index 6a215c235..7b7caf740 100755 --- a/src/api/java/buildcraft/api/enums/EnumMachineState.java +++ b/src/api/java/buildcraft/api/enums/EnumMachineState.java @@ -11,7 +11,7 @@ public enum EnumMachineState implements IStringSerializable { DONE; public static EnumMachineState getType(IBlockState state) { - return (EnumMachineState) state.getValue(BuildCraftProperties.MACHINE_STATE); + return state.getValue(BuildCraftProperties.MACHINE_STATE); } @Override diff --git a/src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java b/src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java new file mode 100644 index 000000000..283ca0b02 --- /dev/null +++ b/src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java @@ -0,0 +1,36 @@ +package buildcraft.api.enums; + +import java.util.Locale; + +import net.minecraft.util.IStringSerializable; + +public enum EnumOptionalSnapshotType implements IStringSerializable { + NONE(null), + TEMPLATE(EnumSnapshotType.TEMPLATE), + BLUEPRINT(EnumSnapshotType.BLUEPRINT); + + public final EnumSnapshotType type; + + EnumOptionalSnapshotType(EnumSnapshotType type) { + this.type = type; + } + + public static EnumOptionalSnapshotType fromNullable(EnumSnapshotType type) { + if (type == null) { + return NONE; + } + switch (type) { + case TEMPLATE: + return TEMPLATE; + case BLUEPRINT: + return BLUEPRINT; + default: + return NONE; + } + } + + @Override + public String getName() { + return name().toLowerCase(Locale.ROOT); + } +} diff --git a/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java b/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java index 68ecb2515..95c648fe1 100755 --- a/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java +++ b/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java @@ -1,22 +1,26 @@ package buildcraft.api.enums; +import java.util.Locale; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IStringSerializable; -public enum EnumRedstoneChipset { +import buildcraft.api.BCItems; + +public enum EnumRedstoneChipset implements IStringSerializable { RED, IRON, GOLD, - DIAMOND, - PULSATING, QUARTZ, - COMP, - EMERALD; + DIAMOND; + + private final String name = name().toLowerCase(Locale.ROOT); public ItemStack getStack(int stackSize) { - Item chipset = Item.getByNameOrId("buildcraft|silicon:redstoneChipset"); + Item chipset = BCItems.SILICON_REDSTONE_CHIPSET; if (chipset == null) { - return null; + return ItemStack.EMPTY; } return new ItemStack(chipset, stackSize, ordinal()); @@ -39,4 +43,9 @@ public enum EnumRedstoneChipset { } return values()[ordinal]; } + + @Override + public String getName() { + return name; + } } diff --git a/src/api/java/buildcraft/api/enums/EnumSnapshotType.java b/src/api/java/buildcraft/api/enums/EnumSnapshotType.java new file mode 100644 index 000000000..b3c21245c --- /dev/null +++ b/src/api/java/buildcraft/api/enums/EnumSnapshotType.java @@ -0,0 +1,12 @@ +package buildcraft.api.enums; + +public enum EnumSnapshotType { + TEMPLATE(9), + BLUEPRINT(3); + + public final int maxPerTick; + + EnumSnapshotType(int maxPerTick) { + this.maxPerTick = maxPerTick; + } +} diff --git a/src/api/java/buildcraft/api/enums/EnumSpring.java b/src/api/java/buildcraft/api/enums/EnumSpring.java index 478b5cae8..21e4cf21c 100755 --- a/src/api/java/buildcraft/api/enums/EnumSpring.java +++ b/src/api/java/buildcraft/api/enums/EnumSpring.java @@ -1,24 +1,29 @@ package buildcraft.api.enums; import java.util.Locale; +import java.util.function.Supplier; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IStringSerializable; import buildcraft.api.properties.BuildCraftProperties; public enum EnumSpring implements IStringSerializable { - WATER(5, -1, Blocks.WATER.getDefaultState()), OIL(6000, 8, null); // Set in BuildCraftEnergy + public static final EnumSpring[] VALUES = values(); + public final int tickRate, chance; public IBlockState liquidBlock; public boolean canGen = true; + public Supplier tileConstructor; + private final String lowerCaseName = name().toLowerCase(Locale.ROOT); - private EnumSpring(int tickRate, int chance, IBlockState liquidBlock) { + EnumSpring(int tickRate, int chance, IBlockState liquidBlock) { this.tickRate = tickRate; this.chance = chance; this.liquidBlock = liquidBlock; diff --git a/src/api/java/buildcraft/api/facades/FacadeAPI.java b/src/api/java/buildcraft/api/facades/FacadeAPI.java index b3e214ea8..ce4cb8f06 100755 --- a/src/api/java/buildcraft/api/facades/FacadeAPI.java +++ b/src/api/java/buildcraft/api/facades/FacadeAPI.java @@ -1,9 +1,35 @@ package buildcraft.api.facades; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import net.minecraftforge.fml.common.event.FMLInterModComms; + public final class FacadeAPI { + public static final String IMC_MOD_TARGET = "buildcrafttransport"; + public static final String IMC_FACADE_DISABLE = "facade_disable_block"; + public static final String IMC_FACADE_CUSTOM = "facade_custom_map_block_item"; + public static final String NBT_CUSTOM_BLOCK_REG_KEY = "block_registry_name"; + public static final String NBT_CUSTOM_BLOCK_META = "block_meta"; + public static final String NBT_CUSTOM_ITEM_STACK = "item_stack"; + public static IFacadeItem facadeItem; private FacadeAPI() { } + + public static void disableBlock(Block block) { + FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_DISABLE, block.getRegistryName()); + } + + public static void mapStateToStack(IBlockState state, ItemStack stack) { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setString(NBT_CUSTOM_BLOCK_REG_KEY, state.getBlock().getRegistryName().toString()); + nbt.setInteger(NBT_CUSTOM_BLOCK_META, state.getBlock().getMetaFromState(state)); + nbt.setTag(NBT_CUSTOM_ITEM_STACK, stack.serializeNBT()); + FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_CUSTOM, nbt); + } } diff --git a/src/api/java/buildcraft/api/facades/IFacadeItem.java b/src/api/java/buildcraft/api/facades/IFacadeItem.java index 1fe981a3b..7f4362b49 100755 --- a/src/api/java/buildcraft/api/facades/IFacadeItem.java +++ b/src/api/java/buildcraft/api/facades/IFacadeItem.java @@ -4,13 +4,16 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.facades; +import javax.annotation.Nonnull; + import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; public interface IFacadeItem { - FacadeType getFacadeType(ItemStack facade); + FacadeType getFacadeType(@Nonnull ItemStack facade); + @Nonnull ItemStack getFacadeForBlock(IBlockState state); - IBlockState[] getBlockStatesForFacade(ItemStack facade); + IBlockState[] getBlockStatesForFacade(@Nonnull ItemStack facade); } diff --git a/src/api/java/buildcraft/api/fuels/ICoolant.java b/src/api/java/buildcraft/api/fuels/ICoolant.java index 5d038c8d5..f81a863e0 100755 --- a/src/api/java/buildcraft/api/fuels/ICoolant.java +++ b/src/api/java/buildcraft/api/fuels/ICoolant.java @@ -4,10 +4,13 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.fuels; -import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; public interface ICoolant { - Fluid getFluid(); + boolean matchesFluid(FluidStack fluid); - float getDegreesCoolingPerMB(float heat); + /** @param fluid + * @param heat + * @return 0 if the input fluid provides no cooling, or a value greater than 0 if it does. */ + float getDegreesCoolingPerMB(FluidStack fluid, float heat); } diff --git a/src/api/java/buildcraft/api/fuels/ICoolantManager.java b/src/api/java/buildcraft/api/fuels/ICoolantManager.java index fb535c438..dfcf78b6d 100755 --- a/src/api/java/buildcraft/api/fuels/ICoolantManager.java +++ b/src/api/java/buildcraft/api/fuels/ICoolantManager.java @@ -11,12 +11,14 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import buildcraft.api.core.StackKey; - public interface ICoolantManager { ICoolant addCoolant(ICoolant coolant); - ICoolant addCoolant(Fluid fluid, float degreesCoolingPerMB); + ICoolant addCoolant(FluidStack fluid, float degreesCoolingPerMb); + + default ICoolant addCoolant(Fluid fluid, float degreesCoolingPerMb) { + return addCoolant(new FluidStack(fluid, 1), degreesCoolingPerMb); + } ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant); @@ -26,7 +28,9 @@ public interface ICoolantManager { Collection getSolidCoolants(); - ICoolant getCoolant(Fluid fluid); + ICoolant getCoolant(FluidStack fluid); + + float getDegreesPerMb(FluidStack fluid, float heat); ISolidCoolant getSolidCoolant(ItemStack solid); } diff --git a/src/api/java/buildcraft/api/fuels/IFuel.java b/src/api/java/buildcraft/api/fuels/IFuel.java index 65891f75a..382eb2a28 100755 --- a/src/api/java/buildcraft/api/fuels/IFuel.java +++ b/src/api/java/buildcraft/api/fuels/IFuel.java @@ -4,10 +4,11 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.fuels; -import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; public interface IFuel { - Fluid getFluid(); + /** @return The input fluid. The {@link FluidStack#amount} is ignored. */ + FluidStack getFluid(); /** @return The number of ticks that a single bucket (1000mb) of this fuel will burn for. */ int getTotalBurningTime(); diff --git a/src/api/java/buildcraft/api/fuels/IFuelManager.java b/src/api/java/buildcraft/api/fuels/IFuelManager.java index 137882139..cb02063e0 100755 --- a/src/api/java/buildcraft/api/fuels/IFuelManager.java +++ b/src/api/java/buildcraft/api/fuels/IFuelManager.java @@ -10,17 +10,27 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; public interface IFuelManager { - IFuel addFuel(IFuel fuel); + F addFuel(F fuel); - IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime); + IFuel addFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime); - IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); + default IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime) { + return addFuel(new FluidStack(fluid, 1), powerPerCycle, totalBurningTime); + } + + /** @param residue The residue fluidstack, per bucket of the original fuel. */ + IDirtyFuel addDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); + + /** @param residue The residue fluidstack, per bucket of the original fuel. */ + default IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) { + return addDirtyFuel(new FluidStack(fuel, 1), powerPerCycle, totalBurningTime, residue); + } Collection getFuels(); - IFuel getFuel(Fluid fluid); + IFuel getFuel(FluidStack fluid); - public interface IDirtyFuel extends IFuel { + interface IDirtyFuel extends IFuel { /** @return The residue fluidstack, per bucket of original fuel. */ FluidStack getResidue(); } diff --git a/src/api/java/buildcraft/api/inventory/IItemTransactor.java b/src/api/java/buildcraft/api/inventory/IItemTransactor.java new file mode 100644 index 000000000..212d2e35f --- /dev/null +++ b/src/api/java/buildcraft/api/inventory/IItemTransactor.java @@ -0,0 +1,72 @@ +package buildcraft.api.inventory; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.NonNullList; + +import buildcraft.api.core.IStackFilter; + +/** A simple way to define something that deals with item insertion and extraction, without caring about slots. */ +public interface IItemTransactor { + /** @param stack The stack to insert. Must not be null! + * @param allOrNone If true then either the entire stack will be used or none of it. + * @param simulate If true then the in-world state of this will not be changed. + * @return The overflow stack. Will be {@link ItemStack#EMPTY} if all of it was accepted. */ + @Nonnull + ItemStack insert(@Nonnull ItemStack stack, boolean allOrNone, boolean simulate); + + /** Similar to {@link #insert(ItemStack, boolean, boolean)} but probably be more efficient at inserting lots of + * items. + * + * @param stacks The stacks to insert. Must not be null! + * @param simulate If true then the in-world state of this will not be changed. + * @return The overflow stacks. Will be an empty list if all of it was accepted. */ + default NonNullList insert(NonNullList stacks, boolean simulate) { + NonNullList leftOver = NonNullList.create(); + for (ItemStack stack : stacks) { + ItemStack leftOverStack = insert(stack, false, simulate); + if (!leftOverStack.isEmpty()) { + leftOver.add(leftOverStack); + } + } + return leftOver; + } + + /** Extracts a number of items that match the given filter + * + * @param filter The filter that MUST be met by the extracted stack. Null means no filter - it can be any item. + * @param min The minimum number of items to extract, or 0 if not enough items can be extracted + * @param max The maximum number of items to extract. + * @param simulate If true then the in-world state of this will not be changed. + * @return The stack that was extracted, or {@link ItemStack#EMPTY} if it could not be. */ + @Nonnull + ItemStack extract(@Nullable IStackFilter filter, int min, int max, boolean simulate); + + default boolean canFullyAccept(@Nonnull ItemStack stack) { + return insert(stack, true, true).isEmpty(); + } + + default boolean canPartiallyAccept(@Nonnull ItemStack stack) { + return insert(stack, false, true).getCount() < stack.getCount(); + } + + @FunctionalInterface + interface IItemInsertable extends IItemTransactor { + @Nonnull + @Override + default ItemStack extract(IStackFilter filter, int min, int max, boolean simulate) { + return ItemStack.EMPTY; + } + } + + @FunctionalInterface + interface IItemExtractable extends IItemTransactor { + @Nonnull + @Override + default ItemStack insert(@Nonnull ItemStack stack, boolean allOrNone, boolean simulate) { + return stack; + } + } +} diff --git a/src/api/java/buildcraft/api/items/IBlueprintItem.java b/src/api/java/buildcraft/api/items/IBlueprintItem.java deleted file mode 100755 index d67bc39fd..000000000 --- a/src/api/java/buildcraft/api/items/IBlueprintItem.java +++ /dev/null @@ -1,9 +0,0 @@ -package buildcraft.api.items; - -import net.minecraft.item.ItemStack; - -import buildcraft.api.enums.EnumBlueprintType; - -public interface IBlueprintItem extends INamedItem { - EnumBlueprintType getType(ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/items/IMapLocation.java b/src/api/java/buildcraft/api/items/IMapLocation.java index b10adecd0..cb5dba538 100755 --- a/src/api/java/buildcraft/api/items/IMapLocation.java +++ b/src/api/java/buildcraft/api/items/IMapLocation.java @@ -13,7 +13,7 @@ import buildcraft.api.core.IZone; /** Created by asie on 2/28/15. */ public interface IMapLocation extends INamedItem { - public enum MapLocationType { + enum MapLocationType { CLEAN, SPOT, AREA, diff --git a/src/api/java/buildcraft/api/library/LibraryAPI.java b/src/api/java/buildcraft/api/library/LibraryAPI.java index b3b1e84f8..b8997930a 100755 --- a/src/api/java/buildcraft/api/library/LibraryAPI.java +++ b/src/api/java/buildcraft/api/library/LibraryAPI.java @@ -5,7 +5,7 @@ import java.util.Set; @Deprecated public final class LibraryAPI { - private static final Set handlers = new HashSet(); + private static final Set handlers = new HashSet<>(); private LibraryAPI() { diff --git a/src/api/java/buildcraft/api/lists/ListRegistry.java b/src/api/java/buildcraft/api/lists/ListRegistry.java index 1f3655244..38a916694 100755 --- a/src/api/java/buildcraft/api/lists/ListRegistry.java +++ b/src/api/java/buildcraft/api/lists/ListRegistry.java @@ -7,8 +7,8 @@ import java.util.List; import net.minecraft.item.Item; public final class ListRegistry { - public static final List> itemClassAsType = new ArrayList>(); - private static final List handlers = new ArrayList(); + public static final List> itemClassAsType = new ArrayList<>(); + private static final List handlers = new ArrayList<>(); private ListRegistry() { diff --git a/src/api/java/buildcraft/api/mj/ILaserTarget.java b/src/api/java/buildcraft/api/mj/ILaserTarget.java index 26adb399c..e1fbfb48f 100755 --- a/src/api/java/buildcraft/api/mj/ILaserTarget.java +++ b/src/api/java/buildcraft/api/mj/ILaserTarget.java @@ -9,15 +9,16 @@ package buildcraft.api.mj; * The respective Block MUST implement ILaserTargetBlock! */ public interface ILaserTarget { - /** Returns true if the target currently needs power. For example, if the Advanced Crafting Table has work to do. + /** Returns The amount of power this target currently needs. * - * @return true if needs power */ - boolean requiresLaserPower(); + * @return The amount of power required, or 0 if no power is required. */ + long getRequiredLaserPower(); /** Transfers power from the laser to the target. * - * @param microJoules The number of micro Minecraft Joules to accept */ - void receiveLaserPower(long microJoules); + * @param microJoules The number of micro Minecraft Joules to accept + * @return The excess power. If the input is less than or equal to {@link #getRequiredLaserPower()} then this will return 0. */ + long receiveLaserPower(long microJoules); /** Return true if the Tile Entity object is no longer a valid target. For example, if its been invalidated. * diff --git a/src/api/java/buildcraft/api/mj/IMjReceiver.java b/src/api/java/buildcraft/api/mj/IMjReceiver.java index fe9eadd0b..a8cecd7d4 100755 --- a/src/api/java/buildcraft/api/mj/IMjReceiver.java +++ b/src/api/java/buildcraft/api/mj/IMjReceiver.java @@ -12,8 +12,19 @@ public interface IMjReceiver extends IMjConnector { *
  • Refuse all power (if you have no more work to do or your {@link MjBattery} is full). * * + * Note that callers are NOT expected to call {@link #canReceive()} before calling this - implementors should check + * all of the conditions in {@link #canReceive()} before accepting power. + * * @param microJoules The number of micro joules to add. * @param simulate If true then just pretend you received power- don't actually change any of your internal state. * @return The excess power. */ long receivePower(long microJoules, boolean simulate); + + /** Checks to see if {@link #receivePower(long, boolean)} *might* accept any power right now, ignoring the amount of + * power contained right now (if any). + * + * @return True if this {@link IMjReceiver} can receive power right now. */ + default boolean canReceive() { + return true; + } } diff --git a/src/api/java/buildcraft/api/mj/MjAPI.java b/src/api/java/buildcraft/api/mj/MjAPI.java index 8bf317e1f..87d74e897 100755 --- a/src/api/java/buildcraft/api/mj/MjAPI.java +++ b/src/api/java/buildcraft/api/mj/MjAPI.java @@ -1,20 +1,17 @@ package buildcraft.api.mj; import java.text.DecimalFormat; -import java.util.concurrent.Callable; import javax.annotation.Nonnull; -import net.minecraft.nbt.NBTBase; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; -import net.minecraftforge.common.capabilities.CapabilityManager; -import buildcraft.api.core.APIHelper; +import buildcraft.api.core.CapabilitiesHelper; public class MjAPI { @@ -30,9 +27,38 @@ public class MjAPI { public static final long MJ = ONE_MINECRAFT_JOULE; /** The decimal format used to display values of MJ to the player. Note that this */ - public static final DecimalFormat MJ_DISPLAY_FORMAT = new DecimalFormat("###0.##"); + public static final DecimalFormat MJ_DISPLAY_FORMAT = new DecimalFormat("#,##0.##"); - public static final IMjEffectManager EFFECT_MANAGER = APIHelper.getInstance("", IMjEffectManager.class, NullaryEffectManager.INSTANCE); + public static IMjEffectManager EFFECT_MANAGER = NullaryEffectManager.INSTANCE; + + // ############### + // + // Helpful methods + // + // ############### + + /** Formats a given MJ value to a player-oriented string. Note that this does not append "MJ" to the value. */ + public static String formatMj(long microMj) { + return formatMjInternal(microMj / (double) MJ); + } + + private static String formatMjInternal(double val) { + return MJ_DISPLAY_FORMAT.format(val); + } + + // ######################################## + // + // Null based classes + // + // ######################################## + + public enum NullaryEffectManager implements IMjEffectManager { + INSTANCE; + @Override public void createPowerLossEffect(World world, Vec3d center, long microJoulesLost) {} + @Override public void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost) {} + @Override public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost) {} + } + // @formatter:on // ############### // @@ -55,63 +81,6 @@ public class MjAPI { @Nonnull public static final Capability CAP_PASSIVE_PROVIDER; - // ############### - // - // Helpful methods - // - // ############### - - /** Formats a given MJ value to a player-oriented string. Note that this does not append "MJ" to the value. */ - public static String formatMj(long microMj) { - return formatMjInternal(microMj / (double) MJ); - } - - /** Formats a given MJ value to a player-oriented string. Note that this DOES append "*MJ" to the value. This does - * however shorten it down to a small length, and displays "µ", "m", "K" or "M" or "G" before the MJ depending on - * how big or small the value is. */ - public static String formatMjShort(long microJoules) { - if (microJoules == 0) { - return "0 Mj"; - } - long limit = 1; - final long nextUnitCap = 800; - if (microJoules < nextUnitCap * limit) {// micro MJ - return formatMjInternal(microJoules) + " µMJ"; - } - limit *= 1000; - if (microJoules < nextUnitCap * limit) { // milli MJ - return formatMjInternal(microJoules / (double) limit) + " mMJ"; - } - limit *= 1000; - if (microJoules < nextUnitCap * limit) { // MJ - return formatMjInternal(microJoules / (double) limit) + " MJ"; - } - limit *= 1000; - if (microJoules < nextUnitCap * limit) {// kilo MJ - return formatMjInternal(microJoules / (double) limit) + " KMJ"; - } - limit *= 1000; - if (microJoules < nextUnitCap * limit) {// mega MJ - return formatMjInternal(microJoules / (double) limit) + " MMJ"; - } - limit *= 1000; - return formatMjInternal(microJoules / (double) limit) + " GMJ"; - } - - // ######################################## - // - // Null based classes - // - // ######################################## - - public enum NullaryEffectManager implements IMjEffectManager { - INSTANCE; - @Override public void createPowerLossEffect(World world, Vec3d center, long microJoulesLost) {} - @Override public void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost) {} - @Override public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost) {} - } - // @formatter:on - // #################### // // Internal API logic @@ -135,50 +104,16 @@ public class MjAPI { private static final Capability CAP_PASSIVE_PROVIDER_FIRST = null; static { - registerCapability(IMjConnector.class); - registerCapability(IMjReceiver.class); - registerCapability(IMjRedstoneReceiver.class); - registerCapability(IMjReadable.class); - registerCapability(IMjPassiveProvider.class); + CapabilitiesHelper.registerCapability(IMjConnector.class); + CapabilitiesHelper.registerCapability(IMjReceiver.class); + CapabilitiesHelper.registerCapability(IMjRedstoneReceiver.class); + CapabilitiesHelper.registerCapability(IMjReadable.class); + CapabilitiesHelper.registerCapability(IMjPassiveProvider.class); - CAP_CONNECTOR = ensureRegistration(CAP_CONNECTOR_FIRST, IMjConnector.class); - CAP_RECEIVER = ensureRegistration(CAP_RECEIVER_FIRST, IMjReceiver.class); - CAP_REDSTONE_RECEIVER = ensureRegistration(CAP_REDSTONE_RECEIVER_FIRST, IMjRedstoneReceiver.class); - CAP_READABLE = ensureRegistration(CAP_READABLE_FIRST, IMjReadable.class); - CAP_PASSIVE_PROVIDER = ensureRegistration(CAP_PASSIVE_PROVIDER_FIRST, IMjPassiveProvider.class); - } - - private static void registerCapability(Class clazz) { - CapabilityManager.INSTANCE.register(clazz, new VoidStorage(), new Callable() { - // No lambda because of java 6... :( - @Override - public T call() throws Exception { - throw new IllegalStateException("You must create your own instances!"); - } - }); - } - - @Nonnull - private static Capability ensureRegistration(Capability cap, Class clazz) { - if (cap == null) { - throw new Error("Capability registration failed for " + clazz); - } - return cap; - } - - private static class VoidStorage implements Capability.IStorage { - @Override - public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { - throw new IllegalStateException("You must create your own instances!"); - } - - @Override - public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { - throw new IllegalStateException("You must create your own instances!"); - } - } - - private static String formatMjInternal(double val) { - return MJ_DISPLAY_FORMAT.format(val); + CAP_CONNECTOR = CapabilitiesHelper.ensureRegistration(CAP_CONNECTOR_FIRST, IMjConnector.class); + CAP_RECEIVER = CapabilitiesHelper.ensureRegistration(CAP_RECEIVER_FIRST, IMjReceiver.class); + CAP_REDSTONE_RECEIVER = CapabilitiesHelper.ensureRegistration(CAP_REDSTONE_RECEIVER_FIRST, IMjRedstoneReceiver.class); + CAP_READABLE = CapabilitiesHelper.ensureRegistration(CAP_READABLE_FIRST, IMjReadable.class); + CAP_PASSIVE_PROVIDER = CapabilitiesHelper.ensureRegistration(CAP_PASSIVE_PROVIDER_FIRST, IMjPassiveProvider.class); } } diff --git a/src/api/java/buildcraft/api/mj/MjBattery.java b/src/api/java/buildcraft/api/mj/MjBattery.java index ca86ce1f3..68c2ea12e 100755 --- a/src/api/java/buildcraft/api/mj/MjBattery.java +++ b/src/api/java/buildcraft/api/mj/MjBattery.java @@ -1,5 +1,7 @@ package buildcraft.api.mj; +import io.netty.buffer.ByteBuf; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; @@ -7,8 +9,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.INBTSerializable; -import io.netty.buffer.ByteBuf; - /** Provides a basic implementation of a simple battery. Note that you should call {@link #tick(World, BlockPos)} or * {@link #tick(World, Vec3d)} every tick to allow for losing excess power. */ public class MjBattery implements INBTSerializable { diff --git a/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java b/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java index 41f78747d..c70c74cb2 100755 --- a/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java +++ b/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java @@ -35,23 +35,27 @@ public class MjCapabilityHelper implements ICapabilityProvider { } @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { - if (capability == MjAPI.CAP_CONNECTOR) return true; - if (capability == MjAPI.CAP_RECEIVER) return receiver != null; - if (capability == MjAPI.CAP_REDSTONE_RECEIVER) return rsReceiver != null; - if (capability == MjAPI.CAP_READABLE) return readable != null; - if (capability == MjAPI.CAP_PASSIVE_PROVIDER) return provider != null; - return false; + public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { + return getCapability(capability, facing) != null; } @Override - public T getCapability(Capability capability, EnumFacing facing) { - if (capability == MjAPI.CAP_CONNECTOR) return (T) connector; - if (capability == MjAPI.CAP_RECEIVER) return (T) receiver; - if (capability == MjAPI.CAP_REDSTONE_RECEIVER) return (T) rsReceiver; - if (capability == MjAPI.CAP_READABLE) return (T) readable; - if (capability == MjAPI.CAP_PASSIVE_PROVIDER) return (T) provider; + public T getCapability(@Nonnull Capability capability, EnumFacing facing) { + if (capability == MjAPI.CAP_CONNECTOR) { + return MjAPI.CAP_CONNECTOR.cast(connector); + } + if (capability == MjAPI.CAP_RECEIVER) { + return MjAPI.CAP_RECEIVER.cast(receiver); + } + if (capability == MjAPI.CAP_REDSTONE_RECEIVER) { + return MjAPI.CAP_REDSTONE_RECEIVER.cast(rsReceiver); + } + if (capability == MjAPI.CAP_READABLE) { + return MjAPI.CAP_READABLE.cast(readable); + } + if (capability == MjAPI.CAP_PASSIVE_PROVIDER) { + return MjAPI.CAP_PASSIVE_PROVIDER.cast(provider); + } return null; } - } diff --git a/src/api/java/buildcraft/api/mj/package-info.java b/src/api/java/buildcraft/api/mj/package-info.java index c2670e4cf..8afa7544e 100755 --- a/src/api/java/buildcraft/api/mj/package-info.java +++ b/src/api/java/buildcraft/api/mj/package-info.java @@ -4,8 +4,8 @@ * power should be passed around in code as micro Mj (10 ^ -6 of an Mj), but shown to the player as full MJ - so divided by 1 * million. *

    - * A single MJ as a constant is available in {@link buildcraft.api.mj.MjAPI#ONE_MINECRAFT_JOULE}, and two player - * formatter's ( {@link buildcraft.api.mj.MjAPI#formatMj(long)}, and {@link buildcraft.api.mj.MjAPI#formatMjShort(long)} + * A single MJ as a constant is available in {@link buildcraft.api.mj.MjAPI#ONE_MINECRAFT_JOULE}, and a player + * formatter {@link buildcraft.api.mj.MjAPI#formatMj(long)} *

    *

    Capability's

    *

    diff --git a/src/api/java/buildcraft/api/permission/IOwner.java b/src/api/java/buildcraft/api/permission/IOwner.java deleted file mode 100755 index 0fa178d2b..000000000 --- a/src/api/java/buildcraft/api/permission/IOwner.java +++ /dev/null @@ -1,24 +0,0 @@ -package buildcraft.api.permission; - -import java.util.UUID; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.server.MinecraftServer; - -/** Defines an owner -- this is an actual player in the world, or an offline player. */ -public interface IOwner { - /** Gets the player, if they actually exist on the server */ - @Nullable - EntityPlayer getPlayer(MinecraftServer server); - - /** Gets the player's UUID */ - @Nonnull - UUID getPlayerUUID(); - - /** Gets the player's name. */ - @Nonnull - String getPlayerName(); -} diff --git a/src/api/java/buildcraft/api/properties/BuildCraftExtendedProperty.java b/src/api/java/buildcraft/api/properties/BuildCraftExtendedProperty.java deleted file mode 100755 index e0ba3a62d..000000000 --- a/src/api/java/buildcraft/api/properties/BuildCraftExtendedProperty.java +++ /dev/null @@ -1,65 +0,0 @@ -package buildcraft.api.properties; - -import java.util.List; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; - -import net.minecraftforge.common.property.IExtendedBlockState; -import net.minecraftforge.common.property.IUnlistedProperty; - -public class BuildCraftExtendedProperty> extends BuildCraftProperty implements IUnlistedProperty { - private final Predicate function; - - public BuildCraftExtendedProperty(String name, Class clazz, Predicate allowingFunction) { - super(name, clazz); - function = allowingFunction; - } - - public BuildCraftExtendedProperty(String name, Class clazz, List allowedValues) { - super(name, clazz, allowedValues); - function = null; - } - - public static BuildCraftExtendedProperty create(String name, final double min, final double max) { - return new BuildCraftExtendedProperty(name, Double.class, new Predicate() { - @Override - public boolean apply(Double input) { - return input >= min && input <= max; - } - }); - } - - /** This is useful if you want to use a particular class for this property, but don't care what the class contains - * (it will never contain an incorrect value) */ - public static > BuildCraftExtendedProperty createExtended(String name, Class clazz) { - return new BuildCraftExtendedProperty(name, clazz, Predicates. alwaysTrue()); - } - - @Override - public boolean isValid(T value) { - if (function == null) { - return values.contains(value); - } - return function.apply(value); - } - - @Override - public Class getType() { - return getValueClass(); - } - - @Override - public String valueToString(T value) { - return valueName(value); - } - - public T getUnlistedValue(IExtendedBlockState state) { - return state.getValue(asUnlistedProperty()); - } - - // Helper methods for arguments - public IUnlistedProperty asUnlistedProperty() { - return this; - } -} diff --git a/src/api/java/buildcraft/api/properties/BuildCraftProperties.java b/src/api/java/buildcraft/api/properties/BuildCraftProperties.java index d7f883b7b..63a519ad0 100755 --- a/src/api/java/buildcraft/api/properties/BuildCraftProperties.java +++ b/src/api/java/buildcraft/api/properties/BuildCraftProperties.java @@ -4,50 +4,54 @@ import java.util.Map; import com.google.common.collect.Maps; +import net.minecraft.block.properties.IProperty; +import net.minecraft.block.properties.PropertyBool; +import net.minecraft.block.properties.PropertyEnum; +import net.minecraft.block.properties.PropertyInteger; import net.minecraft.item.EnumDyeColor; import net.minecraft.util.EnumFacing; -import buildcraft.api.enums.*; +import buildcraft.api.enums.EnumDecoratedBlock; +import buildcraft.api.enums.EnumEngineType; +import buildcraft.api.enums.EnumFillerPattern; +import buildcraft.api.enums.EnumLaserTableType; +import buildcraft.api.enums.EnumMachineState; +import buildcraft.api.enums.EnumOptionalSnapshotType; +import buildcraft.api.enums.EnumPowerStage; +import buildcraft.api.enums.EnumSpring; public final class BuildCraftProperties { - public static final BuildCraftProperty BLOCK_FACING = BuildCraftProperty.create("facing", EnumFacing.Plane.HORIZONTAL.facings()); - public static final BuildCraftProperty BLOCK_FACING_6 = BuildCraftProperty.create("facing", EnumFacing.class); + public static final IProperty BLOCK_FACING = PropertyEnum.create("facing", EnumFacing.class, EnumFacing.Plane.HORIZONTAL.facings()); + public static final IProperty BLOCK_FACING_6 = PropertyEnum.create("facing", EnumFacing.class); - public static final BuildCraftProperty BLOCK_COLOR = BuildCraftProperty.create("color", EnumDyeColor.class); - public static final BuildCraftProperty SPRING_TYPE = BuildCraftProperty.create("type", EnumSpring.class); - public static final BuildCraftProperty ENGINE_TYPE = BuildCraftProperty.create("type", EnumEngineType.class); - public static final BuildCraftProperty LASER_TABLE_TYPE = BuildCraftProperty.create("type", EnumLaserTableType.class); - public static final BuildCraftProperty MACHINE_STATE = BuildCraftProperty.create("state", EnumMachineState.class); - public static final BuildCraftProperty ENERGY_STAGE = BuildCraftProperty.create("stage", EnumPowerStage.class); - public static final BuildCraftProperty BLUEPRINT_TYPE = BuildCraftProperty.create("blueprint_type", EnumBlueprintType.class); - public static final BuildCraftProperty DECORATED_BLOCK = BuildCraftProperty.create("decoration_type", EnumDecoratedBlock.class); + public static final IProperty BLOCK_COLOR = PropertyEnum.create("color", EnumDyeColor.class); + public static final IProperty SPRING_TYPE = PropertyEnum.create("type", EnumSpring.class); + public static final IProperty ENGINE_TYPE = PropertyEnum.create("type", EnumEngineType.class); + public static final IProperty LASER_TABLE_TYPE = PropertyEnum.create("type", EnumLaserTableType.class); + public static final IProperty MACHINE_STATE = PropertyEnum.create("state", EnumMachineState.class); + public static final IProperty ENERGY_STAGE = PropertyEnum.create("stage", EnumPowerStage.class); + public static final IProperty SNAPSHOT_TYPE = PropertyEnum.create("snapshot_type", EnumOptionalSnapshotType.class); + public static final IProperty DECORATED_BLOCK = PropertyEnum.create("decoration_type", EnumDecoratedBlock.class); - public static final BuildCraftProperty GENERIC_PIPE_DATA = BuildCraftProperty.create("pipe_data", 0, 15); - public static final BuildCraftProperty LED_POWER = BuildCraftProperty.create("led_power", 0, 3); + public static final IProperty GENERIC_PIPE_DATA = PropertyInteger.create("pipe_data", 0, 15); + public static final IProperty LED_POWER = PropertyInteger.create("led_power", 0, 3); - public static final BuildCraftProperty JOINED_BELOW = BuildCraftProperty.create("joined_below", false); - public static final BuildCraftProperty MOVING = BuildCraftProperty.create("moving", false); - public static final BuildCraftProperty LED_DONE = BuildCraftProperty.create("led_done", false); - public static final BuildCraftProperty ACTIVE = BuildCraftProperty.create("active", false); - public static final BuildCraftProperty VALID = BuildCraftProperty.create("valid", false); + public static final IProperty JOINED_BELOW = PropertyBool.create("joined_below"); + public static final IProperty MOVING = PropertyBool.create("moving"); + public static final IProperty LED_DONE = PropertyBool.create("led_done"); + public static final IProperty ACTIVE = PropertyBool.create("active"); + public static final IProperty VALID = PropertyBool.create("valid"); - public static final BuildCraftProperty CONNECTED_UP = BuildCraftProperty.create("connected_up", false); - public static final BuildCraftProperty CONNECTED_DOWN = BuildCraftProperty.create("connected_down", false); - public static final BuildCraftProperty CONNECTED_EAST = BuildCraftProperty.create("connected_east", false); - public static final BuildCraftProperty CONNECTED_WEST = BuildCraftProperty.create("connected_west", false); - public static final BuildCraftProperty CONNECTED_NORTH = BuildCraftProperty.create("connected_north", false); - public static final BuildCraftProperty CONNECTED_SOUTH = BuildCraftProperty.create("connected_south", false); + public static final IProperty CONNECTED_UP = PropertyBool.create("connected_up"); + public static final IProperty CONNECTED_DOWN = PropertyBool.create("connected_down"); + public static final IProperty CONNECTED_EAST = PropertyBool.create("connected_east"); + public static final IProperty CONNECTED_WEST = PropertyBool.create("connected_west"); + public static final IProperty CONNECTED_NORTH = PropertyBool.create("connected_north"); + public static final IProperty CONNECTED_SOUTH = PropertyBool.create("connected_south"); - public static final Map> CONNECTED_MAP; + public static final Map> CONNECTED_MAP; - // Unlisted properties - // public static final PropertyDouble FLUID_HEIGHT_NE = new PropertyDouble("height_ne", 0, 1); - // public static final PropertyDouble FLUID_HEIGHT_NW = new PropertyDouble("height_nw", 0, 1); - // public static final PropertyDouble FLUID_HEIGHT_SE = new PropertyDouble("height_se", 0, 1); - // public static final PropertyDouble FLUID_HEIGHT_SW = new PropertyDouble("height_sw", 0, 1); - // public static final PropertyDouble FLUID_FLOW_DIRECTION = new PropertyDouble("direction", - // Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); - public static final BuildCraftProperty FILLER_PATTERN = BuildCraftProperty.create("pattern", EnumFillerPattern.class); + public static final IProperty FILLER_PATTERN = PropertyEnum.create("pattern", EnumFillerPattern.class); // Block state setting flags -these are used by World.markAndNotifyBlock and World.setBlockState. These flags can be // added together to pass the additions @@ -69,7 +73,7 @@ public final class BuildCraftProperties { public static final int UPDATE_ALL = UPDATE_NEIGHBOURS + MARK_BLOCK_FOR_UPDATE + UPDATE_EVEN_CLIENT; static { - Map> map = Maps.newEnumMap(EnumFacing.class); + Map> map = Maps.newEnumMap(EnumFacing.class); map.put(EnumFacing.DOWN, CONNECTED_DOWN); map.put(EnumFacing.UP, CONNECTED_UP); map.put(EnumFacing.EAST, CONNECTED_EAST); diff --git a/src/api/java/buildcraft/api/properties/BuildCraftProperty.java b/src/api/java/buildcraft/api/properties/BuildCraftProperty.java deleted file mode 100755 index f13f82c5b..000000000 --- a/src/api/java/buildcraft/api/properties/BuildCraftProperty.java +++ /dev/null @@ -1,147 +0,0 @@ -package buildcraft.api.properties; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Locale; - -import com.google.common.base.Optional; - -import net.minecraft.block.properties.PropertyHelper; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.math.MathHelper; - -/** This class exists primarily to allow for a property to be used as either a normal IProperty, or an - * IUnlistedProperty. It also exists to give IProperty's generic types. */ -public class BuildCraftProperty> extends PropertyHelper { - private final String name; - private final Class clazz; - protected final List values; - - public BuildCraftProperty(String name, Class clazz, T[] values) { - this(name, clazz, Arrays.asList(values)); - } - - public BuildCraftProperty(String name, Class clazz, List values) { - super(name, clazz); - this.name = name; - this.clazz = clazz; - this.values = values; - } - - /** Used for BuildCraftInifiniteProperty */ - protected BuildCraftProperty(String name, Class clazz) { - super(name, clazz); - this.name = name; - this.clazz = clazz; - this.values = Collections.emptyList(); - } - - public static > BuildCraftProperty create(String name, Class enumeration) { - List values = Arrays.asList(enumeration.getEnumConstants()); - return new BuildCraftProperty(name, enumeration, values); - } - - public static > BuildCraftProperty create(String name, E... values) { - Class clazz = values[0].getDeclaringClass(); - List list = Arrays.asList(values); - return new BuildCraftProperty(name, clazz, list); - } - - public static BuildCraftProperty create(String name, boolean first) { - return new BuildCraftProperty(name, Boolean.class, new Boolean[] { first, !first }); - } - - /** first and last are both inclusive values (use 0, 4 to create an array of [0, 1, 2, 3, 4]) */ - public static BuildCraftProperty create(String name, int first, int last) { - return create(name, first, last, 1); - } - - /** first and last are both inclusive values (use 0, 12, 3 to create an array of [0, 3, 6, 9, 12]) */ - public static BuildCraftProperty create(String name, int first, int last, int difference) { - int actualDiff = Math.abs(difference); - int number = MathHelper.floor(Math.abs(first - last) / (float) actualDiff + 1); - Integer[] array = new Integer[number]; - int addedDiff = actualDiff * (first > last ? -1 : 1); - int current = first; - for (int i = 0; i < array.length; i++) { - array[i] = current; - current += addedDiff; - } - return new BuildCraftProperty(name, Integer.class, array); - } - - public static BuildCraftProperty create(String name, double first, double last) { - return create(name, first, last, 1); - } - - public static BuildCraftProperty create(String name, double first, double last, double difference) { - double actualDiff = Math.abs(difference); - Double[] array = new Double[(int) (Math.abs(first - last) / actualDiff)]; - double addedDiff = actualDiff * (first > last ? -1 : 1); - for (int i = 0; i <= array.length; i++) { - array[i] = first + (first - last) / addedDiff * i; - } - return new BuildCraftProperty(name, Double.class, array); - } - - @Override - public String getName() { - return name; - } - - @Override - public List getAllowedValues() { - return values; - } - - @Override - public Class getValueClass() { - return clazz; - } - - @Override - public String getName(@SuppressWarnings("rawtypes") Comparable value) { - return valueName(value); - } - - protected String valueName(Object value) { - if (value == null) { - return "null"; - } else if (value instanceof IStringSerializable) { - return ((IStringSerializable) value).getName(); - } else if (value instanceof Enum) { - return ((Enum) value).name().toLowerCase(Locale.ROOT); - } else { - return value.toString().toLowerCase(Locale.ROOT); - } - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("BuildCraftProperty [name="); - builder.append(name); - builder.append(", clazz="); - builder.append(clazz); - builder.append(", values="); - builder.append(values); - builder.append("]"); - return builder.toString(); - } - - @Override - public Optional parseValue(String value) { - if (clazz.isEnum()) { - return parseEnum(value, (BuildCraftProperty) this); - } - return Optional.absent(); - } - - public static > Optional parseEnum(String name, BuildCraftProperty prop) { - for (E e : prop.values) { - if (e.name().equalsIgnoreCase(name)) return Optional.of(e); - } - return Optional.absent(); - } -} diff --git a/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java b/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java index 0baba21c0..44a2b01ff 100755 --- a/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java +++ b/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java @@ -1,109 +1,72 @@ package buildcraft.api.recipes; -import java.io.IOException; -import java.util.Iterator; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import com.google.common.collect.ImmutableSet; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.Constants; +import buildcraft.api.core.BuildCraftAPI; /** Provides an immutable assembly recipe */ -public final class AssemblyRecipe { +public final class AssemblyRecipe implements Comparable { + public final ResourceLocation name; public final long requiredMicroJoules; - public final ImmutableSet requiredStacks; - public final ItemStack output; + public final ImmutableSet requiredStacks; + public final @Nonnull ItemStack output; + /** + * Additional tag used to restore network-transmitted recipe to same state.
    + * You need to register own {@link IAssemblyRecipeProvider} using {@link IAssemblyRecipeRegistry#addRecipeProvider(IAssemblyRecipeProvider)} + * to handle this and declare {@link IAssemblyRecipeProvider#getRecipe(ResourceLocation, NBTTagCompound)} method + */ + public final @Nullable NBTTagCompound recipeTag; - public AssemblyRecipe(long requiredMicroJoules, ImmutableSet requiredStacks, ItemStack output) { + public AssemblyRecipe(ResourceLocation name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { + this.name = name; this.requiredMicroJoules = requiredMicroJoules; - this.requiredStacks = requiredStacks; + this.requiredStacks = ImmutableSet.copyOf(requiredStacks); this.output = output; + this.recipeTag = recipeTag; } - public AssemblyRecipe(NBTTagCompound nbt) { - requiredMicroJoules = nbt.getLong("required_micro_joules"); - NBTTagList requiredStacksTag = nbt.getTagList("required_stacks", Constants.NBT.TAG_COMPOUND); - NonNullList requiredStacksArray = NonNullList.withSize(requiredStacksTag.tagCount(), ItemStack.EMPTY); - for(int i = 0; i < requiredStacksTag.tagCount(); i++) { - requiredStacksArray.set(i, new ItemStack(requiredStacksTag.getCompoundTagAt(i))); - } - requiredStacks = ImmutableSet.copyOf(requiredStacksArray); - output = new ItemStack(nbt.getCompoundTag("output")); + public AssemblyRecipe(String name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { + this(BuildCraftAPI.nameToResourceLocation(name), requiredMicroJoules, requiredStacks, output, recipeTag); } - public AssemblyRecipe(PacketBuffer buffer) throws IOException { - requiredMicroJoules = buffer.readLong(); - int count = buffer.readInt(); - NonNullList requiredStacksArray = NonNullList.withSize(count, ItemStack.EMPTY); - for(int i = 0; i < count; i++) { - requiredStacksArray.set(i, buffer.readItemStack()); - } - requiredStacks = ImmutableSet.copyOf(requiredStacksArray); - output = buffer.readItemStack(); + public AssemblyRecipe(ResourceLocation name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output) { + this(name, requiredMicroJoules, requiredStacks, output, null); } - public NBTTagCompound writeToNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("required_micro_joules", requiredMicroJoules); - NBTTagList requiredStacksTag = new NBTTagList(); - for(ItemStack requiredStack : requiredStacks) { - requiredStacksTag.appendTag(requiredStack.serializeNBT()); - } - nbt.setTag("required_stacks", requiredStacksTag); - nbt.setTag("output", output.serializeNBT()); - return nbt; - } - - public void writeToBuffer(PacketBuffer buffer) { - buffer.writeLong(requiredMicroJoules); - buffer.writeInt(requiredStacks.size()); - requiredStacks.forEach(buffer::writeItemStack); - buffer.writeItemStack(output); + public AssemblyRecipe(String name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output) { + this(name, requiredMicroJoules, requiredStacks, output, null); } @Override public boolean equals(Object o) { - if(this == o) { + if (this == o) { return true; } - if(o == null || getClass() != o.getClass()) { + if (o == null || getClass() != o.getClass()) { return false; } AssemblyRecipe that = (AssemblyRecipe) o; - if(requiredMicroJoules != that.requiredMicroJoules) { - return false; - } - if(requiredStacks != null && that.requiredStacks != null) { - Iterator iterator1 = requiredStacks.iterator(); - Iterator iterator2 = that.requiredStacks.iterator(); - while(iterator1.hasNext()) { - if (!iterator2.hasNext()) { - return false; - } - ItemStack o1 = iterator1.next(); - ItemStack o2 = iterator2.next(); - if (!ItemStack.areItemStacksEqual(o1, o2)) { - return false; - } - } - return !iterator2.hasNext() && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; - } else { - return requiredStacks == null && that.requiredStacks == null && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; - } + return name.equals(that.name); } @Override public int hashCode() { - int result = (int) (requiredMicroJoules ^ (requiredMicroJoules >>> 32)); - result = 31 * result + (requiredStacks != null ? requiredStacks.hashCode() : 0); - result = 31 * result + (output != null ? output.hashCode() : 0); - return result; + return name.hashCode(); + } + + @Override + public int compareTo(AssemblyRecipe o) { + return name.toString().compareTo(o.name.toString()); } } diff --git a/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java index fd0838ab5..1c074e9db 100755 --- a/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java +++ b/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java @@ -8,7 +8,7 @@ public final class BuildcraftRecipeRegistry { public static IAssemblyRecipeRegistry assemblyRecipes; public static IIntegrationRecipeRegistry integrationRecipes; - public static IComplexRefineryRecipeManager complexRefinery; + public static IRefineryRecipeManager refineryRecipes; private BuildcraftRecipeRegistry() {} } diff --git a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java index 4e051d78d..f98567653 100755 --- a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java +++ b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java @@ -1,20 +1,32 @@ package buildcraft.api.recipes; import java.util.List; +import java.util.Optional; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; /** Provides a way of registering complex recipes without needing to register every possible variant. If you want the * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class - * IAssemblyRecipeViewable. */ + * IRecipeViewable. */ public interface IAssemblyRecipeProvider { /** Should return a list of all the valid recipes given the input items. The list may be empty, but must not be * null. Note that this will *most likely* be slow to check everything, so you should cache the return value and * re-use it when you can. */ @Nonnull - List getRecipesFor(@Nonnull NonNullList possibleIn); + List getRecipesFor(@Nonnull NonNullList possible); + + /** + * Returns recipe by it's name + * @param recipeTag Additional tag attached to network-transmitted recipe definition + */ + default Optional getRecipe(@Nonnull ResourceLocation name, @Nullable NBTTagCompound recipeTag) { + return Optional.empty(); + } } diff --git a/src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java b/src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java deleted file mode 100755 index 5623b5eaa..000000000 --- a/src/api/java/buildcraft/api/recipes/IComplexRefineryRecipeManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Set; - -import com.google.common.base.Predicate; - -import net.minecraftforge.fluids.FluidStack; - -public interface IComplexRefineryRecipeManager { - IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks); - - IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks, boolean replaceExisting); - - ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks); - - ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo, int ticks, boolean replaceExisting); - - IDistilationRecipe createDistilationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, int ticks); - - IDistilationRecipe addDistilationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, int ticks, boolean replaceExisting); - - IComplexRefineryRegistry getHeatableRegistry(); - - IComplexRefineryRegistry getCoolableRegistry(); - - IComplexRefineryRegistry getDistilationRegistry(); - - public interface IComplexRefineryRegistry { - /** @return an unmodifiable set containing all of the distilation recipies that satisfy the given predicate. All - * of the recipe objects are guarenteed to never be null. */ - Set getRecipes(Predicate toReturn); - - /** @return an unmodifiable set containing all of the distilation recipies. */ - Set getAllRecipes(); - - R getRecipeForInput(FluidStack fluid); - - Set removeRecipes(Predicate toRemove); - - R addRecipe(R recipe, boolean replaceExisting); - } - - public interface IComplexRefineryRecipe { - int ticks(); - - FluidStack in(); - } - - public interface IHeatExchangerRecipe extends IComplexRefineryRecipe { - FluidStack out(); - - int heatFrom(); - - int heatTo(); - } - - public interface IHeatableRecipe extends IHeatExchangerRecipe {} - - public interface ICoolableRecipe extends IHeatExchangerRecipe {} - - public interface IDistilationRecipe extends IComplexRefineryRecipe { - FluidStack outGas(); - - FluidStack outLiquid(); - } -} diff --git a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java index 77b1cfc22..5c3d6446f 100755 --- a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java +++ b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java @@ -1,10 +1,14 @@ package buildcraft.api.recipes; +import java.util.Optional; + import javax.annotation.Nonnull; import javax.annotation.Nullable; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; /** Provides a way of registering complex recipes without needing to register every possible variant. If you want the * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class @@ -17,4 +21,12 @@ public interface IIntegrationRecipeProvider { * @return */ @Nullable IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList toIntegrate); + + /** + * Returns recipe by it's name + * @param recipeTag Additional tag attached to network-transmitted recipe definition + */ + default Optional getRecipe(@Nonnull ResourceLocation name, @Nullable NBTTagCompound recipeTag) { + return Optional.empty(); + } } diff --git a/src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java b/src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java new file mode 100644 index 000000000..65b523bd8 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java @@ -0,0 +1,81 @@ +package buildcraft.api.recipes; + +import java.util.Collection; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import javax.annotation.Nullable; + +import net.minecraftforge.fluids.FluidStack; + +public interface IRefineryRecipeManager { + IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); + + default IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) { + return getHeatableRegistry().addRecipe(createHeatingRecipe(in, out, heatFrom, heatTo)); + } + + ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); + + default ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) { + return getCoolableRegistry().addRecipe(createCoolableRecipe(in, out, heatFrom, heatTo)); + } + + IDistillationRecipe createDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired); + + default IDistillationRecipe addDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired) { + return getDistillationRegistry().addRecipe(createDistillationRecipe(in, outGas, outLiquid, powerRequired)); + } + + IRefineryRegistry getHeatableRegistry(); + + IRefineryRegistry getCoolableRegistry(); + + IRefineryRegistry getDistillationRegistry(); + + interface IRefineryRegistry { + /** @return an unmodifiable collection containing all of the distillation recipes that satisfy the given + * predicate. All of the recipe objects are guaranteed to never be null. */ + Stream getRecipes(Predicate toReturn); + + /** @return an unmodifiable set containing all of the distillation recipes. */ + Collection getAllRecipes(); + + @Nullable + R getRecipeForInput(@Nullable FluidStack fluid); + + Collection removeRecipes(Predicate toRemove); + + /** Adds the given recipe to the registry. Note that this will remove any existing recipes for the passed + * recipe's {@link IRefineryRecipe#in()} + * + * @param recipe The recipe to add. + * @return The input recipe. */ + R addRecipe(R recipe); + } + + interface IRefineryRecipe { + FluidStack in(); + } + + interface IHeatExchangerRecipe extends IRefineryRecipe { + @Nullable + FluidStack out(); + + int heatFrom(); + + int heatTo(); + } + + interface IHeatableRecipe extends IHeatExchangerRecipe {} + + interface ICoolableRecipe extends IHeatExchangerRecipe {} + + interface IDistillationRecipe extends IRefineryRecipe { + long powerRequired(); + + FluidStack outGas(); + + FluidStack outLiquid(); + } +} diff --git a/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java b/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java index afaac2dd8..b2e36aad2 100755 --- a/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java +++ b/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java @@ -1,76 +1,50 @@ package buildcraft.api.recipes; -import java.io.IOException; -import java.util.Iterator; +import java.util.List; import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.util.Constants; +import buildcraft.api.core.BuildCraftAPI; public final class IntegrationRecipe { + public final ResourceLocation name; public final long requiredMicroJoules; - public final @Nonnull ItemStack target; - public final NonNullList toIntegrate; - public final ItemStack output; + public final StackDefinition target; + public final ImmutableList toIntegrate; + public final @Nonnull ItemStack output; + /** + * Additional tag used to restore network-transmitted recipe to same state + * You need to register own {@link IIntegrationRecipeProvider} using {@link IIntegrationRecipeRegistry#addRecipeProvider(IIntegrationRecipeProvider)} + * to handle this and declare {@link IIntegrationRecipeProvider#getRecipe(ResourceLocation, NBTTagCompound)} method + */ + public final @Nullable NBTTagCompound recipeTag; - public IntegrationRecipe(long requiredMicroJoules, @Nonnull ItemStack target, NonNullList toIntegrate, ItemStack output) { + public IntegrationRecipe(ResourceLocation name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { + this.name = name; this.requiredMicroJoules = requiredMicroJoules; this.target = target; - this.toIntegrate = toIntegrate; + this.toIntegrate = ImmutableList.copyOf(toIntegrate); this.output = output; + this.recipeTag = recipeTag; } - public IntegrationRecipe(NBTTagCompound nbt) { - requiredMicroJoules = nbt.getLong("required_micro_joules"); - target = new ItemStack(nbt.getCompoundTag("target")); - NBTTagList toIntegrateTag = nbt.getTagList("to_integrate", Constants.NBT.TAG_COMPOUND); - toIntegrate = NonNullList.withSize(toIntegrateTag.tagCount(), ItemStack.EMPTY); - for (int i = 0; i < toIntegrateTag.tagCount(); i++) { - toIntegrate.set(i, new ItemStack(toIntegrateTag.getCompoundTagAt(i))); - } - output = new ItemStack(nbt.getCompoundTag("output")); + public IntegrationRecipe(String name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { + this(BuildCraftAPI.nameToResourceLocation(name), requiredMicroJoules, target, toIntegrate, output, recipeTag); } - public IntegrationRecipe(PacketBuffer buffer) throws IOException { - requiredMicroJoules = buffer.readLong(); - ItemStack stack = buffer.readItemStack(); - if (stack == null) throw new NullPointerException("stack");// should never happen - target = stack; - int count = buffer.readInt(); - toIntegrate = NonNullList.withSize(count, ItemStack.EMPTY); - for (int i = 0; i < count; i++) { - toIntegrate.set(i, buffer.readItemStack()); - } - output = buffer.readItemStack(); + public IntegrationRecipe(ResourceLocation name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output) { + this(name, requiredMicroJoules, target, toIntegrate, output, null); } - public NBTTagCompound writeToNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("required_micro_joules", requiredMicroJoules); - nbt.setTag("target", target.serializeNBT()); - NBTTagList toIntegrateTag = new NBTTagList(); - for (ItemStack toIntegrateElement : toIntegrate) { - toIntegrateTag.appendTag(toIntegrateElement.serializeNBT()); - } - nbt.setTag("to_integrate", toIntegrateTag); - nbt.setTag("output", output.serializeNBT()); - return nbt; - } - - public void writeToBuffer(PacketBuffer buffer) { - buffer.writeLong(requiredMicroJoules); - buffer.writeItemStack(target); - buffer.writeInt(toIntegrate.size()); - for (ItemStack stack : toIntegrate) { - buffer.writeItemStack(stack); - } - buffer.writeItemStack(output); + public IntegrationRecipe(String name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output) { + this(name, requiredMicroJoules, target, toIntegrate, output, null); } @Override @@ -84,37 +58,11 @@ public final class IntegrationRecipe { IntegrationRecipe that = (IntegrationRecipe) o; - if (requiredMicroJoules != that.requiredMicroJoules) { - return false; - } - if (!ItemStack.areItemStacksEqual(target, that.target)) { - return false; - } - if (toIntegrate != null && that.toIntegrate != null) { - Iterator iterator1 = toIntegrate.iterator(); - Iterator iterator2 = that.toIntegrate.iterator(); - while (iterator1.hasNext()) { - if (!iterator2.hasNext()) { - return false; - } - ItemStack o1 = iterator1.next(); - ItemStack o2 = iterator2.next(); - if (!ItemStack.areItemStacksEqual(o1, o2)) { - return false; - } - } - return !iterator2.hasNext() && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; - } else { - return toIntegrate == null && that.toIntegrate == null && output != null ? ItemStack.areItemStacksEqual(output, that.output) : that.output == null; - } + return name.equals(that.name); } @Override public int hashCode() { - int result = (int) (requiredMicroJoules ^ (requiredMicroJoules >>> 32)); - result = 31 * result + (target != null ? target.hashCode() : 0); - result = 31 * result + (toIntegrate != null ? toIntegrate.hashCode() : 0); - result = 31 * result + (output != null ? output.hashCode() : 0); - return result; + return name.hashCode(); } } diff --git a/src/api/java/buildcraft/api/recipes/StackDefinition.java b/src/api/java/buildcraft/api/recipes/StackDefinition.java new file mode 100644 index 000000000..ae1a6b3b8 --- /dev/null +++ b/src/api/java/buildcraft/api/recipes/StackDefinition.java @@ -0,0 +1,20 @@ +package buildcraft.api.recipes; + +import buildcraft.api.core.IStackFilter; + +/** + * Stack definition for recipe input + */ +public final class StackDefinition { + public final IStackFilter filter; + public final int count; + + public StackDefinition(IStackFilter filter, int count) { + this.filter = filter; + this.count = count; + } + + public StackDefinition(IStackFilter filter) { + this(filter, 1); + } +} diff --git a/src/api/java/buildcraft/api/robots/DockingStation.java b/src/api/java/buildcraft/api/robots/DockingStation.java index 28ecb0830..d3237a018 100755 --- a/src/api/java/buildcraft/api/robots/DockingStation.java +++ b/src/api/java/buildcraft/api/robots/DockingStation.java @@ -4,6 +4,8 @@ * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.robots; +import java.util.Arrays; + import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumFacing; @@ -134,7 +136,7 @@ public abstract class DockingStation { if (array.length == 3) { pos = new BlockPos(array[0], array[1], array[2]); } else if (array.length != 0) { - BCLog.logger.warn("Found an integer array that wwas not the right length! (" + array + ")"); + BCLog.logger.warn("Found an integer array that was not the right length! (" + Arrays.toString(array) + ")"); } else { BCLog.logger.warn("Did not find any integer positions! This is a bug!"); } diff --git a/src/api/java/buildcraft/api/robots/RobotManager.java b/src/api/java/buildcraft/api/robots/RobotManager.java index aa59fc4d7..7c712c91f 100755 --- a/src/api/java/buildcraft/api/robots/RobotManager.java +++ b/src/api/java/buildcraft/api/robots/RobotManager.java @@ -12,17 +12,17 @@ import buildcraft.api.core.BCLog; public abstract class RobotManager { public static IRobotRegistryProvider registryProvider; - public static ArrayList> aiRobots = new ArrayList>(); + public static ArrayList> aiRobots = new ArrayList<>(); static { - aiRobotsByNames = new HashMap>(); - aiRobotsNames = new HashMap, String>(); - aiRobotsByLegacyClassNames = new HashMap>(); - resourceIdNames = new HashMap, String>(); - resourceIdByNames = new HashMap>(); - resourceIdLegacyClassNames = new HashMap>(); - dockingStationNames = new HashMap, String>(); - dockingStationByNames = new HashMap>(); + aiRobotsByNames = new HashMap<>(); + aiRobotsNames = new HashMap<>(); + aiRobotsByLegacyClassNames = new HashMap<>(); + resourceIdNames = new HashMap<>(); + resourceIdByNames = new HashMap<>(); + resourceIdLegacyClassNames = new HashMap<>(); + dockingStationNames = new HashMap<>(); + dockingStationByNames = new HashMap<>(); registerResourceId(ResourceIdBlock.class, "resourceIdBlock", "buildcraft.core.robots.ResourceIdBlock"); registerResourceId(ResourceIdRequest.class, "resourceIdRequest", "buildcraft.core.robots.ResourceIdRequest"); @@ -52,7 +52,7 @@ public abstract class RobotManager { try { aiRobot.getConstructor(EntityRobotBase.class); } catch (NoSuchMethodException e) { - throw new RuntimeException("AI class " + aiRobot.getName() + " lacks NBT load construtor! This is a bug!"); + throw new RuntimeException("AI class " + aiRobot.getName() + " lacks NBT load constructor! This is a bug!"); } aiRobots.add(aiRobot); @@ -91,8 +91,8 @@ public abstract class RobotManager { return resourceIdByNames.get(resourceIdName); } - public static String getResourceIdName(Class resouceIdClass) { - return resourceIdNames.get(resouceIdClass); + public static String getResourceIdName(Class resourceIdClass) { + return resourceIdNames.get(resourceIdClass); } public static Class getResourceIdByLegacyClassName(String resourceIdLegacyClassName) { diff --git a/src/api/java/buildcraft/api/schematics/ISchematicBlock.java b/src/api/java/buildcraft/api/schematics/ISchematicBlock.java new file mode 100644 index 000000000..01475eb48 --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/ISchematicBlock.java @@ -0,0 +1,46 @@ +package buildcraft.api.schematics; + +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import net.minecraftforge.fluids.FluidStack; + +import buildcraft.api.core.InvalidInputDataException; + +public interface ISchematicBlock> { + void init(SchematicBlockContext context); + + boolean isAir(); + + @Nonnull + Set getRequiredBlockOffsets(); + + @Nonnull + List computeRequiredItems(SchematicBlockContext context); + + @Nonnull + List computeRequiredFluids(SchematicBlockContext context); + + S getRotated(Rotation rotation); + + boolean canBuild(World world, BlockPos blockPos); + + boolean build(World world, BlockPos blockPos); + + boolean buildWithoutChecks(World world, BlockPos blockPos); + + boolean isBuilt(World world, BlockPos blockPos); + + NBTTagCompound serializeNBT(); + + /** @throws InvalidInputDataException If the input data wasn't correct or didn't make sense. */ + void deserializeNBT(NBTTagCompound nbt) throws InvalidInputDataException; +} diff --git a/src/api/java/buildcraft/api/schematics/ISchematicEntity.java b/src/api/java/buildcraft/api/schematics/ISchematicEntity.java new file mode 100644 index 000000000..1f087ca68 --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/ISchematicEntity.java @@ -0,0 +1,40 @@ +package buildcraft.api.schematics; + +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import net.minecraftforge.fluids.FluidStack; + +import buildcraft.api.core.InvalidInputDataException; + +public interface ISchematicEntity> { + void init(SchematicEntityContext context); + + Vec3d getPos(); + + @Nonnull + List computeRequiredItems(SchematicEntityContext context); + + @Nonnull + List computeRequiredFluids(SchematicEntityContext context); + + S getRotated(Rotation rotation); + + Entity build(World world, BlockPos basePos); + + Entity buildWithoutChecks(World world, BlockPos basePos); + + NBTTagCompound serializeNBT(); + + /** @throws InvalidInputDataException If the input data wasn't correct or didn't make sense. */ + void deserializeNBT(NBTTagCompound nbt) throws InvalidInputDataException; +} diff --git a/src/api/java/buildcraft/api/schematics/SchematicBlockContext.java b/src/api/java/buildcraft/api/schematics/SchematicBlockContext.java new file mode 100644 index 000000000..0ca98532a --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/SchematicBlockContext.java @@ -0,0 +1,33 @@ +package buildcraft.api.schematics; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class SchematicBlockContext { + @Nonnull + public final World world; + @Nonnull + public final BlockPos basePos; + @Nonnull + public final BlockPos pos; + @Nonnull + public final IBlockState blockState; + @Nonnull + public final Block block; + + public SchematicBlockContext(@Nonnull World world, + @Nonnull BlockPos basePos, + @Nonnull BlockPos pos, + @Nonnull IBlockState blockState, + @Nonnull Block block) { + this.world = world; + this.basePos = basePos; + this.pos = pos; + this.blockState = blockState; + this.block = block; + } +} diff --git a/src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java b/src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java new file mode 100644 index 000000000..e88d6cd4f --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java @@ -0,0 +1,39 @@ +package buildcraft.api.schematics; + +import java.util.function.Predicate; +import java.util.function.Supplier; + +import javax.annotation.Nonnull; + +import net.minecraft.util.ResourceLocation; + +public class SchematicBlockFactory> implements Comparable { + @Nonnull + public final ResourceLocation name; + public final int priority; + @Nonnull + public final Predicate predicate; + @Nonnull + public final Supplier supplier; + @Nonnull + public final Class clazz; + + @SuppressWarnings("unchecked") + public SchematicBlockFactory(@Nonnull ResourceLocation name, + int priority, + @Nonnull Predicate predicate, + @Nonnull Supplier supplier) { + this.name = name; + this.priority = priority; + this.predicate = predicate; + this.supplier = supplier; + clazz = (Class) supplier.get().getClass(); + } + + @Override + public int compareTo(@Nonnull SchematicBlockFactory o) { + return priority != o.priority + ? Integer.compare(priority, o.priority) + : name.toString().compareTo(o.name.toString()); + } +} diff --git a/src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java b/src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java new file mode 100644 index 000000000..541c2777e --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java @@ -0,0 +1,65 @@ +package buildcraft.api.schematics; + +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.function.Predicate; +import java.util.function.Supplier; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; + +import net.minecraft.block.Block; +import net.minecraft.util.ResourceLocation; + +import buildcraft.api.core.BuildCraftAPI; + +public class SchematicBlockFactoryRegistry { + private static final Set> FACTORIES = new TreeSet<>(); + + public static > void registerFactory(String name, + int priority, + Predicate predicate, + Supplier supplier) { + FACTORIES.add(new SchematicBlockFactory<>( + BuildCraftAPI.nameToResourceLocation(name), + priority, + predicate, + supplier + )); + } + + public static > void registerFactory(String name, + int priority, + List blocks, + Supplier supplier) { + registerFactory( + name, + priority, + context -> blocks.contains(context.block), + supplier + ); + } + + public static List> getFactories() { + return ImmutableList.copyOf(FACTORIES); + } + + @Nonnull + public static SchematicBlockFactory getFactoryByInstance(ISchematicBlock instance) { + return FACTORIES.stream() + .filter(schematicBlockFactory -> schematicBlockFactory.clazz == instance.getClass()) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); + } + + @Nullable + public static SchematicBlockFactory getFactoryByName(ResourceLocation name) { + return FACTORIES.stream() + .filter(schematicBlockFactory -> schematicBlockFactory.name.equals(name)) + .findFirst() + .orElse(null); + } +} diff --git a/src/api/java/buildcraft/api/schematics/SchematicEntityContext.java b/src/api/java/buildcraft/api/schematics/SchematicEntityContext.java new file mode 100644 index 000000000..b812556a0 --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/SchematicEntityContext.java @@ -0,0 +1,24 @@ +package buildcraft.api.schematics; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.Entity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class SchematicEntityContext { + @Nonnull + public final World world; + @Nonnull + public final BlockPos basePos; + @Nonnull + public final Entity entity; + + public SchematicEntityContext(@Nonnull World world, + @Nonnull BlockPos basePos, + @Nonnull Entity entity) { + this.world = world; + this.basePos = basePos; + this.entity = entity; + } +} diff --git a/src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java b/src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java new file mode 100644 index 000000000..285f05819 --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java @@ -0,0 +1,39 @@ +package buildcraft.api.schematics; + +import java.util.function.Predicate; +import java.util.function.Supplier; + +import javax.annotation.Nonnull; + +import net.minecraft.util.ResourceLocation; + +public class SchematicEntityFactory> implements Comparable { + @Nonnull + public final ResourceLocation name; + public final int priority; + @Nonnull + public final Predicate predicate; + @Nonnull + public final Supplier supplier; + @Nonnull + public final Class clazz; + + @SuppressWarnings("unchecked") + public SchematicEntityFactory(@Nonnull ResourceLocation name, + int priority, + @Nonnull Predicate predicate, + @Nonnull Supplier supplier) { + this.name = name; + this.priority = priority; + this.predicate = predicate; + this.supplier = supplier; + clazz = (Class) supplier.get().getClass(); + } + + @Override + public int compareTo(@Nonnull SchematicEntityFactory o) { + return priority != o.priority + ? Integer.compare(priority, o.priority) + : name.toString().compareTo(o.name.toString()); + } +} diff --git a/src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java b/src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java new file mode 100644 index 000000000..7bfc97cb0 --- /dev/null +++ b/src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java @@ -0,0 +1,65 @@ +package buildcraft.api.schematics; + +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.function.Predicate; +import java.util.function.Supplier; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.google.common.collect.ImmutableList; + +import net.minecraft.entity.EntityList; +import net.minecraft.util.ResourceLocation; + +import buildcraft.api.core.BuildCraftAPI; + +public class SchematicEntityFactoryRegistry { + private static final Set> FACTORIES = new TreeSet<>(); + + public static > void registerFactory(String name, + int priority, + Predicate predicate, + Supplier supplier) { + FACTORIES.add(new SchematicEntityFactory<>( + BuildCraftAPI.nameToResourceLocation(name), + priority, + predicate, + supplier + )); + } + + public static > void registerFactory(String name, + int priority, + List entities, + Supplier supplier) { + registerFactory( + name, + priority, + context -> entities.contains(EntityList.getKey(context.entity)), + supplier + ); + } + + public static List> getFactories() { + return ImmutableList.copyOf(FACTORIES); + } + + @Nonnull + public static SchematicEntityFactory getFactoryByInstance(ISchematicEntity instance) { + return FACTORIES.stream() + .filter(schematicEntityFactory -> schematicEntityFactory.clazz == instance.getClass()) + .findFirst() + .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); + } + + @Nullable + public static SchematicEntityFactory getFactoryByName(ResourceLocation name) { + return FACTORIES.stream() + .filter(schematicEntityFactory -> schematicEntityFactory.name.equals(name)) + .findFirst() + .orElse(null); + } +} diff --git a/src/api/java/buildcraft/api/statements/IGuiSlot.java b/src/api/java/buildcraft/api/statements/IGuiSlot.java index c7386dd69..0dec933c1 100755 --- a/src/api/java/buildcraft/api/statements/IGuiSlot.java +++ b/src/api/java/buildcraft/api/statements/IGuiSlot.java @@ -14,7 +14,8 @@ public interface IGuiSlot { /** Return the parameter description in the UI */ String getDescription(); - /** @return A sprite to show in a GUI, or null if this should not render a sprite. */ + /** @return A sprite to show in a GUI or in-world (so this must be stitched into the block texture atlas), or null + * if this should not render a sprite. */ @SideOnly(Side.CLIENT) TextureAtlasSprite getGuiSprite(); } diff --git a/src/api/java/buildcraft/api/statements/IStatementContainer.java b/src/api/java/buildcraft/api/statements/IStatementContainer.java index 2e7652fd8..e08a7e85b 100755 --- a/src/api/java/buildcraft/api/statements/IStatementContainer.java +++ b/src/api/java/buildcraft/api/statements/IStatementContainer.java @@ -4,6 +4,8 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; +import javax.annotation.Nullable; + import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -11,5 +13,6 @@ import net.minecraft.util.EnumFacing; public interface IStatementContainer { TileEntity getTile(); + @Nullable TileEntity getNeighbourTile(EnumFacing side); } diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java index 5b8ce9ee2..9b1fd1e19 100755 --- a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java +++ b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java @@ -6,7 +6,7 @@ import net.minecraft.util.EnumFacing; * * Please use wisely. */ public interface ITriggerExternalOverride { - public enum Result { + enum Result { TRUE, FALSE, IGNORE diff --git a/src/api/java/buildcraft/api/statements/StatementManager.java b/src/api/java/buildcraft/api/statements/StatementManager.java index 61266e583..1cd30f130 100755 --- a/src/api/java/buildcraft/api/statements/StatementManager.java +++ b/src/api/java/buildcraft/api/statements/StatementManager.java @@ -4,7 +4,12 @@ * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ package buildcraft.api.statements; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -13,10 +18,10 @@ import buildcraft.api.core.BCLog; public final class StatementManager { - public static Map statements = new HashMap(); - public static Map> parameters = new HashMap>(); - private static List triggerProviders = new LinkedList(); - private static List actionProviders = new LinkedList(); + public static Map statements = new HashMap<>(); + public static Map> parameters = new HashMap<>(); + private static List triggerProviders = new LinkedList<>(); + private static List actionProviders = new LinkedList<>(); static { registerParameterClass(StatementParameterItemStack.class); @@ -53,13 +58,13 @@ public final class StatementManager { } } - LinkedHashSet triggers = new LinkedHashSet(); + LinkedHashSet triggers = new LinkedHashSet<>(); for (ITriggerProvider provider : triggerProviders) { provider.addExternalTriggers(triggers, side, entity); } - return new ArrayList(triggers); + return new ArrayList<>(triggers); } public static List getExternalActions(EnumFacing side, TileEntity entity) { @@ -70,53 +75,53 @@ public final class StatementManager { } } - LinkedHashSet actions = new LinkedHashSet(); + LinkedHashSet actions = new LinkedHashSet<>(); for (IActionProvider provider : actionProviders) { provider.addExternalActions(actions, side, entity); } - return new ArrayList(actions); + return new ArrayList<>(actions); } public static List getInternalTriggers(IStatementContainer container) { - LinkedHashSet triggers = new LinkedHashSet(); + LinkedHashSet triggers = new LinkedHashSet<>(); for (ITriggerProvider provider : triggerProviders) { provider.addInternalTriggers(triggers, container); } - return new ArrayList(triggers); + return new ArrayList<>(triggers); } public static List getInternalActions(IStatementContainer container) { - LinkedHashSet actions = new LinkedHashSet(); + LinkedHashSet actions = new LinkedHashSet<>(); for (IActionProvider provider : actionProviders) { provider.addInternalActions(actions, container); } - return new ArrayList(actions); + return new ArrayList<>(actions); } public static List getInternalSidedTriggers(IStatementContainer container, EnumFacing side) { - LinkedHashSet triggers = new LinkedHashSet(); + LinkedHashSet triggers = new LinkedHashSet<>(); for (ITriggerProvider provider : triggerProviders) { provider.addInternalSidedTriggers(triggers, container, side); } - return new ArrayList(triggers); + return new ArrayList<>(triggers); } public static List getInternalSidedActions(IStatementContainer container, EnumFacing side) { - LinkedHashSet actions = new LinkedHashSet(); + LinkedHashSet actions = new LinkedHashSet<>(); for (IActionProvider provider : actionProviders) { provider.addInternalSidedActions(actions, container, side); } - return new ArrayList(actions); + return new ArrayList<>(actions); } public static IStatementParameter createParameter(String kind) { @@ -130,9 +135,7 @@ public final class StatementManager { try { return param.newInstance(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { + } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } catch (Error error) { BCLog.logErrorAPI(error, IStatementParameter.class); diff --git a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java index 5ed9c4088..ad55c9909 100755 --- a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java +++ b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java @@ -31,6 +31,7 @@ public class StatementParameterItemStack implements IStatementParameter { return null; } + @Nonnull @Override public ItemStack getItemStack() { return stack; diff --git a/src/api/java/buildcraft/api/tablet/TabletAPI.java b/src/api/java/buildcraft/api/tablet/TabletAPI.java index 529862790..3d669838f 100755 --- a/src/api/java/buildcraft/api/tablet/TabletAPI.java +++ b/src/api/java/buildcraft/api/tablet/TabletAPI.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; public final class TabletAPI { - private static final Map programs = new HashMap(); + private static final Map programs = new HashMap<>(); private TabletAPI() { diff --git a/src/api/java/buildcraft/api/template/ITemplateHandler.java b/src/api/java/buildcraft/api/template/ITemplateHandler.java new file mode 100644 index 000000000..e0dac1bf8 --- /dev/null +++ b/src/api/java/buildcraft/api/template/ITemplateHandler.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2017 SpaceToad and the BuildCraft team + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. + */ + +package buildcraft.api.template; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public interface ITemplateHandler { + boolean handle(World world, BlockPos pos, EntityPlayer player, ItemStack stack); +} diff --git a/src/api/java/buildcraft/api/template/ITemplateRegistry.java b/src/api/java/buildcraft/api/template/ITemplateRegistry.java new file mode 100644 index 000000000..ec6d25049 --- /dev/null +++ b/src/api/java/buildcraft/api/template/ITemplateRegistry.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017 SpaceToad and the BuildCraft team + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. + */ + +package buildcraft.api.template; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import buildcraft.api.core.EnumHandlerPriority; + +public interface ITemplateRegistry { + /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL} */ + default void addHandler(ITemplateHandler handler) { + addHandler(handler, EnumHandlerPriority.NORMAL); + } + + void addHandler(ITemplateHandler handler, EnumHandlerPriority priority); + + boolean handle(World world, BlockPos pos, EntityPlayer player, ItemStack stack); +} diff --git a/src/api/java/buildcraft/api/template/TemplateApi.java b/src/api/java/buildcraft/api/template/TemplateApi.java new file mode 100644 index 000000000..423c70eaf --- /dev/null +++ b/src/api/java/buildcraft/api/template/TemplateApi.java @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2017 SpaceToad and the BuildCraft team + * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which + * should be located as "LICENSE.API" in the BuildCraft source code distribution. + */ + +package buildcraft.api.template; + +public class TemplateApi { + public static ITemplateRegistry templateRegistry; +} diff --git a/src/api/java/buildcraft/api/tiles/IControllable.java b/src/api/java/buildcraft/api/tiles/IControllable.java index 633d1fc28..ac9483635 100755 --- a/src/api/java/buildcraft/api/tiles/IControllable.java +++ b/src/api/java/buildcraft/api/tiles/IControllable.java @@ -7,31 +7,22 @@ package buildcraft.api.tiles; /** This interface should be implemented by any Tile Entity which wishes to have non-redstone automation (for example, * BuildCraft Gates, but also other mods which implement it, e.g. OpenComputers). */ public interface IControllable { - public enum Mode { - Unknown, - On, - Off, - Mode, - Loop; + enum Mode { + ON, + OFF, + LOOP; public static final Mode[] VALUES = values(); - public static final Mode[] VALID_VALUES = { On, Off, Loop }; } /** Get the current control mode of the Tile Entity. - * + * * @return */ Mode getControlMode(); /** Set the mode of the Tile Entity. - * - * @param mode */ - void setControlMode(Mode mode); - - /** Check if a given control mode is accepted. If you query IControllable tiles, you MUST check with - * acceptsControlMode first. * * @param mode * @return True if this control mode is accepted. */ - boolean acceptsControlMode(Mode mode); + boolean setControlMode(Mode mode, boolean simulate); } diff --git a/src/api/java/buildcraft/api/tiles/IHeatable.java b/src/api/java/buildcraft/api/tiles/IHeatable.java index 1af6d6b59..d789ab564 100755 --- a/src/api/java/buildcraft/api/tiles/IHeatable.java +++ b/src/api/java/buildcraft/api/tiles/IHeatable.java @@ -12,7 +12,7 @@ public interface IHeatable { /** @return The preferred heat value, in degrees. */ double getIdealHeatValue(); - /** @return The maxmimum heat value, in degrees. */ + /** @return The maximum heat value, in degrees. */ double getMaxHeatValue(); /** @return The current heat value, in degrees. */ diff --git a/src/api/java/buildcraft/api/tiles/TilesAPI.java b/src/api/java/buildcraft/api/tiles/TilesAPI.java new file mode 100644 index 000000000..38478d512 --- /dev/null +++ b/src/api/java/buildcraft/api/tiles/TilesAPI.java @@ -0,0 +1,46 @@ +package buildcraft.api.tiles; + +import javax.annotation.Nonnull; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; + +import buildcraft.api.core.CapabilitiesHelper; + +public class TilesAPI { + @Nonnull + public static final Capability CAP_CONTROLLABLE; + + @Nonnull + public static final Capability CAP_HAS_WORK; + + @Nonnull + public static final Capability CAP_HEATABLE; + + @Nonnull + public static final Capability CAP_TILE_AREA_PROVIDER; + + @CapabilityInject(IControllable.class) + private static final Capability CAP_CONTROLLABLE_FIRST = null; + + @CapabilityInject(IHasWork.class) + private static final Capability CAP_HAS_WORK_FIRST = null; + + @CapabilityInject(IHeatable.class) + private static final Capability CAP_HEATABLE_FIRST = null; + + @CapabilityInject(ITileAreaProvider.class) + private static final Capability CAP_TILE_AREA_PROVIDER_FIRST = null; + + static { + CapabilitiesHelper.registerCapability(IControllable.class); + CapabilitiesHelper.registerCapability(IHasWork.class); + CapabilitiesHelper.registerCapability(IHeatable.class); + CapabilitiesHelper.registerCapability(ITileAreaProvider.class); + + CAP_CONTROLLABLE = CapabilitiesHelper.ensureRegistration(CAP_CONTROLLABLE_FIRST, IControllable.class); + CAP_HAS_WORK = CapabilitiesHelper.ensureRegistration(CAP_HAS_WORK_FIRST, IHasWork.class); + CAP_HEATABLE = CapabilitiesHelper.ensureRegistration(CAP_HEATABLE_FIRST, IHeatable.class); + CAP_TILE_AREA_PROVIDER = CapabilitiesHelper.ensureRegistration(CAP_TILE_AREA_PROVIDER_FIRST, ITileAreaProvider.class); + } +} diff --git a/src/api/java/buildcraft/api/transport/EnumWirePart.java b/src/api/java/buildcraft/api/transport/EnumWirePart.java index 6b9e983d2..f05ff8e44 100755 --- a/src/api/java/buildcraft/api/transport/EnumWirePart.java +++ b/src/api/java/buildcraft/api/transport/EnumWirePart.java @@ -39,7 +39,8 @@ public enum EnumWirePart { Vec3d center = new Vec3d(0.5, 0.5, 0.5); Vec3d edge = new Vec3d(x ? 0.75 : 0.25, y ? 0.75 : 0.25, z ? 0.75 : 0.25); - this.boundingBoxPossible = new AxisAlignedBB(center.xCoord, center.yCoord, center.zCoord, edge.xCoord, edge.yCoord, edge.zCoord); + this.boundingBoxPossible = new AxisAlignedBB(center.xCoord, center.yCoord, center.zCoord, edge.xCoord, + edge.yCoord, edge.zCoord); } public AxisDirection getDirection(EnumFacing.Axis axis) { @@ -50,16 +51,16 @@ public enum EnumWirePart { return y; case Z: return z; + default: + return null; } - return null; } public static EnumWirePart get(int x, int y, int z) { - return get(// - (x % 2 + 2) % 2 == 1,// - (y % 2 + 2) % 2 == 1,// - (z % 2 + 2) % 2 == 1 // - ); + boolean bx = (x % 2 + 2) % 2 == 1; + boolean by = (y % 2 + 2) % 2 == 1; + boolean bz = (z % 2 + 2) % 2 == 1; + return get(bx, by, bz); } public static EnumWirePart get(boolean x, boolean y, boolean z) { diff --git a/src/api/java/buildcraft/api/transport/IInjectable.java b/src/api/java/buildcraft/api/transport/IInjectable.java index 0292ae2ef..2aeebd671 100755 --- a/src/api/java/buildcraft/api/transport/IInjectable.java +++ b/src/api/java/buildcraft/api/transport/IInjectable.java @@ -7,7 +7,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; /** Interface for pipes to implement if they can accept items in a similar fashion to BC pipes. */ -// TODO: Forge Capability! public interface IInjectable { /** Tests to see if this pipe can accept items from the given direction. Useless to call this if you are going to * call {@link #injectItem(ItemStack, boolean, EnumFacing, EnumDyeColor, double)} straight after. */ diff --git a/src/api/java/buildcraft/api/transport/IItemPluggable.java b/src/api/java/buildcraft/api/transport/IItemPluggable.java index f18df6344..704318e67 100755 --- a/src/api/java/buildcraft/api/transport/IItemPluggable.java +++ b/src/api/java/buildcraft/api/transport/IItemPluggable.java @@ -2,8 +2,10 @@ package buildcraft.api.transport; import javax.annotation.Nonnull; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import buildcraft.api.transport.pipe.IPipeHolder; import buildcraft.api.transport.pluggable.PipePluggable; @@ -11,12 +13,12 @@ import buildcraft.api.transport.pluggable.PipePluggable; /** Designates an item that can be placed onto a pipe as a {@link PipePluggable}. */ public interface IItemPluggable { /** Called when this item is placed onto a pipe holder. This can return null if this item does not make a valid - * pluggable. Note that if you return a non-null pluggable then it will *definatly* be added to the pipe, and you + * pluggable. Note that if you return a non-null pluggable then it will *definitely* be added to the pipe, and you * are responsible for making all the effects yourself (like the sound effect). * * @param stack The stack that holds this item * @param holder The pipe holder * @param side The side that the pluggable should be placed on * @return A pluggable to place onto the pipe */ - PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side); + PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side, EntityPlayer player, EnumHand hand); } diff --git a/src/api/java/buildcraft/api/transport/IStripesRegistry.java b/src/api/java/buildcraft/api/transport/IStripesRegistry.java index 73e881993..ae6980603 100755 --- a/src/api/java/buildcraft/api/transport/IStripesRegistry.java +++ b/src/api/java/buildcraft/api/transport/IStripesRegistry.java @@ -6,31 +6,36 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import buildcraft.api.core.EnumHandlerPriority; + public interface IStripesRegistry { + /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL} */ + default void addHandler(IStripesHandlerItem handler) { + addHandler(handler, EnumHandlerPriority.NORMAL); + } - /** Adds a handler with a {@link HandlerPriority} of {@linkplain HandlerPriority#NORMAL NORMAL} */ - void addHandler(IStripesHandlerItem handler); + void addHandler(IStripesHandlerItem handler, EnumHandlerPriority priority); - void addHandler(IStripesHandlerItem handler, HandlerPriority priority); + /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL NORMAL} */ + default void addHandler(IStripesHandlerBlock handler) { + addHandler(handler, EnumHandlerPriority.NORMAL); + } - /** Adds a handler with a {@link HandlerPriority} of {@linkplain HandlerPriority#NORMAL NORMAL} */ - void addHandler(IStripesHandlerBlock handler); - - void addHandler(IStripesHandlerBlock handler, HandlerPriority priority); + void addHandler(IStripesHandlerBlock handler, EnumHandlerPriority priority); /** @param pos The position of the stripes pipe. * @return True if a handler handled the itemstack, false otherwise (and so nothing has been done) */ - boolean handleItem(World world, BlockPos pos, EnumFacing direction, ItemStack stack, EntityPlayer player, IStripesActivator activator); + boolean handleItem(World world, + BlockPos pos, + EnumFacing direction, + ItemStack stack, + EntityPlayer player, + IStripesActivator activator); /** @return True if a handler broke a block, false otherwise (and so nothing has been done) */ - boolean handleBlock(World world, BlockPos pos, EnumFacing direction, EntityPlayer player, IStripesActivator activator); - - // TODO: Ensure that this method really will work better than an integer for priorities. - public enum HandlerPriority { - HIGHEST, - HIGH, - NORMAL, - LOW, - LOWEST - } + boolean handleBlock(World world, + BlockPos pos, + EnumFacing direction, + EntityPlayer player, + IStripesActivator activator); } diff --git a/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java b/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java index ded7b2e22..d4ca9ab26 100755 --- a/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java +++ b/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java @@ -7,7 +7,7 @@ import net.minecraft.world.World; public interface ICustomPipeConnection { /** @return How long the connecting pipe should extend for, in addition to its normal 4/16f connection. Values less - * than or equal to -4/16 indicate that the pipe will not connect at all, and will render as it it was not - * connected. */ - public float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state); + * than or equal to -4 / 16.0f indicate that the pipe will not connect at all, and will render + * as it it was not connected. */ + float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state); } diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java b/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java index 25bc329ca..bded1911d 100755 --- a/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java +++ b/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java @@ -1,11 +1,14 @@ package buildcraft.api.transport.pipe; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.capability.IFluidHandler; import buildcraft.api.core.IFluidFilter; +import buildcraft.api.core.IFluidHandlerAdv; public interface IFlowFluid { /** @param millibuckets @@ -15,11 +18,13 @@ public interface IFlowFluid { FluidStack tryExtractFluid(int millibuckets, EnumFacing from, FluidStack filter); /** Advanced version of {@link #tryExtractFluid(int, EnumFacing, FluidStack)}. Note that this only works for - * instances of {@link IFluidHandler} that ALSO extends IFluidHandlerAdv + * instances of {@link IFluidHandler} that ALSO extends {@link IFluidHandlerAdv} * * @param millibuckets * @param from * @param filter A filter to try and match fluids. - * @return The fluidstack extracted and inserted into the pipe. */ - FluidStack tryExtractFluidAdv(int millibuckets, EnumFacing from, IFluidFilter filter); + * @return The fluidstack extracted and inserted into the pipe. If {@link ActionResult#getType()} equals + * {@link EnumActionResult#PASS} then it means that the {@link IFluidHandler} didn't implement + * {@link IFluidHandlerAdv} and you should call the basic version, if you can. */ + ActionResult tryExtractFluidAdv(int millibuckets, EnumFacing from, IFluidFilter filter); } diff --git a/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java b/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java index fbff67747..1d2d37700 100755 --- a/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java +++ b/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java @@ -3,5 +3,5 @@ package buildcraft.api.transport.pipe; /** To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct * dependency on transport. */ public interface IItemPipe { - PipeDefinition getDefiniton(); + PipeDefinition getDefinition(); } diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipe.java b/src/api/java/buildcraft/api/transport/pipe/IPipe.java index 2a7a15c30..8f3d51e15 100755 --- a/src/api/java/buildcraft/api/transport/pipe/IPipe.java +++ b/src/api/java/buildcraft/api/transport/pipe/IPipe.java @@ -29,8 +29,8 @@ public interface IPipe extends ICapabilityProvider { ConnectedType getConnectedType(EnumFacing side); - public enum ConnectedType { + enum ConnectedType { TILE, - PIPE; + PIPE } } diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java b/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java index 5ce5173b4..9d75f8777 100755 --- a/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java +++ b/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java @@ -1,5 +1,8 @@ package buildcraft.api.transport.pipe; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.EntityPlayer; @@ -9,6 +12,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; + import buildcraft.api.statements.containers.IRedstoneStatementContainer; import buildcraft.api.transport.IWireManager; import buildcraft.api.transport.pluggable.PipePluggable; @@ -23,11 +28,19 @@ public interface IPipeHolder extends IRedstoneStatementContainer { IPipe getPipe(); + @Nullable PipePluggable getPluggable(EnumFacing side); - TileEntity getNeighbouringTile(EnumFacing side); + @Nullable + TileEntity getNeighbourTile(EnumFacing side); - IPipe getNeighbouringPipe(EnumFacing side); + @Nullable + IPipe getNeighbourPipe(EnumFacing side); + + /** Gets the given capability going outwards from the pipe. This will test the + * {@link PipePluggable#getInternalCapability(Capability)} first, and the look at the neighbouring tile. */ + @Nullable + T getCapabilityFromPipe(EnumFacing side, @Nonnull Capability capability); IWireManager getWireManager(); @@ -59,7 +72,7 @@ public interface IPipeHolder extends IRedstoneStatementContainer { /** Called on the server whenever a gui container object is closed. */ void onPlayerClose(EntityPlayer player); - public enum PipeMessageReceiver { + enum PipeMessageReceiver { BEHAVIOUR(null), FLOW(null), PLUGGABLE_DOWN(EnumFacing.DOWN), @@ -89,7 +102,7 @@ public interface IPipeHolder extends IRedstoneStatementContainer { } } - public interface IWriter { + interface IWriter { void write(PacketBuffer buffer); } } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeApi.java b/src/api/java/buildcraft/api/transport/pipe/PipeApi.java index f401dc48f..7fffadd16 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeApi.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeApi.java @@ -3,8 +3,17 @@ package buildcraft.api.transport.pipe; import java.util.IdentityHashMap; import java.util.Map; +import javax.annotation.Nonnull; + +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.CapabilityInject; + +import buildcraft.api.core.CapabilitiesHelper; +import buildcraft.api.mj.MjAPI; +import buildcraft.api.transport.IInjectable; import buildcraft.api.transport.IStripesRegistry; import buildcraft.api.transport.pluggable.IPluggableRegistry; +import buildcraft.api.transport.pluggable.PipePluggable; /** The central holding class for all pipe related registers and methods. */ public final class PipeApi { @@ -18,21 +27,47 @@ public final class PipeApi { /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced * by BuildCraft Transport to config-defined values. */ - public static FluidTransferInfo transferInfoDefault = new FluidTransferInfo(20, 10); + public static FluidTransferInfo fluidInfoDefault = new FluidTransferInfo(20, 10); + + /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced + * by BuildCraft Transport to config-defined values. */ + public static PowerTransferInfo powerInfoDefault = PowerTransferInfo.createFromResistance(8 * MjAPI.MJ, MjAPI.MJ / 32, false); public static final Map fluidTransferData = new IdentityHashMap<>(); + public static final Map powerTransferData = new IdentityHashMap<>(); + + @Nonnull + public static final Capability CAP_PIPE_HOLDER; + + @Nonnull + public static final Capability CAP_PIPE; + + @Nonnull + public static final Capability CAP_PLUG; + + @Nonnull + public static final Capability CAP_INJECTABLE; public static FluidTransferInfo getFluidTransferInfo(PipeDefinition def) { FluidTransferInfo info = fluidTransferData.get(def); if (info == null) { - return transferInfoDefault; + return fluidInfoDefault; + } else { + return info; + } + } + + public static PowerTransferInfo getPowerTransferInfo(PipeDefinition def) { + PowerTransferInfo info = powerTransferData.get(def); + if (info == null) { + return powerInfoDefault; } else { return info; } } public static class FluidTransferInfo { - /** Controls the maximum amount of fluid that can be transfered around and out of a pipe per tick. Note that + /** Controls the maximum amount of fluid that can be transferred around and out of a pipe per tick. Note that * this does not affect the flow rate coming into the pipe. */ public final int transferPerTick; @@ -49,4 +84,66 @@ public final class PipeApi { this.transferDelayMultiplier = transferDelay; } } + + public static class PowerTransferInfo { + public final long transferPerTick; + public final long lossPerTick; + /** The percentage resistance per tick. Should be a value between 0 and {@link MjAPI#MJ} */ + public final long resistancePerTick; + public final boolean isReceiver; + + /** Sets resistancePerTick to be equal to lossPerTick when full power is being transferred, scaling down to 0. + * + * @param transferPerTick + * @param lossPerTick + * @param isReceiver */ + public static PowerTransferInfo createFromLoss(long transferPerTick, long lossPerTick, boolean isReceiver) { + return new PowerTransferInfo(transferPerTick, lossPerTick, lossPerTick * MjAPI.MJ / transferPerTick, isReceiver); + } + + /** Sets lossPerTick to be equal to resistancePerTick when full power is being transferred. + * + * @param transferPerTick + * @param resistancePerTick + * @param isReceiver */ + public static PowerTransferInfo createFromResistance(long transferPerTick, long resistancePerTick, boolean isReceiver) { + return new PowerTransferInfo(transferPerTick, resistancePerTick, resistancePerTick * transferPerTick / MjAPI.MJ, isReceiver); + } + + public PowerTransferInfo(long transferPerTick, long lossPerTick, long resistancePerTick, boolean isReceiver) { + if (transferPerTick < 10) { + transferPerTick = 10; + } + this.transferPerTick = transferPerTick; + this.lossPerTick = lossPerTick; + this.resistancePerTick = resistancePerTick; + this.isReceiver = isReceiver; + } + } + + // Internals + + @CapabilityInject(IPipeHolder.class) + private static Capability capPipeHolder; + + @CapabilityInject(IPipe.class) + private static Capability capPipe; + + @CapabilityInject(PipePluggable.class) + private static Capability capPlug; + + @CapabilityInject(IInjectable.class) + private static Capability capInjectable; + + static { + CapabilitiesHelper.registerCapability(IPipe.class); + CapabilitiesHelper.registerCapability(IPipeHolder.class); + CapabilitiesHelper.registerCapability(IInjectable.class); + CapabilitiesHelper.registerCapability(PipePluggable.class); + + CAP_PIPE = CapabilitiesHelper.ensureRegistration(capPipe, IPipe.class); + CAP_PLUG = CapabilitiesHelper.ensureRegistration(capPlug, PipePluggable.class); + CAP_PIPE_HOLDER = CapabilitiesHelper.ensureRegistration(capPipeHolder, IPipeHolder.class); + CAP_INJECTABLE = CapabilitiesHelper.ensureRegistration(capInjectable, IInjectable.class); + } } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java b/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java index 624d75b99..2e919038f 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java @@ -1,5 +1,8 @@ package buildcraft.api.transport.pipe; +import javax.annotation.Nonnull; + +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; @@ -53,15 +56,17 @@ public abstract class PipeBehaviour implements ICapabilityProvider { return false; } + public void onEntityCollide(Entity entity) {} + public void onTick() {} @Override - public boolean hasCapability(Capability capability, EnumFacing facing) { - return false; + public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { + return getCapability(capability, facing) != null; } @Override - public T getCapability(Capability capability, EnumFacing facing) { + public T getCapability(@Nonnull Capability capability, EnumFacing facing) { return null; } } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java b/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java index 336ce551a..987203442 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java @@ -5,22 +5,13 @@ import java.util.Map; import com.google.common.collect.Maps; import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; /** Use this class to register blocks with custom block sizes so that pipes can connect to them properly. Note that you * do not need to register a custom pipe connection if your block implements ICustomPipeConnection. The registered * version does not override your own implementation. */ public final class PipeConnectionAPI { private static final Map connections = Maps.newHashMap(); - private static final ICustomPipeConnection NOTHING = new ICustomPipeConnection() { - @Override - public float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state) { - return 0; - } - }; + private static final ICustomPipeConnection NOTHING = (world, pos, face, state) -> 0; /** Register a block with a custom connection. Useful if you don't own the block class or are adding it for some-one * else. diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java b/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java index 845d6b70b..6e223512d 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java @@ -69,7 +69,7 @@ public final class PipeDefinition { private static String getActiveModId() { ModContainer mod = Loader.instance().activeModContainer(); if (mod == null) { - throw new IllegalStateException("Cannot interact with PipeDefinition outside of an activly scoped mod!"); + throw new IllegalStateException("Cannot interact with PipeDefinition outside of an actively scoped mod!"); } return mod.getModId(); } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java b/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java index a5c41062c..1c6935e5e 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java @@ -1,7 +1,8 @@ package buildcraft.api.transport.pipe; /** The base class for all pipe events. Some event classes can be cancelled with {@link #cancel()}, however this will - * only have an effect if {@link #canBeCancelled} is true. Refer to indervidual classes for information on what*/ + * only have an effect if {@link #canBeCancelled} is true. Refer to individual classes for information on if they can + * be cancelled, and what cancelling the event does. */ public abstract class PipeEvent { public final boolean canBeCancelled; public final IPipeHolder holder; @@ -25,4 +26,16 @@ public abstract class PipeEvent { public boolean isCanceled() { return canceled; } + + /** Called after every event handler has received this pipe event, to pick up simple mistakes when implementing pipe + * event handlers. + * + * @return Null if there are no state errors, or a message containing information about what is wrong (although this + * may be incomplete) */ + public String checkStateForErrors() { + if (canceled & !canBeCancelled) { + return "Somehow cancelled an event that isn't marked as such!"; + } + return null; + } } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java index f31714203..e557bccfd 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java @@ -4,6 +4,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.EnumSet; +import javax.annotation.Nonnull; + import com.google.common.collect.Lists; import net.minecraft.util.EnumFacing; @@ -24,6 +26,100 @@ public abstract class PipeEventFluid extends PipeEvent { this.flow = flow; } + public static class TryInsert extends PipeEventFluid { + public final EnumFacing from; + /** The incoming fluidstack. Currently changing this does nothing. */ + @Nonnull + public final FluidStack fluid; + + public TryInsert(IPipeHolder holder, IFlowFluid flow, EnumFacing from, @Nonnull FluidStack fluid) { + super(true, holder, flow); + this.from = from; + this.fluid = fluid; + } + } + + /** Fired after collecting the amounts of fluid that can be moved from each pipe part into the centre. */ + public static class PreMoveToCentre extends PipeEventFluid { + /** The fluid that is being moved. Future versions of BC *might* allow more than one fluid type per pipe, but + * for the moment the API doesn't allow pipes to do this. */ + public final FluidStack fluid; + + /** The maximum amount of fluid that the centre pipe could accept. */ + public final int totalAcceptable; + + /** Array of {@link EnumFacing#getIndex()} to the maximum amount of fluid that a given side can offer. DO NOT + * CHANGE THIS! */ + public final int[] totalOffered; + + // Used for checking the state + private final int[] totalOfferedCheck; + + /** Array of {@link EnumFacing#getIndex()} to the amount of fluid that the given side will actually offer to the + * centre. This should *never* be larger than */ + public final int[] actuallyOffered; + + public PreMoveToCentre(IPipeHolder holder, IFlowFluid flow, FluidStack fluid, int totalAcceptable, int[] totalOffered, int[] actuallyOffered) { + super(holder, flow); + this.fluid = fluid; + this.totalAcceptable = totalAcceptable; + this.totalOffered = totalOffered; + totalOfferedCheck = Arrays.copyOf(totalOffered, totalOffered.length); + this.actuallyOffered = actuallyOffered; + } + + @Override + public String checkStateForErrors() { + for (int i = 0; i < totalOffered.length; i++) { + if (totalOffered[i] != totalOfferedCheck[i]) { + return "Changed totalOffered"; + } + if (actuallyOffered[i] > totalOffered[i]) { + return "actuallyOffered[" + i + "](=" + actuallyOffered[i] + ") shouldn't be greater than totalOffered[" + i + "](=" + totalOffered[i] + ")"; + } + } + return super.checkStateForErrors(); + } + } + + /** Fired after {@link PreMoveToCentre} when all of the amounts have been totalled up. */ + public static class OnMoveToCentre extends PipeEventFluid { + /** The fluid that is being moved. Future versions of BC *might* allow more than one fluid type per pipe, but + * for the moment the API doesn't allow pipes to do this. */ + public final FluidStack fluid; + + public final int[] fluidLeavingSide; + public final int[] fluidEnteringCentre; + + // Used for checking the state maximums + private final int[] fluidLeaveCheck, fluidEnterCheck; + + public OnMoveToCentre(IPipeHolder holder, IFlowFluid flow, FluidStack fluid, int[] fluidLeavingSide, int[] fluidEnteringCentre) { + super(holder, flow); + this.fluid = fluid; + this.fluidLeavingSide = fluidLeavingSide; + this.fluidEnteringCentre = fluidEnteringCentre; + fluidLeaveCheck = Arrays.copyOf(fluidLeavingSide, fluidLeavingSide.length); + fluidEnterCheck = Arrays.copyOf(fluidEnteringCentre, fluidEnteringCentre.length); + } + + @Override + public String checkStateForErrors() { + for (int i = 0; i < fluidLeavingSide.length; i++) { + if (fluidLeavingSide[i] > fluidLeaveCheck[i]) { + return "fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] + ") shouldn't be bigger than its original value!(=" + fluidLeaveCheck[i] + ")"; + } + if (fluidEnteringCentre[i] > fluidEnterCheck[i]) { + return "fluidEnteringCentre[" + i + "](=" + fluidEnteringCentre[i] + ") shouldn't be bigger than its original value!(=" + fluidEnterCheck[i] + ")"; + } + if (fluidEnteringCentre[i] > fluidLeavingSide[i]) { + return "fluidEnteringCentre[" + i + "](=" + fluidEnteringCentre[i] + ") shouldn't be bigger than fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] + ")"; + } + } + return super.checkStateForErrors(); + } + } + public static class SideCheck extends PipeEventFluid { public final FluidStack fluid; @@ -126,5 +222,4 @@ public abstract class PipeEventFluid extends PipeEvent { return EnumSet.noneOf(EnumFacing.class); } } - } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java index 1ef3667a6..15eaecaf5 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java @@ -1,9 +1,8 @@ package buildcraft.api.transport.pipe; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - +import java.lang.annotation.ElementType; import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** Designates a method that will receive a pipe event. The method must be public and take a single parameter that @@ -12,12 +11,12 @@ import java.lang.annotation.Target; * @PipeEventHandler
    public void sideCheck(PipeEventItem.SideCheck sideCheck) {
    - // Logic ommited
    + // Logic omitted
    } * *
    */ -@Retention(RUNTIME) -@Target(METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.METHOD) public @interface PipeEventHandler { /** Designates the priority that the handler will be given. All handlers in vanilla BuildCraft use * {@link PipeEventPriority#NORMAL}, so this is given for other pipe mods to fire before or after all BC logic has diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java index 6e1d44820..ab33955d9 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java @@ -1,12 +1,19 @@ package buildcraft.api.transport.pipe; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import net.minecraft.entity.item.EntityItem; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; @@ -245,26 +252,32 @@ public abstract class PipeEventItem extends PipeEvent { } public static class Drop extends PipeEventItem { - @Nonnull - private ItemStack stack; + private final EntityItem entity; - public Drop(IPipeHolder holder, IFlowItems flow, @Nonnull ItemStack stack) { + public Drop(IPipeHolder holder, IFlowItems flow, EntityItem entity) { super(holder, flow); - this.stack = stack; + this.entity = entity; } @Nonnull public ItemStack getStack() { - return this.stack; + ItemStack item = entity.getEntityItem(); + return item.isEmpty() ? ItemStack.EMPTY : item; } public void setStack(ItemStack stack) { if (stack == null) { throw new NullPointerException("stack"); + } else if (stack.isEmpty()) { + entity.setEntityItemStack(ItemStack.EMPTY); } else { - this.stack = stack; + entity.setEntityItemStack(stack); } } + + public EntityItem getEntity() { + return this.entity; + } } /** Base class for {@link Split} and {@link FindDest}. Do not listen to this directly! */ @@ -276,6 +289,14 @@ public abstract class PipeEventItem extends PipeEvent { this.orderedDestinations = orderedDestinations; } + public EnumSet getAllPossibleDestinations() { + EnumSet set = EnumSet.noneOf(EnumFacing.class); + for (EnumSet e : orderedDestinations) { + set.addAll(e); + } + return set; + } + public ImmutableList generateRandomOrder() { ImmutableList.Builder builder = ImmutableList.builder(); for (EnumSet set : orderedDestinations) { @@ -337,7 +358,8 @@ public abstract class PipeEventItem extends PipeEvent { @Nonnull public final ItemStack stack; public final EnumFacing from; - /** An list of the destinations to try, in order. */ + /** The list of the destinations to try, in order. */ + @Nullable public List to; public ItemEntry(EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java index cedaaa83f..21f78937a 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java @@ -3,5 +3,5 @@ package buildcraft.api.transport.pipe; public enum PipeEventPriority { PRE, NORMAL, - POST; + POST } diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java b/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java index d35e34a22..b941b4e73 100755 --- a/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java +++ b/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java @@ -2,6 +2,8 @@ package buildcraft.api.transport.pipe; import java.io.IOException; +import javax.annotation.Nonnull; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; @@ -50,13 +52,10 @@ public abstract class PipeFlow implements ICapabilityProvider { } public final void sendCustomPayload(int id, IWriter writer) { - pipe.getHolder().sendMessage(PipeMessageReceiver.FLOW, new IWriter() { - @Override - public void write(PacketBuffer buffer) { - buffer.writeBoolean(true); - buffer.writeShort(id); - writer.write(buffer); - } + pipe.getHolder().sendMessage(PipeMessageReceiver.FLOW, buffer -> { + buffer.writeBoolean(true); + buffer.writeShort(id); + writer.write(buffer); }); } @@ -71,12 +70,12 @@ public abstract class PipeFlow implements ICapabilityProvider { } @Override - public final boolean hasCapability(Capability capability, EnumFacing facing) { + public final boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { return getCapability(capability, facing) != null; } @Override - public T getCapability(Capability capability, EnumFacing facing) { + public T getCapability(@Nonnull Capability capability, EnumFacing facing) { return null; } } diff --git a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java index a1b180519..8ddb478bf 100755 --- a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java +++ b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java @@ -5,6 +5,8 @@ import java.io.IOException; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -13,12 +15,16 @@ import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumFacing; import net.minecraft.util.NonNullList; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; +import net.minecraft.world.Explosion; +import net.minecraft.world.World; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import buildcraft.api.transport.pipe.IPipeHolder; import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; @@ -76,10 +82,19 @@ public abstract class PipePluggable { return null; } - /** Called whenever this pluggable is removed from the pipe. + /** Gets the {@link Capability} that is accessible from the pipe that this is attached to. * - * @param toDrop A list containing all the items to drop (so you should add your items to this list) */ - public void onRemove(NonNullList toDrop) { + * @param cap + * @return */ + public T getInternalCapability(@Nonnull Capability cap) { + return null; + } + + /** Called whenever this pluggable is removed from the pipe. */ + public void onRemove() {} + + /** @param toDrop A list containing all the items to drop (so you should add your items to this list) * */ + public void getDrops(NonNullList toDrop) { ItemStack stack = getPickStack(); if (!stack.isEmpty()) { toDrop.add(stack); @@ -101,4 +116,34 @@ public abstract class PipePluggable { public PluggableModelKey getModelRenderKey(BlockRenderLayer layer) { return null; } + + /** Called if the {@link IPluggableStaticBaker} returns quads with tint indexes set to + * data * 6 + key.side.ordinal(). "data" is passed in here as "tintIndex". + * + * @return The tint index to render the quad with, or -1 for default. */ + @SideOnly(Side.CLIENT) + public int getBlockColor(int tintIndex) { + return -1; + } + + /** PipePluggable version of + * {@link Block#canBeConnectedTo(net.minecraft.world.IBlockAccess, net.minecraft.util.math.BlockPos, EnumFacing)}. */ + public boolean canBeConnected() { + return false; + } + + /** PipePluggable version of + * {@link Block#isBlockSolid(net.minecraft.world.IBlockAccess, net.minecraft.util.math.BlockPos, EnumFacing)} */ + public boolean isSideSolid() { + return false; + } + + /** PipePluggable version of {@link Block#getExplosionResistance(World, BlockPos, Entity, Explosion)} */ + public float getExplosionResistance(@Nullable Entity exploder, Explosion explosion) { + return 0; + } + + public boolean canConnectToRedstone(@Nullable EnumFacing to) { + return false; + } } diff --git a/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java b/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java index f6e371c3d..61884a668 100755 --- a/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java +++ b/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java @@ -25,7 +25,7 @@ public final class PluggableDefinition { this.creator = null; } - public PluggableDefinition(ResourceLocation identifier, IPluggableCreator creator) { + public PluggableDefinition(ResourceLocation identifier, @Nullable IPluggableCreator creator) { this.identifier = identifier; this.reader = creator; this.loader = creator; diff --git a/src/main/java/mekanism/common/FuelHandler.java b/src/main/java/mekanism/common/FuelHandler.java index d4fded57b..5c5e954a6 100644 --- a/src/main/java/mekanism/common/FuelHandler.java +++ b/src/main/java/mekanism/common/FuelHandler.java @@ -2,10 +2,12 @@ package mekanism.common; import java.util.HashMap; +import buildcraft.api.mj.MjAPI; import mekanism.api.gas.Gas; import mekanism.common.config.MekanismConfig.general; import mekanism.common.util.MekanismUtils; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fml.common.ModAPIManager; import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.fuels.IFuel; @@ -28,7 +30,7 @@ public class FuelHandler if(BCPresent() && gas.hasFluid() && BuildcraftFuelRegistry.fuel != null) { - IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(gas.getFluid()); + IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(new FluidStack(gas.getFluid(), 1)); if(bcFuel != null) { @@ -56,7 +58,7 @@ public class FuelHandler public FuelGas(IFuel bcFuel) { burnTicks = bcFuel.getTotalBurningTime() / Fluid.BUCKET_VOLUME; - energyPerTick = bcFuel.getPowerPerCycle() * general.FROM_RF; + energyPerTick = bcFuel.getPowerPerCycle() * MjAPI.MJ; } } diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index b06fb7bc0..9e84541cf 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -101,13 +101,13 @@ public class MekanismGenerators implements IModule { for(IFuel s : BuildcraftFuelRegistry.fuel.getFuels()) { - if(!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getName()))) + if(!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getFluid().getName()))) { - GasRegistry.register(new Gas(s.getFluid())); + GasRegistry.register(new Gas(s.getFluid().getFluid())); } } - BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), (int)(240 * general.TO_RF), 40 * Fluid.BUCKET_VOLUME); + BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), 240, 40 * Fluid.BUCKET_VOLUME); } //Update the config-dependent recipes after the recipes have actually been added in the first place From a32824a434a2aadcb51633b1ce6a197ad7006722 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 10 Jul 2017 18:56:31 +0200 Subject: [PATCH 05/36] Update BC to a maven dependency --- build.gradle | 5 + build.properties | 1 + src/api/java/buildcraft/api/BCBlocks.java | 122 ------ src/api/java/buildcraft/api/BCItems.java | 167 -------- src/api/java/buildcraft/api/BCModules.java | 67 ---- .../api/blocks/CustomPaintHelper.java | 115 ------ .../api/blocks/CustomRotationHelper.java | 76 ---- .../api/blocks/ICustomPaintHandler.java | 31 -- .../api/blocks/ICustomRotationHandler.java | 11 - .../buildcraft/api/blocks/package-info.java | 8 - .../buildcraft/api/boards/IRedstoneBoard.java | 12 - .../api/boards/RedstoneBoardNBT.java | 45 --- .../api/boards/RedstoneBoardRegistry.java | 32 -- .../api/boards/RedstoneBoardRobot.java | 29 -- .../api/boards/RedstoneBoardRobotNBT.java | 23 -- .../buildcraft/api/boards/package-info.java | 8 - .../java/buildcraft/api/core/BCDebugging.java | 112 ------ src/api/java/buildcraft/api/core/BCLog.java | 43 -- .../buildcraft/api/core/BuildCraftAPI.java | 61 --- .../api/core/CapabilitiesHelper.java | 37 -- .../java/buildcraft/api/core/EnumColor.java | 147 ------- .../api/core/EnumHandlerPriority.java | 17 - .../buildcraft/api/core/EnumPipePart.java | 133 ------- .../buildcraft/api/core/IAreaProvider.java | 17 - src/api/java/buildcraft/api/core/IBox.java | 17 - .../java/buildcraft/api/core/IEngineType.java | 5 - .../api/core/IFakePlayerProvider.java | 40 -- .../buildcraft/api/core/IFluidFilter.java | 12 - .../buildcraft/api/core/IFluidHandlerAdv.java | 18 - .../java/buildcraft/api/core/IInvSlot.java | 26 -- .../buildcraft/api/core/IPathProvider.java | 17 - .../buildcraft/api/core/IPlayerOwned.java | 8 - .../buildcraft/api/core/IStackFilter.java | 28 -- .../buildcraft/api/core/IWorldProperty.java | 14 - src/api/java/buildcraft/api/core/IZone.java | 26 -- .../api/core/InvalidInputDataException.java | 29 -- .../java/buildcraft/api/core/JavaTools.java | 39 -- .../buildcraft/api/core/SafeTimeTracker.java | 70 ---- .../java/buildcraft/api/core/StackKey.java | 124 ------ .../buildcraft/api/core/package-info.java | 8 - .../buildcraft/api/crops/CropManager.java | 86 ---- .../buildcraft/api/crops/ICropHandler.java | 53 --- .../buildcraft/api/crops/package-info.java | 8 - .../api/data/NbtSquishConstants.java | 50 --- .../api/enums/EnumDecoratedBlock.java | 34 -- .../buildcraft/api/enums/EnumEngineType.java | 39 -- .../api/enums/EnumFillerPattern.java | 28 -- .../api/enums/EnumLaserTableType.java | 16 - .../api/enums/EnumMachineState.java | 21 - .../api/enums/EnumOptionalSnapshotType.java | 36 -- .../buildcraft/api/enums/EnumPowerStage.java | 27 -- .../api/enums/EnumRedstoneChipset.java | 51 --- .../api/enums/EnumSnapshotType.java | 12 - .../java/buildcraft/api/enums/EnumSpring.java | 40 -- .../buildcraft/api/enums/package-info.java | 8 - .../api/events/BlockInteractionEvent.java | 22 -- .../api/events/BlockPlacedDownEvent.java | 25 -- .../api/events/PipePlacedEvent.java | 24 -- .../buildcraft/api/events/RobotEvent.java | 53 --- .../api/events/RobotPlacementEvent.java | 22 -- .../buildcraft/api/events/package-info.java | 8 - .../buildcraft/api/facades/FacadeAPI.java | 35 -- .../buildcraft/api/facades/FacadeType.java | 14 - .../buildcraft/api/facades/IFacadeItem.java | 19 - .../buildcraft/api/facades/package-info.java | 8 - .../buildcraft/api/filler/FillerManager.java | 13 - .../buildcraft/api/filler/IFillerPattern.java | 12 - .../api/filler/IFillerRegistry.java | 19 - .../buildcraft/api/filler/package-info.java | 8 - .../api/fuels/BuildcraftFuelRegistry.java | 12 - .../java/buildcraft/api/fuels/ICoolant.java | 16 - .../buildcraft/api/fuels/ICoolantManager.java | 36 -- src/api/java/buildcraft/api/fuels/IFuel.java | 18 - .../buildcraft/api/fuels/IFuelManager.java | 37 -- .../buildcraft/api/fuels/ISolidCoolant.java | 13 - .../buildcraft/api/fuels/package-info.java | 8 - src/api/java/buildcraft/api/gates/IGate.java | 28 -- .../buildcraft/api/gates/package-info.java | 8 - .../api/inventory/IItemTransactor.java | 72 ---- .../api/items/IItemCustomPipeRender.java | 14 - src/api/java/buildcraft/api/items/IList.java | 9 - .../buildcraft/api/items/IMapLocation.java | 69 ---- .../java/buildcraft/api/items/INamedItem.java | 11 - .../buildcraft/api/items/package-info.java | 8 - .../api/library/ILibraryTypeHandler.java | 18 - .../buildcraft/api/library/LibraryAPI.java | 30 -- .../api/library/LibraryTypeHandler.java | 31 -- .../library/LibraryTypeHandlerByteArray.java | 13 - .../api/library/LibraryTypeHandlerNBT.java | 14 - .../buildcraft/api/library/package-info.java | 8 - .../api/lists/ListMatchHandler.java | 28 -- .../buildcraft/api/lists/ListRegistry.java | 26 -- .../buildcraft/api/lists/package-info.java | 8 - .../java/buildcraft/api/mj/ILaserTarget.java | 27 -- .../buildcraft/api/mj/ILaserTargetBlock.java | 12 - .../java/buildcraft/api/mj/IMjConnector.java | 15 - .../buildcraft/api/mj/IMjEffectManager.java | 15 - .../buildcraft/api/mj/IMjPassiveProvider.java | 11 - .../java/buildcraft/api/mj/IMjReadable.java | 8 - .../java/buildcraft/api/mj/IMjReceiver.java | 30 -- .../api/mj/IMjRedstoneReceiver.java | 4 - src/api/java/buildcraft/api/mj/MjAPI.java | 119 ------ src/api/java/buildcraft/api/mj/MjBattery.java | 116 ------ .../buildcraft/api/mj/MjCapabilityHelper.java | 61 --- .../java/buildcraft/api/mj/package-info.java | 26 -- .../java/buildcraft/api/power/IEngine.java | 26 -- .../buildcraft/api/power/IRedstoneEngine.java | 7 - .../buildcraft/api/power/package-info.java | 8 - .../api/properties/BuildCraftProperties.java | 88 ----- .../api/recipes/AssemblyRecipe.java | 72 ---- .../api/recipes/BuildcraftRecipeRegistry.java | 14 - .../api/recipes/IAssemblyRecipeProvider.java | 32 -- .../api/recipes/IAssemblyRecipeRegistry.java | 19 - .../recipes/IIntegrationRecipeProvider.java | 32 -- .../recipes/IIntegrationRecipeRegistry.java | 17 - .../api/recipes/IRefineryRecipeManager.java | 81 ---- .../api/recipes/IntegrationRecipe.java | 68 ---- .../api/recipes/StackDefinition.java | 20 - .../buildcraft/api/recipes/package-info.java | 8 - .../java/buildcraft/api/robots/AIRobot.java | 222 ----------- .../buildcraft/api/robots/DockingStation.java | 227 ----------- .../api/robots/EntityRobotBase.java | 86 ---- .../api/robots/IDockingStationProvider.java | 6 - .../api/robots/IRequestProvider.java | 32 -- .../api/robots/IRobotOverlayItem.java | 14 - .../buildcraft/api/robots/IRobotRegistry.java | 56 --- .../api/robots/IRobotRegistryProvider.java | 7 - .../buildcraft/api/robots/ResourceId.java | 39 -- .../api/robots/ResourceIdBlock.java | 71 ---- .../api/robots/ResourceIdRequest.java | 54 --- .../buildcraft/api/robots/RobotManager.java | 114 ------ .../buildcraft/api/robots/package-info.java | 8 - .../api/schematics/ISchematicBlock.java | 46 --- .../api/schematics/ISchematicEntity.java | 40 -- .../api/schematics/SchematicBlockContext.java | 33 -- .../api/schematics/SchematicBlockFactory.java | 39 -- .../SchematicBlockFactoryRegistry.java | 65 --- .../schematics/SchematicEntityContext.java | 24 -- .../schematics/SchematicEntityFactory.java | 39 -- .../SchematicEntityFactoryRegistry.java | 65 --- .../buildcraft/api/statements/IAction.java | 6 - .../api/statements/IActionExternal.java | 12 - .../api/statements/IActionInternal.java | 10 - .../api/statements/IActionInternalSided.java | 7 - .../api/statements/IActionProvider.java | 20 - .../api/statements/IActionReceptor.java | 9 - .../api/statements/IActionSingle.java | 6 - .../buildcraft/api/statements/IGuiSlot.java | 21 - .../IOverrideDefaultStatements.java | 13 - .../buildcraft/api/statements/IStatement.java | 26 -- .../api/statements/IStatementContainer.java | 18 - .../api/statements/IStatementParameter.java | 33 -- .../buildcraft/api/statements/ITrigger.java | 6 - .../api/statements/ITriggerExternal.java | 14 - .../statements/ITriggerExternalOverride.java | 16 - .../api/statements/ITriggerInternal.java | 11 - .../api/statements/ITriggerInternalSided.java | 7 - .../api/statements/ITriggerProvider.java | 21 - .../api/statements/StatementManager.java | 147 ------- .../api/statements/StatementMouseClick.java | 23 -- .../StatementParameterItemStack.java | 109 ----- .../api/statements/StatementSlot.java | 45 --- .../IRedstoneStatementContainer.java | 17 - .../containers/ISidedStatementContainer.java | 10 - .../api/statements/package-info.java | 8 - .../java/buildcraft/api/tablet/ITablet.java | 19 - .../java/buildcraft/api/tablet/TabletAPI.java | 20 - .../buildcraft/api/tablet/TabletBitmap.java | 55 --- .../buildcraft/api/tablet/TabletProgram.java | 17 - .../api/tablet/TabletProgramFactory.java | 19 - .../buildcraft/api/tablet/TabletTicker.java | 36 -- .../buildcraft/api/tablet/package-info.java | 8 - .../api/template/ITemplateHandler.java | 16 - .../api/template/ITemplateRegistry.java | 25 -- .../buildcraft/api/template/TemplateApi.java | 11 - .../buildcraft/api/tiles/IControllable.java | 28 -- .../buildcraft/api/tiles/IDebuggable.java | 17 - .../java/buildcraft/api/tiles/IHasWork.java | 14 - .../java/buildcraft/api/tiles/IHeatable.java | 26 -- .../api/tiles/ITileAreaProvider.java | 10 - .../java/buildcraft/api/tiles/TilesAPI.java | 46 --- .../buildcraft/api/tiles/package-info.java | 8 - .../buildcraft/api/tools/IToolWrench.java | 32 -- .../buildcraft/api/tools/package-info.java | 8 - .../api/transport/EnumWirePart.java | 81 ---- .../buildcraft/api/transport/IInjectable.java | 27 -- .../api/transport/IItemPluggable.java | 24 -- .../api/transport/IStripesActivator.java | 16 - .../api/transport/IStripesHandlerBlock.java | 18 - .../api/transport/IStripesHandlerItem.java | 30 -- .../api/transport/IStripesRegistry.java | 41 -- .../api/transport/IWireManager.java | 24 -- .../buildcraft/api/transport/WireNode.java | 61 --- .../api/transport/package-info.java | 8 - .../transport/pipe/ICustomPipeConnection.java | 13 - .../api/transport/pipe/IFlowFluid.java | 30 -- .../api/transport/pipe/IFlowItems.java | 32 -- .../api/transport/pipe/IFlowPower.java | 17 - .../api/transport/pipe/IItemPipe.java | 7 - .../buildcraft/api/transport/pipe/IPipe.java | 36 -- .../pipe/IPipeBehaviourRenderer.java | 11 - .../api/transport/pipe/IPipeConnection.java | 26 -- .../api/transport/pipe/IPipeFlowRenderer.java | 12 - .../api/transport/pipe/IPipeHolder.java | 108 ----- .../api/transport/pipe/IPipeRegistry.java | 17 - .../api/transport/pipe/PipeApi.java | 149 ------- .../api/transport/pipe/PipeApiClient.java | 26 -- .../api/transport/pipe/PipeBehaviour.java | 72 ---- .../api/transport/pipe/PipeConnectionAPI.java | 42 -- .../api/transport/pipe/PipeDefinition.java | 159 -------- .../api/transport/pipe/PipeEvent.java | 41 -- .../pipe/PipeEventActionActivate.java | 18 - .../api/transport/pipe/PipeEventFluid.java | 225 ----------- .../api/transport/pipe/PipeEventHandler.java | 28 -- .../api/transport/pipe/PipeEventItem.java | 371 ------------------ .../api/transport/pipe/PipeEventPower.java | 73 ---- .../api/transport/pipe/PipeEventPriority.java | 7 - .../transport/pipe/PipeEventStatement.java | 66 ---- .../api/transport/pipe/PipeFlow.java | 81 ---- .../api/transport/pipe/PipeFlowType.java | 23 -- .../transport/pluggable/IFacadePluggable.java | 11 - .../pluggable/IPlugDynamicRenderer.java | 7 - .../pluggable/IPluggableRegistry.java | 9 - .../pluggable/IPluggableStaticBaker.java | 13 - .../transport/pluggable/PipePluggable.java | 149 ------- .../pluggable/PluggableDefinition.java | 69 ---- .../pluggable/PluggableModelKey.java | 38 -- .../generators/common/MekanismGenerators.java | 3 +- 228 files changed, 8 insertions(+), 8690 deletions(-) delete mode 100644 src/api/java/buildcraft/api/BCBlocks.java delete mode 100644 src/api/java/buildcraft/api/BCItems.java delete mode 100644 src/api/java/buildcraft/api/BCModules.java delete mode 100755 src/api/java/buildcraft/api/blocks/CustomPaintHelper.java delete mode 100755 src/api/java/buildcraft/api/blocks/CustomRotationHelper.java delete mode 100755 src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java delete mode 100755 src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java delete mode 100755 src/api/java/buildcraft/api/blocks/package-info.java delete mode 100755 src/api/java/buildcraft/api/boards/IRedstoneBoard.java delete mode 100755 src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java delete mode 100755 src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java delete mode 100755 src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java delete mode 100755 src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java delete mode 100755 src/api/java/buildcraft/api/boards/package-info.java delete mode 100755 src/api/java/buildcraft/api/core/BCDebugging.java delete mode 100755 src/api/java/buildcraft/api/core/BCLog.java delete mode 100755 src/api/java/buildcraft/api/core/BuildCraftAPI.java delete mode 100644 src/api/java/buildcraft/api/core/CapabilitiesHelper.java delete mode 100755 src/api/java/buildcraft/api/core/EnumColor.java delete mode 100644 src/api/java/buildcraft/api/core/EnumHandlerPriority.java delete mode 100755 src/api/java/buildcraft/api/core/EnumPipePart.java delete mode 100755 src/api/java/buildcraft/api/core/IAreaProvider.java delete mode 100755 src/api/java/buildcraft/api/core/IBox.java delete mode 100644 src/api/java/buildcraft/api/core/IEngineType.java delete mode 100644 src/api/java/buildcraft/api/core/IFakePlayerProvider.java delete mode 100755 src/api/java/buildcraft/api/core/IFluidFilter.java delete mode 100755 src/api/java/buildcraft/api/core/IFluidHandlerAdv.java delete mode 100755 src/api/java/buildcraft/api/core/IInvSlot.java delete mode 100755 src/api/java/buildcraft/api/core/IPathProvider.java delete mode 100644 src/api/java/buildcraft/api/core/IPlayerOwned.java delete mode 100755 src/api/java/buildcraft/api/core/IStackFilter.java delete mode 100755 src/api/java/buildcraft/api/core/IWorldProperty.java delete mode 100755 src/api/java/buildcraft/api/core/IZone.java delete mode 100644 src/api/java/buildcraft/api/core/InvalidInputDataException.java delete mode 100755 src/api/java/buildcraft/api/core/JavaTools.java delete mode 100755 src/api/java/buildcraft/api/core/SafeTimeTracker.java delete mode 100755 src/api/java/buildcraft/api/core/StackKey.java delete mode 100755 src/api/java/buildcraft/api/core/package-info.java delete mode 100755 src/api/java/buildcraft/api/crops/CropManager.java delete mode 100755 src/api/java/buildcraft/api/crops/ICropHandler.java delete mode 100755 src/api/java/buildcraft/api/crops/package-info.java delete mode 100644 src/api/java/buildcraft/api/data/NbtSquishConstants.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumEngineType.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumFillerPattern.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumLaserTableType.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumMachineState.java delete mode 100644 src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumPowerStage.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java delete mode 100644 src/api/java/buildcraft/api/enums/EnumSnapshotType.java delete mode 100755 src/api/java/buildcraft/api/enums/EnumSpring.java delete mode 100755 src/api/java/buildcraft/api/enums/package-info.java delete mode 100755 src/api/java/buildcraft/api/events/BlockInteractionEvent.java delete mode 100755 src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java delete mode 100755 src/api/java/buildcraft/api/events/PipePlacedEvent.java delete mode 100755 src/api/java/buildcraft/api/events/RobotEvent.java delete mode 100755 src/api/java/buildcraft/api/events/RobotPlacementEvent.java delete mode 100755 src/api/java/buildcraft/api/events/package-info.java delete mode 100755 src/api/java/buildcraft/api/facades/FacadeAPI.java delete mode 100755 src/api/java/buildcraft/api/facades/FacadeType.java delete mode 100755 src/api/java/buildcraft/api/facades/IFacadeItem.java delete mode 100755 src/api/java/buildcraft/api/facades/package-info.java delete mode 100755 src/api/java/buildcraft/api/filler/FillerManager.java delete mode 100755 src/api/java/buildcraft/api/filler/IFillerPattern.java delete mode 100755 src/api/java/buildcraft/api/filler/IFillerRegistry.java delete mode 100755 src/api/java/buildcraft/api/filler/package-info.java delete mode 100755 src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.java delete mode 100755 src/api/java/buildcraft/api/fuels/ICoolant.java delete mode 100755 src/api/java/buildcraft/api/fuels/ICoolantManager.java delete mode 100755 src/api/java/buildcraft/api/fuels/IFuel.java delete mode 100755 src/api/java/buildcraft/api/fuels/IFuelManager.java delete mode 100755 src/api/java/buildcraft/api/fuels/ISolidCoolant.java delete mode 100755 src/api/java/buildcraft/api/fuels/package-info.java delete mode 100755 src/api/java/buildcraft/api/gates/IGate.java delete mode 100755 src/api/java/buildcraft/api/gates/package-info.java delete mode 100644 src/api/java/buildcraft/api/inventory/IItemTransactor.java delete mode 100755 src/api/java/buildcraft/api/items/IItemCustomPipeRender.java delete mode 100755 src/api/java/buildcraft/api/items/IList.java delete mode 100755 src/api/java/buildcraft/api/items/IMapLocation.java delete mode 100755 src/api/java/buildcraft/api/items/INamedItem.java delete mode 100755 src/api/java/buildcraft/api/items/package-info.java delete mode 100755 src/api/java/buildcraft/api/library/ILibraryTypeHandler.java delete mode 100755 src/api/java/buildcraft/api/library/LibraryAPI.java delete mode 100755 src/api/java/buildcraft/api/library/LibraryTypeHandler.java delete mode 100755 src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java delete mode 100755 src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java delete mode 100755 src/api/java/buildcraft/api/library/package-info.java delete mode 100755 src/api/java/buildcraft/api/lists/ListMatchHandler.java delete mode 100755 src/api/java/buildcraft/api/lists/ListRegistry.java delete mode 100755 src/api/java/buildcraft/api/lists/package-info.java delete mode 100755 src/api/java/buildcraft/api/mj/ILaserTarget.java delete mode 100755 src/api/java/buildcraft/api/mj/ILaserTargetBlock.java delete mode 100755 src/api/java/buildcraft/api/mj/IMjConnector.java delete mode 100755 src/api/java/buildcraft/api/mj/IMjEffectManager.java delete mode 100755 src/api/java/buildcraft/api/mj/IMjPassiveProvider.java delete mode 100755 src/api/java/buildcraft/api/mj/IMjReadable.java delete mode 100755 src/api/java/buildcraft/api/mj/IMjReceiver.java delete mode 100755 src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java delete mode 100755 src/api/java/buildcraft/api/mj/MjAPI.java delete mode 100755 src/api/java/buildcraft/api/mj/MjBattery.java delete mode 100755 src/api/java/buildcraft/api/mj/MjCapabilityHelper.java delete mode 100755 src/api/java/buildcraft/api/mj/package-info.java delete mode 100755 src/api/java/buildcraft/api/power/IEngine.java delete mode 100755 src/api/java/buildcraft/api/power/IRedstoneEngine.java delete mode 100755 src/api/java/buildcraft/api/power/package-info.java delete mode 100755 src/api/java/buildcraft/api/properties/BuildCraftProperties.java delete mode 100755 src/api/java/buildcraft/api/recipes/AssemblyRecipe.java delete mode 100755 src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java delete mode 100755 src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java delete mode 100755 src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java delete mode 100755 src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java delete mode 100755 src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java delete mode 100644 src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java delete mode 100755 src/api/java/buildcraft/api/recipes/IntegrationRecipe.java delete mode 100644 src/api/java/buildcraft/api/recipes/StackDefinition.java delete mode 100755 src/api/java/buildcraft/api/recipes/package-info.java delete mode 100755 src/api/java/buildcraft/api/robots/AIRobot.java delete mode 100755 src/api/java/buildcraft/api/robots/DockingStation.java delete mode 100755 src/api/java/buildcraft/api/robots/EntityRobotBase.java delete mode 100755 src/api/java/buildcraft/api/robots/IDockingStationProvider.java delete mode 100755 src/api/java/buildcraft/api/robots/IRequestProvider.java delete mode 100755 src/api/java/buildcraft/api/robots/IRobotOverlayItem.java delete mode 100755 src/api/java/buildcraft/api/robots/IRobotRegistry.java delete mode 100755 src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java delete mode 100755 src/api/java/buildcraft/api/robots/ResourceId.java delete mode 100755 src/api/java/buildcraft/api/robots/ResourceIdBlock.java delete mode 100755 src/api/java/buildcraft/api/robots/ResourceIdRequest.java delete mode 100755 src/api/java/buildcraft/api/robots/RobotManager.java delete mode 100755 src/api/java/buildcraft/api/robots/package-info.java delete mode 100644 src/api/java/buildcraft/api/schematics/ISchematicBlock.java delete mode 100644 src/api/java/buildcraft/api/schematics/ISchematicEntity.java delete mode 100644 src/api/java/buildcraft/api/schematics/SchematicBlockContext.java delete mode 100644 src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java delete mode 100644 src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java delete mode 100644 src/api/java/buildcraft/api/schematics/SchematicEntityContext.java delete mode 100644 src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java delete mode 100644 src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java delete mode 100755 src/api/java/buildcraft/api/statements/IAction.java delete mode 100755 src/api/java/buildcraft/api/statements/IActionExternal.java delete mode 100755 src/api/java/buildcraft/api/statements/IActionInternal.java delete mode 100755 src/api/java/buildcraft/api/statements/IActionInternalSided.java delete mode 100755 src/api/java/buildcraft/api/statements/IActionProvider.java delete mode 100755 src/api/java/buildcraft/api/statements/IActionReceptor.java delete mode 100755 src/api/java/buildcraft/api/statements/IActionSingle.java delete mode 100755 src/api/java/buildcraft/api/statements/IGuiSlot.java delete mode 100755 src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java delete mode 100755 src/api/java/buildcraft/api/statements/IStatement.java delete mode 100755 src/api/java/buildcraft/api/statements/IStatementContainer.java delete mode 100755 src/api/java/buildcraft/api/statements/IStatementParameter.java delete mode 100755 src/api/java/buildcraft/api/statements/ITrigger.java delete mode 100755 src/api/java/buildcraft/api/statements/ITriggerExternal.java delete mode 100755 src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java delete mode 100755 src/api/java/buildcraft/api/statements/ITriggerInternal.java delete mode 100755 src/api/java/buildcraft/api/statements/ITriggerInternalSided.java delete mode 100755 src/api/java/buildcraft/api/statements/ITriggerProvider.java delete mode 100755 src/api/java/buildcraft/api/statements/StatementManager.java delete mode 100755 src/api/java/buildcraft/api/statements/StatementMouseClick.java delete mode 100755 src/api/java/buildcraft/api/statements/StatementParameterItemStack.java delete mode 100755 src/api/java/buildcraft/api/statements/StatementSlot.java delete mode 100755 src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java delete mode 100755 src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java delete mode 100755 src/api/java/buildcraft/api/statements/package-info.java delete mode 100755 src/api/java/buildcraft/api/tablet/ITablet.java delete mode 100755 src/api/java/buildcraft/api/tablet/TabletAPI.java delete mode 100755 src/api/java/buildcraft/api/tablet/TabletBitmap.java delete mode 100755 src/api/java/buildcraft/api/tablet/TabletProgram.java delete mode 100755 src/api/java/buildcraft/api/tablet/TabletProgramFactory.java delete mode 100755 src/api/java/buildcraft/api/tablet/TabletTicker.java delete mode 100755 src/api/java/buildcraft/api/tablet/package-info.java delete mode 100644 src/api/java/buildcraft/api/template/ITemplateHandler.java delete mode 100644 src/api/java/buildcraft/api/template/ITemplateRegistry.java delete mode 100644 src/api/java/buildcraft/api/template/TemplateApi.java delete mode 100755 src/api/java/buildcraft/api/tiles/IControllable.java delete mode 100755 src/api/java/buildcraft/api/tiles/IDebuggable.java delete mode 100755 src/api/java/buildcraft/api/tiles/IHasWork.java delete mode 100755 src/api/java/buildcraft/api/tiles/IHeatable.java delete mode 100755 src/api/java/buildcraft/api/tiles/ITileAreaProvider.java delete mode 100644 src/api/java/buildcraft/api/tiles/TilesAPI.java delete mode 100755 src/api/java/buildcraft/api/tiles/package-info.java delete mode 100755 src/api/java/buildcraft/api/tools/IToolWrench.java delete mode 100755 src/api/java/buildcraft/api/tools/package-info.java delete mode 100755 src/api/java/buildcraft/api/transport/EnumWirePart.java delete mode 100755 src/api/java/buildcraft/api/transport/IInjectable.java delete mode 100755 src/api/java/buildcraft/api/transport/IItemPluggable.java delete mode 100755 src/api/java/buildcraft/api/transport/IStripesActivator.java delete mode 100755 src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java delete mode 100755 src/api/java/buildcraft/api/transport/IStripesHandlerItem.java delete mode 100755 src/api/java/buildcraft/api/transport/IStripesRegistry.java delete mode 100755 src/api/java/buildcraft/api/transport/IWireManager.java delete mode 100755 src/api/java/buildcraft/api/transport/WireNode.java delete mode 100755 src/api/java/buildcraft/api/transport/package-info.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IFlowItems.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IFlowPower.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IItemPipe.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IPipe.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeApi.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEvent.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeFlow.java delete mode 100755 src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java delete mode 100755 src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java diff --git a/build.gradle b/build.gradle index 029b88844..11dc58195 100644 --- a/build.gradle +++ b/build.gradle @@ -57,6 +57,10 @@ repositories { name 'hwyla' url 'http://tehnut.info/maven' } + maven { + name 'buildcraft' + url 'https://mod-buildcraft.com/maven/' + } } // Define properties file @@ -90,6 +94,7 @@ dependencies { compile "inventory-tweaks:InventoryTweaks:${config.invtweak_version}:api" compile "li.cil.oc:OpenComputers:MC${config.minecraft_version}-${config.opencomputers_version}:api" deobfCompile "mcp.mobius.waila:Hwyla:${config.hwyla_version}" + deobfCompile "com.mod-buildcraft:buildcraft-api:${config.buildcraft_version}" } processResources diff --git a/build.properties b/build.properties index db230f8a1..d85a5e3de 100644 --- a/build.properties +++ b/build.properties @@ -8,3 +8,4 @@ tesla_version=1.11-1.3.0.52 invtweak_version=1.62+beta.89 opencomputers_version=1.7.0.24 hwyla_version=1.8.13-B26_1.11 +buildcraft_version=7.99.6 diff --git a/src/api/java/buildcraft/api/BCBlocks.java b/src/api/java/buildcraft/api/BCBlocks.java deleted file mode 100644 index c864fd797..000000000 --- a/src/api/java/buildcraft/api/BCBlocks.java +++ /dev/null @@ -1,122 +0,0 @@ -package buildcraft.api; - -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; - -import buildcraft.api.core.BCDebugging; -import buildcraft.api.core.BCLog; - -/** Stores all of BuildCraft's blocks, from all of its modules. If any of them have been disabled by the user (or it the - * module is not installed) then they will be null. This is the equivalent of {@link Blocks} */ -public class BCBlocks { - private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.blocks"); - - // BC Core - public static final Block CORE_DECORATED; - public static final Block CORE_ENGINE; - public static final Block CORE_MARKER_VOLUME; - public static final Block CORE_MARKER_PATH; - - // BC Builders - - // BC Energy - - // BC Factory - public static final Block FACTORY_TANK; - public static final Block FACTORY_PUMP; - public static final Block FACTORY_CHUTE; - public static final Block FACTORY_FLOOD_GATE; - public static final Block FACTORY_MINING_WELL; - public static final Block FACTORY_AUTOWORKBENCH_ITEM; - public static final Block FACTORY_DISTILLER; - public static final Block FACTORY_HEAT_EXCHANGE_START; - public static final Block FACTORY_HEAT_EXCHANGE_MIDDLE; - public static final Block FACTORY_HEAT_EXCHANGE_END; - - // BC Robotics - - // BC Silicon - public static final Block SILICON_LASER; - public static final Block SILICON_TABLE_ASSEMBLY; - public static final Block SILICON_TABLE_INTEGRATION; - public static final Block SILICON_TABLE_ADV_CRAFT; - public static final Block SILICON_TABLE_CHARGING; - public static final Block SILICON_TABLE_PROGRAMMING; - - // BC Transport - - // Set of items scanned - private static final Set SCANNED = DEBUG ? new HashSet<>() : null; - - static { - if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) { - throw new RuntimeException("Accessed BC blocks too early! You can only use them from init onwards!"); - } - String core = "core"; - CORE_DECORATED = getRegisteredBlock(core, "decorated"); - CORE_ENGINE = getRegisteredBlock(core, "engine"); - CORE_MARKER_VOLUME = getRegisteredBlock(core, "marker_volume"); - CORE_MARKER_PATH = getRegisteredBlock(core, "marker_path"); - - String energy = "energy"; - - String factory = "factory"; - FACTORY_TANK = getRegisteredBlock(factory, "tank"); - FACTORY_PUMP = getRegisteredBlock(factory, "pump"); - FACTORY_CHUTE = getRegisteredBlock(factory, "chute"); - FACTORY_FLOOD_GATE = getRegisteredBlock(factory, "flood_gate"); - FACTORY_MINING_WELL = getRegisteredBlock(factory, "mining_well"); - FACTORY_AUTOWORKBENCH_ITEM = getRegisteredBlock(factory, "autoworkbench_item"); - FACTORY_DISTILLER = getRegisteredBlock(factory, "distiller"); - FACTORY_HEAT_EXCHANGE_START = getRegisteredBlock(factory, "heat_exchange_start"); - FACTORY_HEAT_EXCHANGE_MIDDLE = getRegisteredBlock(factory, "heat_exchange_middle"); - FACTORY_HEAT_EXCHANGE_END = getRegisteredBlock(factory, "heat_exchange_end"); - - String silicon = "silicon"; - SILICON_LASER = getRegisteredBlock(silicon, "laser"); - SILICON_TABLE_ASSEMBLY = getRegisteredBlock(silicon, "assembly_table"); - SILICON_TABLE_INTEGRATION = getRegisteredBlock(silicon, "integration_table"); - SILICON_TABLE_ADV_CRAFT = getRegisteredBlock(silicon, "advanced_crafting_table"); - SILICON_TABLE_CHARGING = getRegisteredBlock(silicon, "charging_table"); - SILICON_TABLE_PROGRAMMING = getRegisteredBlock(silicon, "programming_table"); - - if (DEBUG) { - for (Block block : Block.REGISTRY) { - ResourceLocation id = block.getRegistryName(); - if (id.getResourceDomain().startsWith("buildcraft")) { - if (!SCANNED.contains(id.toString())) { - BCLog.logger.warn("[api.blocks] Found a block " + id.toString() + " that was not registered with the API! Is this a bug?"); - } - } - } - } - } - - private static Block getRegisteredBlock(String module, String regName) { - String modid = "buildcraft" + module; - Block block = Block.REGISTRY.getObject(new ResourceLocation(modid, regName)); - - if (block != Blocks.AIR) { - if (DEBUG) { - BCLog.logger.info("[api.blocks] Found the block " + regName + " from the module " + module); - SCANNED.add(modid + ":" + regName); - } - return block; - } - if (DEBUG) { - if (Loader.isModLoaded(modid)) { - BCLog.logger.info("[api.blocks] Did not find the block " + regName + " despite the appropriate mod being loaded (" + modid + ")"); - } else { - BCLog.logger.info("[api.blocks] Did not find the block " + regName + " probably because the mod is not loaded (" + modid + ")"); - } - } - return null; - } -} diff --git a/src/api/java/buildcraft/api/BCItems.java b/src/api/java/buildcraft/api/BCItems.java deleted file mode 100644 index 2497aff15..000000000 --- a/src/api/java/buildcraft/api/BCItems.java +++ /dev/null @@ -1,167 +0,0 @@ -package buildcraft.api; - -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; - -import buildcraft.api.core.BCDebugging; -import buildcraft.api.core.BCLog; - -/** Stores all of BuildCraft's items, from all of its modules. If any of them have been disabled by the user (or it the - * module is not installed) then they will be null. This is the equivalent of {@link Items} */ -public class BCItems { - private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.items"); - - // The (optional) items in BC LIB, and has other rules for when they are enabled. - public static final Item LIB_GUIDE; - public static final Item LIB_DEBUGGER; - - // BC Core - public static final Item CORE_WRENCH; - public static final Item CORE_DIAMOND_SHARD; - public static final Item CORE_LIST; - public static final Item CORE_MAP_LOCATION; - public static final Item CORE_PAINTBRUSH; - public static final Item CORE_GEAR_WOOD; - public static final Item CORE_GEAR_STONE; - public static final Item CORE_GEAR_IRON; - public static final Item CORE_GEAR_GOLD; - public static final Item CORE_GEAR_DIAMOND; - public static final Item CORE_MARKER_CONNECTOR; - public static final Item CORE_GOGGLES; - - // BC Builders - public static final Item BUILDERS_SINGLE_SCHEMATIC; - public static final Item BUILDERS_SNAPSHOT; - - // BC Energy - public static final Item ENERGY_GLOB_OF_OIL; - - // BC Factory - public static final Item FACTORY_PLASTIC_SHEET; - - // BC Robotics - public static final Item ROBOTICS_REDSTONE_BOARD; - public static final Item ROBOTICS_ROBOT; - public static final Item ROBOTICS_ROBOT_GOGGLES; - public static final Item ROBOTICS_PLUGGABLE_ROBOT_STATION; - - // BC Silicon - public static final Item SILICON_REDSTONE_CHIPSET; - - // BC Transport - public static final Item TRANSPORT_WATERPROOF; - public static final Item TRANSPORT_GATE_COPIER; - public static final Item TRANSPORT_PLUGGABLE_GATE; - public static final Item TRANSPORT_PLUGGABLE_WIRE; - public static final Item TRANSPORT_PLUGGABLE_BLOCKER; - public static final Item TRANSPORT_PLUGGABLE_LENS; - public static final Item TRANSPORT_PLUGGABLE_POWER_ADAPTOR; - public static final Item TRANSPORT_PLUGGABLE_FACADE; - - public static final Item TRANSPORT_PIPE_WOOD_ITEM; - public static final Item TRANSPORT_PIPE_WOOD_FLUID; - public static final Item TRANSPORT_PIPE_WOOD_POWER; - - // ... a few more needed... - - public static final Item TRANSPORT_PIPE_DIAMOND_ITEM; - - // Set of items scanned - private static final Set SCANNED = DEBUG ? new HashSet<>() : null; - - static { - if (!Loader.instance().hasReachedState(LoaderState.INITIALIZATION)) { - throw new RuntimeException("Accessed BC items too early! You can only use them from init onwards!"); - } - final String lib = "lib"; - LIB_GUIDE = getRegisteredItem(lib, "guide"); - LIB_DEBUGGER = getRegisteredItem(lib, "debugger"); - - final String core = "core"; - CORE_WRENCH = getRegisteredItem(core, "wrench"); - CORE_DIAMOND_SHARD = getRegisteredItem(core, "diamond_shard"); - CORE_LIST = getRegisteredItem(core, "list"); - CORE_MAP_LOCATION = getRegisteredItem(core, "map_location"); - CORE_PAINTBRUSH = getRegisteredItem(core, "paintbrush"); - CORE_GEAR_WOOD = getRegisteredItem(core, "gear_wood"); - CORE_GEAR_STONE = getRegisteredItem(core, "gear_stone"); - CORE_GEAR_IRON = getRegisteredItem(core, "gear_iron"); - CORE_GEAR_GOLD = getRegisteredItem(core, "gear_gold"); - CORE_GEAR_DIAMOND = getRegisteredItem(core, "gear_diamond"); - CORE_MARKER_CONNECTOR = getRegisteredItem(core, "marker_connector"); - CORE_GOGGLES = getRegisteredItem(core, "goggles"); - - final String builders = "builders"; - BUILDERS_SINGLE_SCHEMATIC = getRegisteredItem(builders, "single_schematic"); - BUILDERS_SNAPSHOT = getRegisteredItem(builders, "snapshot"); - - final String energy = "energy"; - ENERGY_GLOB_OF_OIL = getRegisteredItem(energy, "glob_oil"); - - final String factory = "factory"; - FACTORY_PLASTIC_SHEET = getRegisteredItem(factory, "plastic_sheet"); - - final String robotics = "robotics"; - ROBOTICS_REDSTONE_BOARD = getRegisteredItem(robotics, "redstone_board"); - ROBOTICS_ROBOT = getRegisteredItem(robotics, "robot"); - ROBOTICS_PLUGGABLE_ROBOT_STATION = getRegisteredItem(robotics, "robot_station"); - ROBOTICS_ROBOT_GOGGLES = getRegisteredItem(robotics, "robot_goggles"); - - final String silicon = "silicon"; - SILICON_REDSTONE_CHIPSET = getRegisteredItem(silicon, "redstone_chipset"); - - final String transport = "transport"; - TRANSPORT_WATERPROOF = getRegisteredItem(transport, "waterproof"); - TRANSPORT_GATE_COPIER = getRegisteredItem(transport, "gate_copier"); - TRANSPORT_PLUGGABLE_GATE = getRegisteredItem(transport, "plug_gate"); - TRANSPORT_PLUGGABLE_WIRE = getRegisteredItem(transport, "plug_wire"); - TRANSPORT_PLUGGABLE_BLOCKER = getRegisteredItem(transport, "plug_blocker"); - TRANSPORT_PLUGGABLE_LENS = getRegisteredItem(transport, "plug_lens"); - TRANSPORT_PLUGGABLE_FACADE = getRegisteredItem(transport, "plug_facade"); - TRANSPORT_PLUGGABLE_POWER_ADAPTOR = getRegisteredItem(transport, "plug_power_adapter"); - TRANSPORT_PIPE_WOOD_ITEM = getRegisteredItem(transport, "pipe_wood_item"); - TRANSPORT_PIPE_WOOD_FLUID = getRegisteredItem(transport, "pipe_wood_fluid"); - TRANSPORT_PIPE_WOOD_POWER = getRegisteredItem(transport, "pipe_wood_power"); - - TRANSPORT_PIPE_DIAMOND_ITEM = getRegisteredItem(transport, "pipe_diamond_item"); - - if (DEBUG) { - for (Item item : Item.REGISTRY) { - ResourceLocation id = item.getRegistryName(); - if (id.getResourceDomain().startsWith("buildcraft")) { - if (!SCANNED.contains(id.toString())) { - BCLog.logger.warn("[api.items] Found an item " + id.toString() + " that was not registered with the API! Is this a bug?"); - } - } - } - } - } - - private static Item getRegisteredItem(String module, String regName) { - String modid = "buildcraft" + module; - Item item = Item.REGISTRY.getObject(new ResourceLocation(modid, regName)); - if (item != null) { - if (DEBUG) { - BCLog.logger.info("[api.items] Found the item " + regName + " from the module " + module); - SCANNED.add(modid + ":" + regName); - } - return item; - } - if (DEBUG) { - if (Loader.isModLoaded(modid)) { - BCLog.logger.info("[api.items] Did not find the item " + regName + " despite the appropriate mod being loaded (" + modid + ")"); - } else { - BCLog.logger.info("[api.items] Did not find the item " + regName + " probably because the mod is not loaded (" + modid + ")"); - } - } - - return null; - } -} diff --git a/src/api/java/buildcraft/api/BCModules.java b/src/api/java/buildcraft/api/BCModules.java deleted file mode 100644 index 73e769690..000000000 --- a/src/api/java/buildcraft/api/BCModules.java +++ /dev/null @@ -1,67 +0,0 @@ -package buildcraft.api; - -import java.util.Locale; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.LoaderState; - -import buildcraft.api.core.BCLog; - -public enum BCModules { - LIB, - // Base module for all BC. - CORE, - // Potentially optional modules for adding more BC functionality - BUILDERS, - ENERGY, - FACTORY, - ROBOTICS, - SILICON, - TRANSPORT, - // Optional module for compatibility with other mods - COMPAT; - - public static final BCModules[] VALUES = values(); - - private static final String MODID_START = "buildcraft"; - private final String modid, part; - - BCModules() { - part = name().toLowerCase(Locale.ROOT); - this.modid = MODID_START + part; - } - - public static void fmlPreInit() {} - - public static boolean isBcMod(String modid) { - if (!modid.startsWith(MODID_START)) return false; - String post = modid.substring(MODID_START.length()); - for (BCModules module : VALUES) { - if (post.equals(module.part)) { - return true; - } - } - return false; - } - - public boolean isLoaded() { - return Loader.isModLoaded(modid); - } - - public String getModId() { - return modid; - } - - static { - if (!Loader.instance().hasReachedState(LoaderState.CONSTRUCTING)) { - throw new RuntimeException("Accessed BC modules too early! You can only use them from construction onwards!"); - } - for (BCModules module : values()) { - if (module.isLoaded()) { - BCLog.logger.info("[api.modules] Module " + module.name().toLowerCase(Locale.ROOT) + " is loaded!"); - } else { - BCLog.logger.warn("[api.modules] Module " + module.name().toLowerCase(Locale.ROOT) + " is NOT loaded!"); - } - } - } -} diff --git a/src/api/java/buildcraft/api/blocks/CustomPaintHelper.java b/src/api/java/buildcraft/api/blocks/CustomPaintHelper.java deleted file mode 100755 index 2517af2bb..000000000 --- a/src/api/java/buildcraft/api/blocks/CustomPaintHelper.java +++ /dev/null @@ -1,115 +0,0 @@ -package buildcraft.api.blocks; - -import java.util.List; -import java.util.Map; - -import javax.annotation.Nullable; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -import buildcraft.api.core.BCDebugging; -import buildcraft.api.core.BCLog; - -/** Provides a simple way to paint a single block, iterating through all {@link ICustomPaintHandler}'s that are - * registered for the block. */ -public enum CustomPaintHelper { - INSTANCE; - - /* If you want to test your class-based rotation registration then add the system property - * "-Dbuildcraft.api.rotation.debug.class=true" to your launch. */ - private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.painting"); - - private final Map> handlers = Maps.newIdentityHashMap(); - private final List allHandlers = Lists.newArrayList(); - - /** Registers a handler that will be called LAST for ALL blocks, if all other paint handlers have returned PASS or - * none are registered for that block. */ - public void registerHandlerForAll(ICustomPaintHandler handler) { - if (DEBUG) { - BCLog.logger.info("[api.painting] Adding a paint handler for ALL blocks (" + handler.getClass() + ")"); - } - allHandlers.add(handler); - } - - /** Register's a paint handler for every class of a given block. */ - public void registerHandlerForAll(Class blockClass, ICustomPaintHandler handler) { - for (Block block : Block.REGISTRY) { - Class foundClass = block.getClass(); - if (blockClass.isAssignableFrom(foundClass)) { - if (DEBUG) { - BCLog.logger.info("[api.painting] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass); - } - registerHandlerInternal(block, handler); - } - } - } - - public void registerHandler(Block block, ICustomPaintHandler handler) { - if (registerHandlerInternal(block, handler)) { - if (DEBUG) { - BCLog.logger.info("[api.painting] Setting a paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")"); - } - } else if (DEBUG) { - BCLog.logger.info("[api.painting] Adding another paint handler for block " + block.getRegistryName() + "(" + handler.getClass() + ")"); - } - } - - private boolean registerHandlerInternal(Block block, ICustomPaintHandler handler) { - if (!handlers.containsKey(block)) { - List forBlock = Lists.newArrayList(); - forBlock.add(handler); - handlers.put(block, forBlock); - return true; - } else { - handlers.get(block).add(handler); - return false; - } - } - - /** Attempts to paint a block at the given position. Basically iterates through all registered paint handlers. */ - public EnumActionResult attemptPaintBlock(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paint) { - Block block = state.getBlock(); - if (block instanceof ICustomPaintHandler) { - return ((ICustomPaintHandler) block).attemptPaint(world, pos, state, hitPos, hitSide, paint); - } - List custom = handlers.get(block); - if (custom == null || custom.isEmpty()) { - return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint); - } - for (ICustomPaintHandler handler : custom) { - EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); - if (result != EnumActionResult.PASS) { - return result; - } - } - return defaultAttemptPaint(world, pos, state, hitPos, hitSide, paint); - } - - private EnumActionResult defaultAttemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, EnumFacing hitSide, @Nullable EnumDyeColor paint) { - for (ICustomPaintHandler handler : allHandlers) { - EnumActionResult result = handler.attemptPaint(world, pos, state, hitPos, hitSide, paint); - if (result != EnumActionResult.PASS) { - return result; - } - } - if (paint == null) { - return EnumActionResult.FAIL; - } - Block b = state.getBlock(); - if (b.recolorBlock(world, pos, hitSide, paint)) { - return EnumActionResult.SUCCESS; - } else { - return EnumActionResult.FAIL; - } - } -} diff --git a/src/api/java/buildcraft/api/blocks/CustomRotationHelper.java b/src/api/java/buildcraft/api/blocks/CustomRotationHelper.java deleted file mode 100755 index 235c0de11..000000000 --- a/src/api/java/buildcraft/api/blocks/CustomRotationHelper.java +++ /dev/null @@ -1,76 +0,0 @@ -package buildcraft.api.blocks; - -import java.util.List; -import java.util.Map; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import buildcraft.api.core.BCDebugging; -import buildcraft.api.core.BCLog; - -public enum CustomRotationHelper { - INSTANCE; - - /* If you want to test your class-based rotation registration then add the system property - * "-Dbuildcraft.api.rotation.debug.class=true" to your launch. */ - private static final boolean DEBUG = BCDebugging.shouldDebugLog("api.rotation"); - - private final Map> handlers = Maps.newIdentityHashMap(); - - public void registerHandlerForAll(Class blockClass, ICustomRotationHandler handler) { - for (Block block : Block.REGISTRY) { - Class foundClass = block.getClass(); - if (blockClass.isAssignableFrom(foundClass)) { - if (DEBUG) { - BCLog.logger.info("[api.rotation] Found an assignable block " + block.getRegistryName() + " (" + foundClass + ") for " + blockClass); - } - registerHandlerInternal(block, handler); - } - } - } - - public void registerHandler(Block block, ICustomRotationHandler handler) { - if (registerHandlerInternal(block, handler)) { - if (DEBUG) { - BCLog.logger.info("[api.rotation] Setting a rotation handler for block " + block.getRegistryName()); - } - } else if (DEBUG) { - BCLog.logger.info("[api.rotation] Adding another rotation handler for block " + block.getRegistryName()); - } - } - - private boolean registerHandlerInternal(Block block, ICustomRotationHandler handler) { - if (!handlers.containsKey(block)) { - List forBlock = Lists.newArrayList(); - forBlock.add(handler); - handlers.put(block, forBlock); - return true; - } else { - handlers.get(block).add(handler); - return false; - } - } - - public EnumActionResult attemptRotateBlock(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched) { - Block block = state.getBlock(); - if (block instanceof ICustomRotationHandler) { - return ((ICustomRotationHandler) block).attemptRotation(world, pos, state, sideWrenched); - } - if (!handlers.containsKey(block)) return EnumActionResult.PASS; - for (ICustomRotationHandler handler : handlers.get(block)) { - EnumActionResult result = handler.attemptRotation(world, pos, state, sideWrenched); - if (result != EnumActionResult.PASS) { - return result; - } - } - return EnumActionResult.PASS; - } -} diff --git a/src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java b/src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java deleted file mode 100755 index fd79c910a..000000000 --- a/src/api/java/buildcraft/api/blocks/ICustomPaintHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package buildcraft.api.blocks; - -import javax.annotation.Nullable; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -/** Provides a way to paint blocks from any position. You can either implement this on a block, or register an instance - * for a block with {@link CustomPaintHelper} */ -public interface ICustomPaintHandler { - /** Attempts to paint the given block. This can also only paint a specific part of the block (as the hit position is - * given). - * - * @param world The world that the block is contained within. - * @param pos The position of the block. - * @param state The current state of the block. - * @param hitPos The absolute hit position of the paintbrush, relative the world's origin. - * @param hitSide The side of the block that was hit. - * @param paintColour The paint colour to attempt to paint with, null if the paint should be cleared (so if this was - * a stained glass block, and null was passed, this would set it to a normal, clear, non-stained glass - * block. - * @return The result of attempting to paint. SUCCESS means that you changed the block from before to a new value, - * FAIL means you COULD have handled the block, but it was already painted to that colour, or PASS if you - * have no idea how to handle the block in question. */ - EnumActionResult attemptPaint(World world, BlockPos pos, IBlockState state, Vec3d hitPos, @Nullable EnumFacing hitSide, @Nullable EnumDyeColor paintColour); -} diff --git a/src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java b/src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java deleted file mode 100755 index 9076f8fd0..000000000 --- a/src/api/java/buildcraft/api/blocks/ICustomRotationHandler.java +++ /dev/null @@ -1,11 +0,0 @@ -package buildcraft.api.blocks; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface ICustomRotationHandler { - EnumActionResult attemptRotation(World world, BlockPos pos, IBlockState state, EnumFacing sideWrenched); -} diff --git a/src/api/java/buildcraft/api/blocks/package-info.java b/src/api/java/buildcraft/api/blocks/package-info.java deleted file mode 100755 index c3bc6eac1..000000000 --- a/src/api/java/buildcraft/api/blocks/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|blocks") -package buildcraft.api.blocks; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/boards/IRedstoneBoard.java b/src/api/java/buildcraft/api/boards/IRedstoneBoard.java deleted file mode 100755 index 2aa375e92..000000000 --- a/src/api/java/buildcraft/api/boards/IRedstoneBoard.java +++ /dev/null @@ -1,12 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.boards; - -public interface IRedstoneBoard { - - void updateBoard(T container); - - RedstoneBoardNBT getNBTHandler(); -} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java b/src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java deleted file mode 100755 index 0ced64a8b..000000000 --- a/src/api/java/buildcraft/api/boards/RedstoneBoardNBT.java +++ /dev/null @@ -1,45 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.boards; - -import java.util.List; -import java.util.Random; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.common.util.Constants; - -public abstract class RedstoneBoardNBT { - - private static Random rand = new Random(); - - public abstract String getID(); - - public abstract void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced); - - public abstract String getDisplayName(); - - public abstract IRedstoneBoard create(NBTTagCompound nbt, T object); - - public abstract String getItemModelLocation(); - - public void createBoard(NBTTagCompound nbt) { - nbt.setString("id", getID()); - } - - public int getParameterNumber(NBTTagCompound nbt) { - if (!nbt.hasKey("parameters")) { - return 0; - } else { - return nbt.getTagList("parameters", Constants.NBT.TAG_COMPOUND).tagCount(); - } - } - - public float nextFloat(int difficulty) { - return 1F - (float) Math.pow(rand.nextFloat(), 1F / difficulty); - } -} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java b/src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java deleted file mode 100755 index edfe79cb5..000000000 --- a/src/api/java/buildcraft/api/boards/RedstoneBoardRegistry.java +++ /dev/null @@ -1,32 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.boards; - -import java.util.Collection; - -import net.minecraft.nbt.NBTTagCompound; - -public abstract class RedstoneBoardRegistry { - - public static RedstoneBoardRegistry instance; - - /** Register a redstone board type. - * - * @param redstoneBoardNBT The RedstoneBoardNBT instance containing the board information. - * @param microJoules MJ price of the board, in micro MJ. */ - public abstract void registerBoardType(RedstoneBoardNBT redstoneBoardNBT, long microJoules); - - public abstract void setEmptyRobotBoard(RedstoneBoardRobotNBT redstoneBoardNBT); - - public abstract RedstoneBoardRobotNBT getEmptyRobotBoard(); - - public abstract RedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt); - - public abstract RedstoneBoardNBT getRedstoneBoard(String id); - - public abstract Collection> getAllBoardNBTs(); - - public abstract long getPowerCost(RedstoneBoardNBT board); -} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java b/src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java deleted file mode 100755 index b0ed0638f..000000000 --- a/src/api/java/buildcraft/api/boards/RedstoneBoardRobot.java +++ /dev/null @@ -1,29 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.boards; - -import buildcraft.api.robots.AIRobot; -import buildcraft.api.robots.EntityRobotBase; - -public abstract class RedstoneBoardRobot extends AIRobot implements IRedstoneBoard { - - public RedstoneBoardRobot(EntityRobotBase iRobot) { - super(iRobot); - } - - @Override - public abstract RedstoneBoardRobotNBT getNBTHandler(); - - @Override - public final void updateBoard(EntityRobotBase container) { - - } - - @Override - public boolean canLoadFromNBT() { - return true; - } - -} diff --git a/src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java b/src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java deleted file mode 100755 index 4a4161b19..000000000 --- a/src/api/java/buildcraft/api/boards/RedstoneBoardRobotNBT.java +++ /dev/null @@ -1,23 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.boards; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.robots.EntityRobotBase; - -public abstract class RedstoneBoardRobotNBT extends RedstoneBoardNBT { - - @Override - public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) { - return create(robot); - } - - public abstract RedstoneBoardRobot create(EntityRobotBase robot); - - public abstract ResourceLocation getRobotTexture(); - -} diff --git a/src/api/java/buildcraft/api/boards/package-info.java b/src/api/java/buildcraft/api/boards/package-info.java deleted file mode 100755 index 6253f5b79..000000000 --- a/src/api/java/buildcraft/api/boards/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|boards") -package buildcraft.api.boards; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/core/BCDebugging.java b/src/api/java/buildcraft/api/core/BCDebugging.java deleted file mode 100755 index 732be03d0..000000000 --- a/src/api/java/buildcraft/api/core/BCDebugging.java +++ /dev/null @@ -1,112 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.Locale; - -import net.minecraft.world.World; - -/** Provides a way to quickly enable or disable certain debug conditions via VM arguments or whether the client/server - * is in a dev environment */ -public class BCDebugging { - public enum DebugStatus { - NONE, - ENABLE, - LOGGING_ONLY, - ALL - } - - enum DebugLevel { - LOG, - COMPLEX; - - final String name = name().toLowerCase(Locale.ROOT); - boolean isAllOn; - } - - private static final DebugStatus DEBUG_STATUS; - - static { - // Basically we enable debugging for the dev-environment, and disable everything for normal players. - // However if you provide VM arguments then the behaviour changes somewhat: - // (VM argument is "-Dbuildcraft.debug=...") - // - "enable" Enables debugging even if you are not in a dev environment - // - "disable" Disables ALL debugging (and doesn't output any messages even in the dev environment) - // - "log" Major debug options are turned on. Registry setup + API usage etc - // - "all" All possible debug options are turned on. Lots of spam. Not recommended. - - String value = System.getProperty("buildcraft.debug"); - if ("enable".equals(value)) DEBUG_STATUS = DebugStatus.ENABLE; - else if ("all".equals(value)) DEBUG_STATUS = DebugStatus.ALL; - else if ("disable".equals(value)) { - // let people disable the messages if they are in a dev environment but don't want messages. - DEBUG_STATUS = DebugStatus.NONE; - } else if ("log".equals(value)) { - // Some debugging options are more than just logging, so we will differentiate between them - DEBUG_STATUS = DebugStatus.LOGGING_ONLY; - } else if (World.class.getName().contains("World")) { - // Dev environment - DEBUG_STATUS = DebugStatus.ENABLE; - } else { - // Most likely a built jar - don't spam people with info they probably don't need - DEBUG_STATUS = DebugStatus.NONE; - } - - if (DEBUG_STATUS == DebugStatus.ALL) { - BCLog.logger.info("[debugger] Debugging automatically enabled for ALL of buildcraft. Prepare for log spam."); - } else if (DEBUG_STATUS == DebugStatus.LOGGING_ONLY) { - BCLog.logger.info("[debugger] Debugging automatically enabled for some non-spammy parts of buildcraft."); - } else if (DEBUG_STATUS == DebugStatus.ENABLE) { - BCLog.logger.info("[debugger] Debugging not automatically enabled for all of buildcraft. Logging all possible debug options."); - BCLog.logger.info(" To enable it for only logging messages add \"-Dbuildcraft.debug=log\" to your launch VM arguments"); - BCLog.logger.info(" To enable it for ALL debugging \"-Dbuildcraft.debug=all\" to your launch VM arguments"); - BCLog.logger.info(" To remove this message and all future ones add \"-Dbuildcraft.debug=disable\" to your launch VM arguments"); - } - - DebugLevel.COMPLEX.isAllOn = DEBUG_STATUS == DebugStatus.ALL; - DebugLevel.LOG.isAllOn = DEBUG_STATUS == DebugStatus.ALL || DEBUG_STATUS == DebugStatus.LOGGING_ONLY; - } - - public static boolean shouldDebugComplex(String string) { - return shouldDebug(string, DebugLevel.COMPLEX); - } - - public static boolean shouldDebugLog(String string) { - return shouldDebug(string, DebugLevel.LOG); - } - - private static boolean shouldDebug(String option, DebugLevel type) { - String prop = getProp(option); - String actual = System.getProperty(prop); - if ("false".equals(actual)) { - BCLog.logger.info("[debugger] Debugging manually disabled for \"" + option + "\" (" + type + ")."); - return false; - } else if ("true".equals(actual)) { - BCLog.logger.info("[debugger] Debugging enabled for \"" + option + "\" (" + type + ")."); - return true; - } - if (type.isAllOn) { - BCLog.logger.info("[debugger] Debugging automatically enabled for \"" + option + "\" (" + type + ")."); - return true; - } - if ("complex".equals(actual) || type.name.equals(actual)) { - BCLog.logger.info("[debugger] Debugging enabled for \"" + option + "\" (" + type + ")."); - return true; - } else { - StringBuilder log = new StringBuilder(); - log.append("[debugger] To enable debugging for "); - log.append(option); - log.append(" add the option \"-D"); - log.append(prop); - log.append("=true\" to your launch config as a VM argument (").append(type).append(")."); - BCLog.logger.info(log); - } - return false; - } - - private static String getProp(String string) { - return "buildcraft." + string + ".debug"; - } -} diff --git a/src/api/java/buildcraft/api/core/BCLog.java b/src/api/java/buildcraft/api/core/BCLog.java deleted file mode 100755 index f74509173..000000000 --- a/src/api/java/buildcraft/api/core/BCLog.java +++ /dev/null @@ -1,43 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public final class BCLog { - public static final Logger logger = LogManager.getLogger("BuildCraft"); - - /** Deactivate constructor */ - private BCLog() {} - - @Deprecated - public static void logErrorAPI(String mod, Throwable error, Class classFile) { - logErrorAPI(error, classFile); - } - - public static void logErrorAPI(Throwable error, Class classFile) { - StringBuilder msg = new StringBuilder("API error! Please update your mods. Error: "); - msg.append(error); - StackTraceElement[] stackTrace = error.getStackTrace(); - if (stackTrace.length > 0) { - msg.append(", ").append(stackTrace[0]); - } - - logger.log(Level.ERROR, msg.toString()); - - if (classFile != null) { - msg.append("API error: ").append(classFile.getSimpleName()).append(" is loaded from ").append(classFile.getProtectionDomain() - .getCodeSource().getLocation()); - logger.log(Level.ERROR, msg.toString()); - } - } - - @Deprecated - public static String getVersion() { - return BuildCraftAPI.getVersion(); - } -} diff --git a/src/api/java/buildcraft/api/core/BuildCraftAPI.java b/src/api/java/buildcraft/api/core/BuildCraftAPI.java deleted file mode 100755 index f7f24c0cb..000000000 --- a/src/api/java/buildcraft/api/core/BuildCraftAPI.java +++ /dev/null @@ -1,61 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.HashMap; -import java.util.Set; - -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; - -public final class BuildCraftAPI { - public static IFakePlayerProvider fakePlayerProvider; - - public static final Set softBlocks = Sets.newHashSet(); - public static final HashMap worldProperties = Maps.newHashMap(); - - /** Deactivate constructor */ - private BuildCraftAPI() {} - - public static String getVersion() { - ModContainer container = Loader.instance().getIndexedModList().get("buildcraftlib"); - if (container != null) { - return container.getDisplayVersion(); - } - return "UNKNOWN VERSION"; - } - - public static IWorldProperty getWorldProperty(String name) { - return worldProperties.get(name); - } - - public static void registerWorldProperty(String name, IWorldProperty property) { - if (worldProperties.containsKey(name)) { - BCLog.logger.warn("The WorldProperty key '" + name + "' is being overridden with " + property.getClass().getSimpleName() + "!"); - } - worldProperties.put(name, property); - } - - public static boolean isSoftBlock(World world, BlockPos pos) { - return worldProperties.get("soft").get(world, pos); - } - - public static ResourceLocation nameToResourceLocation(String name) { - if (name.indexOf(':') > 0) return new ResourceLocation(name); - ModContainer modContainer = Loader.instance().activeModContainer(); - if (modContainer == null) { - throw new IllegalStateException("Illegal recipe name " + name + ". Provide domain id to register it correctly."); - } - return new ResourceLocation(modContainer.getModId(), name); - } -} diff --git a/src/api/java/buildcraft/api/core/CapabilitiesHelper.java b/src/api/java/buildcraft/api/core/CapabilitiesHelper.java deleted file mode 100644 index d5795c935..000000000 --- a/src/api/java/buildcraft/api/core/CapabilitiesHelper.java +++ /dev/null @@ -1,37 +0,0 @@ -package buildcraft.api.core; - -import javax.annotation.Nonnull; - -import net.minecraft.nbt.NBTBase; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityManager; - -public class CapabilitiesHelper { - public static void registerCapability(Class clazz) { - CapabilityManager.INSTANCE.register(clazz, new VoidStorage<>(), () -> { - throw new IllegalStateException("You must create your own instances!"); - }); - } - - @Nonnull - public static Capability ensureRegistration(Capability cap, Class clazz) { - if (cap == null) { - throw new Error("Capability registration failed for " + clazz); - } - return cap; - } - - public static class VoidStorage implements Capability.IStorage { - @Override - public NBTBase writeNBT(Capability capability, T instance, EnumFacing side) { - throw new IllegalStateException("You must create your own instances!"); - } - - @Override - public void readNBT(Capability capability, T instance, EnumFacing side, NBTBase nbt) { - throw new IllegalStateException("You must create your own instances!"); - } - } -} diff --git a/src/api/java/buildcraft/api/core/EnumColor.java b/src/api/java/buildcraft/api/core/EnumColor.java deleted file mode 100755 index 028843870..000000000 --- a/src/api/java/buildcraft/api/core/EnumColor.java +++ /dev/null @@ -1,147 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.Locale; -import java.util.Random; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.util.IStringSerializable; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.translation.I18n; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -/** Use minecraft's EnumDyeColor in as many places as possible. */ -@Deprecated -public enum EnumColor implements IStringSerializable { - - BLACK, - RED, - GREEN, - BROWN, - BLUE, - PURPLE, - CYAN, - LIGHT_GRAY, - GRAY, - PINK, - LIME, - YELLOW, - LIGHT_BLUE, - MAGENTA, - ORANGE, - WHITE; - - public static final EnumColor[] VALUES = values(); - public static final String[] DYES = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", - "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" }; - public static final String[] NAMES = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", - "LightBlue", "Magenta", "Orange", "White" }; - public static final int[] DARK_HEX = { 0x2D2D2D, 0xA33835, 0x394C1E, 0x5C3A24, 0x3441A2, 0x843FBF, 0x36809E, 0x888888, 0x444444, 0xE585A0, - 0x3FAA36, 0xCFC231, 0x7F9AD1, 0xFF64FF, 0xFF6A00, 0xFFFFFF }; - public static final int[] LIGHT_HEX = { 0x181414, 0xBE2B27, 0x007F0E, 0x89502D, 0x253193, 0x7e34bf, 0x299799, 0xa0a7a7, 0x7A7A7A, 0xD97199, - 0x39D52E, 0xFFD91C, 0x66AAFF, 0xD943C6, 0xEA7835, 0xe4e4e4 }; - - @SideOnly(Side.CLIENT) - private static ResourceLocation iconSheet; - - @SideOnly(Side.CLIENT) - private static TextureAtlasSprite[] brushSprites; - - public int getDarkHex() { - return DARK_HEX[ordinal()]; - } - - public int getLightHex() { - return LIGHT_HEX[ordinal()]; - } - - public static EnumColor fromId(int id) { - if (id < 0 || id >= VALUES.length) { - return WHITE; - } - return VALUES[id]; - } - - public static EnumColor fromDye(String dyeTag) { - for (int id = 0; id < DYES.length; id++) { - if (DYES[id].equals(dyeTag)) { - return VALUES[id]; - } - } - return null; - } - - public static EnumColor fromName(String name) { - for (int id = 0; id < NAMES.length; id++) { - if (NAMES[id].equals(name)) { - return VALUES[id]; - } - } - return null; - } - - public static EnumColor getRand() { - return VALUES[new Random().nextInt(VALUES.length)]; - } - - public EnumColor getNext() { - EnumColor next = VALUES[(ordinal() + 1) % VALUES.length]; - return next; - } - - public EnumColor getPrevious() { - EnumColor previous = VALUES[(ordinal() + VALUES.length - 1) % VALUES.length]; - return previous; - } - - public EnumColor inverse() { - return EnumColor.VALUES[15 - ordinal()]; - } - - public String getTag() { - return "color." + name().replace("_", ".").toLowerCase(Locale.ENGLISH); - } - - public String getBasicTag() { - return name().replace("_", ".").toLowerCase(Locale.ENGLISH); - } - - @Override - public String getName() { - return NAMES[ordinal()]; - } - - public String getLocalizedName() { - return I18n.translateToLocal(getTag()); - } - - public String getDye() { - return DYES[ordinal()]; - } - - @Override - public String toString() { - String s = name().replace("_", " "); - String[] words = s.split(" "); - StringBuilder b = new StringBuilder(); - for (String word : words) { - b.append(word.charAt(0)).append(word.substring(1).toLowerCase(Locale.ENGLISH)).append(" "); - } - return b.toString().trim(); - } - - @SideOnly(Side.CLIENT) - public static void registerSprites(TextureAtlasSprite[] sprites) { - brushSprites = sprites; - } - - @SideOnly(Side.CLIENT) - public TextureAtlasSprite getSprite() { - return brushSprites[ordinal()]; - } -} diff --git a/src/api/java/buildcraft/api/core/EnumHandlerPriority.java b/src/api/java/buildcraft/api/core/EnumHandlerPriority.java deleted file mode 100644 index 66145a2f5..000000000 --- a/src/api/java/buildcraft/api/core/EnumHandlerPriority.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2017 SpaceToad and the BuildCraft team - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. - */ - -package buildcraft.api.core; - -public enum EnumHandlerPriority implements Comparable { - HIGHEST, - HIGH, - NORMAL, - LOW, - LOWEST; - - public static final EnumHandlerPriority[] VALUES = values(); -} diff --git a/src/api/java/buildcraft/api/core/EnumPipePart.java b/src/api/java/buildcraft/api/core/EnumPipePart.java deleted file mode 100755 index 3eb3731b0..000000000 --- a/src/api/java/buildcraft/api/core/EnumPipePart.java +++ /dev/null @@ -1,133 +0,0 @@ -package buildcraft.api.core; - -import java.util.Locale; -import java.util.Map; - -import com.google.common.collect.Maps; - -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTPrimitive; -import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.IStringSerializable; - -public enum EnumPipePart implements IStringSerializable { - DOWN(EnumFacing.DOWN), - UP(EnumFacing.UP), - NORTH(EnumFacing.NORTH), - SOUTH(EnumFacing.SOUTH), - WEST(EnumFacing.WEST), - EAST(EnumFacing.EAST), - /** CENTER, UNKNOWN and ALL are all valid uses of this. */ - CENTER(null); - - public static final EnumPipePart[] VALUES = values(); - public static final EnumPipePart[] FACES; - public static final EnumPipePart[] HORIZONTALS; - - private static final Map facingMap = Maps.newEnumMap(EnumFacing.class); - private static final Map nameMap = Maps.newHashMap(); - private static final int MAX_VALUES = values().length; - - public final EnumFacing face; - - static { - for (EnumPipePart part : values()) { - nameMap.put(part.name(), part); - if (part.face != null) facingMap.put(part.face, part); - } - FACES = fromFacingArray(EnumFacing.VALUES); - HORIZONTALS = fromFacingArray(EnumFacing.HORIZONTALS); - } - - private static EnumPipePart[] fromFacingArray(EnumFacing... faces) { - EnumPipePart[] arr = new EnumPipePart[faces.length]; - for (int i = 0; i < faces.length; i++) { - arr[i] = fromFacing(faces[i]); - } - return arr; - } - - public static int ordinal(EnumFacing face) { - return face == null ? 6 : face.ordinal(); - } - - public static EnumPipePart fromFacing(EnumFacing face) { - if (face == null) { - return EnumPipePart.CENTER; - } - return facingMap.get(face); - } - - public static EnumPipePart[] validFaces() { - return FACES; - } - - public static EnumPipePart fromMeta(int meta) { - if (meta < 0 || meta >= MAX_VALUES) { - return EnumPipePart.CENTER; - } - return VALUES[meta]; - } - - EnumPipePart(EnumFacing face) { - this.face = face; - } - - public int getIndex() { - if (face == null) return 6; - return face.getIndex(); - } - - @Override - public String getName() { - return name().toLowerCase(Locale.ROOT); - } - - public EnumPipePart next() { - switch (this) { - case DOWN: - return EAST; - case EAST: - return NORTH; - case NORTH: - return SOUTH; - case SOUTH: - return UP; - case UP: - return WEST; - case WEST: - return DOWN; - default: - return DOWN; - } - } - - public EnumPipePart opposite() { - if (this == CENTER) { - return CENTER; - } - return fromFacing(face.getOpposite()); - } - - public static EnumPipePart readFromNBT(NBTBase base) { - if (base == null) { - return CENTER; - } - if (base instanceof NBTTagString) { - NBTTagString nbtString = (NBTTagString) base; - String string = nbtString.getString(); - return nameMap.getOrDefault(string, CENTER); - } else { - byte ord = ((NBTPrimitive) base).getByte(); - if (ord < 0 || ord > 6) { - return CENTER; - } - return values()[ord]; - } - } - - public NBTBase writeToNBT() { - return new NBTTagString(name()); - } -} diff --git a/src/api/java/buildcraft/api/core/IAreaProvider.java b/src/api/java/buildcraft/api/core/IAreaProvider.java deleted file mode 100755 index 02bcf0ca9..000000000 --- a/src/api/java/buildcraft/api/core/IAreaProvider.java +++ /dev/null @@ -1,17 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import net.minecraft.util.math.BlockPos; - -/** To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers. */ -public interface IAreaProvider { - BlockPos min(); - - BlockPos max(); - - /** Remove from the world all objects used to define the area. */ - void removeFromWorld(); -} diff --git a/src/api/java/buildcraft/api/core/IBox.java b/src/api/java/buildcraft/api/core/IBox.java deleted file mode 100755 index 2c6a4a3bb..000000000 --- a/src/api/java/buildcraft/api/core/IBox.java +++ /dev/null @@ -1,17 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import net.minecraft.util.math.BlockPos; - -public interface IBox extends IZone { - IBox expand(int amount); - - IBox contract(int amount); - - BlockPos min(); - - BlockPos max(); -} diff --git a/src/api/java/buildcraft/api/core/IEngineType.java b/src/api/java/buildcraft/api/core/IEngineType.java deleted file mode 100644 index b8710961a..000000000 --- a/src/api/java/buildcraft/api/core/IEngineType.java +++ /dev/null @@ -1,5 +0,0 @@ -package buildcraft.api.core; - -public interface IEngineType { - String getItemModelLocation(); -} diff --git a/src/api/java/buildcraft/api/core/IFakePlayerProvider.java b/src/api/java/buildcraft/api/core/IFakePlayerProvider.java deleted file mode 100644 index c8bed734b..000000000 --- a/src/api/java/buildcraft/api/core/IFakePlayerProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - *

    - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. - */ -package buildcraft.api.core; - -import com.mojang.authlib.GameProfile; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.WorldServer; - -import net.minecraftforge.common.util.FakePlayer; - -public interface IFakePlayerProvider { - /** - * Returns the generic buildcraft fake player. Note that you shouldn't use this anymore, as you should store the - * UUID of the real player who created the block or entity that calls this. - */ - @Deprecated - FakePlayer getBuildCraftPlayer(WorldServer world); - - /** - * @param world - * @param profile The owner's profile. - * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this - * player is left around as it holds a reference to the world object. - */ - FakePlayer getFakePlayer(WorldServer world, GameProfile profile); - - /** - * @param world - * @param profile The owner's profile. - * @param pos - * @return A fake player that can be used IN THE CURRENT METHOD CONTEXT ONLY! This will cause problems if this - * player is left around as it holds a reference to the world object. - */ - FakePlayer getFakePlayer(WorldServer world, GameProfile profile, BlockPos pos); -} diff --git a/src/api/java/buildcraft/api/core/IFluidFilter.java b/src/api/java/buildcraft/api/core/IFluidFilter.java deleted file mode 100755 index 0cd10d669..000000000 --- a/src/api/java/buildcraft/api/core/IFluidFilter.java +++ /dev/null @@ -1,12 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - *

    - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.core; - -import net.minecraftforge.fluids.FluidStack; - -public interface IFluidFilter { - - boolean matches(FluidStack fluid); -} diff --git a/src/api/java/buildcraft/api/core/IFluidHandlerAdv.java b/src/api/java/buildcraft/api/core/IFluidHandlerAdv.java deleted file mode 100755 index aba2d8a64..000000000 --- a/src/api/java/buildcraft/api/core/IFluidHandlerAdv.java +++ /dev/null @@ -1,18 +0,0 @@ -package buildcraft.api.core; - -import javax.annotation.Nullable; - -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; - -/** A version of {@link IFluidHandler} that can drain a fluid that a fluid filter accepts. */ -public interface IFluidHandlerAdv extends IFluidHandler { - /** Drains fluid out of internal tanks, distribution is left entirely to the IFluidHandler. - * - * @param filter A filter to filter the possible fluids that can be extracted. - * @param maxDrain The maximum amount of fluid to drain - * @param doDrain If false, drain will only be simulated. - * @return FluidStack representing the Fluid and amount that was (or would have been, if simulated) drained. */ - @Nullable - FluidStack drain(IFluidFilter filter, int maxDrain, boolean doDrain); -} diff --git a/src/api/java/buildcraft/api/core/IInvSlot.java b/src/api/java/buildcraft/api/core/IInvSlot.java deleted file mode 100755 index a047a2f87..000000000 --- a/src/api/java/buildcraft/api/core/IInvSlot.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import net.minecraft.item.ItemStack; - -public interface IInvSlot { - /** Returns the slot number of the underlying Inventory. - * - * @return the slot number */ - int getIndex(); - - boolean canPutStackInSlot(ItemStack stack); - - boolean canTakeStackFromSlot(ItemStack stack); - - boolean isItemValidForSlot(ItemStack stack); - - ItemStack decreaseStackInSlot(int amount); - - ItemStack getStackInSlot(); - - void setStackInSlot(ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/core/IPathProvider.java b/src/api/java/buildcraft/api/core/IPathProvider.java deleted file mode 100755 index f21ef36c5..000000000 --- a/src/api/java/buildcraft/api/core/IPathProvider.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.core; - -import java.util.List; - -import net.minecraft.util.math.BlockPos; - -import buildcraft.api.items.IMapLocation.MapLocationType; - -/** To be implemented by TileEntities able to provide a path on the world, typically BuildCraft path markers. */ -public interface IPathProvider { - /** @return The completed path. This should loop back onto itself (The last position is the same as the first - * position) if you are {@link MapLocationType#PATH_REPEATING} */ - List getPath(); - - /** Remove from the world all objects used to define the path. */ - void removeFromWorld(); -} diff --git a/src/api/java/buildcraft/api/core/IPlayerOwned.java b/src/api/java/buildcraft/api/core/IPlayerOwned.java deleted file mode 100644 index 8aa80fe4f..000000000 --- a/src/api/java/buildcraft/api/core/IPlayerOwned.java +++ /dev/null @@ -1,8 +0,0 @@ -package buildcraft.api.core; - -import com.mojang.authlib.GameProfile; - -/** Defines an entity or tile that is owned by a specific player. */ -public interface IPlayerOwned { - GameProfile getOwner(); -} diff --git a/src/api/java/buildcraft/api/core/IStackFilter.java b/src/api/java/buildcraft/api/core/IStackFilter.java deleted file mode 100755 index 2c810c9f6..000000000 --- a/src/api/java/buildcraft/api/core/IStackFilter.java +++ /dev/null @@ -1,28 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - *

    - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.core; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -/** This interface provides a convenient means of dealing with entire classes of items without having to specify each - * item individually. */ -public interface IStackFilter { - - /** Check to see if a given stack matches this filter. - * - * @param stack The stack to test. stack.isEmpty will always return false. - * @return True if it does match, false otherwise. */ - boolean matches(@Nonnull ItemStack stack); - - /** - * Returns example stack to match this filter - */ - default NonNullList getExamples() { - return NonNullList.withSize(0, ItemStack.EMPTY); - } -} diff --git a/src/api/java/buildcraft/api/core/IWorldProperty.java b/src/api/java/buildcraft/api/core/IWorldProperty.java deleted file mode 100755 index 415dc12d1..000000000 --- a/src/api/java/buildcraft/api/core/IWorldProperty.java +++ /dev/null @@ -1,14 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface IWorldProperty { - boolean get(World world, BlockPos pos); - - void clear(); -} diff --git a/src/api/java/buildcraft/api/core/IZone.java b/src/api/java/buildcraft/api/core/IZone.java deleted file mode 100755 index 21a5df210..000000000 --- a/src/api/java/buildcraft/api/core/IZone.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.Random; - -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; - -public interface IZone { - /** Returns the smallest possible distance that the index would have to be changed by in order for - * {@link #contains(Vec3d)} to return true. If the position is already inside then this will return 0 */ - double distanceTo(BlockPos index); - - /** Returns {@link #distanceTo(BlockPos)} but squared. Usually this will be quicker to calculate. */ - double distanceToSquared(BlockPos index); - - /** Returns true if the point is enclosed by this zone, such that none of the coordinates lie outside the range - * specified by this zone. */ - boolean contains(Vec3d point); - - /** Gets a random position that {@link #contains(Vec3d)} will return true. */ - BlockPos getRandomBlockPos(Random rand); -} diff --git a/src/api/java/buildcraft/api/core/InvalidInputDataException.java b/src/api/java/buildcraft/api/core/InvalidInputDataException.java deleted file mode 100644 index 866c36cb1..000000000 --- a/src/api/java/buildcraft/api/core/InvalidInputDataException.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2017 SpaceToad and the BuildCraft team - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not - * distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/ - */ - -package buildcraft.api.core; - -import java.io.IOException; - -/** - * Indicates that we failed to load from NBT or some other file. - */ -public class InvalidInputDataException extends IOException { - public InvalidInputDataException() { - } - - public InvalidInputDataException(String message) { - super(message); - } - - public InvalidInputDataException(Throwable cause) { - super(cause); - } - - public InvalidInputDataException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/api/java/buildcraft/api/core/JavaTools.java b/src/api/java/buildcraft/api/core/JavaTools.java deleted file mode 100755 index 7b7eb513c..000000000 --- a/src/api/java/buildcraft/api/core/JavaTools.java +++ /dev/null @@ -1,39 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import java.util.Arrays; - -public final class JavaTools { - private JavaTools() { - - } - - public static T[] concat(T[] first, T[] second) { - T[] result = Arrays.copyOf(first, first.length + second.length); - System.arraycopy(second, 0, result, first.length, second.length); - return result; - } - - public static int[] concat(int[] first, int[] second) { - int[] result = Arrays.copyOf(first, first.length + second.length); - System.arraycopy(second, 0, result, first.length, second.length); - return result; - } - - public static float[] concat(float[] first, float[] second) { - float[] result = Arrays.copyOf(first, first.length + second.length); - System.arraycopy(second, 0, result, first.length, second.length); - return result; - } - - public static String surroundWithQuotes(String stringToSurroundWithQuotes) { - return String.format("\"%s\"", stringToSurroundWithQuotes); - } - - public static String stripSurroundingQuotes(String stringToStripQuotes) { - return stringToStripQuotes.replaceAll("^\"|\"$", ""); - } -} diff --git a/src/api/java/buildcraft/api/core/SafeTimeTracker.java b/src/api/java/buildcraft/api/core/SafeTimeTracker.java deleted file mode 100755 index 30593bef0..000000000 --- a/src/api/java/buildcraft/api/core/SafeTimeTracker.java +++ /dev/null @@ -1,70 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import net.minecraft.world.World; - -/** Provides a way of tracking time in the world, without requiring manual ticking. */ -public class SafeTimeTracker { - - private long lastMark = Long.MIN_VALUE; - private long duration = -1; - private long randomRange = 0; - private long lastRandomDelay = 0; - private long internalDelay = 1; - - /** Only use this if the delay time changes (say, if you use this to determine when a refining should be complete */ - public SafeTimeTracker() { - - } - - public SafeTimeTracker(long delay) { - internalDelay = delay; - } - - /** In many situations, it is a bad idea to have all objects of the same kind to be waiting for the exact same - * amount of time, as that can lead to some situation where they're all synchronized and got to work all at the same - * time. When created with a random range, the mark that is set when reaching the expect delay will be added with a - * random number between [0, range[, meaning that the event will take between 0 and range more tick to run. */ - public SafeTimeTracker(long delay, long random) { - internalDelay = delay; - randomRange = random; - } - - /** Return true if the internal delay has passed since last time marked was called successfully. */ - public boolean markTimeIfDelay(World world) { - return markTimeIfDelay(world, internalDelay); - } - - /** Return true if a given delay has passed since last time marked was called successfully. */ - public boolean markTimeIfDelay(World world, long delay) { - if (world == null) { - return false; - } - - long currentTime = world.getTotalWorldTime(); - - if (currentTime < lastMark) { - lastMark = currentTime; - return false; - } else if (lastMark + delay + lastRandomDelay <= currentTime) { - duration = currentTime - lastMark; - lastMark = currentTime; - lastRandomDelay = (int) (Math.random() * randomRange); - - return true; - } else { - return false; - } - } - - public long durationOfLastDelay() { - return duration > 0 ? duration : 0; - } - - public void markTime(World world) { - lastMark = world.getTotalWorldTime(); - } -} diff --git a/src/api/java/buildcraft/api/core/StackKey.java b/src/api/java/buildcraft/api/core/StackKey.java deleted file mode 100755 index d8c2c44cc..000000000 --- a/src/api/java/buildcraft/api/core/StackKey.java +++ /dev/null @@ -1,124 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.core; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -/** This class is used whenever stacks needs to be stored as keys. */ -public final class StackKey { - public final ItemStack stack; - public final FluidStack fluidStack; - - public StackKey(FluidStack fluidStack) { - this(null, fluidStack); - } - - public StackKey(ItemStack stack) { - this(stack, null); - } - - public StackKey(ItemStack stack, FluidStack fluidStack) { - this.stack = stack; - this.fluidStack = fluidStack; - } - - public static StackKey stack(Item item, int amount, int damage) { - return new StackKey(new ItemStack(item, amount, damage)); - } - - public static StackKey stack(Block block, int amount, int damage) { - return new StackKey(new ItemStack(block, amount, damage)); - } - - public static StackKey stack(Item item) { - return new StackKey(new ItemStack(item, 1, 0)); - } - - public static StackKey stack(Block block) { - return new StackKey(new ItemStack(block, 1, 0)); - } - - public static StackKey stack(ItemStack itemStack) { - return new StackKey(itemStack); - } - - public static StackKey fluid(Fluid fluid, int amount) { - return new StackKey(new FluidStack(fluid, amount)); - } - - public static StackKey fluid(Fluid fluid) { - return new StackKey(new FluidStack(fluid, 1000)); - } - - public static StackKey fluid(FluidStack fluidStack) { - return new StackKey(fluidStack); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || o.getClass() != StackKey.class) { - return false; - } - StackKey k = (StackKey) o; - if ((stack == null ^ k.stack == null) || (fluidStack == null ^ k.fluidStack == null)) { - return false; - } - if (stack != null) { - if (stack.getItem() != k.stack.getItem() || stack.getHasSubtypes() && stack.getItemDamage() != k.stack.getItemDamage() || !objectsEqual( - stack.getTagCompound(), k.stack.getTagCompound())) { - return false; - } - } - if (fluidStack != null) { - if (!fluidStack.isFluidEqual(k.fluidStack) || fluidStack.amount != k.fluidStack.amount) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - int result = 7; - if (stack != null) { - result = 31 * result + stack.getItem().hashCode(); - result = 31 * result + stack.getItemDamage(); - result = 31 * result + objectHashCode(stack.getTagCompound()); - } - result = 31 * result + 7; - if (fluidStack != null) { - result = 31 * result + fluidStack.getFluid().getName().hashCode(); - result = 31 * result + fluidStack.amount; - result = 31 * result + objectHashCode(fluidStack.tag); - } - return result; - } - - private boolean objectsEqual(Object o1, Object o2) { - if (o1 == null && o2 == null) { - return true; - } else if (o1 == null || o2 == null) { - return false; - } else { - return o1.equals(o2); - } - } - - private int objectHashCode(Object o) { - return o != null ? o.hashCode() : 0; - } - - public StackKey copy() { - return new StackKey(stack != null ? stack.copy() : null, fluidStack != null ? fluidStack.copy() : null); - } -} diff --git a/src/api/java/buildcraft/api/core/package-info.java b/src/api/java/buildcraft/api/core/package-info.java deleted file mode 100755 index dde5377cc..000000000 --- a/src/api/java/buildcraft/api/core/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.2", owner = "buildcraftlib", provides = "BuildCraftAPI|core") -package buildcraft.api.core; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/crops/CropManager.java b/src/api/java/buildcraft/api/crops/CropManager.java deleted file mode 100755 index 68a430201..000000000 --- a/src/api/java/buildcraft/api/crops/CropManager.java +++ /dev/null @@ -1,86 +0,0 @@ -package buildcraft.api.crops; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public final class CropManager { - private static List handlers = new ArrayList<>(); - private static ICropHandler defaultHandler; - - private CropManager() { - - } - - public static void registerHandler(ICropHandler cropHandler) { - handlers.add(cropHandler); - } - - public static void setDefaultHandler(ICropHandler cropHandler) { - defaultHandler = cropHandler; - } - - public static ICropHandler getDefaultHandler() { - return defaultHandler; - } - - public static boolean isSeed(ItemStack stack) { - for (ICropHandler cropHandler : handlers) { - if (cropHandler.isSeed(stack)) { - return true; - } - } - return defaultHandler.isSeed(stack); - } - - public static boolean canSustainPlant(World world, ItemStack seed, BlockPos pos) { - for (ICropHandler cropHandler : handlers) { - if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos)) { - return true; - } - } - return defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos); - } - - /** Attempts to plant the crop given by the seed into the world. Also checks to make sure that - * {@link ICropHandler#isSeed(ItemStack)} is true, and - * {@link ICropHandler#canSustainPlant(World, ItemStack, BlockPos)} is true for the position. */ - public static boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos) { - for (ICropHandler cropHandler : handlers) { - if (cropHandler.isSeed(seed) && cropHandler.canSustainPlant(world, seed, pos) && cropHandler.plantCrop(world, player, seed, pos)) { - return true; - } - } - if (defaultHandler.isSeed(seed) && defaultHandler.canSustainPlant(world, seed, pos)) { - return defaultHandler.plantCrop(world, player, seed, pos); - } - return false; - } - - public static boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos) { - for (ICropHandler cropHandler : handlers) { - if (cropHandler.isMature(blockAccess, state, pos)) { - return true; - } - } - return defaultHandler.isMature(blockAccess, state, pos); - } - - public static boolean harvestCrop(World world, BlockPos pos, NonNullList drops) { - IBlockState state = world.getBlockState(pos); - for (ICropHandler cropHandler : handlers) { - if (cropHandler.isMature(world, state, pos)) { - return cropHandler.harvestCrop(world, pos, drops); - } - } - return defaultHandler.isMature(world, state, pos) && defaultHandler.harvestCrop(world, pos, drops); - } - -} diff --git a/src/api/java/buildcraft/api/crops/ICropHandler.java b/src/api/java/buildcraft/api/crops/ICropHandler.java deleted file mode 100755 index 845108fe0..000000000 --- a/src/api/java/buildcraft/api/crops/ICropHandler.java +++ /dev/null @@ -1,53 +0,0 @@ -package buildcraft.api.crops; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -public interface ICropHandler { - - /** Check if an item is a seed. - * - * @param stack - * @return true if the item can be planted. */ - boolean isSeed(ItemStack stack); - - /** Check if the item can be planted. You can assume canSustainPlant() will only be called if isSeed() returned - * true. - * - * @param world - * @param seed - * @param pos - * @return true if the item can be planted at pos. */ - boolean canSustainPlant(World world, ItemStack seed, BlockPos pos); - - /** Plant the item in the block. You can assume plantCrop() will only be called if canSustainPlant() returned true. - * - * @param world - * @param player - * @param seed - * @param pos - * @return true if the item was planted at pos. */ - boolean plantCrop(World world, EntityPlayer player, ItemStack seed, BlockPos pos); - - /** Check if a crop is mature and can be harvested. - * - * @param blockAccess - * @param state - * @param pos - * @return true if the block at pos is mature and can be harvested. */ - boolean isMature(IBlockAccess blockAccess, IBlockState state, BlockPos pos); - - /** Harvest the crop. You can assume harvestCrop() will only be called if isMature() returned true. - * - * @param world - * @param pos - * @param drops a list to return the harvest's drops. - * @return true if the block was successfully harvested. */ - boolean harvestCrop(World world, BlockPos pos, NonNullList drops); - -} diff --git a/src/api/java/buildcraft/api/crops/package-info.java b/src/api/java/buildcraft/api/crops/package-info.java deleted file mode 100755 index 803ce050a..000000000 --- a/src/api/java/buildcraft/api/crops/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "BuildCraftAPI|Core", provides = "BuildCraftAPI|crops") -package buildcraft.api.crops; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/data/NbtSquishConstants.java b/src/api/java/buildcraft/api/data/NbtSquishConstants.java deleted file mode 100644 index 942f0a8e4..000000000 --- a/src/api/java/buildcraft/api/data/NbtSquishConstants.java +++ /dev/null @@ -1,50 +0,0 @@ -package buildcraft.api.data; - -import java.util.zip.GZIPInputStream; - -import net.minecraft.nbt.CompressedStreamTools; -import net.minecraft.nbt.NBTTagCompound; - -public class NbtSquishConstants { - /** Default written NBT Tag type- this is provided by - * {@link CompressedStreamTools#write(NBTTagCompound, java.io.DataOutput)} and - * {@link CompressedStreamTools#read(java.io.DataInput, net.minecraft.nbt.NBTSizeTracker)}. - * - * Generally more suited to smaller NBT tags, and it writes fairly quickly. Can quickly use up a lot of space for - * larger/more complex tags so it is recommended that you also pass it through a GZIP compressor to take up a much - * smaller space. */ - public static final int VANILLA = 0; - public static final int VANILLA_COMPRESSED = 1; - /** Buildcraft provided NBT compressor - puts every tag type into a dictionary and then refers to the dictionary for - * every tag which is written out. Can get much better space usage than {@link #VANILLA}, but at the cost of - * time. */ - public static final int BUILDCRAFT_V1 = 2; - public static final int BUILDCRAFT_V1_COMPRESSED = 3; - - public static final int BUILDCRAFT_MAGIC_1 = 0xbc; - public static final int BUILDCRAFT_MAGIC_2 = 0xa1; - /** The magic identifier for this type of file. First byte is BC, second is A1. */ - public static final int BUILDCRAFT_MAGIC = (BUILDCRAFT_MAGIC_1 << 8) | BUILDCRAFT_MAGIC_2; - - // GZIP uses the opposite byte order to us, so swap it around for us - public static final int GZIP_MAGIC_1 = GZIPInputStream.GZIP_MAGIC & 0xff; - public static final int GZIP_MAGIC_2 = GZIPInputStream.GZIP_MAGIC >> 8; - public static final int GZIP_MAGIC = (GZIP_MAGIC_1 << 8) | GZIP_MAGIC_2; - - // The flags used by BUILDCRAFT_V1 to check the existence of each dictionary - public static final int FLAG_HAS_BYTES = 1 << 0; - public static final int FLAG_HAS_SHORTS = 1 << 1; - public static final int FLAG_HAS_INTS = 1 << 2; - public static final int FLAG_HAS_LONGS = 1 << 3; - public static final int FLAG_HAS_FLOATS = 1 << 4; - public static final int FLAG_HAS_DOUBLES = 1 << 5; - public static final int FLAG_HAS_BYTE_ARRAYS = 1 << 6; - public static final int FLAG_HAS_INT_ARRAYS = 1 << 7; - public static final int FLAG_HAS_STRINGS = 1 << 8; - public static final int FLAG_HAS_COMPLEX = 1 << 9; - - // Complex types - public static final int COMPLEX_COMPOUND = 0; - public static final int COMPLEX_LIST = 1; - public static final int COMPLEX_LIST_PACKED = 2; -} diff --git a/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java b/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java deleted file mode 100755 index 0a6b53feb..000000000 --- a/src/api/java/buildcraft/api/enums/EnumDecoratedBlock.java +++ /dev/null @@ -1,34 +0,0 @@ -package buildcraft.api.enums; - -import java.util.Locale; - -import net.minecraft.util.IStringSerializable; - -public enum EnumDecoratedBlock implements IStringSerializable { - DESTROY(0), - BLUEPRINT(10), - TEMPLATE(10), - PAPER(10), - LEATHER(10), - LASER_BACK(0); - - public static final EnumDecoratedBlock[] VALUES = values(); - - public final int lightValue; - - EnumDecoratedBlock(int lightValue) { - this.lightValue = lightValue; - } - - @Override - public String getName() { - return name().toLowerCase(Locale.ROOT); - } - - public static EnumDecoratedBlock fromMeta(int meta) { - if (meta < 0 || meta >= VALUES.length) { - return EnumDecoratedBlock.DESTROY; - } - return VALUES[meta]; - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumEngineType.java b/src/api/java/buildcraft/api/enums/EnumEngineType.java deleted file mode 100755 index 38cdc62f7..000000000 --- a/src/api/java/buildcraft/api/enums/EnumEngineType.java +++ /dev/null @@ -1,39 +0,0 @@ -package buildcraft.api.enums; - -import net.minecraft.util.IStringSerializable; - -import buildcraft.api.core.IEngineType; - -public enum EnumEngineType implements IStringSerializable, IEngineType { - WOOD("core", "wood"), - STONE("energy", "stone"), - IRON("energy", "iron"), - CREATIVE("energy", "creative"); - - public final String unlocalizedTag; - public final String resourceLocation; - - public static final EnumEngineType[] VALUES = values(); - - EnumEngineType(String mod, String loc) { - unlocalizedTag = loc; - resourceLocation = "buildcraft" + mod + ":blocks/engine/inv/" + loc; - } - - @Override - public String getItemModelLocation() { - return resourceLocation; - } - - @Override - public String getName() { - return unlocalizedTag; - } - - public static EnumEngineType fromMeta(int meta) { - if (meta < 0 || meta >= VALUES.length) { - meta = 0; - } - return VALUES[meta]; - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumFillerPattern.java b/src/api/java/buildcraft/api/enums/EnumFillerPattern.java deleted file mode 100755 index 4570f0c79..000000000 --- a/src/api/java/buildcraft/api/enums/EnumFillerPattern.java +++ /dev/null @@ -1,28 +0,0 @@ -package buildcraft.api.enums; - -import java.util.Locale; - -import net.minecraft.util.IStringSerializable; - -public enum EnumFillerPattern implements IStringSerializable { - NONE, - BOX, - CLEAR, - CYLINDER, - FILL, - FLATTEN, - FRAME, - HORIZON, - PYRAMID, - STAIRS; - - @Override - public String toString() { - return getName(); - } - - @Override - public String getName() { - return name().toLowerCase(Locale.ROOT); - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumLaserTableType.java b/src/api/java/buildcraft/api/enums/EnumLaserTableType.java deleted file mode 100755 index dbf99a5c7..000000000 --- a/src/api/java/buildcraft/api/enums/EnumLaserTableType.java +++ /dev/null @@ -1,16 +0,0 @@ -package buildcraft.api.enums; - -import net.minecraft.util.IStringSerializable; - -public enum EnumLaserTableType implements IStringSerializable { - ASSEMBLY_TABLE, - ADVANCED_CRAFTING_TABLE, - INTEGRATION_TABLE, - CHARGING_TABLE, - PROGRAMMING_TABLE; - - @Override - public String getName() { - return name(); - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumMachineState.java b/src/api/java/buildcraft/api/enums/EnumMachineState.java deleted file mode 100755 index 7b7caf740..000000000 --- a/src/api/java/buildcraft/api/enums/EnumMachineState.java +++ /dev/null @@ -1,21 +0,0 @@ -package buildcraft.api.enums; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.IStringSerializable; - -import buildcraft.api.properties.BuildCraftProperties; - -public enum EnumMachineState implements IStringSerializable { - OFF, - ON, - DONE; - - public static EnumMachineState getType(IBlockState state) { - return state.getValue(BuildCraftProperties.MACHINE_STATE); - } - - @Override - public String getName() { - return name(); - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java b/src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java deleted file mode 100644 index 283ca0b02..000000000 --- a/src/api/java/buildcraft/api/enums/EnumOptionalSnapshotType.java +++ /dev/null @@ -1,36 +0,0 @@ -package buildcraft.api.enums; - -import java.util.Locale; - -import net.minecraft.util.IStringSerializable; - -public enum EnumOptionalSnapshotType implements IStringSerializable { - NONE(null), - TEMPLATE(EnumSnapshotType.TEMPLATE), - BLUEPRINT(EnumSnapshotType.BLUEPRINT); - - public final EnumSnapshotType type; - - EnumOptionalSnapshotType(EnumSnapshotType type) { - this.type = type; - } - - public static EnumOptionalSnapshotType fromNullable(EnumSnapshotType type) { - if (type == null) { - return NONE; - } - switch (type) { - case TEMPLATE: - return TEMPLATE; - case BLUEPRINT: - return BLUEPRINT; - default: - return NONE; - } - } - - @Override - public String getName() { - return name().toLowerCase(Locale.ROOT); - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumPowerStage.java b/src/api/java/buildcraft/api/enums/EnumPowerStage.java deleted file mode 100755 index 0a88baecd..000000000 --- a/src/api/java/buildcraft/api/enums/EnumPowerStage.java +++ /dev/null @@ -1,27 +0,0 @@ -package buildcraft.api.enums; - -import java.util.Locale; - -import net.minecraft.util.IStringSerializable; - -public enum EnumPowerStage implements IStringSerializable { - BLUE, - GREEN, - YELLOW, - RED, - OVERHEAT, - BLACK; - - public static final EnumPowerStage[] VALUES = values(); - - private final String modelName = name().toLowerCase(Locale.ROOT); - - public String getModelName() { - return modelName; - } - - @Override - public String getName() { - return getModelName(); - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java b/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java deleted file mode 100755 index 95c648fe1..000000000 --- a/src/api/java/buildcraft/api/enums/EnumRedstoneChipset.java +++ /dev/null @@ -1,51 +0,0 @@ -package buildcraft.api.enums; - -import java.util.Locale; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IStringSerializable; - -import buildcraft.api.BCItems; - -public enum EnumRedstoneChipset implements IStringSerializable { - RED, - IRON, - GOLD, - QUARTZ, - DIAMOND; - - private final String name = name().toLowerCase(Locale.ROOT); - - public ItemStack getStack(int stackSize) { - Item chipset = BCItems.SILICON_REDSTONE_CHIPSET; - if (chipset == null) { - return ItemStack.EMPTY; - } - - return new ItemStack(chipset, stackSize, ordinal()); - } - - public ItemStack getStack() { - return getStack(1); - } - - public static EnumRedstoneChipset fromStack(ItemStack stack) { - if (stack == null) { - return RED; - } - return fromOrdinal(stack.getMetadata()); - } - - public static EnumRedstoneChipset fromOrdinal(int ordinal) { - if (ordinal < 0 || ordinal >= values().length) { - return RED; - } - return values()[ordinal]; - } - - @Override - public String getName() { - return name; - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumSnapshotType.java b/src/api/java/buildcraft/api/enums/EnumSnapshotType.java deleted file mode 100644 index b3c21245c..000000000 --- a/src/api/java/buildcraft/api/enums/EnumSnapshotType.java +++ /dev/null @@ -1,12 +0,0 @@ -package buildcraft.api.enums; - -public enum EnumSnapshotType { - TEMPLATE(9), - BLUEPRINT(3); - - public final int maxPerTick; - - EnumSnapshotType(int maxPerTick) { - this.maxPerTick = maxPerTick; - } -} diff --git a/src/api/java/buildcraft/api/enums/EnumSpring.java b/src/api/java/buildcraft/api/enums/EnumSpring.java deleted file mode 100755 index 21e4cf21c..000000000 --- a/src/api/java/buildcraft/api/enums/EnumSpring.java +++ /dev/null @@ -1,40 +0,0 @@ -package buildcraft.api.enums; - -import java.util.Locale; -import java.util.function.Supplier; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.init.Blocks; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IStringSerializable; - -import buildcraft.api.properties.BuildCraftProperties; - -public enum EnumSpring implements IStringSerializable { - WATER(5, -1, Blocks.WATER.getDefaultState()), - OIL(6000, 8, null); // Set in BuildCraftEnergy - - public static final EnumSpring[] VALUES = values(); - - public final int tickRate, chance; - public IBlockState liquidBlock; - public boolean canGen = true; - public Supplier tileConstructor; - - private final String lowerCaseName = name().toLowerCase(Locale.ROOT); - - EnumSpring(int tickRate, int chance, IBlockState liquidBlock) { - this.tickRate = tickRate; - this.chance = chance; - this.liquidBlock = liquidBlock; - } - - public static EnumSpring fromState(IBlockState state) { - return state.getValue(BuildCraftProperties.SPRING_TYPE); - } - - @Override - public String getName() { - return lowerCaseName; - } -} diff --git a/src/api/java/buildcraft/api/enums/package-info.java b/src/api/java/buildcraft/api/enums/package-info.java deleted file mode 100755 index 8c585be95..000000000 --- a/src/api/java/buildcraft/api/enums/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|enums") -package buildcraft.api.enums; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/events/BlockInteractionEvent.java b/src/api/java/buildcraft/api/events/BlockInteractionEvent.java deleted file mode 100755 index 4a4d8b7bd..000000000 --- a/src/api/java/buildcraft/api/events/BlockInteractionEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.events; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class BlockInteractionEvent extends Event { - public final EntityPlayer player; - public final IBlockState state; - - public BlockInteractionEvent(EntityPlayer player, IBlockState state) { - this.player = player; - this.state = state; - } -} diff --git a/src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java b/src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java deleted file mode 100755 index 22a8a74fa..000000000 --- a/src/api/java/buildcraft/api/events/BlockPlacedDownEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.events; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.math.BlockPos; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class BlockPlacedDownEvent extends Event { - public final EntityPlayer player; - public final IBlockState state; - public final BlockPos pos; - - public BlockPlacedDownEvent(EntityPlayer player, BlockPos pos, IBlockState state) { - this.player = player; - this.state = state; - this.pos = pos; - } -} diff --git a/src/api/java/buildcraft/api/events/PipePlacedEvent.java b/src/api/java/buildcraft/api/events/PipePlacedEvent.java deleted file mode 100755 index 3664a57d2..000000000 --- a/src/api/java/buildcraft/api/events/PipePlacedEvent.java +++ /dev/null @@ -1,24 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.events; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.util.math.BlockPos; - -import net.minecraftforge.fml.common.eventhandler.Event; - -public class PipePlacedEvent extends Event { - public EntityPlayer player; - public Item pipeType; - public BlockPos pos; - - public PipePlacedEvent(EntityPlayer player, Item pipeType, BlockPos pos) { - this.player = player; - this.pipeType = pipeType; - this.pos = pos; - } - -} diff --git a/src/api/java/buildcraft/api/events/RobotEvent.java b/src/api/java/buildcraft/api/events/RobotEvent.java deleted file mode 100755 index 9b12b64d2..000000000 --- a/src/api/java/buildcraft/api/events/RobotEvent.java +++ /dev/null @@ -1,53 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.events; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -import buildcraft.api.robots.EntityRobotBase; - -public abstract class RobotEvent extends Event { - public final EntityRobotBase robot; - - public RobotEvent(EntityRobotBase robot) { - this.robot = robot; - } - - @Cancelable - public static class Place extends RobotEvent { - public final EntityPlayer player; - - public Place(EntityRobotBase robot, EntityPlayer player) { - super(robot); - this.player = player; - } - } - - @Cancelable - public static class Interact extends RobotEvent { - public final EntityPlayer player; - public final ItemStack item; - - public Interact(EntityRobotBase robot, EntityPlayer player, ItemStack item) { - super(robot); - this.player = player; - this.item = item; - } - } - - @Cancelable - public static class Dismantle extends RobotEvent { - public final EntityPlayer player; - - public Dismantle(EntityRobotBase robot, EntityPlayer player) { - super(robot); - this.player = player; - } - } -} diff --git a/src/api/java/buildcraft/api/events/RobotPlacementEvent.java b/src/api/java/buildcraft/api/events/RobotPlacementEvent.java deleted file mode 100755 index b0abc44d8..000000000 --- a/src/api/java/buildcraft/api/events/RobotPlacementEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.events; - -import net.minecraft.entity.player.EntityPlayer; - -import net.minecraftforge.fml.common.eventhandler.Cancelable; -import net.minecraftforge.fml.common.eventhandler.Event; - -@Cancelable -public class RobotPlacementEvent extends Event { - public EntityPlayer player; - public String robotProgram; - - public RobotPlacementEvent(EntityPlayer player, String robotProgram) { - this.player = player; - this.robotProgram = robotProgram; - } - -} diff --git a/src/api/java/buildcraft/api/events/package-info.java b/src/api/java/buildcraft/api/events/package-info.java deleted file mode 100755 index 06cd25fea..000000000 --- a/src/api/java/buildcraft/api/events/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|events") -package buildcraft.api.events; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/facades/FacadeAPI.java b/src/api/java/buildcraft/api/facades/FacadeAPI.java deleted file mode 100755 index ce4cb8f06..000000000 --- a/src/api/java/buildcraft/api/facades/FacadeAPI.java +++ /dev/null @@ -1,35 +0,0 @@ -package buildcraft.api.facades; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.fml.common.event.FMLInterModComms; - -public final class FacadeAPI { - public static final String IMC_MOD_TARGET = "buildcrafttransport"; - public static final String IMC_FACADE_DISABLE = "facade_disable_block"; - public static final String IMC_FACADE_CUSTOM = "facade_custom_map_block_item"; - public static final String NBT_CUSTOM_BLOCK_REG_KEY = "block_registry_name"; - public static final String NBT_CUSTOM_BLOCK_META = "block_meta"; - public static final String NBT_CUSTOM_ITEM_STACK = "item_stack"; - - public static IFacadeItem facadeItem; - - private FacadeAPI() { - - } - - public static void disableBlock(Block block) { - FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_DISABLE, block.getRegistryName()); - } - - public static void mapStateToStack(IBlockState state, ItemStack stack) { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setString(NBT_CUSTOM_BLOCK_REG_KEY, state.getBlock().getRegistryName().toString()); - nbt.setInteger(NBT_CUSTOM_BLOCK_META, state.getBlock().getMetaFromState(state)); - nbt.setTag(NBT_CUSTOM_ITEM_STACK, stack.serializeNBT()); - FMLInterModComms.sendMessage(IMC_MOD_TARGET, IMC_FACADE_CUSTOM, nbt); - } -} diff --git a/src/api/java/buildcraft/api/facades/FacadeType.java b/src/api/java/buildcraft/api/facades/FacadeType.java deleted file mode 100755 index c88d89ff4..000000000 --- a/src/api/java/buildcraft/api/facades/FacadeType.java +++ /dev/null @@ -1,14 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.facades; - -public enum FacadeType { - Basic, - Phased; - - public static FacadeType fromOrdinal(int ordinal) { - return ordinal == 1 ? Phased : Basic; - } -} diff --git a/src/api/java/buildcraft/api/facades/IFacadeItem.java b/src/api/java/buildcraft/api/facades/IFacadeItem.java deleted file mode 100755 index 7f4362b49..000000000 --- a/src/api/java/buildcraft/api/facades/IFacadeItem.java +++ /dev/null @@ -1,19 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.facades; - -import javax.annotation.Nonnull; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.item.ItemStack; - -public interface IFacadeItem { - FacadeType getFacadeType(@Nonnull ItemStack facade); - - @Nonnull - ItemStack getFacadeForBlock(IBlockState state); - - IBlockState[] getBlockStatesForFacade(@Nonnull ItemStack facade); -} diff --git a/src/api/java/buildcraft/api/facades/package-info.java b/src/api/java/buildcraft/api/facades/package-info.java deleted file mode 100755 index 2c79167b3..000000000 --- a/src/api/java/buildcraft/api/facades/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|facades") -package buildcraft.api.facades; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/filler/FillerManager.java b/src/api/java/buildcraft/api/filler/FillerManager.java deleted file mode 100755 index 03567c45a..000000000 --- a/src/api/java/buildcraft/api/filler/FillerManager.java +++ /dev/null @@ -1,13 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.filler; - -public final class FillerManager { - - public static IFillerRegistry registry; - - /** Deactivate constructor */ - private FillerManager() {} -} diff --git a/src/api/java/buildcraft/api/filler/IFillerPattern.java b/src/api/java/buildcraft/api/filler/IFillerPattern.java deleted file mode 100755 index db52b51f0..000000000 --- a/src/api/java/buildcraft/api/filler/IFillerPattern.java +++ /dev/null @@ -1,12 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.filler; - -import buildcraft.api.statements.IStatement; - -/** A type of statement that is used for filler patterns. */ -public interface IFillerPattern extends IStatement { - // Object getBlockOverlay(); -} diff --git a/src/api/java/buildcraft/api/filler/IFillerRegistry.java b/src/api/java/buildcraft/api/filler/IFillerRegistry.java deleted file mode 100755 index f9e588f62..000000000 --- a/src/api/java/buildcraft/api/filler/IFillerRegistry.java +++ /dev/null @@ -1,19 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.filler; - -import java.util.Collection; - -public interface IFillerRegistry { - void addPattern(IFillerPattern pattern); - - IFillerPattern getPattern(String patternName); - - IFillerPattern getNextPattern(IFillerPattern currentPattern); - - IFillerPattern getPreviousPattern(IFillerPattern currentPattern); - - Collection getPatterns(); -} diff --git a/src/api/java/buildcraft/api/filler/package-info.java b/src/api/java/buildcraft/api/filler/package-info.java deleted file mode 100755 index 3e9d907de..000000000 --- a/src/api/java/buildcraft/api/filler/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "4.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|filler") -package buildcraft.api.filler; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.java b/src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.java deleted file mode 100755 index 545ac3d3b..000000000 --- a/src/api/java/buildcraft/api/fuels/BuildcraftFuelRegistry.java +++ /dev/null @@ -1,12 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.fuels; - -public final class BuildcraftFuelRegistry { - public static IFuelManager fuel; - public static ICoolantManager coolant; - - private BuildcraftFuelRegistry() {} -} diff --git a/src/api/java/buildcraft/api/fuels/ICoolant.java b/src/api/java/buildcraft/api/fuels/ICoolant.java deleted file mode 100755 index f81a863e0..000000000 --- a/src/api/java/buildcraft/api/fuels/ICoolant.java +++ /dev/null @@ -1,16 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.fuels; - -import net.minecraftforge.fluids.FluidStack; - -public interface ICoolant { - boolean matchesFluid(FluidStack fluid); - - /** @param fluid - * @param heat - * @return 0 if the input fluid provides no cooling, or a value greater than 0 if it does. */ - float getDegreesCoolingPerMB(FluidStack fluid, float heat); -} diff --git a/src/api/java/buildcraft/api/fuels/ICoolantManager.java b/src/api/java/buildcraft/api/fuels/ICoolantManager.java deleted file mode 100755 index dfcf78b6d..000000000 --- a/src/api/java/buildcraft/api/fuels/ICoolantManager.java +++ /dev/null @@ -1,36 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.fuels; - -import java.util.Collection; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -public interface ICoolantManager { - ICoolant addCoolant(ICoolant coolant); - - ICoolant addCoolant(FluidStack fluid, float degreesCoolingPerMb); - - default ICoolant addCoolant(Fluid fluid, float degreesCoolingPerMb) { - return addCoolant(new FluidStack(fluid, 1), degreesCoolingPerMb); - } - - ISolidCoolant addSolidCoolant(ISolidCoolant solidCoolant); - - ISolidCoolant addSolidCoolant(ItemStack solid, FluidStack fluid, float multiplier); - - Collection getCoolants(); - - Collection getSolidCoolants(); - - ICoolant getCoolant(FluidStack fluid); - - float getDegreesPerMb(FluidStack fluid, float heat); - - ISolidCoolant getSolidCoolant(ItemStack solid); -} diff --git a/src/api/java/buildcraft/api/fuels/IFuel.java b/src/api/java/buildcraft/api/fuels/IFuel.java deleted file mode 100755 index 382eb2a28..000000000 --- a/src/api/java/buildcraft/api/fuels/IFuel.java +++ /dev/null @@ -1,18 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.fuels; - -import net.minecraftforge.fluids.FluidStack; - -public interface IFuel { - /** @return The input fluid. The {@link FluidStack#amount} is ignored. */ - FluidStack getFluid(); - - /** @return The number of ticks that a single bucket (1000mb) of this fuel will burn for. */ - int getTotalBurningTime(); - - /** @return The amount (in micro mj) of power that this fuel will give off in 1 tick. */ - long getPowerPerCycle(); -} diff --git a/src/api/java/buildcraft/api/fuels/IFuelManager.java b/src/api/java/buildcraft/api/fuels/IFuelManager.java deleted file mode 100755 index cb02063e0..000000000 --- a/src/api/java/buildcraft/api/fuels/IFuelManager.java +++ /dev/null @@ -1,37 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.fuels; - -import java.util.Collection; - -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -public interface IFuelManager { - F addFuel(F fuel); - - IFuel addFuel(FluidStack fluid, long powerPerCycle, int totalBurningTime); - - default IFuel addFuel(Fluid fluid, long powerPerCycle, int totalBurningTime) { - return addFuel(new FluidStack(fluid, 1), powerPerCycle, totalBurningTime); - } - - /** @param residue The residue fluidstack, per bucket of the original fuel. */ - IDirtyFuel addDirtyFuel(FluidStack fuel, long powerPerCycle, int totalBurningTime, FluidStack residue); - - /** @param residue The residue fluidstack, per bucket of the original fuel. */ - default IDirtyFuel addDirtyFuel(Fluid fuel, long powerPerCycle, int totalBurningTime, FluidStack residue) { - return addDirtyFuel(new FluidStack(fuel, 1), powerPerCycle, totalBurningTime, residue); - } - - Collection getFuels(); - - IFuel getFuel(FluidStack fluid); - - interface IDirtyFuel extends IFuel { - /** @return The residue fluidstack, per bucket of original fuel. */ - FluidStack getResidue(); - } -} diff --git a/src/api/java/buildcraft/api/fuels/ISolidCoolant.java b/src/api/java/buildcraft/api/fuels/ISolidCoolant.java deleted file mode 100755 index 2b466efeb..000000000 --- a/src/api/java/buildcraft/api/fuels/ISolidCoolant.java +++ /dev/null @@ -1,13 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.fuels; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fluids.FluidStack; - -public interface ISolidCoolant { - FluidStack getFluidFromSolidCoolant(ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/fuels/package-info.java b/src/api/java/buildcraft/api/fuels/package-info.java deleted file mode 100755 index 93d524dbf..000000000 --- a/src/api/java/buildcraft/api/fuels/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|fuels") -package buildcraft.api.fuels; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/gates/IGate.java b/src/api/java/buildcraft/api/gates/IGate.java deleted file mode 100755 index 2d9302c3c..000000000 --- a/src/api/java/buildcraft/api/gates/IGate.java +++ /dev/null @@ -1,28 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.gates; - -import java.util.List; - -import buildcraft.api.statements.IStatement; -import buildcraft.api.statements.IStatementParameter; -import buildcraft.api.statements.StatementSlot; -import buildcraft.api.statements.containers.ISidedStatementContainer; -import buildcraft.api.transport.pipe.IPipeHolder; - -public interface IGate extends ISidedStatementContainer { - - IPipeHolder getPipeHolder(); - - List getTriggers(); - - List getActions(); - - List getActiveActions(); - - List getTriggerParameters(int slot); - - List getActionParameters(int slot); -} diff --git a/src/api/java/buildcraft/api/gates/package-info.java b/src/api/java/buildcraft/api/gates/package-info.java deleted file mode 100755 index b86ad48bd..000000000 --- a/src/api/java/buildcraft/api/gates/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "4.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") -package buildcraft.api.gates; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/inventory/IItemTransactor.java b/src/api/java/buildcraft/api/inventory/IItemTransactor.java deleted file mode 100644 index 212d2e35f..000000000 --- a/src/api/java/buildcraft/api/inventory/IItemTransactor.java +++ /dev/null @@ -1,72 +0,0 @@ -package buildcraft.api.inventory; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -import buildcraft.api.core.IStackFilter; - -/** A simple way to define something that deals with item insertion and extraction, without caring about slots. */ -public interface IItemTransactor { - /** @param stack The stack to insert. Must not be null! - * @param allOrNone If true then either the entire stack will be used or none of it. - * @param simulate If true then the in-world state of this will not be changed. - * @return The overflow stack. Will be {@link ItemStack#EMPTY} if all of it was accepted. */ - @Nonnull - ItemStack insert(@Nonnull ItemStack stack, boolean allOrNone, boolean simulate); - - /** Similar to {@link #insert(ItemStack, boolean, boolean)} but probably be more efficient at inserting lots of - * items. - * - * @param stacks The stacks to insert. Must not be null! - * @param simulate If true then the in-world state of this will not be changed. - * @return The overflow stacks. Will be an empty list if all of it was accepted. */ - default NonNullList insert(NonNullList stacks, boolean simulate) { - NonNullList leftOver = NonNullList.create(); - for (ItemStack stack : stacks) { - ItemStack leftOverStack = insert(stack, false, simulate); - if (!leftOverStack.isEmpty()) { - leftOver.add(leftOverStack); - } - } - return leftOver; - } - - /** Extracts a number of items that match the given filter - * - * @param filter The filter that MUST be met by the extracted stack. Null means no filter - it can be any item. - * @param min The minimum number of items to extract, or 0 if not enough items can be extracted - * @param max The maximum number of items to extract. - * @param simulate If true then the in-world state of this will not be changed. - * @return The stack that was extracted, or {@link ItemStack#EMPTY} if it could not be. */ - @Nonnull - ItemStack extract(@Nullable IStackFilter filter, int min, int max, boolean simulate); - - default boolean canFullyAccept(@Nonnull ItemStack stack) { - return insert(stack, true, true).isEmpty(); - } - - default boolean canPartiallyAccept(@Nonnull ItemStack stack) { - return insert(stack, false, true).getCount() < stack.getCount(); - } - - @FunctionalInterface - interface IItemInsertable extends IItemTransactor { - @Nonnull - @Override - default ItemStack extract(IStackFilter filter, int min, int max, boolean simulate) { - return ItemStack.EMPTY; - } - } - - @FunctionalInterface - interface IItemExtractable extends IItemTransactor { - @Nonnull - @Override - default ItemStack insert(@Nonnull ItemStack stack, boolean allOrNone, boolean simulate) { - return stack; - } - } -} diff --git a/src/api/java/buildcraft/api/items/IItemCustomPipeRender.java b/src/api/java/buildcraft/api/items/IItemCustomPipeRender.java deleted file mode 100755 index 697b87597..000000000 --- a/src/api/java/buildcraft/api/items/IItemCustomPipeRender.java +++ /dev/null @@ -1,14 +0,0 @@ -package buildcraft.api.items; - -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IItemCustomPipeRender { - float getPipeRenderScale(ItemStack stack); - - /** @return False to use the default renderer, true otherwise. */ - @SideOnly(Side.CLIENT) - boolean renderItemInPipe(ItemStack stack, double x, double y, double z); -} diff --git a/src/api/java/buildcraft/api/items/IList.java b/src/api/java/buildcraft/api/items/IList.java deleted file mode 100755 index 1456d2468..000000000 --- a/src/api/java/buildcraft/api/items/IList.java +++ /dev/null @@ -1,9 +0,0 @@ -package buildcraft.api.items; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; - -public interface IList extends INamedItem { - boolean matches(@Nonnull ItemStack stackList, @Nonnull ItemStack item); -} diff --git a/src/api/java/buildcraft/api/items/IMapLocation.java b/src/api/java/buildcraft/api/items/IMapLocation.java deleted file mode 100755 index cb5dba538..000000000 --- a/src/api/java/buildcraft/api/items/IMapLocation.java +++ /dev/null @@ -1,69 +0,0 @@ -package buildcraft.api.items; - -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; - -import buildcraft.api.core.IBox; -import buildcraft.api.core.IZone; - -/** Created by asie on 2/28/15. */ -public interface IMapLocation extends INamedItem { - enum MapLocationType { - CLEAN, - SPOT, - AREA, - PATH, - ZONE, - /** Like PATH but repeats around in a loop. */ - PATH_REPEATING; - - public final int meta = ordinal(); - - public static MapLocationType getFromStack(@Nonnull ItemStack stack) { - int dam = stack.getItemDamage(); - if (dam < 0 || dam >= values().length) { - return MapLocationType.CLEAN; - } - return values()[dam]; - } - - public void setToStack(@Nonnull ItemStack stack) { - stack.setItemDamage(meta); - } - } - - /** This function can be used for SPOT types. - * - * @param stack - * @return The point representing the map location. */ - BlockPos getPoint(@Nonnull ItemStack stack); - - /** This function can be used for SPOT and AREA types. - * - * @param stack - * @return The box representing the map location. */ - IBox getBox(@Nonnull ItemStack stack); - - /** This function can be used for SPOT, AREA and ZONE types. The PATH type needs to be handled separately. - * - * @param stack - * @return An IZone representing the map location - also an instance of IBox for SPOT and AREA types. */ - IZone getZone(@Nonnull ItemStack stack); - - /** This function can be used for SPOT and PATH types. - * - * @param stack - * @return A list of BlockPoses representing the path the Map Location stores. */ - List getPath(@Nonnull ItemStack stack); - - /** This function can be used for SPOT types only. - * - * @param stack - * @return The side of the spot. */ - EnumFacing getPointSide(@Nonnull ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/items/INamedItem.java b/src/api/java/buildcraft/api/items/INamedItem.java deleted file mode 100755 index 87c342075..000000000 --- a/src/api/java/buildcraft/api/items/INamedItem.java +++ /dev/null @@ -1,11 +0,0 @@ -package buildcraft.api.items; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; - -public interface INamedItem { - String getName(@Nonnull ItemStack stack); - - boolean setName(@Nonnull ItemStack stack, String name); -} diff --git a/src/api/java/buildcraft/api/items/package-info.java b/src/api/java/buildcraft/api/items/package-info.java deleted file mode 100755 index f6d2835d6..000000000 --- a/src/api/java/buildcraft/api/items/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|items") -package buildcraft.api.items; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/library/ILibraryTypeHandler.java b/src/api/java/buildcraft/api/library/ILibraryTypeHandler.java deleted file mode 100755 index 8616d10fe..000000000 --- a/src/api/java/buildcraft/api/library/ILibraryTypeHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public interface ILibraryTypeHandler { - boolean isHandler(ItemStack stack, boolean store); - - String getFileExtension(); - - int getTextColor(); - - String getName(ItemStack stack); - - ItemStack load(ItemStack stack, NBTTagCompound compound); - - boolean store(ItemStack stack, NBTTagCompound compound); -} diff --git a/src/api/java/buildcraft/api/library/LibraryAPI.java b/src/api/java/buildcraft/api/library/LibraryAPI.java deleted file mode 100755 index b8997930a..000000000 --- a/src/api/java/buildcraft/api/library/LibraryAPI.java +++ /dev/null @@ -1,30 +0,0 @@ -package buildcraft.api.library; - -import java.util.HashSet; -import java.util.Set; - -@Deprecated -public final class LibraryAPI { - private static final Set handlers = new HashSet<>(); - - private LibraryAPI() { - - } - - public static Set getHandlerSet() { - return handlers; - } - - public static void registerHandler(LibraryTypeHandler handler) { - handlers.add(handler); - } - - public static LibraryTypeHandler getHandlerFor(String extension) { - for (LibraryTypeHandler h : handlers) { - if (h.isInputExtension(extension)) { - return h; - } - } - return null; - } -} diff --git a/src/api/java/buildcraft/api/library/LibraryTypeHandler.java b/src/api/java/buildcraft/api/library/LibraryTypeHandler.java deleted file mode 100755 index 08db4f6f3..000000000 --- a/src/api/java/buildcraft/api/library/LibraryTypeHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; - -@Deprecated -public abstract class LibraryTypeHandler { - public enum HandlerType { - LOAD, - STORE - } - - private final String extension; - - public LibraryTypeHandler(String extension) { - this.extension = extension; - } - - public abstract boolean isHandler(ItemStack stack, HandlerType type); - - public boolean isInputExtension(String ext) { - return extension.equals(ext); - } - - public String getOutputExtension() { - return extension; - } - - public abstract int getTextColor(); - - public abstract String getName(ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java b/src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java deleted file mode 100755 index c7c5e2317..000000000 --- a/src/api/java/buildcraft/api/library/LibraryTypeHandlerByteArray.java +++ /dev/null @@ -1,13 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; - -public abstract class LibraryTypeHandlerByteArray extends LibraryTypeHandler { - public LibraryTypeHandlerByteArray(String extension) { - super(extension); - } - - public abstract ItemStack load(ItemStack stack, byte[] data); - - public abstract byte[] store(ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java b/src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java deleted file mode 100755 index a656ff7c7..000000000 --- a/src/api/java/buildcraft/api/library/LibraryTypeHandlerNBT.java +++ /dev/null @@ -1,14 +0,0 @@ -package buildcraft.api.library; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public abstract class LibraryTypeHandlerNBT extends LibraryTypeHandler { - public LibraryTypeHandlerNBT(String extension) { - super(extension); - } - - public abstract ItemStack load(ItemStack stack, NBTTagCompound nbt); - - public abstract boolean store(ItemStack stack, NBTTagCompound nbt); -} diff --git a/src/api/java/buildcraft/api/library/package-info.java b/src/api/java/buildcraft/api/library/package-info.java deleted file mode 100755 index e41a0dc0f..000000000 --- a/src/api/java/buildcraft/api/library/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "2.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|library") -package buildcraft.api.library; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/lists/ListMatchHandler.java b/src/api/java/buildcraft/api/lists/ListMatchHandler.java deleted file mode 100755 index 339176ed9..000000000 --- a/src/api/java/buildcraft/api/lists/ListMatchHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package buildcraft.api.lists; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; - -public abstract class ListMatchHandler { - public enum Type { - TYPE, - MATERIAL, - CLASS - } - - public abstract boolean matches(Type type, @Nonnull ItemStack stack, @Nonnull ItemStack target, boolean precise); - - public abstract boolean isValidSource(Type type, @Nonnull ItemStack stack); - - /** Get custom client examples. - * - * @param type - * @param stack - * @return A List (even empty!) if the examples satisfy this handler, null if iteration and .matches should be used - * instead. */ - public NonNullList getClientExamples(Type type, @Nonnull ItemStack stack) { - return null; - } -} diff --git a/src/api/java/buildcraft/api/lists/ListRegistry.java b/src/api/java/buildcraft/api/lists/ListRegistry.java deleted file mode 100755 index 38a916694..000000000 --- a/src/api/java/buildcraft/api/lists/ListRegistry.java +++ /dev/null @@ -1,26 +0,0 @@ -package buildcraft.api.lists; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import net.minecraft.item.Item; - -public final class ListRegistry { - public static final List> itemClassAsType = new ArrayList<>(); - private static final List handlers = new ArrayList<>(); - - private ListRegistry() { - - } - - public static void registerHandler(ListMatchHandler h) { - if (h != null) { - handlers.add(h); - } - } - - public static List getHandlers() { - return Collections.unmodifiableList(handlers); - } -} diff --git a/src/api/java/buildcraft/api/lists/package-info.java b/src/api/java/buildcraft/api/lists/package-info.java deleted file mode 100755 index 603c33587..000000000 --- a/src/api/java/buildcraft/api/lists/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|lists") -package buildcraft.api.lists; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/mj/ILaserTarget.java b/src/api/java/buildcraft/api/mj/ILaserTarget.java deleted file mode 100755 index e1fbfb48f..000000000 --- a/src/api/java/buildcraft/api/mj/ILaserTarget.java +++ /dev/null @@ -1,27 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.mj; - -/** This interface should be defined by any Tile which wants to receive power from BuildCraft lasers. - * - * The respective Block MUST implement ILaserTargetBlock! */ -public interface ILaserTarget { - - /** Returns The amount of power this target currently needs. - * - * @return The amount of power required, or 0 if no power is required. */ - long getRequiredLaserPower(); - - /** Transfers power from the laser to the target. - * - * @param microJoules The number of micro Minecraft Joules to accept - * @return The excess power. If the input is less than or equal to {@link #getRequiredLaserPower()} then this will return 0. */ - long receiveLaserPower(long microJoules); - - /** Return true if the Tile Entity object is no longer a valid target. For example, if its been invalidated. - * - * @return true if no longer a valid target object */ - boolean isInvalidTarget(); -} diff --git a/src/api/java/buildcraft/api/mj/ILaserTargetBlock.java b/src/api/java/buildcraft/api/mj/ILaserTargetBlock.java deleted file mode 100755 index 3e511f7d5..000000000 --- a/src/api/java/buildcraft/api/mj/ILaserTargetBlock.java +++ /dev/null @@ -1,12 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.mj; - -/** This is a marker interface for laser targets. Implement it on your Block. - * - * It is used by BuildCraft Lasers for optimization purposes. */ -public interface ILaserTargetBlock { - -} diff --git a/src/api/java/buildcraft/api/mj/IMjConnector.java b/src/api/java/buildcraft/api/mj/IMjConnector.java deleted file mode 100755 index 3c5f997a3..000000000 --- a/src/api/java/buildcraft/api/mj/IMjConnector.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.api.mj; - -import javax.annotation.Nonnull; - -/** Signifies that this should visibly connect to other Mj handling entities/tiles. This should NEVER be the tile - * entity, but an encapsulated class that refers back to it. Use {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR} to access - * this. */ -public interface IMjConnector { - /** Checks to see if this connector can connect to the other connector. By default this should check that the other - * connector is the same power system. - * - * @param other - * @return */ - boolean canConnect(@Nonnull IMjConnector other); -} diff --git a/src/api/java/buildcraft/api/mj/IMjEffectManager.java b/src/api/java/buildcraft/api/mj/IMjEffectManager.java deleted file mode 100755 index c7fb899b0..000000000 --- a/src/api/java/buildcraft/api/mj/IMjEffectManager.java +++ /dev/null @@ -1,15 +0,0 @@ -package buildcraft.api.mj; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -/** Various effects for showing power loss visibly, and for large amounts of power, causes some damage to nearby - * entities. */ -public interface IMjEffectManager { - void createPowerLossEffect(World world, Vec3d center, long microJoulesLost); - - void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost); - - void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost); -} diff --git a/src/api/java/buildcraft/api/mj/IMjPassiveProvider.java b/src/api/java/buildcraft/api/mj/IMjPassiveProvider.java deleted file mode 100755 index 55b33c685..000000000 --- a/src/api/java/buildcraft/api/mj/IMjPassiveProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package buildcraft.api.mj; - -/** Designates a machine that provides power passively- it does not attempt to manually output its power (like an - * engine). Power can be extracted from this by powered wooden kinesis pipes, for example. */ -public interface IMjPassiveProvider extends IMjConnector { - /** Attempts to extract power from this provider - * - * @param simulate - * @return Either 0, min, max, or a value between min and max. */ - long extractPower(long min, long max, boolean simulate); -} diff --git a/src/api/java/buildcraft/api/mj/IMjReadable.java b/src/api/java/buildcraft/api/mj/IMjReadable.java deleted file mode 100755 index 616592263..000000000 --- a/src/api/java/buildcraft/api/mj/IMjReadable.java +++ /dev/null @@ -1,8 +0,0 @@ -package buildcraft.api.mj; - -/** Indicates an MJ consumer that has readable information. */ -public interface IMjReadable extends IMjConnector { - long getStored(); - - long getCapacity(); -} diff --git a/src/api/java/buildcraft/api/mj/IMjReceiver.java b/src/api/java/buildcraft/api/mj/IMjReceiver.java deleted file mode 100755 index a8cecd7d4..000000000 --- a/src/api/java/buildcraft/api/mj/IMjReceiver.java +++ /dev/null @@ -1,30 +0,0 @@ -package buildcraft.api.mj; - -/** Designates a machine that can receive power. */ -public interface IMjReceiver extends IMjConnector { - /** @return The number of microjoules that this receiver currently wants, and can accept. */ - long getPowerRequested(); - - /** Receives power. You are encouraged to either: - *

      - *
    • Use up all power immediately, or when you next tick. - *
    • Store all power in something like an {@link MjBattery} for later usage. - *
    • Refuse all power (if you have no more work to do or your {@link MjBattery} is full). - *
    - * - * Note that callers are NOT expected to call {@link #canReceive()} before calling this - implementors should check - * all of the conditions in {@link #canReceive()} before accepting power. - * - * @param microJoules The number of micro joules to add. - * @param simulate If true then just pretend you received power- don't actually change any of your internal state. - * @return The excess power. */ - long receivePower(long microJoules, boolean simulate); - - /** Checks to see if {@link #receivePower(long, boolean)} *might* accept any power right now, ignoring the amount of - * power contained right now (if any). - * - * @return True if this {@link IMjReceiver} can receive power right now. */ - default boolean canReceive() { - return true; - } -} diff --git a/src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java b/src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java deleted file mode 100755 index 11eb5de63..000000000 --- a/src/api/java/buildcraft/api/mj/IMjRedstoneReceiver.java +++ /dev/null @@ -1,4 +0,0 @@ -package buildcraft.api.mj; - -/** Designates that a receiver can receive redstone power (cheap, free, small amounts) */ -public interface IMjRedstoneReceiver extends IMjReceiver {} diff --git a/src/api/java/buildcraft/api/mj/MjAPI.java b/src/api/java/buildcraft/api/mj/MjAPI.java deleted file mode 100755 index 87d74e897..000000000 --- a/src/api/java/buildcraft/api/mj/MjAPI.java +++ /dev/null @@ -1,119 +0,0 @@ -package buildcraft.api.mj; - -import java.text.DecimalFormat; - -import javax.annotation.Nonnull; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityInject; - -import buildcraft.api.core.CapabilitiesHelper; - -public class MjAPI { - - // ################################ - // - // Useful constants (Public API) - // - // ################################ - - /** A single minecraft joule, in micro joules (the power system base unit) */ - public static final long ONE_MINECRAFT_JOULE = 1 * 1000L * 1000L; - /** The same as {@link #ONE_MINECRAFT_JOULE}, but a shorter field name */ - public static final long MJ = ONE_MINECRAFT_JOULE; - - /** The decimal format used to display values of MJ to the player. Note that this */ - public static final DecimalFormat MJ_DISPLAY_FORMAT = new DecimalFormat("#,##0.##"); - - public static IMjEffectManager EFFECT_MANAGER = NullaryEffectManager.INSTANCE; - - // ############### - // - // Helpful methods - // - // ############### - - /** Formats a given MJ value to a player-oriented string. Note that this does not append "MJ" to the value. */ - public static String formatMj(long microMj) { - return formatMjInternal(microMj / (double) MJ); - } - - private static String formatMjInternal(double val) { - return MJ_DISPLAY_FORMAT.format(val); - } - - // ######################################## - // - // Null based classes - // - // ######################################## - - public enum NullaryEffectManager implements IMjEffectManager { - INSTANCE; - @Override public void createPowerLossEffect(World world, Vec3d center, long microJoulesLost) {} - @Override public void createPowerLossEffect(World world, Vec3d center, EnumFacing direction, long microJoulesLost) {} - @Override public void createPowerLossEffect(World world, Vec3d center, Vec3d direction, long microJoulesLost) {} - } - // @formatter:on - - // ############### - // - // Capabilities - // - // ############### - - @Nonnull - public static final Capability CAP_CONNECTOR; - - @Nonnull - public static final Capability CAP_RECEIVER; - - @Nonnull - public static final Capability CAP_REDSTONE_RECEIVER; - - @Nonnull - public static final Capability CAP_READABLE; - - @Nonnull - public static final Capability CAP_PASSIVE_PROVIDER; - - // #################### - // - // Internal API logic - // - // ################### - - // Private fields for the registrations -- this allows us to make the actual fields @Nonnull as we check later - @CapabilityInject(IMjConnector.class) - private static final Capability CAP_CONNECTOR_FIRST = null; - - @CapabilityInject(IMjReceiver.class) - private static final Capability CAP_RECEIVER_FIRST = null; - - @CapabilityInject(IMjRedstoneReceiver.class) - private static final Capability CAP_REDSTONE_RECEIVER_FIRST = null; - - @CapabilityInject(IMjReadable.class) - private static final Capability CAP_READABLE_FIRST = null; - - @CapabilityInject(IMjPassiveProvider.class) - private static final Capability CAP_PASSIVE_PROVIDER_FIRST = null; - - static { - CapabilitiesHelper.registerCapability(IMjConnector.class); - CapabilitiesHelper.registerCapability(IMjReceiver.class); - CapabilitiesHelper.registerCapability(IMjRedstoneReceiver.class); - CapabilitiesHelper.registerCapability(IMjReadable.class); - CapabilitiesHelper.registerCapability(IMjPassiveProvider.class); - - CAP_CONNECTOR = CapabilitiesHelper.ensureRegistration(CAP_CONNECTOR_FIRST, IMjConnector.class); - CAP_RECEIVER = CapabilitiesHelper.ensureRegistration(CAP_RECEIVER_FIRST, IMjReceiver.class); - CAP_REDSTONE_RECEIVER = CapabilitiesHelper.ensureRegistration(CAP_REDSTONE_RECEIVER_FIRST, IMjRedstoneReceiver.class); - CAP_READABLE = CapabilitiesHelper.ensureRegistration(CAP_READABLE_FIRST, IMjReadable.class); - CAP_PASSIVE_PROVIDER = CapabilitiesHelper.ensureRegistration(CAP_PASSIVE_PROVIDER_FIRST, IMjPassiveProvider.class); - } -} diff --git a/src/api/java/buildcraft/api/mj/MjBattery.java b/src/api/java/buildcraft/api/mj/MjBattery.java deleted file mode 100755 index 68c2ea12e..000000000 --- a/src/api/java/buildcraft/api/mj/MjBattery.java +++ /dev/null @@ -1,116 +0,0 @@ -package buildcraft.api.mj; - -import io.netty.buffer.ByteBuf; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -import net.minecraftforge.common.util.INBTSerializable; - -/** Provides a basic implementation of a simple battery. Note that you should call {@link #tick(World, BlockPos)} or - * {@link #tick(World, Vec3d)} every tick to allow for losing excess power. */ -public class MjBattery implements INBTSerializable { - private final long capacity; - private long microJoules = 0; - - public MjBattery(long capacity) { - this.capacity = capacity; - } - - @Override - public NBTTagCompound serializeNBT() { - NBTTagCompound nbt = new NBTTagCompound(); - nbt.setLong("stored", microJoules); - return nbt; - } - - @Override - public void deserializeNBT(NBTTagCompound nbt) { - microJoules = nbt.getLong("stored"); - } - - public void writeToBuffer(ByteBuf buffer) { - buffer.writeLong(microJoules); - } - - public void readFromBuffer(ByteBuf buffer) { - microJoules = buffer.readLong(); - } - - public long addPower(long microJoulesToAdd, boolean simulate) { - if (!simulate) { - this.microJoules += microJoulesToAdd; - } - return 0; - } - - /** Attempts to add power, but only if this is not already full. - * - * @param microJoulesToAdd The power to add. - * @return The excess power. */ - public long addPowerChecking(long microJoulesToAdd, boolean simulate) { - if (isFull()) { - return microJoulesToAdd; - } else { - return addPower(microJoulesToAdd, simulate); - } - } - - public long extractAll() { - return extractPower(0, microJoules); - } - - /** Attempts to extract exactly the given amount of power. - * - * @param power The amount of power to extract. - * @return True if the power was removed, false if not. */ - public boolean extractPower(long power) { - return extractPower(power, power) > 0; - } - - public long extractPower(long min, long max) { - if (microJoules < min) return 0; - long extracting = Math.min(microJoules, max); - microJoules -= extracting; - return extracting; - } - - public boolean isFull() { - return microJoules >= capacity; - } - - public long getStored() { - return microJoules; - } - - public long getCapacity() { - return capacity; - } - - public void tick(World world, BlockPos position) { - tick(world, new Vec3d(position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5)); - } - - public void tick(World world, Vec3d position) { - if (microJoules > capacity * 2) { - losePower(world, position); - } - } - - protected void losePower(World world, Vec3d position) { - long diff = microJoules - capacity * 2; - long lost = ceilDivide(diff, 32); - microJoules -= lost; - MjAPI.EFFECT_MANAGER.createPowerLossEffect(world, position, lost); - } - - private static long ceilDivide(long val, long by) { - return (val / by) + (val % by == 0 ? 0 : 1); - } - - public String getDebugString() { - return MjAPI.formatMj(microJoules) + " / " + MjAPI.formatMj(capacity) + " MJ"; - } -} diff --git a/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java b/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java deleted file mode 100755 index c70c74cb2..000000000 --- a/src/api/java/buildcraft/api/mj/MjCapabilityHelper.java +++ /dev/null @@ -1,61 +0,0 @@ -package buildcraft.api.mj; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; - -/** Provides a quick way to return all types of a single {@link IMjConnector} for all the different capabilities. */ -public class MjCapabilityHelper implements ICapabilityProvider { - - @Nonnull - private final IMjConnector connector; - - @Nullable - private final IMjReceiver receiver; - - @Nullable - private final IMjRedstoneReceiver rsReceiver; - - @Nullable - private final IMjReadable readable; - - @Nullable - private final IMjPassiveProvider provider; - - public MjCapabilityHelper(@Nonnull IMjConnector mj) { - this.connector = mj; - this.receiver = mj instanceof IMjReceiver ? (IMjReceiver) mj : null; - this.rsReceiver = mj instanceof IMjRedstoneReceiver ? (IMjRedstoneReceiver) mj : null; - this.readable = mj instanceof IMjReadable ? (IMjReadable) mj : null; - this.provider = mj instanceof IMjPassiveProvider ? (IMjPassiveProvider) mj : null; - } - - @Override - public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return getCapability(capability, facing) != null; - } - - @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - if (capability == MjAPI.CAP_CONNECTOR) { - return MjAPI.CAP_CONNECTOR.cast(connector); - } - if (capability == MjAPI.CAP_RECEIVER) { - return MjAPI.CAP_RECEIVER.cast(receiver); - } - if (capability == MjAPI.CAP_REDSTONE_RECEIVER) { - return MjAPI.CAP_REDSTONE_RECEIVER.cast(rsReceiver); - } - if (capability == MjAPI.CAP_READABLE) { - return MjAPI.CAP_READABLE.cast(readable); - } - if (capability == MjAPI.CAP_PASSIVE_PROVIDER) { - return MjAPI.CAP_PASSIVE_PROVIDER.cast(provider); - } - return null; - } -} diff --git a/src/api/java/buildcraft/api/mj/package-info.java b/src/api/java/buildcraft/api/mj/package-info.java deleted file mode 100755 index 8afa7544e..000000000 --- a/src/api/java/buildcraft/api/mj/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Contains the Minecraft Joule API (shortened to Mj), reborn. - *

    - * MJ is stored in the long type, as micro Mj - so you need a long storing a value of 1 million to have a single MJ. All - * power should be passed around in code as micro Mj (10 ^ -6 of an Mj), but shown to the player as full MJ - so divided by 1 - * million. - *

    - * A single MJ as a constant is available in {@link buildcraft.api.mj.MjAPI#ONE_MINECRAFT_JOULE}, and a player - * formatter {@link buildcraft.api.mj.MjAPI#formatMj(long)} - *

    - *

    Capability's

    - *

    - * MJ should be exposed from tile entities and entities via the forge capability system as one of the following types: - *

      - *
    • {@link buildcraft.api.mj.IMjConnector} for *anything* that can (potentially) connect to any other Mj type. All - * other types extend this. You should expose this with the capability - * {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR}
    • - *
    • {@link buildcraft.api.mj.IMjReadable} for something that has an internal battery. This is used for adding gate - * triggers. This should be exposed with the capability {@link buildcraft.api.mj.MjAPI#CAP_READABLE}
    • - *
    • {@link buildcraft.api.mj.IMjReceiver} for something that receives power. This should be exposed with the - * capability {@link buildcraft.api.mj.MjAPI#CAP_RECEIVER}
    • - *
    - * Note that you *must* expose the base interface types as capabilities as well as the top type so if you have an - * instance of {@link buildcraft.api.mj.IMjReceiver} then you must return it for both of the capability's - * {@link buildcraft.api.mj.MjAPI#CAP_CONNECTOR} and {@link buildcraft.api.mj.MjAPI#CAP_RECEIVER}. A simple way to do - * this is provided in {@link buildcraft.api.mj.MjCapabilityHelper}. */ -package buildcraft.api.mj; diff --git a/src/api/java/buildcraft/api/power/IEngine.java b/src/api/java/buildcraft/api/power/IEngine.java deleted file mode 100755 index c25037cc4..000000000 --- a/src/api/java/buildcraft/api/power/IEngine.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.power; - -import net.minecraft.util.EnumFacing; - -/** Engines should implement this interface if they want to support BuildCraft's behaviour of passing power between - * engines without using receivePower() (which has other issues). */ -public interface IEngine { - /** Returns true if the engine wants to receive power from another engine on this side. - * - * @param side - * @return */ - boolean canReceiveFromEngine(EnumFacing side); - - /** Receives power from an engine. - * - * @param microJoules The number of micro joules to add. - * @param simulate If true then just pretend you received power- don't actually change any of your internal state. - * @return True if all the power was accepted, false if not. - * - * @see buildcraft.api.mj.IMjReceiver#receivePower(long, boolean) */ - boolean receivePower(long microJoules, boolean simulate); -} diff --git a/src/api/java/buildcraft/api/power/IRedstoneEngine.java b/src/api/java/buildcraft/api/power/IRedstoneEngine.java deleted file mode 100755 index 3fc534d45..000000000 --- a/src/api/java/buildcraft/api/power/IRedstoneEngine.java +++ /dev/null @@ -1,7 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.power; - -public interface IRedstoneEngine {} diff --git a/src/api/java/buildcraft/api/power/package-info.java b/src/api/java/buildcraft/api/power/package-info.java deleted file mode 100755 index c20c3ee4c..000000000 --- a/src/api/java/buildcraft/api/power/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.3", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|power") -package buildcraft.api.power; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/properties/BuildCraftProperties.java b/src/api/java/buildcraft/api/properties/BuildCraftProperties.java deleted file mode 100755 index 63a519ad0..000000000 --- a/src/api/java/buildcraft/api/properties/BuildCraftProperties.java +++ /dev/null @@ -1,88 +0,0 @@ -package buildcraft.api.properties; - -import java.util.Map; - -import com.google.common.collect.Maps; - -import net.minecraft.block.properties.IProperty; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.properties.PropertyEnum; -import net.minecraft.block.properties.PropertyInteger; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.util.EnumFacing; - -import buildcraft.api.enums.EnumDecoratedBlock; -import buildcraft.api.enums.EnumEngineType; -import buildcraft.api.enums.EnumFillerPattern; -import buildcraft.api.enums.EnumLaserTableType; -import buildcraft.api.enums.EnumMachineState; -import buildcraft.api.enums.EnumOptionalSnapshotType; -import buildcraft.api.enums.EnumPowerStage; -import buildcraft.api.enums.EnumSpring; - -public final class BuildCraftProperties { - public static final IProperty BLOCK_FACING = PropertyEnum.create("facing", EnumFacing.class, EnumFacing.Plane.HORIZONTAL.facings()); - public static final IProperty BLOCK_FACING_6 = PropertyEnum.create("facing", EnumFacing.class); - - public static final IProperty BLOCK_COLOR = PropertyEnum.create("color", EnumDyeColor.class); - public static final IProperty SPRING_TYPE = PropertyEnum.create("type", EnumSpring.class); - public static final IProperty ENGINE_TYPE = PropertyEnum.create("type", EnumEngineType.class); - public static final IProperty LASER_TABLE_TYPE = PropertyEnum.create("type", EnumLaserTableType.class); - public static final IProperty MACHINE_STATE = PropertyEnum.create("state", EnumMachineState.class); - public static final IProperty ENERGY_STAGE = PropertyEnum.create("stage", EnumPowerStage.class); - public static final IProperty SNAPSHOT_TYPE = PropertyEnum.create("snapshot_type", EnumOptionalSnapshotType.class); - public static final IProperty DECORATED_BLOCK = PropertyEnum.create("decoration_type", EnumDecoratedBlock.class); - - public static final IProperty GENERIC_PIPE_DATA = PropertyInteger.create("pipe_data", 0, 15); - public static final IProperty LED_POWER = PropertyInteger.create("led_power", 0, 3); - - public static final IProperty JOINED_BELOW = PropertyBool.create("joined_below"); - public static final IProperty MOVING = PropertyBool.create("moving"); - public static final IProperty LED_DONE = PropertyBool.create("led_done"); - public static final IProperty ACTIVE = PropertyBool.create("active"); - public static final IProperty VALID = PropertyBool.create("valid"); - - public static final IProperty CONNECTED_UP = PropertyBool.create("connected_up"); - public static final IProperty CONNECTED_DOWN = PropertyBool.create("connected_down"); - public static final IProperty CONNECTED_EAST = PropertyBool.create("connected_east"); - public static final IProperty CONNECTED_WEST = PropertyBool.create("connected_west"); - public static final IProperty CONNECTED_NORTH = PropertyBool.create("connected_north"); - public static final IProperty CONNECTED_SOUTH = PropertyBool.create("connected_south"); - - public static final Map> CONNECTED_MAP; - - public static final IProperty FILLER_PATTERN = PropertyEnum.create("pattern", EnumFillerPattern.class); - - // Block state setting flags -these are used by World.markAndNotifyBlock and World.setBlockState. These flags can be - // added together to pass the additions - public static final int UPDATE_NONE = 0; - /** This updates the neighbouring blocks that the new block is set. It also updates the comparator output of this - * block. */ - public static final int UPDATE_NEIGHBOURS = 1; - /** This will mark the block for an update next tick, as well as send an update to the client (if this is a server - * world). */ - public static final int MARK_BLOCK_FOR_UPDATE = 2; - /** This will mark the block for an update, even if this is a client world. It is useless to use this if - * world.isRemote returns false. */ - public static final int UPDATE_EVEN_CLIENT = 4 + MARK_BLOCK_FOR_UPDATE; // 6 - - // Pre-added flags- pass these as-is to the World.markAndNotifyBlock and World.setBlockState methods. - /** This will do what both {@link #UPDATE_NEIGHBOURS} and {@link #MARK_BLOCK_FOR_UPDATE} do. */ - public static final int MARK_THIS_AND_NEIGHBOURS = UPDATE_NEIGHBOURS + MARK_BLOCK_FOR_UPDATE; - /** This will update everything about this block. */ - public static final int UPDATE_ALL = UPDATE_NEIGHBOURS + MARK_BLOCK_FOR_UPDATE + UPDATE_EVEN_CLIENT; - - static { - Map> map = Maps.newEnumMap(EnumFacing.class); - map.put(EnumFacing.DOWN, CONNECTED_DOWN); - map.put(EnumFacing.UP, CONNECTED_UP); - map.put(EnumFacing.EAST, CONNECTED_EAST); - map.put(EnumFacing.WEST, CONNECTED_WEST); - map.put(EnumFacing.NORTH, CONNECTED_NORTH); - map.put(EnumFacing.SOUTH, CONNECTED_SOUTH); - CONNECTED_MAP = Maps.immutableEnumMap(map); - } - - /** Deactivate constructor */ - private BuildCraftProperties() {} -} diff --git a/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java b/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java deleted file mode 100755 index 44a2b01ff..000000000 --- a/src/api/java/buildcraft/api/recipes/AssemblyRecipe.java +++ /dev/null @@ -1,72 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Set; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableSet; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - -/** Provides an immutable assembly recipe */ -public final class AssemblyRecipe implements Comparable { - public final ResourceLocation name; - public final long requiredMicroJoules; - public final ImmutableSet requiredStacks; - public final @Nonnull ItemStack output; - /** - * Additional tag used to restore network-transmitted recipe to same state.
    - * You need to register own {@link IAssemblyRecipeProvider} using {@link IAssemblyRecipeRegistry#addRecipeProvider(IAssemblyRecipeProvider)} - * to handle this and declare {@link IAssemblyRecipeProvider#getRecipe(ResourceLocation, NBTTagCompound)} method - */ - public final @Nullable NBTTagCompound recipeTag; - - public AssemblyRecipe(ResourceLocation name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { - this.name = name; - this.requiredMicroJoules = requiredMicroJoules; - this.requiredStacks = ImmutableSet.copyOf(requiredStacks); - this.output = output; - this.recipeTag = recipeTag; - } - - public AssemblyRecipe(String name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { - this(BuildCraftAPI.nameToResourceLocation(name), requiredMicroJoules, requiredStacks, output, recipeTag); - } - - public AssemblyRecipe(ResourceLocation name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output) { - this(name, requiredMicroJoules, requiredStacks, output, null); - } - - public AssemblyRecipe(String name, long requiredMicroJoules, Set requiredStacks, @Nonnull ItemStack output) { - this(name, requiredMicroJoules, requiredStacks, output, null); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - AssemblyRecipe that = (AssemblyRecipe) o; - - return name.equals(that.name); - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public int compareTo(AssemblyRecipe o) { - return name.toString().compareTo(o.name.toString()); - } -} diff --git a/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java deleted file mode 100755 index 1c074e9db..000000000 --- a/src/api/java/buildcraft/api/recipes/BuildcraftRecipeRegistry.java +++ /dev/null @@ -1,14 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.recipes; - -public final class BuildcraftRecipeRegistry { - - public static IAssemblyRecipeRegistry assemblyRecipes; - public static IIntegrationRecipeRegistry integrationRecipes; - public static IRefineryRecipeManager refineryRecipes; - - private BuildcraftRecipeRegistry() {} -} diff --git a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java deleted file mode 100755 index f98567653..000000000 --- a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.List; -import java.util.Optional; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; - -/** Provides a way of registering complex recipes without needing to register every possible variant. If you want the - * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class - * IRecipeViewable. */ -public interface IAssemblyRecipeProvider { - - /** Should return a list of all the valid recipes given the input items. The list may be empty, but must not be - * null. Note that this will *most likely* be slow to check everything, so you should cache the return value and - * re-use it when you can. */ - @Nonnull - List getRecipesFor(@Nonnull NonNullList possible); - - /** - * Returns recipe by it's name - * @param recipeTag Additional tag attached to network-transmitted recipe definition - */ - default Optional getRecipe(@Nonnull ResourceLocation name, @Nullable NBTTagCompound recipeTag) { - return Optional.empty(); - } -} diff --git a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java deleted file mode 100755 index 9665f40d7..000000000 --- a/src/api/java/buildcraft/api/recipes/IAssemblyRecipeRegistry.java +++ /dev/null @@ -1,19 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Iterator; - -import javax.annotation.Nonnull; - -public interface IAssemblyRecipeRegistry extends IAssemblyRecipeProvider { - void addRecipe(@Nonnull AssemblyRecipe recipe); - - void addRecipeProvider(@Nonnull IAssemblyRecipeProvider provider); - - /** Gets all of the simple recipes that are registered. Note that you *can* use the returned iterator's - * {@link Iterator#remove()} method to remove recipes from this registry. */ - Iterable getAllRecipes(); - - /** Gets all of the complex recipe providers that are registered. Note that you *can* use the returned iterator's - * {@link Iterator#remove()} method to remove providers from this registry. */ - Iterable getAllRecipeProviders(); -} diff --git a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java deleted file mode 100755 index 5c3d6446f..000000000 --- a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Optional; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; - -/** Provides a way of registering complex recipes without needing to register every possible variant. If you want the - * recipes to be viewable in JEI and the guide book then you will *also* need to implement the bc lib class - * IIntegrationRecipeViewable. */ -public interface IIntegrationRecipeProvider { - /** Gets an integration recipe for the given ingredients. - * - * @param target The center itemstack. - * @param toIntegrate A list of stacks to try to integrate to the - * @return */ - @Nullable - IntegrationRecipe getRecipeFor(@Nonnull ItemStack target, @Nonnull NonNullList toIntegrate); - - /** - * Returns recipe by it's name - * @param recipeTag Additional tag attached to network-transmitted recipe definition - */ - default Optional getRecipe(@Nonnull ResourceLocation name, @Nullable NBTTagCompound recipeTag) { - return Optional.empty(); - } -} diff --git a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java b/src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java deleted file mode 100755 index 7e4c55b72..000000000 --- a/src/api/java/buildcraft/api/recipes/IIntegrationRecipeRegistry.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Iterator; - -public interface IIntegrationRecipeRegistry extends IIntegrationRecipeProvider { - void addRecipe(IntegrationRecipe recipe); - - void addRecipeProvider(IIntegrationRecipeProvider provider); - - /** Gets all of the simple recipes that are registered. Note that you *can* use the returned iterator's - * {@link Iterator#remove()} method to remove recipes from this registry. */ - Iterable getAllRecipes(); - - /** Gets all of the complex recipe providers that are registered. Note that you *can* use the returned iterator's - * {@link Iterator#remove()} method to remove providers from this registry. */ - Iterable getAllRecipeProviders(); -} diff --git a/src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java b/src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java deleted file mode 100644 index 65b523bd8..000000000 --- a/src/api/java/buildcraft/api/recipes/IRefineryRecipeManager.java +++ /dev/null @@ -1,81 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.Collection; -import java.util.function.Predicate; -import java.util.stream.Stream; - -import javax.annotation.Nullable; - -import net.minecraftforge.fluids.FluidStack; - -public interface IRefineryRecipeManager { - IHeatableRecipe createHeatingRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); - - default IHeatableRecipe addHeatableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) { - return getHeatableRegistry().addRecipe(createHeatingRecipe(in, out, heatFrom, heatTo)); - } - - ICoolableRecipe createCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo); - - default ICoolableRecipe addCoolableRecipe(FluidStack in, FluidStack out, int heatFrom, int heatTo) { - return getCoolableRegistry().addRecipe(createCoolableRecipe(in, out, heatFrom, heatTo)); - } - - IDistillationRecipe createDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired); - - default IDistillationRecipe addDistillationRecipe(FluidStack in, FluidStack outGas, FluidStack outLiquid, long powerRequired) { - return getDistillationRegistry().addRecipe(createDistillationRecipe(in, outGas, outLiquid, powerRequired)); - } - - IRefineryRegistry getHeatableRegistry(); - - IRefineryRegistry getCoolableRegistry(); - - IRefineryRegistry getDistillationRegistry(); - - interface IRefineryRegistry { - /** @return an unmodifiable collection containing all of the distillation recipes that satisfy the given - * predicate. All of the recipe objects are guaranteed to never be null. */ - Stream getRecipes(Predicate toReturn); - - /** @return an unmodifiable set containing all of the distillation recipes. */ - Collection getAllRecipes(); - - @Nullable - R getRecipeForInput(@Nullable FluidStack fluid); - - Collection removeRecipes(Predicate toRemove); - - /** Adds the given recipe to the registry. Note that this will remove any existing recipes for the passed - * recipe's {@link IRefineryRecipe#in()} - * - * @param recipe The recipe to add. - * @return The input recipe. */ - R addRecipe(R recipe); - } - - interface IRefineryRecipe { - FluidStack in(); - } - - interface IHeatExchangerRecipe extends IRefineryRecipe { - @Nullable - FluidStack out(); - - int heatFrom(); - - int heatTo(); - } - - interface IHeatableRecipe extends IHeatExchangerRecipe {} - - interface ICoolableRecipe extends IHeatExchangerRecipe {} - - interface IDistillationRecipe extends IRefineryRecipe { - long powerRequired(); - - FluidStack outGas(); - - FluidStack outLiquid(); - } -} diff --git a/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java b/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java deleted file mode 100755 index b2e36aad2..000000000 --- a/src/api/java/buildcraft/api/recipes/IntegrationRecipe.java +++ /dev/null @@ -1,68 +0,0 @@ -package buildcraft.api.recipes; - -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - -public final class IntegrationRecipe { - public final ResourceLocation name; - public final long requiredMicroJoules; - public final StackDefinition target; - public final ImmutableList toIntegrate; - public final @Nonnull ItemStack output; - /** - * Additional tag used to restore network-transmitted recipe to same state - * You need to register own {@link IIntegrationRecipeProvider} using {@link IIntegrationRecipeRegistry#addRecipeProvider(IIntegrationRecipeProvider)} - * to handle this and declare {@link IIntegrationRecipeProvider#getRecipe(ResourceLocation, NBTTagCompound)} method - */ - public final @Nullable NBTTagCompound recipeTag; - - public IntegrationRecipe(ResourceLocation name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { - this.name = name; - this.requiredMicroJoules = requiredMicroJoules; - this.target = target; - this.toIntegrate = ImmutableList.copyOf(toIntegrate); - this.output = output; - this.recipeTag = recipeTag; - } - - public IntegrationRecipe(String name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output, @Nullable NBTTagCompound recipeTag) { - this(BuildCraftAPI.nameToResourceLocation(name), requiredMicroJoules, target, toIntegrate, output, recipeTag); - } - - public IntegrationRecipe(ResourceLocation name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output) { - this(name, requiredMicroJoules, target, toIntegrate, output, null); - } - - public IntegrationRecipe(String name, long requiredMicroJoules, StackDefinition target, List toIntegrate, @Nonnull ItemStack output) { - this(name, requiredMicroJoules, target, toIntegrate, output, null); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - IntegrationRecipe that = (IntegrationRecipe) o; - - return name.equals(that.name); - } - - @Override - public int hashCode() { - return name.hashCode(); - } -} diff --git a/src/api/java/buildcraft/api/recipes/StackDefinition.java b/src/api/java/buildcraft/api/recipes/StackDefinition.java deleted file mode 100644 index ae1a6b3b8..000000000 --- a/src/api/java/buildcraft/api/recipes/StackDefinition.java +++ /dev/null @@ -1,20 +0,0 @@ -package buildcraft.api.recipes; - -import buildcraft.api.core.IStackFilter; - -/** - * Stack definition for recipe input - */ -public final class StackDefinition { - public final IStackFilter filter; - public final int count; - - public StackDefinition(IStackFilter filter, int count) { - this.filter = filter; - this.count = count; - } - - public StackDefinition(IStackFilter filter) { - this(filter, 1); - } -} diff --git a/src/api/java/buildcraft/api/recipes/package-info.java b/src/api/java/buildcraft/api/recipes/package-info.java deleted file mode 100755 index f8cc9942a..000000000 --- a/src/api/java/buildcraft/api/recipes/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|recipes") -package buildcraft.api.recipes; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/robots/AIRobot.java b/src/api/java/buildcraft/api/robots/AIRobot.java deleted file mode 100755 index 0fad58245..000000000 --- a/src/api/java/buildcraft/api/robots/AIRobot.java +++ /dev/null @@ -1,222 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.robots; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -import buildcraft.api.mj.MjAPI; - -public class AIRobot { - public EntityRobotBase robot; - - private AIRobot delegateAI; - private AIRobot parentAI; - - private boolean success; - - public AIRobot(EntityRobotBase iRobot) { - robot = iRobot; - success = true; - } - - public void start() { - - } - - public void preempt(AIRobot ai) { - - } - - public void update() { - // Update should always handle terminate. Some AI are not using update - // at all, their code being in start() and end(). In these case, - // calling update is a malfunction, the ai should be terminated. - terminate(); - } - - public void end() { - - } - - /** This gets called when a delegate AI ends work naturally. - * - * @param ai The delegate AI which ended work. */ - public void delegateAIEnded(AIRobot ai) { - - } - - /** This gets called when a delegate AI is forcibly aborted. - * - * @param ai The delegate AI which was aborted. */ - public void delegateAIAborted(AIRobot ai) { - - } - - public void writeSelfToNBT(NBTTagCompound nbt) { - - } - - public void loadSelfFromNBT(NBTTagCompound nbt) { - - } - - public boolean success() { - return success; - } - - protected void setSuccess(boolean iSuccess) { - success = iSuccess; - } - - public long getPowerCost() { - return MjAPI.MJ / 10; - } - - public boolean canLoadFromNBT() { - return false; - } - - /** Tries to receive items in parameters, return items that are left after the operation. */ - public ItemStack receiveItem(ItemStack stack) { - return stack; - } - - public final void terminate() { - abortDelegateAI(); - end(); - - if (parentAI != null) { - parentAI.delegateAI = null; - parentAI.delegateAIEnded(this); - } - } - - public final void abort() { - abortDelegateAI(); - - try { - end(); - - if (parentAI != null) { - parentAI.delegateAI = null; - parentAI.delegateAIAborted(this); - } - } catch (Throwable e) { - e.printStackTrace(); - delegateAI = null; - - if (parentAI != null) { - parentAI.delegateAI = null; - } - } - } - - public final void cycle() { - try { - preempt(delegateAI); - - if (delegateAI != null) { - delegateAI.cycle(); - } else { - robot.getBattery().extractPower(1, getPowerCost()); - update(); - } - } catch (Throwable e) { - e.printStackTrace(); - abort(); - } - } - - public final void startDelegateAI(AIRobot ai) { - abortDelegateAI(); - delegateAI = ai; - ai.parentAI = this; - delegateAI.start(); - } - - public final void abortDelegateAI() { - if (delegateAI != null) { - delegateAI.abort(); - } - } - - public final AIRobot getActiveAI() { - if (delegateAI != null) { - return delegateAI.getActiveAI(); - } else { - return this; - } - } - - public final AIRobot getDelegateAI() { - return delegateAI; - } - - public final void writeToNBT(NBTTagCompound nbt) { - nbt.setString("aiName", RobotManager.getAIRobotName(getClass())); - - NBTTagCompound data = new NBTTagCompound(); - writeSelfToNBT(data); - nbt.setTag("data", data); - - if (delegateAI != null && delegateAI.canLoadFromNBT()) { - NBTTagCompound sub = new NBTTagCompound(); - - delegateAI.writeToNBT(sub); - nbt.setTag("delegateAI", sub); - } - } - - public final void loadFromNBT(NBTTagCompound nbt) { - loadSelfFromNBT(nbt.getCompoundTag("data")); - - if (nbt.hasKey("delegateAI")) { - NBTTagCompound sub = nbt.getCompoundTag("delegateAI"); - - try { - Class aiRobotClass; - if (sub.hasKey("class")) { - // Migration support for 6.4.x - aiRobotClass = RobotManager.getAIRobotByLegacyClassName(sub.getString("class")); - } else { - aiRobotClass = RobotManager.getAIRobotByName(sub.getString("aiName")); - } - if (aiRobotClass != null) { - delegateAI = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class).newInstance(robot); - delegateAI.parentAI = this; - - if (delegateAI.canLoadFromNBT()) { - delegateAI.loadFromNBT(sub); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - - public static AIRobot loadAI(NBTTagCompound nbt, EntityRobotBase robot) { - AIRobot ai = null; - - try { - Class aiRobotClass; - if (nbt.hasKey("class")) { - // Migration support for 6.4.x - aiRobotClass = RobotManager.getAIRobotByLegacyClassName(nbt.getString("class")); - } else { - aiRobotClass = RobotManager.getAIRobotByName(nbt.getString("aiName")); - } - if (aiRobotClass != null) { - ai = (AIRobot) aiRobotClass.getConstructor(EntityRobotBase.class).newInstance(robot); - ai.loadFromNBT(nbt); - } - } catch (Throwable e) { - e.printStackTrace(); - } - - return ai; - } -} diff --git a/src/api/java/buildcraft/api/robots/DockingStation.java b/src/api/java/buildcraft/api/robots/DockingStation.java deleted file mode 100755 index d3237a018..000000000 --- a/src/api/java/buildcraft/api/robots/DockingStation.java +++ /dev/null @@ -1,227 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.robots; - -import java.util.Arrays; - -import net.minecraft.inventory.IInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fluids.capability.IFluidHandler; - -import buildcraft.api.core.BCLog; -import buildcraft.api.core.EnumPipePart; -import buildcraft.api.statements.StatementSlot; -import buildcraft.api.transport.IInjectable; - -public abstract class DockingStation { - public EnumFacing side; - public World world; - - private long robotTakingId = EntityRobotBase.NULL_ROBOT_ID; - private EntityRobotBase robotTaking; - - private boolean linkIsMain = false; - - private BlockPos pos; - - public DockingStation(BlockPos iIndex, EnumFacing iSide) { - pos = iIndex; - side = iSide; - } - - public DockingStation() {} - - public boolean isMainStation() { - return linkIsMain; - } - - public BlockPos getPos() { - return pos; - } - - public EnumFacing side() { - return side; - } - - public EntityRobotBase robotTaking() { - if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) { - return null; - } else if (robotTaking == null) { - robotTaking = RobotManager.registryProvider.getRegistry(world).getLoadedRobot(robotTakingId); - } - - return robotTaking; - } - - public void invalidateRobotTakingEntity() { - robotTaking = null; - } - - public long linkedId() { - return robotTakingId; - } - - public boolean takeAsMain(EntityRobotBase robot) { - if (robotTakingId == EntityRobotBase.NULL_ROBOT_ID) { - IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world); - linkIsMain = true; - robotTaking = robot; - robotTakingId = robot.getRobotId(); - registry.registryMarkDirty(); - robot.setMainStation(this); - registry.take(this, robot.getRobotId()); - - return true; - } else { - return robotTakingId == robot.getRobotId(); - } - } - - public boolean take(EntityRobotBase robot) { - if (robotTaking == null) { - IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world); - linkIsMain = false; - robotTaking = robot; - robotTakingId = robot.getRobotId(); - registry.registryMarkDirty(); - registry.take(this, robot.getRobotId()); - - return true; - } else { - return robot.getRobotId() == robotTakingId; - } - } - - public void release(EntityRobotBase robot) { - if (robotTaking == robot && !linkIsMain) { - IRobotRegistry registry = RobotManager.registryProvider.getRegistry(world); - unsafeRelease(robot); - registry.registryMarkDirty(); - registry.release(this, robot.getRobotId()); - } - } - - /** Same a release but doesn't clear the registry (presumably called from the registry). */ - public void unsafeRelease(EntityRobotBase robot) { - if (robotTaking == robot) { - linkIsMain = false; - robotTaking = null; - robotTakingId = EntityRobotBase.NULL_ROBOT_ID; - } - } - - public void writeToNBT(NBTTagCompound nbt) { - nbt.setIntArray("pos", new int[] { getPos().getX(), getPos().getY(), getPos().getZ() }); - nbt.setByte("side", (byte) side.ordinal()); - nbt.setBoolean("isMain", linkIsMain); - nbt.setLong("robotId", robotTakingId); - } - - public void readFromNBT(NBTTagCompound nbt) { - if (nbt.hasKey("index")) { - // For compatibility with older versions of minecraft and buildcraft - NBTTagCompound indexNBT = nbt.getCompoundTag("index"); - int x = indexNBT.getInteger("i"); - int y = indexNBT.getInteger("j"); - int z = indexNBT.getInteger("k"); - pos = new BlockPos(x, y, z); - } else { - int[] array = nbt.getIntArray("pos"); - if (array.length == 3) { - pos = new BlockPos(array[0], array[1], array[2]); - } else if (array.length != 0) { - BCLog.logger.warn("Found an integer array that was not the right length! (" + Arrays.toString(array) + ")"); - } else { - BCLog.logger.warn("Did not find any integer positions! This is a bug!"); - } - } - side = EnumFacing.values()[nbt.getByte("side")]; - linkIsMain = nbt.getBoolean("isMain"); - robotTakingId = nbt.getLong("robotId"); - } - - public boolean isTaken() { - return robotTakingId != EntityRobotBase.NULL_ROBOT_ID; - } - - public long robotIdTaking() { - return robotTakingId; - } - - public BlockPos index() { - return pos; - } - - @Override - public String toString() { - return "{" + pos + ", " + side + " :" + robotTakingId + "}"; - } - - public boolean linkIsDocked() { - if (robotTaking() != null) { - return robotTaking().getDockingStation() == this; - } else { - return false; - } - } - - public boolean canRelease() { - return !isMainStation() && !linkIsDocked(); - } - - public boolean isInitialized() { - return true; - } - - public abstract Iterable getActiveActions(); - - public IInjectable getItemOutput() { - return null; - } - - public EnumPipePart getItemOutputSide() { - return EnumPipePart.CENTER; - } - - public IInventory getItemInput() { - return null; - } - - public EnumPipePart getItemInputSide() { - return EnumPipePart.CENTER; - } - - public IFluidHandler getFluidOutput() { - return null; - } - - public EnumPipePart getFluidOutputSide() { - return EnumPipePart.CENTER; - } - - public IFluidHandler getFluidInput() { - return null; - } - - public EnumPipePart getFluidInputSide() { - return EnumPipePart.CENTER; - } - - public boolean providesPower() { - return false; - } - - public IRequestProvider getRequestProvider() { - return null; - } - - public void onChunkUnload() { - - } -} diff --git a/src/api/java/buildcraft/api/robots/EntityRobotBase.java b/src/api/java/buildcraft/api/robots/EntityRobotBase.java deleted file mode 100755 index 0e6439d04..000000000 --- a/src/api/java/buildcraft/api/robots/EntityRobotBase.java +++ /dev/null @@ -1,86 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.robots; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.items.IItemHandler; - -import buildcraft.api.boards.RedstoneBoardRobot; -import buildcraft.api.core.IFluidHandlerAdv; -import buildcraft.api.core.IZone; -import buildcraft.api.mj.MjAPI; -import buildcraft.api.mj.MjBattery; - -public abstract class EntityRobotBase extends EntityLiving implements IItemHandler, IFluidHandlerAdv { - - public static final long MAX_POWER = 5000 * MjAPI.MJ; - public static final long SAFETY_POWER = MAX_POWER / 5; - public static final long SHUTDOWN_POWER = 0; - public static final long NULL_ROBOT_ID = Long.MAX_VALUE; - - public EntityRobotBase(World par1World) { - super(par1World); - } - - public abstract void setItemInUse(ItemStack stack); - - public abstract void setItemActive(boolean b); - - public abstract boolean isMoving(); - - public abstract DockingStation getLinkedStation(); - - public abstract RedstoneBoardRobot getBoard(); - - public abstract void aimItemAt(float yaw, float pitch); - - public abstract void aimItemAt(BlockPos pos); - - public abstract float getAimYaw(); - - public abstract float getAimPitch(); - - public long getPower() { - return getBattery().getStored(); - } - - public abstract MjBattery getBattery(); - - public abstract DockingStation getDockingStation(); - - public abstract void dock(DockingStation station); - - public abstract void undock(); - - public abstract IZone getZoneToWork(); - - public abstract IZone getZoneToLoadUnload(); - - public abstract boolean containsItems(); - - public abstract boolean hasFreeSlot(); - - public abstract void unreachableEntityDetected(Entity entity); - - public abstract boolean isKnownUnreachable(Entity entity); - - public abstract long getRobotId(); - - public abstract IRobotRegistry getRegistry(); - - public abstract void releaseResources(); - - public abstract void onChunkUnload(); - - public abstract ItemStack receiveItem(TileEntity tile, ItemStack stack); - - public abstract void setMainStation(DockingStation station); -} diff --git a/src/api/java/buildcraft/api/robots/IDockingStationProvider.java b/src/api/java/buildcraft/api/robots/IDockingStationProvider.java deleted file mode 100755 index 0cbd3c3b8..000000000 --- a/src/api/java/buildcraft/api/robots/IDockingStationProvider.java +++ /dev/null @@ -1,6 +0,0 @@ -package buildcraft.api.robots; - -/** By default, this can be either an IPipePluggable or a TileEntity. */ -public interface IDockingStationProvider { - DockingStation getStation(); -} diff --git a/src/api/java/buildcraft/api/robots/IRequestProvider.java b/src/api/java/buildcraft/api/robots/IRequestProvider.java deleted file mode 100755 index 2e56148a8..000000000 --- a/src/api/java/buildcraft/api/robots/IRequestProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.robots; - -import net.minecraft.item.ItemStack; - -/** Provide requests of items that need to be fulfilled. - * - * Requests are organized as an linear array, where null entries mark slots without a requests. A request in a slot, or - * the amount of slots, is allowed to change before a call to {@link #offerItem(int, ItemStack)}, but it is not - * recommended that this is frequent, since the request delivery won't fail until it is offered the previous request. */ -public interface IRequestProvider { - /** Return the total number of request slots available from this provider. - * - * @return */ - int getRequestsCount(); - - /** Return a stack with the request in the slot. - * - * @param slot - * @return the request in the slot, or null if there's no request. */ - ItemStack getRequest(int slot); - - /** Fulfill the request in slot with the stack given and return any excess. - * - * @param slot - * @param stack - * @return any excess that was not used to fulfill the request. */ - ItemStack offerItem(int slot, ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/robots/IRobotOverlayItem.java b/src/api/java/buildcraft/api/robots/IRobotOverlayItem.java deleted file mode 100755 index fa39ee1a1..000000000 --- a/src/api/java/buildcraft/api/robots/IRobotOverlayItem.java +++ /dev/null @@ -1,14 +0,0 @@ -package buildcraft.api.robots; - -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.item.ItemStack; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IRobotOverlayItem { - boolean isValidRobotOverlay(ItemStack stack); - - @SideOnly(Side.CLIENT) - void renderRobotOverlay(ItemStack stack, TextureManager textureManager); -} diff --git a/src/api/java/buildcraft/api/robots/IRobotRegistry.java b/src/api/java/buildcraft/api/robots/IRobotRegistry.java deleted file mode 100755 index 96360f564..000000000 --- a/src/api/java/buildcraft/api/robots/IRobotRegistry.java +++ /dev/null @@ -1,56 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.robots; - -import java.util.Collection; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; - -public interface IRobotRegistry { - - long getNextRobotId(); - - void registerRobot(EntityRobotBase robot); - - void killRobot(EntityRobotBase robot); - - void unloadRobot(EntityRobotBase robot); - - EntityRobotBase getLoadedRobot(long id); - - boolean isTaken(ResourceId resourceId); - - long robotIdTaking(ResourceId resourceId); - - EntityRobotBase robotTaking(ResourceId resourceId); - - boolean take(ResourceId resourceId, EntityRobotBase robot); - - boolean take(ResourceId resourceId, long robotId); - - void release(ResourceId resourceId); - - void releaseResources(EntityRobotBase robot); - - DockingStation getStation(BlockPos pos, EnumFacing side); - - Collection getStations(); - - void registerStation(DockingStation station); - - void removeStation(DockingStation station); - - void take(DockingStation station, long robotId); - - void release(DockingStation station, long robotId); - - void writeToNBT(NBTTagCompound nbt); - - void readFromNBT(NBTTagCompound nbt); - - void registryMarkDirty(); -} diff --git a/src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java b/src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java deleted file mode 100755 index 001249453..000000000 --- a/src/api/java/buildcraft/api/robots/IRobotRegistryProvider.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.robots; - -import net.minecraft.world.World; - -public interface IRobotRegistryProvider { - IRobotRegistry getRegistry(World world); -} diff --git a/src/api/java/buildcraft/api/robots/ResourceId.java b/src/api/java/buildcraft/api/robots/ResourceId.java deleted file mode 100755 index 539503a0f..000000000 --- a/src/api/java/buildcraft/api/robots/ResourceId.java +++ /dev/null @@ -1,39 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.robots; - -import net.minecraft.nbt.NBTTagCompound; - -public abstract class ResourceId { - - protected ResourceId() {} - - public void writeToNBT(NBTTagCompound nbt) { - nbt.setString("resourceName", RobotManager.getResourceIdName(getClass())); - } - - protected void readFromNBT(NBTTagCompound nbt) {} - - public static ResourceId load(NBTTagCompound nbt) { - try { - Class cls; - if (nbt.hasKey("class")) { - // Migration support for 6.4.x - cls = RobotManager.getResourceIdByLegacyClassName(nbt.getString("class")); - } else { - cls = RobotManager.getResourceIdByName(nbt.getString("resourceName")); - } - - ResourceId id = (ResourceId) cls.newInstance(); - id.readFromNBT(nbt); - - return id; - } catch (Throwable e) { - e.printStackTrace(); - } - - return null; - } -} diff --git a/src/api/java/buildcraft/api/robots/ResourceIdBlock.java b/src/api/java/buildcraft/api/robots/ResourceIdBlock.java deleted file mode 100755 index 4e89a5826..000000000 --- a/src/api/java/buildcraft/api/robots/ResourceIdBlock.java +++ /dev/null @@ -1,71 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.robots; - -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.math.BlockPos; - -import buildcraft.api.core.EnumPipePart; - -public class ResourceIdBlock extends ResourceId { - - public BlockPos pos = new BlockPos(0, 0, 0); - public EnumPipePart side = EnumPipePart.CENTER; - - public ResourceIdBlock() { - - } - - public ResourceIdBlock(int x, int y, int z) { - pos = new BlockPos(x, y, z); - } - - public ResourceIdBlock(BlockPos iIndex) { - pos = iIndex; - } - - public ResourceIdBlock(TileEntity tile) { - pos = tile.getPos(); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || obj.getClass() != getClass()) { - return false; - } - - ResourceIdBlock compareId = (ResourceIdBlock) obj; - - return pos.equals(compareId.pos) && side == compareId.side; - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(pos.hashCode()).append(side != null ? side.ordinal() : 0).build(); - } - - @Override - public void writeToNBT(NBTTagCompound nbt) { - super.writeToNBT(nbt); - - int[] arr = new int[] { pos.getX(), pos.getY(), pos.getZ() }; - nbt.setIntArray("pos", arr); - - nbt.setTag("side", side.writeToNBT()); - } - - @Override - protected void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); - int[] arr = nbt.getIntArray("pos"); - pos = new BlockPos(arr[0], arr[1], arr[2]); - - side = EnumPipePart.readFromNBT(nbt.getTag("side")); - } -} diff --git a/src/api/java/buildcraft/api/robots/ResourceIdRequest.java b/src/api/java/buildcraft/api/robots/ResourceIdRequest.java deleted file mode 100755 index d224b8e76..000000000 --- a/src/api/java/buildcraft/api/robots/ResourceIdRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.robots; - -import org.apache.commons.lang3.builder.HashCodeBuilder; - -import net.minecraft.nbt.NBTTagCompound; - -import buildcraft.api.core.EnumPipePart; - -public class ResourceIdRequest extends ResourceIdBlock { - - private int slot; - - public ResourceIdRequest() { - - } - - public ResourceIdRequest(DockingStation station, int slot) { - pos = station.index(); - side = EnumPipePart.fromFacing(station.side()); - this.slot = slot; - } - - @Override - public boolean equals(Object obj) { - if (obj == null) return false; - if (!super.equals(obj)) return false; - ResourceIdRequest compareId = (ResourceIdRequest) obj; - - return slot == compareId.slot; - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(super.hashCode()).append(slot).build(); - } - - @Override - public void writeToNBT(NBTTagCompound nbt) { - super.writeToNBT(nbt); - - nbt.setInteger("localId", slot); - } - - @Override - protected void readFromNBT(NBTTagCompound nbt) { - super.readFromNBT(nbt); - - slot = nbt.getInteger("localId"); - } -} diff --git a/src/api/java/buildcraft/api/robots/RobotManager.java b/src/api/java/buildcraft/api/robots/RobotManager.java deleted file mode 100755 index 7c712c91f..000000000 --- a/src/api/java/buildcraft/api/robots/RobotManager.java +++ /dev/null @@ -1,114 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.robots; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import buildcraft.api.core.BCLog; - -public abstract class RobotManager { - public static IRobotRegistryProvider registryProvider; - public static ArrayList> aiRobots = new ArrayList<>(); - - static { - aiRobotsByNames = new HashMap<>(); - aiRobotsNames = new HashMap<>(); - aiRobotsByLegacyClassNames = new HashMap<>(); - resourceIdNames = new HashMap<>(); - resourceIdByNames = new HashMap<>(); - resourceIdLegacyClassNames = new HashMap<>(); - dockingStationNames = new HashMap<>(); - dockingStationByNames = new HashMap<>(); - - registerResourceId(ResourceIdBlock.class, "resourceIdBlock", "buildcraft.core.robots.ResourceIdBlock"); - registerResourceId(ResourceIdRequest.class, "resourceIdRequest", "buildcraft.core.robots.ResourceIdRequest"); - } - - private static Map, String> aiRobotsNames; - private static Map> aiRobotsByNames; - private static Map> aiRobotsByLegacyClassNames; - - private static Map, String> resourceIdNames; - private static Map> resourceIdByNames; - private static Map> resourceIdLegacyClassNames; - - private static Map, String> dockingStationNames; - private static Map> dockingStationByNames; - - public static void registerAIRobot(Class aiRobot, String name) { - registerAIRobot(aiRobot, name, null); - } - - public static void registerAIRobot(Class aiRobot, String name, String legacyClassName) { - if (aiRobotsByNames.containsKey(name)) { - BCLog.logger.info("Overriding " + aiRobotsByNames.get(name).getName() + " with " + aiRobot.getName()); - } - - // Check if NBT-load constructor is present - try { - aiRobot.getConstructor(EntityRobotBase.class); - } catch (NoSuchMethodException e) { - throw new RuntimeException("AI class " + aiRobot.getName() + " lacks NBT load constructor! This is a bug!"); - } - - aiRobots.add(aiRobot); - aiRobotsByNames.put(name, aiRobot); - aiRobotsNames.put(aiRobot, name); - if (legacyClassName != null) { - aiRobotsByLegacyClassNames.put(legacyClassName, aiRobot); - } - } - - public static Class getAIRobotByName(String aiRobotName) { - return aiRobotsByNames.get(aiRobotName); - } - - public static String getAIRobotName(Class aiRobotClass) { - return aiRobotsNames.get(aiRobotClass); - } - - public static Class getAIRobotByLegacyClassName(String aiRobotLegacyClassName) { - return aiRobotsByLegacyClassNames.get(aiRobotLegacyClassName); - } - - public static void registerResourceId(Class resourceId, String name) { - registerResourceId(resourceId, name, null); - } - - public static void registerResourceId(Class resourceId, String name, String legacyClassName) { - resourceIdByNames.put(name, resourceId); - resourceIdNames.put(resourceId, name); - if (legacyClassName != null) { - resourceIdLegacyClassNames.put(legacyClassName, resourceId); - } - } - - public static Class getResourceIdByName(String resourceIdName) { - return resourceIdByNames.get(resourceIdName); - } - - public static String getResourceIdName(Class resourceIdClass) { - return resourceIdNames.get(resourceIdClass); - } - - public static Class getResourceIdByLegacyClassName(String resourceIdLegacyClassName) { - return resourceIdLegacyClassNames.get(resourceIdLegacyClassName); - } - - public static void registerDockingStation(Class dockingStation, String name) { - dockingStationByNames.put(name, dockingStation); - dockingStationNames.put(dockingStation, name); - } - - public static Class getDockingStationByName(String dockingStationTypeName) { - return dockingStationByNames.get(dockingStationTypeName); - } - - public static String getDockingStationName(Class dockingStation) { - return dockingStationNames.get(dockingStation); - } -} diff --git a/src/api/java/buildcraft/api/robots/package-info.java b/src/api/java/buildcraft/api/robots/package-info.java deleted file mode 100755 index 4fd622b34..000000000 --- a/src/api/java/buildcraft/api/robots/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|robotics") -package buildcraft.api.robots; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/schematics/ISchematicBlock.java b/src/api/java/buildcraft/api/schematics/ISchematicBlock.java deleted file mode 100644 index 01475eb48..000000000 --- a/src/api/java/buildcraft/api/schematics/ISchematicBlock.java +++ /dev/null @@ -1,46 +0,0 @@ -package buildcraft.api.schematics; - -import java.util.List; -import java.util.Set; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.fluids.FluidStack; - -import buildcraft.api.core.InvalidInputDataException; - -public interface ISchematicBlock> { - void init(SchematicBlockContext context); - - boolean isAir(); - - @Nonnull - Set getRequiredBlockOffsets(); - - @Nonnull - List computeRequiredItems(SchematicBlockContext context); - - @Nonnull - List computeRequiredFluids(SchematicBlockContext context); - - S getRotated(Rotation rotation); - - boolean canBuild(World world, BlockPos blockPos); - - boolean build(World world, BlockPos blockPos); - - boolean buildWithoutChecks(World world, BlockPos blockPos); - - boolean isBuilt(World world, BlockPos blockPos); - - NBTTagCompound serializeNBT(); - - /** @throws InvalidInputDataException If the input data wasn't correct or didn't make sense. */ - void deserializeNBT(NBTTagCompound nbt) throws InvalidInputDataException; -} diff --git a/src/api/java/buildcraft/api/schematics/ISchematicEntity.java b/src/api/java/buildcraft/api/schematics/ISchematicEntity.java deleted file mode 100644 index 1f087ca68..000000000 --- a/src/api/java/buildcraft/api/schematics/ISchematicEntity.java +++ /dev/null @@ -1,40 +0,0 @@ -package buildcraft.api.schematics; - -import java.util.List; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; - -import net.minecraftforge.fluids.FluidStack; - -import buildcraft.api.core.InvalidInputDataException; - -public interface ISchematicEntity> { - void init(SchematicEntityContext context); - - Vec3d getPos(); - - @Nonnull - List computeRequiredItems(SchematicEntityContext context); - - @Nonnull - List computeRequiredFluids(SchematicEntityContext context); - - S getRotated(Rotation rotation); - - Entity build(World world, BlockPos basePos); - - Entity buildWithoutChecks(World world, BlockPos basePos); - - NBTTagCompound serializeNBT(); - - /** @throws InvalidInputDataException If the input data wasn't correct or didn't make sense. */ - void deserializeNBT(NBTTagCompound nbt) throws InvalidInputDataException; -} diff --git a/src/api/java/buildcraft/api/schematics/SchematicBlockContext.java b/src/api/java/buildcraft/api/schematics/SchematicBlockContext.java deleted file mode 100644 index 0ca98532a..000000000 --- a/src/api/java/buildcraft/api/schematics/SchematicBlockContext.java +++ /dev/null @@ -1,33 +0,0 @@ -package buildcraft.api.schematics; - -import javax.annotation.Nonnull; - -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class SchematicBlockContext { - @Nonnull - public final World world; - @Nonnull - public final BlockPos basePos; - @Nonnull - public final BlockPos pos; - @Nonnull - public final IBlockState blockState; - @Nonnull - public final Block block; - - public SchematicBlockContext(@Nonnull World world, - @Nonnull BlockPos basePos, - @Nonnull BlockPos pos, - @Nonnull IBlockState blockState, - @Nonnull Block block) { - this.world = world; - this.basePos = basePos; - this.pos = pos; - this.blockState = blockState; - this.block = block; - } -} diff --git a/src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java b/src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java deleted file mode 100644 index e88d6cd4f..000000000 --- a/src/api/java/buildcraft/api/schematics/SchematicBlockFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -package buildcraft.api.schematics; - -import java.util.function.Predicate; -import java.util.function.Supplier; - -import javax.annotation.Nonnull; - -import net.minecraft.util.ResourceLocation; - -public class SchematicBlockFactory> implements Comparable { - @Nonnull - public final ResourceLocation name; - public final int priority; - @Nonnull - public final Predicate predicate; - @Nonnull - public final Supplier supplier; - @Nonnull - public final Class clazz; - - @SuppressWarnings("unchecked") - public SchematicBlockFactory(@Nonnull ResourceLocation name, - int priority, - @Nonnull Predicate predicate, - @Nonnull Supplier supplier) { - this.name = name; - this.priority = priority; - this.predicate = predicate; - this.supplier = supplier; - clazz = (Class) supplier.get().getClass(); - } - - @Override - public int compareTo(@Nonnull SchematicBlockFactory o) { - return priority != o.priority - ? Integer.compare(priority, o.priority) - : name.toString().compareTo(o.name.toString()); - } -} diff --git a/src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java b/src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java deleted file mode 100644 index 541c2777e..000000000 --- a/src/api/java/buildcraft/api/schematics/SchematicBlockFactoryRegistry.java +++ /dev/null @@ -1,65 +0,0 @@ -package buildcraft.api.schematics; - -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.function.Predicate; -import java.util.function.Supplier; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.block.Block; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - -public class SchematicBlockFactoryRegistry { - private static final Set> FACTORIES = new TreeSet<>(); - - public static > void registerFactory(String name, - int priority, - Predicate predicate, - Supplier supplier) { - FACTORIES.add(new SchematicBlockFactory<>( - BuildCraftAPI.nameToResourceLocation(name), - priority, - predicate, - supplier - )); - } - - public static > void registerFactory(String name, - int priority, - List blocks, - Supplier supplier) { - registerFactory( - name, - priority, - context -> blocks.contains(context.block), - supplier - ); - } - - public static List> getFactories() { - return ImmutableList.copyOf(FACTORIES); - } - - @Nonnull - public static SchematicBlockFactory getFactoryByInstance(ISchematicBlock instance) { - return FACTORIES.stream() - .filter(schematicBlockFactory -> schematicBlockFactory.clazz == instance.getClass()) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); - } - - @Nullable - public static SchematicBlockFactory getFactoryByName(ResourceLocation name) { - return FACTORIES.stream() - .filter(schematicBlockFactory -> schematicBlockFactory.name.equals(name)) - .findFirst() - .orElse(null); - } -} diff --git a/src/api/java/buildcraft/api/schematics/SchematicEntityContext.java b/src/api/java/buildcraft/api/schematics/SchematicEntityContext.java deleted file mode 100644 index b812556a0..000000000 --- a/src/api/java/buildcraft/api/schematics/SchematicEntityContext.java +++ /dev/null @@ -1,24 +0,0 @@ -package buildcraft.api.schematics; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.Entity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public class SchematicEntityContext { - @Nonnull - public final World world; - @Nonnull - public final BlockPos basePos; - @Nonnull - public final Entity entity; - - public SchematicEntityContext(@Nonnull World world, - @Nonnull BlockPos basePos, - @Nonnull Entity entity) { - this.world = world; - this.basePos = basePos; - this.entity = entity; - } -} diff --git a/src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java b/src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java deleted file mode 100644 index 285f05819..000000000 --- a/src/api/java/buildcraft/api/schematics/SchematicEntityFactory.java +++ /dev/null @@ -1,39 +0,0 @@ -package buildcraft.api.schematics; - -import java.util.function.Predicate; -import java.util.function.Supplier; - -import javax.annotation.Nonnull; - -import net.minecraft.util.ResourceLocation; - -public class SchematicEntityFactory> implements Comparable { - @Nonnull - public final ResourceLocation name; - public final int priority; - @Nonnull - public final Predicate predicate; - @Nonnull - public final Supplier supplier; - @Nonnull - public final Class clazz; - - @SuppressWarnings("unchecked") - public SchematicEntityFactory(@Nonnull ResourceLocation name, - int priority, - @Nonnull Predicate predicate, - @Nonnull Supplier supplier) { - this.name = name; - this.priority = priority; - this.predicate = predicate; - this.supplier = supplier; - clazz = (Class) supplier.get().getClass(); - } - - @Override - public int compareTo(@Nonnull SchematicEntityFactory o) { - return priority != o.priority - ? Integer.compare(priority, o.priority) - : name.toString().compareTo(o.name.toString()); - } -} diff --git a/src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java b/src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java deleted file mode 100644 index 7bfc97cb0..000000000 --- a/src/api/java/buildcraft/api/schematics/SchematicEntityFactoryRegistry.java +++ /dev/null @@ -1,65 +0,0 @@ -package buildcraft.api.schematics; - -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.function.Predicate; -import java.util.function.Supplier; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.entity.EntityList; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.core.BuildCraftAPI; - -public class SchematicEntityFactoryRegistry { - private static final Set> FACTORIES = new TreeSet<>(); - - public static > void registerFactory(String name, - int priority, - Predicate predicate, - Supplier supplier) { - FACTORIES.add(new SchematicEntityFactory<>( - BuildCraftAPI.nameToResourceLocation(name), - priority, - predicate, - supplier - )); - } - - public static > void registerFactory(String name, - int priority, - List entities, - Supplier supplier) { - registerFactory( - name, - priority, - context -> entities.contains(EntityList.getKey(context.entity)), - supplier - ); - } - - public static List> getFactories() { - return ImmutableList.copyOf(FACTORIES); - } - - @Nonnull - public static SchematicEntityFactory getFactoryByInstance(ISchematicEntity instance) { - return FACTORIES.stream() - .filter(schematicEntityFactory -> schematicEntityFactory.clazz == instance.getClass()) - .findFirst() - .orElseThrow(() -> new IllegalStateException("Didn't find a factory for " + instance.getClass())); - } - - @Nullable - public static SchematicEntityFactory getFactoryByName(ResourceLocation name) { - return FACTORIES.stream() - .filter(schematicEntityFactory -> schematicEntityFactory.name.equals(name)) - .findFirst() - .orElse(null); - } -} diff --git a/src/api/java/buildcraft/api/statements/IAction.java b/src/api/java/buildcraft/api/statements/IAction.java deleted file mode 100755 index 2cd0c359f..000000000 --- a/src/api/java/buildcraft/api/statements/IAction.java +++ /dev/null @@ -1,6 +0,0 @@ -package buildcraft.api.statements; - -/** Marker interface that designates a class as being an action. Note that you *must* implement ONE of the following - * interfaces to be recognised as an action: {@link IActionInternal}, {@link IActionInternalSided}, or - * {@link IActionExternal} */ -public interface IAction extends IStatement {} diff --git a/src/api/java/buildcraft/api/statements/IActionExternal.java b/src/api/java/buildcraft/api/statements/IActionExternal.java deleted file mode 100755 index 9086612ca..000000000 --- a/src/api/java/buildcraft/api/statements/IActionExternal.java +++ /dev/null @@ -1,12 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -public interface IActionExternal extends IAction { - void actionActivate(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); -} diff --git a/src/api/java/buildcraft/api/statements/IActionInternal.java b/src/api/java/buildcraft/api/statements/IActionInternal.java deleted file mode 100755 index 1ec5260f3..000000000 --- a/src/api/java/buildcraft/api/statements/IActionInternal.java +++ /dev/null @@ -1,10 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -public interface IActionInternal extends IAction { - - void actionActivate(IStatementContainer source, IStatementParameter[] parameters); -} diff --git a/src/api/java/buildcraft/api/statements/IActionInternalSided.java b/src/api/java/buildcraft/api/statements/IActionInternalSided.java deleted file mode 100755 index 0ae3d70d3..000000000 --- a/src/api/java/buildcraft/api/statements/IActionInternalSided.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.statements; - -import net.minecraft.util.EnumFacing; - -public interface IActionInternalSided extends IAction { - void actionActivate(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); -} diff --git a/src/api/java/buildcraft/api/statements/IActionProvider.java b/src/api/java/buildcraft/api/statements/IActionProvider.java deleted file mode 100755 index fa550ff83..000000000 --- a/src/api/java/buildcraft/api/statements/IActionProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import java.util.Collection; - -import javax.annotation.Nonnull; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -public interface IActionProvider { - void addInternalActions(Collection actions, IStatementContainer container); - - void addInternalSidedActions(Collection actions, IStatementContainer container, @Nonnull EnumFacing side); - - void addExternalActions(Collection actions, @Nonnull EnumFacing side, TileEntity tile); -} diff --git a/src/api/java/buildcraft/api/statements/IActionReceptor.java b/src/api/java/buildcraft/api/statements/IActionReceptor.java deleted file mode 100755 index 34155b86a..000000000 --- a/src/api/java/buildcraft/api/statements/IActionReceptor.java +++ /dev/null @@ -1,9 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -public interface IActionReceptor { - void actionActivated(IStatement statement, IStatementParameter[] parameters); -} diff --git a/src/api/java/buildcraft/api/statements/IActionSingle.java b/src/api/java/buildcraft/api/statements/IActionSingle.java deleted file mode 100755 index 861e37eb2..000000000 --- a/src/api/java/buildcraft/api/statements/IActionSingle.java +++ /dev/null @@ -1,6 +0,0 @@ -package buildcraft.api.statements; - -public interface IActionSingle extends IAction { - /** @return True if this action should only be fired for the first tick of it being active. */ - boolean singleActionTick(); -} diff --git a/src/api/java/buildcraft/api/statements/IGuiSlot.java b/src/api/java/buildcraft/api/statements/IGuiSlot.java deleted file mode 100755 index 0dec933c1..000000000 --- a/src/api/java/buildcraft/api/statements/IGuiSlot.java +++ /dev/null @@ -1,21 +0,0 @@ -package buildcraft.api.statements; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IGuiSlot { - /** Every parameter needs a unique tag, it should be in the format of "<modid>:<name>". - * - * @return the unique id */ - String getUniqueTag(); - - /** Return the parameter description in the UI */ - String getDescription(); - - /** @return A sprite to show in a GUI or in-world (so this must be stitched into the block texture atlas), or null - * if this should not render a sprite. */ - @SideOnly(Side.CLIENT) - TextureAtlasSprite getGuiSprite(); -} diff --git a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java b/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java deleted file mode 100755 index cb2dc78e1..000000000 --- a/src/api/java/buildcraft/api/statements/IOverrideDefaultStatements.java +++ /dev/null @@ -1,13 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import java.util.List; - -public interface IOverrideDefaultStatements { - List overrideTriggers(); - - List overrideActions(); -} diff --git a/src/api/java/buildcraft/api/statements/IStatement.java b/src/api/java/buildcraft/api/statements/IStatement.java deleted file mode 100755 index 70c20836e..000000000 --- a/src/api/java/buildcraft/api/statements/IStatement.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -/** Designates some sort of statement. Most of the time you should implement {@link ITriggerExternal}, - * {@link ITriggerInternal}, {@link IActionExternal} or {@link IActionInternal} though. */ -public interface IStatement extends IGuiSlot { - - /** Return the maximum number of parameter this statement can have, 0 if none. */ - int maxParameters(); - - /** Return the minimum number of parameter this statement can have, 0 if none. */ - int minParameters(); - - /** Create parameters for the statement. */ - IStatementParameter createParameter(int index); - - /** This returns the statement after a left rotation. Used in particular in blueprints orientation. */ - IStatement rotateLeft(); - - /** This returns a group of related statements. For example "redstone signal input" should probably return an array - * of "RS_SIGNAL_ON" and "RS_SIGNAL_OFF". It is recommended to return an array containing this object. */ - IStatement[] getPossible(); -} diff --git a/src/api/java/buildcraft/api/statements/IStatementContainer.java b/src/api/java/buildcraft/api/statements/IStatementContainer.java deleted file mode 100755 index e08a7e85b..000000000 --- a/src/api/java/buildcraft/api/statements/IStatementContainer.java +++ /dev/null @@ -1,18 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import javax.annotation.Nullable; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -/** This is implemented by objects containing Statements, such as Gates and TileEntities. */ -public interface IStatementContainer { - TileEntity getTile(); - - @Nullable - TileEntity getNeighbourTile(EnumFacing side); -} diff --git a/src/api/java/buildcraft/api/statements/IStatementParameter.java b/src/api/java/buildcraft/api/statements/IStatementParameter.java deleted file mode 100755 index 8e15b9c46..000000000 --- a/src/api/java/buildcraft/api/statements/IStatementParameter.java +++ /dev/null @@ -1,33 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public interface IStatementParameter extends IGuiSlot { - - /** @return An itemstack to render for this parameter, or {@link ItemStack#EMPTY} if this should not render an - * itemstack. */ - @Nonnull - ItemStack getItemStack(); - - /** Return true if you handled the mouse click and do not want all possible values to be shown, or false if you - * did nothing and wish to show all possible values. - * - * @see #getPossible(IStatementContainer, IStatement)*/ - boolean onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse); - - void readFromNBT(NBTTagCompound compound); - - void writeToNBT(NBTTagCompound compound); - - /** This returns the parameter after a left rotation. Used in particular in blueprints orientation. */ - IStatementParameter rotateLeft(); - - IStatementParameter[] getPossible(IStatementContainer source, IStatement stmt); -} diff --git a/src/api/java/buildcraft/api/statements/ITrigger.java b/src/api/java/buildcraft/api/statements/ITrigger.java deleted file mode 100755 index cdb65c971..000000000 --- a/src/api/java/buildcraft/api/statements/ITrigger.java +++ /dev/null @@ -1,6 +0,0 @@ -package buildcraft.api.statements; - -/** Marker interface that designates a class as being a trigger. Note that you *must* implement ONE of the following - * interfaces to be recognised as a trigger: {@link ITriggerInternal}, {@link ITriggerInternalSided}, or - * {@link ITriggerExternal} */ -public interface ITrigger extends IStatement {} diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternal.java b/src/api/java/buildcraft/api/statements/ITriggerExternal.java deleted file mode 100755 index 87a848fef..000000000 --- a/src/api/java/buildcraft/api/statements/ITriggerExternal.java +++ /dev/null @@ -1,14 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -public interface ITriggerExternal extends ITrigger { - - boolean isTriggerActive(TileEntity target, EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); - -} diff --git a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java b/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java deleted file mode 100755 index 9b1fd1e19..000000000 --- a/src/api/java/buildcraft/api/statements/ITriggerExternalOverride.java +++ /dev/null @@ -1,16 +0,0 @@ -package buildcraft.api.statements; - -import net.minecraft.util.EnumFacing; - -/** This interface can be used by tiles to override external trigger behaviour. - * - * Please use wisely. */ -public interface ITriggerExternalOverride { - enum Result { - TRUE, - FALSE, - IGNORE - } - - Result override(EnumFacing side, IStatementContainer source, ITriggerExternal trigger, IStatementParameter[] parameters); -} diff --git a/src/api/java/buildcraft/api/statements/ITriggerInternal.java b/src/api/java/buildcraft/api/statements/ITriggerInternal.java deleted file mode 100755 index 8ca49961d..000000000 --- a/src/api/java/buildcraft/api/statements/ITriggerInternal.java +++ /dev/null @@ -1,11 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -public interface ITriggerInternal extends ITrigger { - - boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters); - -} diff --git a/src/api/java/buildcraft/api/statements/ITriggerInternalSided.java b/src/api/java/buildcraft/api/statements/ITriggerInternalSided.java deleted file mode 100755 index 73459f004..000000000 --- a/src/api/java/buildcraft/api/statements/ITriggerInternalSided.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.statements; - -import net.minecraft.util.EnumFacing; - -public interface ITriggerInternalSided extends ITrigger { - boolean isTriggerActive(EnumFacing side, IStatementContainer source, IStatementParameter[] parameters); -} diff --git a/src/api/java/buildcraft/api/statements/ITriggerProvider.java b/src/api/java/buildcraft/api/statements/ITriggerProvider.java deleted file mode 100755 index 8f3bf0317..000000000 --- a/src/api/java/buildcraft/api/statements/ITriggerProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import java.util.Collection; - -import javax.annotation.Nonnull; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -public interface ITriggerProvider { - void addInternalTriggers(Collection triggers, IStatementContainer container); - - void addInternalSidedTriggers(Collection triggers, IStatementContainer container, @Nonnull EnumFacing side); - - /** Returns the list of triggers available to a gate next to the given block. */ - void addExternalTriggers(Collection triggers, @Nonnull EnumFacing side, TileEntity tile); -} diff --git a/src/api/java/buildcraft/api/statements/StatementManager.java b/src/api/java/buildcraft/api/statements/StatementManager.java deleted file mode 100755 index 1cd30f130..000000000 --- a/src/api/java/buildcraft/api/statements/StatementManager.java +++ /dev/null @@ -1,147 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import buildcraft.api.core.BCLog; - -public final class StatementManager { - - public static Map statements = new HashMap<>(); - public static Map> parameters = new HashMap<>(); - private static List triggerProviders = new LinkedList<>(); - private static List actionProviders = new LinkedList<>(); - - static { - registerParameterClass(StatementParameterItemStack.class); - } - - /** Deactivate constructor */ - private StatementManager() {} - - public static void registerTriggerProvider(ITriggerProvider provider) { - if (provider != null && !triggerProviders.contains(provider)) { - triggerProviders.add(provider); - } - } - - public static void registerActionProvider(IActionProvider provider) { - if (provider != null && !actionProviders.contains(provider)) { - actionProviders.add(provider); - } - } - - public static void registerStatement(IStatement statement) { - statements.put(statement.getUniqueTag(), statement); - } - - public static void registerParameterClass(Class param) { - parameters.put(createParameter(param).getUniqueTag(), param); - } - - public static List getExternalTriggers(EnumFacing side, TileEntity entity) { - if (entity instanceof IOverrideDefaultStatements) { - List result = ((IOverrideDefaultStatements) entity).overrideTriggers(); - if (result != null) { - return result; - } - } - - LinkedHashSet triggers = new LinkedHashSet<>(); - - for (ITriggerProvider provider : triggerProviders) { - provider.addExternalTriggers(triggers, side, entity); - } - - return new ArrayList<>(triggers); - } - - public static List getExternalActions(EnumFacing side, TileEntity entity) { - if (entity instanceof IOverrideDefaultStatements) { - List result = ((IOverrideDefaultStatements) entity).overrideActions(); - if (result != null) { - return result; - } - } - - LinkedHashSet actions = new LinkedHashSet<>(); - - for (IActionProvider provider : actionProviders) { - provider.addExternalActions(actions, side, entity); - } - - return new ArrayList<>(actions); - } - - public static List getInternalTriggers(IStatementContainer container) { - LinkedHashSet triggers = new LinkedHashSet<>(); - - for (ITriggerProvider provider : triggerProviders) { - provider.addInternalTriggers(triggers, container); - } - - return new ArrayList<>(triggers); - } - - public static List getInternalActions(IStatementContainer container) { - LinkedHashSet actions = new LinkedHashSet<>(); - - for (IActionProvider provider : actionProviders) { - provider.addInternalActions(actions, container); - } - - return new ArrayList<>(actions); - } - - public static List getInternalSidedTriggers(IStatementContainer container, EnumFacing side) { - LinkedHashSet triggers = new LinkedHashSet<>(); - - for (ITriggerProvider provider : triggerProviders) { - provider.addInternalSidedTriggers(triggers, container, side); - } - - return new ArrayList<>(triggers); - } - - public static List getInternalSidedActions(IStatementContainer container, EnumFacing side) { - LinkedHashSet actions = new LinkedHashSet<>(); - - for (IActionProvider provider : actionProviders) { - provider.addInternalSidedActions(actions, container, side); - } - - return new ArrayList<>(actions); - } - - public static IStatementParameter createParameter(String kind) { - return createParameter(parameters.get(kind)); - } - - private static IStatementParameter createParameter(Class param) { - if (param == null) { - return null; - } - - try { - return param.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - e.printStackTrace(); - } catch (Error error) { - BCLog.logErrorAPI(error, IStatementParameter.class); - throw error; - } - - return null; - } -} diff --git a/src/api/java/buildcraft/api/statements/StatementMouseClick.java b/src/api/java/buildcraft/api/statements/StatementMouseClick.java deleted file mode 100755 index c39ed336f..000000000 --- a/src/api/java/buildcraft/api/statements/StatementMouseClick.java +++ /dev/null @@ -1,23 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -public final class StatementMouseClick { - private int button; - private boolean shift; - - public StatementMouseClick(int button, boolean shift) { - this.button = button; - this.shift = shift; - } - - public boolean isShift() { - return shift; - } - - public int getButton() { - return button; - } -} diff --git a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java b/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java deleted file mode 100755 index ad55c9909..000000000 --- a/src/api/java/buildcraft/api/statements/StatementParameterItemStack.java +++ /dev/null @@ -1,109 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.statements; - -import java.util.Objects; - -import javax.annotation.Nonnull; - -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public class StatementParameterItemStack implements IStatementParameter { - // needed because ItemStack.EMPTY doesn't have @Nonnull applied to it :/ - @Nonnull - private static final ItemStack EMPTY_STACK; - - static { - ItemStack stack = ItemStack.EMPTY; - if (stack == null) throw new Error("Somehow ItemStack.EMPTY was null!"); - EMPTY_STACK = stack; - } - - @Nonnull - protected ItemStack stack = EMPTY_STACK; - - @Override - public TextureAtlasSprite getGuiSprite() { - return null; - } - - @Nonnull - @Override - public ItemStack getItemStack() { - return stack; - } - - @Override - public boolean onClick(IStatementContainer source, IStatement stmt, ItemStack stack, StatementMouseClick mouse) { - if (stack != null) { - this.stack = stack.copy(); - this.stack.setCount(1); - } else { - this.stack = EMPTY_STACK; - } - return true; - } - - @Override - public void writeToNBT(NBTTagCompound compound) { - if (!stack.isEmpty()) { - NBTTagCompound tagCompound = new NBTTagCompound(); - stack.writeToNBT(tagCompound); - compound.setTag("stack", tagCompound); - } - } - - @Override - public void readFromNBT(NBTTagCompound compound) { - ItemStack read = new ItemStack(compound.getCompoundTag("stack")); - if (read.isEmpty()) { - stack = EMPTY_STACK; - } else { - stack = read; - } - } - - @Override - public boolean equals(Object object) { - if (object instanceof StatementParameterItemStack) { - StatementParameterItemStack param = (StatementParameterItemStack) object; - - return ItemStack.areItemStacksEqual(stack, param.stack) && ItemStack.areItemStackTagsEqual(stack, param.stack); - } else { - return false; - } - } - - @Override - public int hashCode() { - return Objects.hashCode(stack); - } - - @Override - public String getDescription() { - if (stack.isEmpty()) { - return ""; - } else { - return stack.getDisplayName(); - } - } - - @Override - public String getUniqueTag() { - return "buildcraft:stack"; - } - - @Override - public IStatementParameter rotateLeft() { - return this; - } - - @Override - public IStatementParameter[] getPossible(IStatementContainer source, IStatement stmt) { - return null; - } -} diff --git a/src/api/java/buildcraft/api/statements/StatementSlot.java b/src/api/java/buildcraft/api/statements/StatementSlot.java deleted file mode 100755 index b3306b4bd..000000000 --- a/src/api/java/buildcraft/api/statements/StatementSlot.java +++ /dev/null @@ -1,45 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License 1.0, or MMPL. Please check the contents - * of the license located in http://www.mod-buildcraft.com/MMPL-1.0.txt */ -package buildcraft.api.statements; - -import java.util.Arrays; -import java.util.Objects; - -import buildcraft.api.core.EnumPipePart; - -public class StatementSlot { - public IStatement statement; - public IStatementParameter[] parameters; - public EnumPipePart part = EnumPipePart.CENTER; - - @Override - public boolean equals(Object o) { - if (!(o instanceof StatementSlot)) { - return false; - } - StatementSlot s = (StatementSlot) o; - if (s.statement != statement || parameters.length != s.parameters.length) { - return false; - } - for (int i = 0; i < parameters.length; i++) { - IStatementParameter p1 = parameters[i]; - IStatementParameter p2 = s.parameters[i]; - if (p1 == null) { - if (p2 != null) return false; - continue; - } - if (p2 == null) return false; - if (!(p1.equals(p2))) { - return false; - } - } - return true; - } - - @Override - public int hashCode() { - return Objects.hash(statement, Arrays.deepHashCode(parameters)); - } -} diff --git a/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java b/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java deleted file mode 100755 index 1d7989aa0..000000000 --- a/src/api/java/buildcraft/api/statements/containers/IRedstoneStatementContainer.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.statements.containers; - -import net.minecraft.util.EnumFacing; - -public interface IRedstoneStatementContainer { - /** Get the redstone input from a given side. - * - * @param side The side - use "null" for maximum input. - * @return The redstone input, from 0 to 15. */ - int getRedstoneInput(EnumFacing side); - - /** Set the redstone input for a given side. - * - * @param side The side - use "null" for all sides. - * @return Whether the set was successful. */ - boolean setRedstoneOutput(EnumFacing side, int value); -} diff --git a/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java b/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java deleted file mode 100755 index b65ace45a..000000000 --- a/src/api/java/buildcraft/api/statements/containers/ISidedStatementContainer.java +++ /dev/null @@ -1,10 +0,0 @@ -package buildcraft.api.statements.containers; - -import net.minecraft.util.EnumFacing; - -import buildcraft.api.statements.IStatementContainer; - -/** Created by asie on 3/14/15. */ -public interface ISidedStatementContainer extends IStatementContainer { - EnumFacing getSide(); -} diff --git a/src/api/java/buildcraft/api/statements/package-info.java b/src/api/java/buildcraft/api/statements/package-info.java deleted file mode 100755 index 7dd2c74e6..000000000 --- a/src/api/java/buildcraft/api/statements/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.1", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements") -package buildcraft.api.statements; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/tablet/ITablet.java b/src/api/java/buildcraft/api/tablet/ITablet.java deleted file mode 100755 index e88a4cf36..000000000 --- a/src/api/java/buildcraft/api/tablet/ITablet.java +++ /dev/null @@ -1,19 +0,0 @@ -package buildcraft.api.tablet; - -import net.minecraft.nbt.NBTTagCompound; - -import net.minecraftforge.fml.relauncher.Side; - -public interface ITablet { - Side getSide(); - - void refreshScreen(TabletBitmap data); - - int getScreenWidth(); - - int getScreenHeight(); - - void launchProgram(String name); - - void sendMessage(NBTTagCompound compound); -} diff --git a/src/api/java/buildcraft/api/tablet/TabletAPI.java b/src/api/java/buildcraft/api/tablet/TabletAPI.java deleted file mode 100755 index 3d669838f..000000000 --- a/src/api/java/buildcraft/api/tablet/TabletAPI.java +++ /dev/null @@ -1,20 +0,0 @@ -package buildcraft.api.tablet; - -import java.util.HashMap; -import java.util.Map; - -public final class TabletAPI { - private static final Map programs = new HashMap<>(); - - private TabletAPI() { - - } - - public static void registerProgram(TabletProgramFactory factory) { - programs.put(factory.getName(), factory); - } - - public static TabletProgramFactory getProgram(String name) { - return programs.get(name); - } -} diff --git a/src/api/java/buildcraft/api/tablet/TabletBitmap.java b/src/api/java/buildcraft/api/tablet/TabletBitmap.java deleted file mode 100755 index 82b236b9f..000000000 --- a/src/api/java/buildcraft/api/tablet/TabletBitmap.java +++ /dev/null @@ -1,55 +0,0 @@ -package buildcraft.api.tablet; - -public class TabletBitmap { - public final int width, height; - protected int[] data; - - public TabletBitmap(int width, int height) { - this.width = width; - this.height = height; - this.data = new int[width * height]; - } - - public TabletBitmap(ITablet tablet) { - this(tablet.getScreenWidth(), tablet.getScreenHeight()); - } - - public int[] getData() { - return data; - } - - public int get(int x, int y) { - if (x < 0 || y < 0 || x >= width || y >= height) { - return 0; - } - return data[y * width + x]; - } - - public void set(int x, int y, int shade) { - if (x < 0 || y < 0 || x >= width || y >= height) { - return; - } - data[y * width + x] = shade; - } - - public void set(int x, int y, TabletBitmap bitmap) { - for (int i = 0; i < bitmap.height; i++) { - if (i >= height) { - break; - } - for (int h = 0; h < bitmap.width; h++) { - if (h >= width) { - break; - } - - set(x + h, y + i, bitmap.get(h, i)); - } - } - } - - public TabletBitmap duplicate() { - TabletBitmap cloned = new TabletBitmap(this.width, this.height); - cloned.data = this.data.clone(); - return cloned; - } -} diff --git a/src/api/java/buildcraft/api/tablet/TabletProgram.java b/src/api/java/buildcraft/api/tablet/TabletProgram.java deleted file mode 100755 index ea098f47c..000000000 --- a/src/api/java/buildcraft/api/tablet/TabletProgram.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.tablet; - -import net.minecraft.nbt.NBTTagCompound; - -public abstract class TabletProgram { - public void tick(float time) { - - } - - public boolean hasEnded() { - return false; - } - - public void receiveMessage(NBTTagCompound compound) { - - } -} diff --git a/src/api/java/buildcraft/api/tablet/TabletProgramFactory.java b/src/api/java/buildcraft/api/tablet/TabletProgramFactory.java deleted file mode 100755 index 8f3bb414c..000000000 --- a/src/api/java/buildcraft/api/tablet/TabletProgramFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -package buildcraft.api.tablet; - -public abstract class TabletProgramFactory { - /** Create an instance of the tablet program specified by this Factory. - * - * Both parameters are mutable and can be edited freely; however, the NBTTagCompound will only be synchronized after - * you leave the program. - * - * Please note that the program runs client-side SOLELY. For server-side queries, you must implement a custom - * communications protocol. - * - * @param tablet - * @return An instance of the TabletProgram. */ - public abstract TabletProgram create(ITablet tablet); - - public abstract String getName(); - - public abstract TabletBitmap getIcon(); -} diff --git a/src/api/java/buildcraft/api/tablet/TabletTicker.java b/src/api/java/buildcraft/api/tablet/TabletTicker.java deleted file mode 100755 index 33656fb80..000000000 --- a/src/api/java/buildcraft/api/tablet/TabletTicker.java +++ /dev/null @@ -1,36 +0,0 @@ -package buildcraft.api.tablet; - -/** Utility class for capturing tablet ticks every X seconds. */ -public class TabletTicker { - private final float tickTime; - private float time = 0.0F; - private int ticked = 0; - - public TabletTicker(float tickTime) { - this.tickTime = tickTime; - } - - public void add(float time) { - this.time += time; - - while (this.time >= tickTime) { - this.time -= tickTime; - ticked++; - } - } - - public int getTicks() { - return ticked; - } - - public boolean tick() { - boolean oldTicked = ticked > 0; - ticked = 0; - return oldTicked; - } - - public void reset() { - ticked = 0; - time = 0; - } -} diff --git a/src/api/java/buildcraft/api/tablet/package-info.java b/src/api/java/buildcraft/api/tablet/package-info.java deleted file mode 100755 index cc87d8657..000000000 --- a/src/api/java/buildcraft/api/tablet/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tablet") -package buildcraft.api.tablet; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/template/ITemplateHandler.java b/src/api/java/buildcraft/api/template/ITemplateHandler.java deleted file mode 100644 index e0dac1bf8..000000000 --- a/src/api/java/buildcraft/api/template/ITemplateHandler.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2017 SpaceToad and the BuildCraft team - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. - */ - -package buildcraft.api.template; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface ITemplateHandler { - boolean handle(World world, BlockPos pos, EntityPlayer player, ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/template/ITemplateRegistry.java b/src/api/java/buildcraft/api/template/ITemplateRegistry.java deleted file mode 100644 index ec6d25049..000000000 --- a/src/api/java/buildcraft/api/template/ITemplateRegistry.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2017 SpaceToad and the BuildCraft team - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. - */ - -package buildcraft.api.template; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import buildcraft.api.core.EnumHandlerPriority; - -public interface ITemplateRegistry { - /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL} */ - default void addHandler(ITemplateHandler handler) { - addHandler(handler, EnumHandlerPriority.NORMAL); - } - - void addHandler(ITemplateHandler handler, EnumHandlerPriority priority); - - boolean handle(World world, BlockPos pos, EntityPlayer player, ItemStack stack); -} diff --git a/src/api/java/buildcraft/api/template/TemplateApi.java b/src/api/java/buildcraft/api/template/TemplateApi.java deleted file mode 100644 index 423c70eaf..000000000 --- a/src/api/java/buildcraft/api/template/TemplateApi.java +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright (c) 2017 SpaceToad and the BuildCraft team - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. - */ - -package buildcraft.api.template; - -public class TemplateApi { - public static ITemplateRegistry templateRegistry; -} diff --git a/src/api/java/buildcraft/api/tiles/IControllable.java b/src/api/java/buildcraft/api/tiles/IControllable.java deleted file mode 100755 index ac9483635..000000000 --- a/src/api/java/buildcraft/api/tiles/IControllable.java +++ /dev/null @@ -1,28 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.tiles; - -/** This interface should be implemented by any Tile Entity which wishes to have non-redstone automation (for example, - * BuildCraft Gates, but also other mods which implement it, e.g. OpenComputers). */ -public interface IControllable { - enum Mode { - ON, - OFF, - LOOP; - - public static final Mode[] VALUES = values(); - } - - /** Get the current control mode of the Tile Entity. - * - * @return */ - Mode getControlMode(); - - /** Set the mode of the Tile Entity. - * - * @param mode - * @return True if this control mode is accepted. */ - boolean setControlMode(Mode mode, boolean simulate); -} diff --git a/src/api/java/buildcraft/api/tiles/IDebuggable.java b/src/api/java/buildcraft/api/tiles/IDebuggable.java deleted file mode 100755 index 4e5cb3d5d..000000000 --- a/src/api/java/buildcraft/api/tiles/IDebuggable.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.tiles; - -import java.util.List; - -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public interface IDebuggable { - /** Get the debug information from a tile entity as a list of strings, used for the F3 debug menu. The left and - * right parameters correspond to the sides of the F3 screen. - * - * @param side The side the block was clicked on, may be null if we don't know, or is the "centre" side */ - @SideOnly(Side.CLIENT) - void getDebugInfo(List left, List right, EnumFacing side); -} diff --git a/src/api/java/buildcraft/api/tiles/IHasWork.java b/src/api/java/buildcraft/api/tiles/IHasWork.java deleted file mode 100755 index fa8719644..000000000 --- a/src/api/java/buildcraft/api/tiles/IHasWork.java +++ /dev/null @@ -1,14 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.tiles; - -/** This interface should be implemented by any Tile Entity which carries out work (crafting, ore processing, mining, et - * cetera). */ -public interface IHasWork { - /** Check if the Tile Entity is currently doing any work. - * - * @return True if the Tile Entity is doing work. */ - boolean hasWork(); -} diff --git a/src/api/java/buildcraft/api/tiles/IHeatable.java b/src/api/java/buildcraft/api/tiles/IHeatable.java deleted file mode 100755 index d789ab564..000000000 --- a/src/api/java/buildcraft/api/tiles/IHeatable.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.tiles; - -/** This interface should be implemented by Tile Entities which have an internal heat value. */ -public interface IHeatable { - /** @return The minimum heat value, in degrees. */ - double getMinHeatValue(); - - /** @return The preferred heat value, in degrees. */ - double getIdealHeatValue(); - - /** @return The maximum heat value, in degrees. */ - double getMaxHeatValue(); - - /** @return The current heat value, in degrees. */ - double getCurrentHeatValue(); - - /** Set the heat of the tile. - * - * @param value Heat value, in degrees. - * @return The heat the tile has after the set. */ - double setHeatValue(double value); -} diff --git a/src/api/java/buildcraft/api/tiles/ITileAreaProvider.java b/src/api/java/buildcraft/api/tiles/ITileAreaProvider.java deleted file mode 100755 index 89a7c1456..000000000 --- a/src/api/java/buildcraft/api/tiles/ITileAreaProvider.java +++ /dev/null @@ -1,10 +0,0 @@ -package buildcraft.api.tiles; - -import net.minecraft.util.math.BlockPos; - -import buildcraft.api.core.IAreaProvider; - -/** Used for more fine-grained control of whether or not a machine connects to the provider here. */ -public interface ITileAreaProvider extends IAreaProvider { - boolean isValidFromLocation(BlockPos pos); -} diff --git a/src/api/java/buildcraft/api/tiles/TilesAPI.java b/src/api/java/buildcraft/api/tiles/TilesAPI.java deleted file mode 100644 index 38478d512..000000000 --- a/src/api/java/buildcraft/api/tiles/TilesAPI.java +++ /dev/null @@ -1,46 +0,0 @@ -package buildcraft.api.tiles; - -import javax.annotation.Nonnull; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityInject; - -import buildcraft.api.core.CapabilitiesHelper; - -public class TilesAPI { - @Nonnull - public static final Capability CAP_CONTROLLABLE; - - @Nonnull - public static final Capability CAP_HAS_WORK; - - @Nonnull - public static final Capability CAP_HEATABLE; - - @Nonnull - public static final Capability CAP_TILE_AREA_PROVIDER; - - @CapabilityInject(IControllable.class) - private static final Capability CAP_CONTROLLABLE_FIRST = null; - - @CapabilityInject(IHasWork.class) - private static final Capability CAP_HAS_WORK_FIRST = null; - - @CapabilityInject(IHeatable.class) - private static final Capability CAP_HEATABLE_FIRST = null; - - @CapabilityInject(ITileAreaProvider.class) - private static final Capability CAP_TILE_AREA_PROVIDER_FIRST = null; - - static { - CapabilitiesHelper.registerCapability(IControllable.class); - CapabilitiesHelper.registerCapability(IHasWork.class); - CapabilitiesHelper.registerCapability(IHeatable.class); - CapabilitiesHelper.registerCapability(ITileAreaProvider.class); - - CAP_CONTROLLABLE = CapabilitiesHelper.ensureRegistration(CAP_CONTROLLABLE_FIRST, IControllable.class); - CAP_HAS_WORK = CapabilitiesHelper.ensureRegistration(CAP_HAS_WORK_FIRST, IHasWork.class); - CAP_HEATABLE = CapabilitiesHelper.ensureRegistration(CAP_HEATABLE_FIRST, IHeatable.class); - CAP_TILE_AREA_PROVIDER = CapabilitiesHelper.ensureRegistration(CAP_TILE_AREA_PROVIDER_FIRST, ITileAreaProvider.class); - } -} diff --git a/src/api/java/buildcraft/api/tiles/package-info.java b/src/api/java/buildcraft/api/tiles/package-info.java deleted file mode 100755 index d4c217fc3..000000000 --- a/src/api/java/buildcraft/api/tiles/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tiles") -package buildcraft.api.tiles; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/tools/IToolWrench.java b/src/api/java/buildcraft/api/tools/IToolWrench.java deleted file mode 100755 index 9201b5560..000000000 --- a/src/api/java/buildcraft/api/tools/IToolWrench.java +++ /dev/null @@ -1,32 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.tools; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.RayTraceResult; - -/*** Implement this interface on subclasses of Item to have that item work as a wrench for buildcraft */ -public interface IToolWrench { - - /*** Called to ensure that the wrench can be used. - * - * @param player - The player doing the wrenching - * @param hand - Which hand was holding the wrench - * @param wrench - The item stack that holds the wrench - * @param rayTrace - The object that is being wrenched - * - * @return true if wrenching is allowed, false if not */ - boolean canWrench(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace); - - /*** Callback after the wrench has been used. This can be used to decrease durability or for other purposes. - * - * @param player - The player doing the wrenching - * @param hand - Which hand was holding the wrench - * @param wrench - The item stack that holds the wrench - * @param rayTrace - The object that is being wrenched */ - void wrenchUsed(EntityPlayer player, EnumHand hand, ItemStack wrench, RayTraceResult rayTrace); -} diff --git a/src/api/java/buildcraft/api/tools/package-info.java b/src/api/java/buildcraft/api/tools/package-info.java deleted file mode 100755 index 873fba1b0..000000000 --- a/src/api/java/buildcraft/api/tools/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|tools") -package buildcraft.api.tools; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/transport/EnumWirePart.java b/src/api/java/buildcraft/api/transport/EnumWirePart.java deleted file mode 100755 index f05ff8e44..000000000 --- a/src/api/java/buildcraft/api/transport/EnumWirePart.java +++ /dev/null @@ -1,81 +0,0 @@ -package buildcraft.api.transport; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumFacing.AxisDirection; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.Vec3d; - -public enum EnumWirePart { - EAST_UP_SOUTH(true, true, true), - EAST_UP_NORTH(true, true, false), - EAST_DOWN_SOUTH(true, false, true), - EAST_DOWN_NORTH(true, false, false), - WEST_UP_SOUTH(false, true, true), - WEST_UP_NORTH(false, true, false), - WEST_DOWN_SOUTH(false, false, true), - WEST_DOWN_NORTH(false, false, false); - - public static final EnumWirePart[] VALUES = values(); - - public final AxisDirection x, y, z; - - /** The bounding box for rendering a wire or selecting an already-placed wire. */ - public final AxisAlignedBB boundingBox; - - /** The bounding box that is used when adding pipe wire to a pipe */ - public final AxisAlignedBB boundingBoxPossible; - - EnumWirePart(boolean x, boolean y, boolean z) { - this.x = x ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; - this.y = y ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; - this.z = z ? AxisDirection.POSITIVE : AxisDirection.NEGATIVE; - double x1 = this.x.getOffset() * (5 / 16.0) + 0.5; - double y1 = this.y.getOffset() * (5 / 16.0) + 0.5; - double z1 = this.z.getOffset() * (5 / 16.0) + 0.5; - double x2 = this.x.getOffset() * (4 / 16.0) + 0.5; - double y2 = this.y.getOffset() * (4 / 16.0) + 0.5; - double z2 = this.z.getOffset() * (4 / 16.0) + 0.5; - this.boundingBox = new AxisAlignedBB(x1, y1, z1, x2, y2, z2); - - Vec3d center = new Vec3d(0.5, 0.5, 0.5); - Vec3d edge = new Vec3d(x ? 0.75 : 0.25, y ? 0.75 : 0.25, z ? 0.75 : 0.25); - this.boundingBoxPossible = new AxisAlignedBB(center.xCoord, center.yCoord, center.zCoord, edge.xCoord, - edge.yCoord, edge.zCoord); - } - - public AxisDirection getDirection(EnumFacing.Axis axis) { - switch (axis) { - case X: - return x; - case Y: - return y; - case Z: - return z; - default: - return null; - } - } - - public static EnumWirePart get(int x, int y, int z) { - boolean bx = (x % 2 + 2) % 2 == 1; - boolean by = (y % 2 + 2) % 2 == 1; - boolean bz = (z % 2 + 2) % 2 == 1; - return get(bx, by, bz); - } - - public static EnumWirePart get(boolean x, boolean y, boolean z) { - if (x) { - if (y) { - return z ? EAST_UP_SOUTH : EAST_UP_NORTH; - } else { - return z ? EAST_DOWN_SOUTH : EAST_DOWN_NORTH; - } - } else { - if (y) { - return z ? WEST_UP_SOUTH : WEST_UP_NORTH; - } else { - return z ? WEST_DOWN_SOUTH : WEST_DOWN_NORTH; - } - } - } -} diff --git a/src/api/java/buildcraft/api/transport/IInjectable.java b/src/api/java/buildcraft/api/transport/IInjectable.java deleted file mode 100755 index 2aeebd671..000000000 --- a/src/api/java/buildcraft/api/transport/IInjectable.java +++ /dev/null @@ -1,27 +0,0 @@ -package buildcraft.api.transport; - -import javax.annotation.Nonnull; - -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -/** Interface for pipes to implement if they can accept items in a similar fashion to BC pipes. */ -public interface IInjectable { - /** Tests to see if this pipe can accept items from the given direction. Useless to call this if you are going to - * call {@link #injectItem(ItemStack, boolean, EnumFacing, EnumDyeColor, double)} straight after. */ - boolean canInjectItems(EnumFacing from); - - /** Offers an ItemStack for addition to the pipe. Will be rejected if the pipe doesn't accept items from that side. - * This should never be called on the client side! Implementors are free to throw an exception if be called on the - * client side. - * - * @param stack ItemStack offered for addition. Do not manipulate this! - * @param doAdd If false no actual addition should take place. Implementors should simulate. - * @param from Orientation the ItemStack is offered from. - * @param color The color of the item to be added to the pipe, or null for no color. - * @param speed The speed of the item to be added (in blocks per tick) or {@code <=0} if a default should be used. - * @return The left over stack that was not accepted. */ - @Nonnull - ItemStack injectItem(@Nonnull ItemStack stack, boolean doAdd, EnumFacing from, EnumDyeColor color, double speed); -} diff --git a/src/api/java/buildcraft/api/transport/IItemPluggable.java b/src/api/java/buildcraft/api/transport/IItemPluggable.java deleted file mode 100755 index 704318e67..000000000 --- a/src/api/java/buildcraft/api/transport/IItemPluggable.java +++ /dev/null @@ -1,24 +0,0 @@ -package buildcraft.api.transport; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; - -import buildcraft.api.transport.pipe.IPipeHolder; -import buildcraft.api.transport.pluggable.PipePluggable; - -/** Designates an item that can be placed onto a pipe as a {@link PipePluggable}. */ -public interface IItemPluggable { - /** Called when this item is placed onto a pipe holder. This can return null if this item does not make a valid - * pluggable. Note that if you return a non-null pluggable then it will *definitely* be added to the pipe, and you - * are responsible for making all the effects yourself (like the sound effect). - * - * @param stack The stack that holds this item - * @param holder The pipe holder - * @param side The side that the pluggable should be placed on - * @return A pluggable to place onto the pipe */ - PipePluggable onPlace(@Nonnull ItemStack stack, IPipeHolder holder, EnumFacing side, EntityPlayer player, EnumHand hand); -} diff --git a/src/api/java/buildcraft/api/transport/IStripesActivator.java b/src/api/java/buildcraft/api/transport/IStripesActivator.java deleted file mode 100755 index a0dd7c878..000000000 --- a/src/api/java/buildcraft/api/transport/IStripesActivator.java +++ /dev/null @@ -1,16 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.transport; - -import javax.annotation.Nonnull; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -public interface IStripesActivator { - boolean sendItem(@Nonnull ItemStack itemStack, EnumFacing from); - - void dropItem(@Nonnull ItemStack itemStack, EnumFacing from); -} diff --git a/src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java b/src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java deleted file mode 100755 index 888cac43e..000000000 --- a/src/api/java/buildcraft/api/transport/IStripesHandlerBlock.java +++ /dev/null @@ -1,18 +0,0 @@ -package buildcraft.api.transport; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface IStripesHandlerBlock { - - /** @param world - * @param pos - * @param direction - * @param player - * @param activator - * @return True if this broke a block, false otherwise (note that this handler MUST NOT return false if it has - * changed the world in any way) */ - boolean handle(World world, BlockPos pos, EnumFacing direction, EntityPlayer player, IStripesActivator activator); -} diff --git a/src/api/java/buildcraft/api/transport/IStripesHandlerItem.java b/src/api/java/buildcraft/api/transport/IStripesHandlerItem.java deleted file mode 100755 index 6512be8cb..000000000 --- a/src/api/java/buildcraft/api/transport/IStripesHandlerItem.java +++ /dev/null @@ -1,30 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.transport; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumHand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface IStripesHandlerItem { - - /** Called to handle the given {@link ItemStack} within the world. Note that the player's inventory will be empty, - * except that the target stack will be set into its {@link EnumHand#MAIN_HAND}. Any items left in the players - * inventory will be returned back through the activator with - * {@link IStripesActivator#sendItem(ItemStack, EnumFacing)} - * - * @param world - * @param pos - * @param direction - * @param stack The {@link ItemStack} being used - * @param player - * @param activator - * @return True if this used the item, false otherwise (note that this handler MUST NOT return false if it has - * changed the world in any way) */ - boolean handle(World world, BlockPos pos, EnumFacing direction, ItemStack stack, EntityPlayer player, IStripesActivator activator); -} diff --git a/src/api/java/buildcraft/api/transport/IStripesRegistry.java b/src/api/java/buildcraft/api/transport/IStripesRegistry.java deleted file mode 100755 index ae6980603..000000000 --- a/src/api/java/buildcraft/api/transport/IStripesRegistry.java +++ /dev/null @@ -1,41 +0,0 @@ -package buildcraft.api.transport; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import buildcraft.api.core.EnumHandlerPriority; - -public interface IStripesRegistry { - /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL} */ - default void addHandler(IStripesHandlerItem handler) { - addHandler(handler, EnumHandlerPriority.NORMAL); - } - - void addHandler(IStripesHandlerItem handler, EnumHandlerPriority priority); - - /** Adds a handler with a {@link EnumHandlerPriority} of {@linkplain EnumHandlerPriority#NORMAL NORMAL} */ - default void addHandler(IStripesHandlerBlock handler) { - addHandler(handler, EnumHandlerPriority.NORMAL); - } - - void addHandler(IStripesHandlerBlock handler, EnumHandlerPriority priority); - - /** @param pos The position of the stripes pipe. - * @return True if a handler handled the itemstack, false otherwise (and so nothing has been done) */ - boolean handleItem(World world, - BlockPos pos, - EnumFacing direction, - ItemStack stack, - EntityPlayer player, - IStripesActivator activator); - - /** @return True if a handler broke a block, false otherwise (and so nothing has been done) */ - boolean handleBlock(World world, - BlockPos pos, - EnumFacing direction, - EntityPlayer player, - IStripesActivator activator); -} diff --git a/src/api/java/buildcraft/api/transport/IWireManager.java b/src/api/java/buildcraft/api/transport/IWireManager.java deleted file mode 100755 index 942c3ab58..000000000 --- a/src/api/java/buildcraft/api/transport/IWireManager.java +++ /dev/null @@ -1,24 +0,0 @@ -package buildcraft.api.transport; - -import net.minecraft.item.EnumDyeColor; - -import buildcraft.api.transport.pipe.IPipeHolder; - -public interface IWireManager { - - IPipeHolder getHolder(); - - void updateBetweens(boolean recursive); - - EnumDyeColor getColorOfPart(EnumWirePart part); - - EnumDyeColor removePart(EnumWirePart part); - - boolean addPart(EnumWirePart part, EnumDyeColor colour); - - boolean hasPartOfColor(EnumDyeColor color); - - boolean isPowered(EnumWirePart part); - - boolean isAnyPowered(EnumDyeColor color); -} diff --git a/src/api/java/buildcraft/api/transport/WireNode.java b/src/api/java/buildcraft/api/transport/WireNode.java deleted file mode 100755 index 5430b6438..000000000 --- a/src/api/java/buildcraft/api/transport/WireNode.java +++ /dev/null @@ -1,61 +0,0 @@ -package buildcraft.api.transport; - -import java.util.EnumMap; -import java.util.Map; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumFacing.AxisDirection; -import net.minecraft.util.math.BlockPos; - -public class WireNode { - public final BlockPos pos; - public final EnumWirePart part; - private final int hash; - - public WireNode(BlockPos pos, EnumWirePart part) { - this.pos = pos; - this.part = part; - hash = pos.hashCode() * 31 + part.hashCode(); - } - - @Override - public int hashCode() { - return hash; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - WireNode other = (WireNode) obj; - return part == other.part // - && pos.equals(other.pos); - } - - @Override - public String toString() { - return "(" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ", " + part + ")"; - } - - public WireNode offset(EnumFacing face) { - int nx = (part.x == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetX(); - int ny = (part.y == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetY(); - int nz = (part.z == AxisDirection.POSITIVE ? 1 : 0) + face.getFrontOffsetZ(); - EnumWirePart nPart = EnumWirePart.get(nx, ny, nz); - if (nx < 0 || ny < 0 || nz < 0 || nx > 1 || ny > 1 || nz > 1) { - return new WireNode(pos.offset(face), nPart); - } else { - return new WireNode(pos, nPart); - } - } - - public Map getAllPossibleConnections() { - Map map = new EnumMap<>(EnumFacing.class); - - for (EnumFacing face : EnumFacing.VALUES) { - map.put(face, offset(face)); - } - return map; - } -} diff --git a/src/api/java/buildcraft/api/transport/package-info.java b/src/api/java/buildcraft/api/transport/package-info.java deleted file mode 100755 index 004c271a1..000000000 --- a/src/api/java/buildcraft/api/transport/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -@API(apiVersion = "5.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|transport") -package buildcraft.api.transport; - -import net.minecraftforge.fml.common.API; diff --git a/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java b/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java deleted file mode 100755 index d4ca9ab26..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/ICustomPipeConnection.java +++ /dev/null @@ -1,13 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.block.state.IBlockState; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -public interface ICustomPipeConnection { - /** @return How long the connecting pipe should extend for, in addition to its normal 4/16f connection. Values less - * than or equal to -4 / 16.0f indicate that the pipe will not connect at all, and will render - * as it it was not connected. */ - float getExtension(World world, BlockPos pos, EnumFacing face, IBlockState state); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java b/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java deleted file mode 100755 index bded1911d..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IFlowFluid.java +++ /dev/null @@ -1,30 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.capability.IFluidHandler; - -import buildcraft.api.core.IFluidFilter; -import buildcraft.api.core.IFluidHandlerAdv; - -public interface IFlowFluid { - /** @param millibuckets - * @param from - * @param filter The fluidstack that the extracted fluid must match, or null for any fluid. - * @return The fluidstack extracted and inserted into the pipe. */ - FluidStack tryExtractFluid(int millibuckets, EnumFacing from, FluidStack filter); - - /** Advanced version of {@link #tryExtractFluid(int, EnumFacing, FluidStack)}. Note that this only works for - * instances of {@link IFluidHandler} that ALSO extends {@link IFluidHandlerAdv} - * - * @param millibuckets - * @param from - * @param filter A filter to try and match fluids. - * @return The fluidstack extracted and inserted into the pipe. If {@link ActionResult#getType()} equals - * {@link EnumActionResult#PASS} then it means that the {@link IFluidHandler} didn't implement - * {@link IFluidHandlerAdv} and you should call the basic version, if you can. */ - ActionResult tryExtractFluidAdv(int millibuckets, EnumFacing from, IFluidFilter filter); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowItems.java b/src/api/java/buildcraft/api/transport/pipe/IFlowItems.java deleted file mode 100755 index 91a8b3afa..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IFlowItems.java +++ /dev/null @@ -1,32 +0,0 @@ -package buildcraft.api.transport.pipe; - -import javax.annotation.Nonnull; - -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -import buildcraft.api.core.IStackFilter; -import buildcraft.api.transport.IInjectable; - -public interface IFlowItems extends IInjectable { - /** Attempts to extract items from the inventory connected to this pipe on the given side. - * - * @param count The maximum number of items to extract - * @param from The direction to extract from. - * @param colour The colour that extracted items should be painted. - * @param filter The filter to determine what can be extracted. - * @return The number of items extracted. */ - int tryExtractItems(int count, EnumFacing from, EnumDyeColor colour, IStackFilter filter); - - /** Inserts an item directly into the centre of this pipe, going in the given direction. This should ONLY be called - * from an instance of {@link PipeBehaviour}, as otherwise it can lead to problems. (For example crashing if a pipe - * contains an item that the pipe behaviour doesn't expect). - * - * @param stack ItemStack offered for addition. Do not manipulate this! - * @param from Orientation the ItemStack should pretend to be coming from. - * @param colour The colour of the item to be added to the pipe, or null for no colour. - * @param speed The speed of the item to be added (in blocks per tick) or {@code <=0} if a default should be - * used. */ - void insertItemsForce(@Nonnull ItemStack stack, EnumFacing from, EnumDyeColor colour, double speed); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IFlowPower.java b/src/api/java/buildcraft/api/transport/pipe/IFlowPower.java deleted file mode 100755 index 051d0ad1c..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IFlowPower.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.util.EnumFacing; - -import buildcraft.api.mj.IMjPassiveProvider; - -public interface IFlowPower { - /** Makes this pipe reconfigure itself, possibly due to the addition of new modules. */ - void reconfigure(); - - /** Attempts to extract power from the {@link IMjPassiveProvider} connected to this pipe on the given side. - * - * @param maxPower The Maximum amount of power that can be extracted. - * @param from The side (of this pipe) to take power from. - * @return The amount of power extracted. */ - long tryExtractPower(long maxPower, EnumFacing from); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java b/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java deleted file mode 100755 index 1d2d37700..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IItemPipe.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.transport.pipe; - -/** To be implemented by the real item pipe in Transport mod, but leaves knowledge for classes that do not have direct - * dependency on transport. */ -public interface IItemPipe { - PipeDefinition getDefinition(); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipe.java b/src/api/java/buildcraft/api/transport/pipe/IPipe.java deleted file mode 100755 index 8f3d51e15..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IPipe.java +++ /dev/null @@ -1,36 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.item.EnumDyeColor; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.common.capabilities.ICapabilityProvider; - -public interface IPipe extends ICapabilityProvider { - IPipeHolder getHolder(); - - PipeDefinition getDefinition(); - - PipeBehaviour getBehaviour(); - - PipeFlow getFlow(); - - EnumDyeColor getColour(); - - void setColour(EnumDyeColor colour); - - void markForUpdate(); - - TileEntity getConnectedTile(EnumFacing side); - - IPipe getConnectedPipe(EnumFacing side); - - boolean isConnected(EnumFacing side); - - ConnectedType getConnectedType(EnumFacing side); - - enum ConnectedType { - TILE, - PIPE - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java b/src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java deleted file mode 100755 index f981c9ea2..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IPipeBehaviourRenderer.java +++ /dev/null @@ -1,11 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.client.renderer.VertexBuffer; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public interface IPipeBehaviourRenderer { - void render(B behaviour, double x, double y, double z, float partialTicks, VertexBuffer vb); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java b/src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java deleted file mode 100755 index 55a514286..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IPipeConnection.java +++ /dev/null @@ -1,26 +0,0 @@ -/** Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team http://www.mod-buildcraft.com - * - * The BuildCraft API is distributed under the terms of the MIT License. Please check the contents of the license, which - * should be located as "LICENSE.API" in the BuildCraft source code distribution. */ -package buildcraft.api.transport.pipe; - -import net.minecraft.util.EnumFacing; - -@Deprecated -// TODO: Test to see if this is necessary! (Or perhaps make it a capability) -public interface IPipeConnection { - - enum ConnectOverride { - - CONNECT, - DISCONNECT, - DEFAULT - } - - /** Allows you to override pipe connection logic. - * - * @param type - * @param with - * @return CONNECT to force a connection, DISCONNECT to force no connection, and DEFAULT to let the pipe decide. */ - ConnectOverride overridePipeConnection(Object/*IPipeTile.PipeType*/ type, EnumFacing with); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java b/src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java deleted file mode 100755 index 787f9e99d..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IPipeFlowRenderer.java +++ /dev/null @@ -1,12 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.client.renderer.VertexBuffer; - -public interface IPipeFlowRenderer { - /** @param flow The flow to render - * @param x - * @param y - * @param z - * @param vb The (optional) vertex buffer that you can render into. Note that you can still do GL stuff. */ - void render(F flow, double x, double y, double z, float partialTicks, VertexBuffer vb); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java b/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java deleted file mode 100755 index 9d75f8777..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IPipeHolder.java +++ /dev/null @@ -1,108 +0,0 @@ -package buildcraft.api.transport.pipe; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.mojang.authlib.GameProfile; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import net.minecraftforge.common.capabilities.Capability; - -import buildcraft.api.statements.containers.IRedstoneStatementContainer; -import buildcraft.api.transport.IWireManager; -import buildcraft.api.transport.pluggable.PipePluggable; - -/** Designates a tile that can contain a pipe, up to 6 sided pluggables. */ -public interface IPipeHolder extends IRedstoneStatementContainer { - World getPipeWorld(); - - BlockPos getPipePos(); - - TileEntity getPipeTile(); - - IPipe getPipe(); - - @Nullable - PipePluggable getPluggable(EnumFacing side); - - @Nullable - TileEntity getNeighbourTile(EnumFacing side); - - @Nullable - IPipe getNeighbourPipe(EnumFacing side); - - /** Gets the given capability going outwards from the pipe. This will test the - * {@link PipePluggable#getInternalCapability(Capability)} first, and the look at the neighbouring tile. */ - @Nullable - T getCapabilityFromPipe(EnumFacing side, @Nonnull Capability capability); - - IWireManager getWireManager(); - - GameProfile getOwner(); - - /** @return True if at least 1 handler received this event, false if not. */ - boolean fireEvent(PipeEvent event); - - void scheduleRenderUpdate(); - - /** @param parts The parts that want to send a network update. */ - void scheduleNetworkUpdate(PipeMessageReceiver... parts); - - /** Schedules a GUI network update, that is only the players who currently have a pipe element open in a GUI will be - * updated. - * - * @param parts The parts that want to send a network update. */ - void scheduleNetworkGuiUpdate(PipeMessageReceiver... parts); - - /** Sends a custom message from a pluggable or pipe centre to the server/client (depending on which side this is - * currently on). */ - void sendMessage(PipeMessageReceiver to, IWriter writer); - - void sendGuiMessage(PipeMessageReceiver to, IWriter writer); - - /** Called on the server whenever a gui container object is opened. */ - void onPlayerOpen(EntityPlayer player); - - /** Called on the server whenever a gui container object is closed. */ - void onPlayerClose(EntityPlayer player); - - enum PipeMessageReceiver { - BEHAVIOUR(null), - FLOW(null), - PLUGGABLE_DOWN(EnumFacing.DOWN), - PLUGGABLE_UP(EnumFacing.UP), - PLUGGABLE_NORTH(EnumFacing.NORTH), - PLUGGABLE_SOUTH(EnumFacing.SOUTH), - PLUGGABLE_WEST(EnumFacing.WEST), - PLUGGABLE_EAST(EnumFacing.EAST), - WIRES(null); - // Wires are updated differently (they never use this API) - - public static final PipeMessageReceiver[] VALUES = values(); - public static final PipeMessageReceiver[] PLUGGABLES = new PipeMessageReceiver[6]; - - static { - for (PipeMessageReceiver type : VALUES) { - if (type.face != null) { - PLUGGABLES[type.face.ordinal()] = type; - } - } - } - - public final EnumFacing face; - - PipeMessageReceiver(EnumFacing face) { - this.face = face; - } - } - - interface IWriter { - void write(PacketBuffer buffer); - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java b/src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java deleted file mode 100755 index 23672c6bf..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/IPipeRegistry.java +++ /dev/null @@ -1,17 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.util.ResourceLocation; - -public interface IPipeRegistry { - PipeDefinition getDefinition(ResourceLocation identifier); - - IItemPipe registerPipeAndItem(PipeDefinition definition); - - void registerPipe(PipeDefinition definition); - - void setItemForPipe(PipeDefinition definition, IItemPipe item); - - IItemPipe getItemForPipe(PipeDefinition definition); - - Iterable getAllRegisteredPipes(); -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeApi.java b/src/api/java/buildcraft/api/transport/pipe/PipeApi.java deleted file mode 100755 index 7fffadd16..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeApi.java +++ /dev/null @@ -1,149 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.util.IdentityHashMap; -import java.util.Map; - -import javax.annotation.Nonnull; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.CapabilityInject; - -import buildcraft.api.core.CapabilitiesHelper; -import buildcraft.api.mj.MjAPI; -import buildcraft.api.transport.IInjectable; -import buildcraft.api.transport.IStripesRegistry; -import buildcraft.api.transport.pluggable.IPluggableRegistry; -import buildcraft.api.transport.pluggable.PipePluggable; - -/** The central holding class for all pipe related registers and methods. */ -public final class PipeApi { - public static IPipeRegistry pipeRegistry; - public static IPluggableRegistry pluggableRegistry; - public static IStripesRegistry stripeRegistry; - public static PipeFlowType flowStructure; - public static PipeFlowType flowItems; - public static PipeFlowType flowFluids; - public static PipeFlowType flowPower; - - /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced - * by BuildCraft Transport to config-defined values. */ - public static FluidTransferInfo fluidInfoDefault = new FluidTransferInfo(20, 10); - - /** The default transfer information used if a pipe definition has not been registered. Note that this is replaced - * by BuildCraft Transport to config-defined values. */ - public static PowerTransferInfo powerInfoDefault = PowerTransferInfo.createFromResistance(8 * MjAPI.MJ, MjAPI.MJ / 32, false); - - public static final Map fluidTransferData = new IdentityHashMap<>(); - public static final Map powerTransferData = new IdentityHashMap<>(); - - @Nonnull - public static final Capability CAP_PIPE_HOLDER; - - @Nonnull - public static final Capability CAP_PIPE; - - @Nonnull - public static final Capability CAP_PLUG; - - @Nonnull - public static final Capability CAP_INJECTABLE; - - public static FluidTransferInfo getFluidTransferInfo(PipeDefinition def) { - FluidTransferInfo info = fluidTransferData.get(def); - if (info == null) { - return fluidInfoDefault; - } else { - return info; - } - } - - public static PowerTransferInfo getPowerTransferInfo(PipeDefinition def) { - PowerTransferInfo info = powerTransferData.get(def); - if (info == null) { - return powerInfoDefault; - } else { - return info; - } - } - - public static class FluidTransferInfo { - /** Controls the maximum amount of fluid that can be transferred around and out of a pipe per tick. Note that - * this does not affect the flow rate coming into the pipe. */ - public final int transferPerTick; - - /** Controls how long the pipe should delay incoming fluids by. Minimum value is 1, because of the way that - * fluids are handled internally. This value is multiplied by the fluids viscosity, and divided by 100 to give - * the actual delay. */ - public final double transferDelayMultiplier; - - public FluidTransferInfo(int transferPerTick, int transferDelay) { - this.transferPerTick = transferPerTick; - if (transferDelay <= 0) { - transferDelay = 1; - } - this.transferDelayMultiplier = transferDelay; - } - } - - public static class PowerTransferInfo { - public final long transferPerTick; - public final long lossPerTick; - /** The percentage resistance per tick. Should be a value between 0 and {@link MjAPI#MJ} */ - public final long resistancePerTick; - public final boolean isReceiver; - - /** Sets resistancePerTick to be equal to lossPerTick when full power is being transferred, scaling down to 0. - * - * @param transferPerTick - * @param lossPerTick - * @param isReceiver */ - public static PowerTransferInfo createFromLoss(long transferPerTick, long lossPerTick, boolean isReceiver) { - return new PowerTransferInfo(transferPerTick, lossPerTick, lossPerTick * MjAPI.MJ / transferPerTick, isReceiver); - } - - /** Sets lossPerTick to be equal to resistancePerTick when full power is being transferred. - * - * @param transferPerTick - * @param resistancePerTick - * @param isReceiver */ - public static PowerTransferInfo createFromResistance(long transferPerTick, long resistancePerTick, boolean isReceiver) { - return new PowerTransferInfo(transferPerTick, resistancePerTick, resistancePerTick * transferPerTick / MjAPI.MJ, isReceiver); - } - - public PowerTransferInfo(long transferPerTick, long lossPerTick, long resistancePerTick, boolean isReceiver) { - if (transferPerTick < 10) { - transferPerTick = 10; - } - this.transferPerTick = transferPerTick; - this.lossPerTick = lossPerTick; - this.resistancePerTick = resistancePerTick; - this.isReceiver = isReceiver; - } - } - - // Internals - - @CapabilityInject(IPipeHolder.class) - private static Capability capPipeHolder; - - @CapabilityInject(IPipe.class) - private static Capability capPipe; - - @CapabilityInject(PipePluggable.class) - private static Capability capPlug; - - @CapabilityInject(IInjectable.class) - private static Capability capInjectable; - - static { - CapabilitiesHelper.registerCapability(IPipe.class); - CapabilitiesHelper.registerCapability(IPipeHolder.class); - CapabilitiesHelper.registerCapability(IInjectable.class); - CapabilitiesHelper.registerCapability(PipePluggable.class); - - CAP_PIPE = CapabilitiesHelper.ensureRegistration(capPipe, IPipe.class); - CAP_PLUG = CapabilitiesHelper.ensureRegistration(capPlug, PipePluggable.class); - CAP_PIPE_HOLDER = CapabilitiesHelper.ensureRegistration(capPipeHolder, IPipeHolder.class); - CAP_INJECTABLE = CapabilitiesHelper.ensureRegistration(capInjectable, IInjectable.class); - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java b/src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java deleted file mode 100755 index 04650bfb2..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeApiClient.java +++ /dev/null @@ -1,26 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import buildcraft.api.transport.pluggable.IPlugDynamicRenderer; -import buildcraft.api.transport.pluggable.IPluggableStaticBaker; -import buildcraft.api.transport.pluggable.PipePluggable; -import buildcraft.api.transport.pluggable.PluggableModelKey; - -@SideOnly(Side.CLIENT) -public enum PipeApiClient { - INSTANCE; - - public static IClientRegistry registry; - - public interface IClientRegistry { - void registerRenderer(Class flowClass, IPipeFlowRenderer renderer); - - void registerRenderer(Class behaviourClass, IPipeBehaviourRenderer renderer); - -

    void registerRenderer(Class plugClass, IPlugDynamicRenderer

    renderer); - -

    void registerBaker(Class keyClass, IPluggableStaticBaker

    renderer); - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java b/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java deleted file mode 100755 index 2e919038f..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeBehaviour.java +++ /dev/null @@ -1,72 +0,0 @@ -package buildcraft.api.transport.pipe; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.RayTraceResult; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.relauncher.Side; - -import buildcraft.api.core.EnumPipePart; - -public abstract class PipeBehaviour implements ICapabilityProvider { - public final IPipe pipe; - - public PipeBehaviour(IPipe pipe) { - this.pipe = pipe; - } - - public PipeBehaviour(IPipe pipe, NBTTagCompound nbt) { - this.pipe = pipe; - } - - public NBTTagCompound writeToNbt() { - NBTTagCompound nbt = new NBTTagCompound(); - - return nbt; - } - - public void writePayload(PacketBuffer buffer, Side side) {} - - public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) {} - - public int getTextureIndex(EnumFacing face) { - return 0; - } - - // Event handling - - public boolean canConnect(EnumFacing face, PipeBehaviour other) { - return true; - } - - public boolean canConnect(EnumFacing face, TileEntity oTile) { - return true; - } - - public boolean onPipeActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, EnumPipePart part) { - return false; - } - - public void onEntityCollide(Entity entity) {} - - public void onTick() {} - - @Override - public boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return getCapability(capability, facing) != null; - } - - @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - return null; - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java b/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java deleted file mode 100755 index 987203442..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeConnectionAPI.java +++ /dev/null @@ -1,42 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.util.Map; - -import com.google.common.collect.Maps; - -import net.minecraft.block.Block; - -/** Use this class to register blocks with custom block sizes so that pipes can connect to them properly. Note that you - * do not need to register a custom pipe connection if your block implements ICustomPipeConnection. The registered - * version does not override your own implementation. */ -public final class PipeConnectionAPI { - private static final Map connections = Maps.newHashMap(); - private static final ICustomPipeConnection NOTHING = (world, pos, face, state) -> 0; - - /** Register a block with a custom connection. Useful if you don't own the block class or are adding it for some-one - * else. - * - * @param block The block instance - * @param connection The connection instance */ - public static void registerConnection(Block block, ICustomPipeConnection connection) { - connections.put(block, connection); - } - - /** Ensures that a particular block will always have the default connection, no matter what the bounding box the the - * block is. */ - public static void registerConnectionAsNothing(Block block) { - connections.put(block, NOTHING); - } - - /** Gets the current custom connection that the block uses. Will be null if nothing has been set. */ - public static ICustomPipeConnection getCustomConnection(Block block) { - if (block instanceof ICustomPipeConnection) { - return (ICustomPipeConnection) block; - } - ICustomPipeConnection connection = connections.get(block); - if (connection != null) { - return connection; - } - return null; - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java b/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java deleted file mode 100755 index 6e223512d..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeDefinition.java +++ /dev/null @@ -1,159 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ResourceLocation; - -import net.minecraftforge.fml.common.Loader; -import net.minecraftforge.fml.common.ModContainer; - -public final class PipeDefinition { - public final ResourceLocation identifier; - public final IPipeCreator logicConstructor; - public final IPipeLoader logicLoader; - public final PipeFlowType flowType; - public final String[] textures; - public final int itemTextureTop, itemTextureCenter, itemTextureBottom; - - public PipeDefinition(PipeDefinitionBuilder builder) { - this.identifier = builder.identifier; - this.textures = new String[builder.textureSuffixes.length]; - for (int i = 0; i < textures.length; i++) { - textures[i] = builder.texturePrefix + builder.textureSuffixes[i]; - } - this.logicConstructor = builder.logicConstructor; - this.logicLoader = builder.logicLoader; - this.flowType = builder.flowType; - this.itemTextureTop = builder.itemTextureTop; - this.itemTextureCenter = builder.itemTextureCenter; - this.itemTextureBottom = builder.itemTextureBottom; - } - - @FunctionalInterface - public interface IPipeCreator { - PipeBehaviour createBehaviour(IPipe t); - } - - @FunctionalInterface - public interface IPipeLoader { - PipeBehaviour loadBehaviour(IPipe t, NBTTagCompound u); - } - - public static class PipeDefinitionBuilder { - public ResourceLocation identifier; - public String texturePrefix; - public String[] textureSuffixes = { "" }; - public IPipeCreator logicConstructor; - public IPipeLoader logicLoader; - public PipeFlowType flowType; - public int itemTextureTop = 0; - public int itemTextureCenter = 0; - public int itemTextureBottom = 0; - - public PipeDefinitionBuilder() {} - - public PipeDefinitionBuilder(ResourceLocation identifier, IPipeCreator logicConstructor, IPipeLoader logicLoader, PipeFlowType flowType) { - this.identifier = identifier; - this.logicConstructor = logicConstructor; - this.logicLoader = logicLoader; - this.flowType = flowType; - } - - public PipeDefinitionBuilder idTexPrefix(String both) { - return id(both).texPrefix(both); - } - - public PipeDefinitionBuilder idTex(String both) { - return id(both).tex(both); - } - - private static String getActiveModId() { - ModContainer mod = Loader.instance().activeModContainer(); - if (mod == null) { - throw new IllegalStateException("Cannot interact with PipeDefinition outside of an actively scoped mod!"); - } - return mod.getModId(); - } - - public PipeDefinitionBuilder id(String post) { - identifier = new ResourceLocation(getActiveModId(), post); - return this; - } - - public PipeDefinitionBuilder tex(String prefix, String... suffixes) { - return texPrefix(prefix).texSuffixes(suffixes); - } - - /** Sets the texture prefix to be: [current_mod_id]:pipes/[prefix] where [current_mod_id] is the - * modid of the currently loaded mod, and [prefix] is the string parameter given. - * - * @return this */ - public PipeDefinitionBuilder texPrefix(String prefix) { - return texPrefixDirect(getActiveModId() + ":pipes/" + prefix); - } - - /** Sets the {@link #texturePrefix} to the input string, without any additions or changes (unlike - * {@link #texPrefix(String)}) - * - * @return this */ - public PipeDefinitionBuilder texPrefixDirect(String prefix) { - texturePrefix = prefix; - return this; - } - - /** Sets {@link #textureSuffixes} to the given array, or to {""} if the argument list is empty or - * null. - * - * @return this. */ - public PipeDefinitionBuilder texSuffixes(String... suffixes) { - if (suffixes == null || suffixes.length == 0) { - textureSuffixes = new String[] { "" }; - } else { - textureSuffixes = suffixes; - } - return this; - } - - public PipeDefinitionBuilder itemTex(int all) { - itemTextureTop = all; - itemTextureCenter = all; - itemTextureBottom = all; - return this; - } - - public PipeDefinitionBuilder itemTex(int top, int center, int bottom) { - itemTextureTop = top; - itemTextureCenter = center; - itemTextureBottom = bottom; - return this; - } - - public PipeDefinitionBuilder logic(IPipeCreator creator, IPipeLoader loader) { - logicConstructor = creator; - logicLoader = loader; - return this; - } - - public PipeDefinitionBuilder flowItem() { - return flow(PipeApi.flowItems); - } - - public PipeDefinitionBuilder flowFluid() { - return flow(PipeApi.flowFluids); - } - - public PipeDefinitionBuilder flowPower() { - return flow(PipeApi.flowPower); - } - - public PipeDefinitionBuilder flow(PipeFlowType flow) { - flowType = flow; - return this; - } - - public PipeDefinition define() { - PipeDefinition def = new PipeDefinition(this); - PipeApi.pipeRegistry.registerPipe(def); - return def; - } - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java b/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java deleted file mode 100755 index 1c6935e5e..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEvent.java +++ /dev/null @@ -1,41 +0,0 @@ -package buildcraft.api.transport.pipe; - -/** The base class for all pipe events. Some event classes can be cancelled with {@link #cancel()}, however this will - * only have an effect if {@link #canBeCancelled} is true. Refer to individual classes for information on if they can - * be cancelled, and what cancelling the event does. */ -public abstract class PipeEvent { - public final boolean canBeCancelled; - public final IPipeHolder holder; - private boolean canceled = false; - - public PipeEvent(IPipeHolder holder) { - this(false, holder); - } - - protected PipeEvent(boolean canBeCancelled, IPipeHolder holder) { - this.canBeCancelled = canBeCancelled; - this.holder = holder; - } - - public void cancel() { - if (canBeCancelled) { - canceled = true; - } - } - - public boolean isCanceled() { - return canceled; - } - - /** Called after every event handler has received this pipe event, to pick up simple mistakes when implementing pipe - * event handlers. - * - * @return Null if there are no state errors, or a message containing information about what is wrong (although this - * may be incomplete) */ - public String checkStateForErrors() { - if (canceled & !canBeCancelled) { - return "Somehow cancelled an event that isn't marked as such!"; - } - return null; - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java deleted file mode 100755 index ea6b37acc..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventActionActivate.java +++ /dev/null @@ -1,18 +0,0 @@ -package buildcraft.api.transport.pipe; - -import buildcraft.api.core.EnumPipePart; -import buildcraft.api.statements.IAction; -import buildcraft.api.statements.IStatementParameter; - -public class PipeEventActionActivate extends PipeEvent { - public final IAction action; - public final IStatementParameter[] params; - public final EnumPipePart part; - - public PipeEventActionActivate(IPipeHolder holder, IAction action, IStatementParameter[] params, EnumPipePart part) { - super(holder); - this.action = action; - this.params = params; - this.part = part; - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java deleted file mode 100755 index e557bccfd..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventFluid.java +++ /dev/null @@ -1,225 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; - -import javax.annotation.Nonnull; - -import com.google.common.collect.Lists; - -import net.minecraft.util.EnumFacing; - -import net.minecraftforge.fluids.FluidStack; - -public abstract class PipeEventFluid extends PipeEvent { - - public final IFlowFluid flow; - - protected PipeEventFluid(IPipeHolder holder, IFlowFluid flow) { - super(holder); - this.flow = flow; - } - - protected PipeEventFluid(boolean canBeCancelled, IPipeHolder holder, IFlowFluid flow) { - super(canBeCancelled, holder); - this.flow = flow; - } - - public static class TryInsert extends PipeEventFluid { - public final EnumFacing from; - /** The incoming fluidstack. Currently changing this does nothing. */ - @Nonnull - public final FluidStack fluid; - - public TryInsert(IPipeHolder holder, IFlowFluid flow, EnumFacing from, @Nonnull FluidStack fluid) { - super(true, holder, flow); - this.from = from; - this.fluid = fluid; - } - } - - /** Fired after collecting the amounts of fluid that can be moved from each pipe part into the centre. */ - public static class PreMoveToCentre extends PipeEventFluid { - /** The fluid that is being moved. Future versions of BC *might* allow more than one fluid type per pipe, but - * for the moment the API doesn't allow pipes to do this. */ - public final FluidStack fluid; - - /** The maximum amount of fluid that the centre pipe could accept. */ - public final int totalAcceptable; - - /** Array of {@link EnumFacing#getIndex()} to the maximum amount of fluid that a given side can offer. DO NOT - * CHANGE THIS! */ - public final int[] totalOffered; - - // Used for checking the state - private final int[] totalOfferedCheck; - - /** Array of {@link EnumFacing#getIndex()} to the amount of fluid that the given side will actually offer to the - * centre. This should *never* be larger than */ - public final int[] actuallyOffered; - - public PreMoveToCentre(IPipeHolder holder, IFlowFluid flow, FluidStack fluid, int totalAcceptable, int[] totalOffered, int[] actuallyOffered) { - super(holder, flow); - this.fluid = fluid; - this.totalAcceptable = totalAcceptable; - this.totalOffered = totalOffered; - totalOfferedCheck = Arrays.copyOf(totalOffered, totalOffered.length); - this.actuallyOffered = actuallyOffered; - } - - @Override - public String checkStateForErrors() { - for (int i = 0; i < totalOffered.length; i++) { - if (totalOffered[i] != totalOfferedCheck[i]) { - return "Changed totalOffered"; - } - if (actuallyOffered[i] > totalOffered[i]) { - return "actuallyOffered[" + i + "](=" + actuallyOffered[i] + ") shouldn't be greater than totalOffered[" + i + "](=" + totalOffered[i] + ")"; - } - } - return super.checkStateForErrors(); - } - } - - /** Fired after {@link PreMoveToCentre} when all of the amounts have been totalled up. */ - public static class OnMoveToCentre extends PipeEventFluid { - /** The fluid that is being moved. Future versions of BC *might* allow more than one fluid type per pipe, but - * for the moment the API doesn't allow pipes to do this. */ - public final FluidStack fluid; - - public final int[] fluidLeavingSide; - public final int[] fluidEnteringCentre; - - // Used for checking the state maximums - private final int[] fluidLeaveCheck, fluidEnterCheck; - - public OnMoveToCentre(IPipeHolder holder, IFlowFluid flow, FluidStack fluid, int[] fluidLeavingSide, int[] fluidEnteringCentre) { - super(holder, flow); - this.fluid = fluid; - this.fluidLeavingSide = fluidLeavingSide; - this.fluidEnteringCentre = fluidEnteringCentre; - fluidLeaveCheck = Arrays.copyOf(fluidLeavingSide, fluidLeavingSide.length); - fluidEnterCheck = Arrays.copyOf(fluidEnteringCentre, fluidEnteringCentre.length); - } - - @Override - public String checkStateForErrors() { - for (int i = 0; i < fluidLeavingSide.length; i++) { - if (fluidLeavingSide[i] > fluidLeaveCheck[i]) { - return "fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] + ") shouldn't be bigger than its original value!(=" + fluidLeaveCheck[i] + ")"; - } - if (fluidEnteringCentre[i] > fluidEnterCheck[i]) { - return "fluidEnteringCentre[" + i + "](=" + fluidEnteringCentre[i] + ") shouldn't be bigger than its original value!(=" + fluidEnterCheck[i] + ")"; - } - if (fluidEnteringCentre[i] > fluidLeavingSide[i]) { - return "fluidEnteringCentre[" + i + "](=" + fluidEnteringCentre[i] + ") shouldn't be bigger than fluidLeavingSide[" + i + "](=" + fluidLeavingSide[i] + ")"; - } - } - return super.checkStateForErrors(); - } - } - - public static class SideCheck extends PipeEventFluid { - public final FluidStack fluid; - - /** The priorities of each side. Stored inversely to the values given, so a higher priority will have a lower - * value than a lower priority. */ - private final int[] priority = new int[6]; - private final EnumSet allowed = EnumSet.allOf(EnumFacing.class); - - public SideCheck(IPipeHolder holder, IFlowFluid flow, FluidStack fluid) { - super(holder, flow); - this.fluid = fluid; - } - - /** Checks to see if a side if allowed. Note that this may return true even though a later handler might - * disallow a side, so you should only use this to skip checking a side (for example a diamond pipe might not - * check the filters for a specific side if its already been disallowed) */ - public boolean isAllowed(EnumFacing side) { - return allowed.contains(side); - } - - /** Disallows the specific side(s) from being a destination for the item. If no sides are allowed, then the - * fluid will stay in the current pipe section. */ - public void disallow(EnumFacing... sides) { - for (EnumFacing side : sides) { - allowed.remove(side); - } - } - - public void disallowAll(Collection sides) { - allowed.removeAll(sides); - } - - public void disallowAllExcept(EnumFacing... sides) { - allowed.retainAll(Lists.newArrayList(sides)); - } - - public void disallowAllExcept(Collection sides) { - allowed.retainAll(sides); - } - - public void disallowAll() { - allowed.clear(); - } - - public void increasePriority(EnumFacing side) { - increasePriority(side, 1); - } - - public void increasePriority(EnumFacing side, int by) { - priority[side.ordinal()] -= by; - } - - public void decreasePriority(EnumFacing side) { - decreasePriority(side, 1); - } - - public void decreasePriority(EnumFacing side, int by) { - increasePriority(side, -by); - } - - public EnumSet getOrder() { - if (allowed.isEmpty()) { - return EnumSet.noneOf(EnumFacing.class); - } - if (allowed.size() == 1) { - return allowed; - } - outer_loop: while (true) { - int val = priority[0]; - for (int i = 1; i < priority.length; i++) { - if (priority[i] != val) { - break outer_loop; - } - } - // No need to work out the order when all destinations have the same priority - return allowed; - } - - int[] ordered = Arrays.copyOf(priority, 6); - Arrays.sort(ordered); - int last = 0; - for (int i = 0; i < 6; i++) { - int current = ordered[i]; - if (i != 0 && current == last) { - continue; - } - last = current; - EnumSet set = EnumSet.noneOf(EnumFacing.class); - for (EnumFacing face : EnumFacing.VALUES) { - if (allowed.contains(face)) { - if (priority[face.ordinal()] == current) { - set.add(face); - } - } - } - if (set.size() > 0) { - return set; - } - } - return EnumSet.noneOf(EnumFacing.class); - } - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java deleted file mode 100755 index 15eaecaf5..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Designates a method that will receive a pipe event. The method must be public and take a single parameter that - * extends {@link PipeEvent}.
    - * An example is:
    - * - @PipeEventHandler
    - public void sideCheck(PipeEventItem.SideCheck sideCheck) {
    - // Logic omitted
    - } - * - *
    */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface PipeEventHandler { - /** Designates the priority that the handler will be given. All handlers in vanilla BuildCraft use - * {@link PipeEventPriority#NORMAL}, so this is given for other pipe mods to fire before or after all BC logic has - * taken place. */ - PipeEventPriority priority() default PipeEventPriority.NORMAL; - - /** If true then the event handler will be called even if an event has already been cancelled. */ - boolean receiveCancelled() default false; -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java deleted file mode 100755 index ab33955d9..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventItem.java +++ /dev/null @@ -1,371 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.EnumDyeColor; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; - -public abstract class PipeEventItem extends PipeEvent { - - public final IFlowItems flow; - - protected PipeEventItem(IPipeHolder holder, IFlowItems flow) { - super(holder); - this.flow = flow; - } - - protected PipeEventItem(boolean canBeCancelled, IPipeHolder holder, IFlowItems flow) { - super(canBeCancelled, holder); - this.flow = flow; - } - - // ################ - // - // Misc events - // - // ################ - - /** Fires whenever item insertion is attempted. The item might have been extracted by the pipe behaviour, inserted - * by another pipe or even a different kind of tile. Note that you have no way of telling what caused this event. */ - public static class TryInsert extends PipeEventItem { - public final EnumDyeColor colour; - public final EnumFacing from; - /** The itemstack that is attempting to be inserted. NEVER CHANGE THIS! */ - @Nonnull - public final ItemStack attempting; - /** The count of items that are being accepted into this pipe. Starts off at the stack count of - * {@link #attempting} */ - public int accepted; - - public TryInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, @Nonnull ItemStack attempting) { - super(true, holder, flow); - this.colour = colour; - this.from = from; - this.attempting = attempting; - this.accepted = attempting.getCount(); - } - - /** Stops the item from being accepted. */ - @Override - public void cancel() { - super.cancel(); - } - } - - public static abstract class ReachDest extends PipeEventItem { - public EnumDyeColor colour; - @Nonnull - private ItemStack stack; - - public ReachDest(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack) { - super(holder, flow); - this.colour = colour; - this.stack = stack; - } - - @Nonnull - public ItemStack getStack() { - return this.stack; - } - - public void setStack(ItemStack stack) { - if (stack == null) { - throw new NullPointerException("stack"); - } else { - this.stack = stack; - } - } - } - - /** Fired after {@link TryInsert} (if some items were allowed in) to modify the incoming itemstack or its colour. */ - public static class OnInsert extends ReachDest { - public final EnumFacing from; - - public OnInsert(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { - super(holder, flow, colour, stack); - this.from = from; - } - } - - /** Fired whenever an item reaches the centre of a pipe. Note that you *can* change the itemstack or the colour. */ - public static class ReachCenter extends ReachDest { - public final EnumFacing from; - - public ReachCenter(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { - super(holder, flow, colour, stack); - this.from = from; - } - } - - /** Fired whenever an item reaches the end of a pipe. Note that you *can* change the itemstack or the colour. */ - public static class ReachEnd extends ReachDest { - public final EnumFacing to; - - public ReachEnd(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing to) { - super(holder, flow, colour, stack); - this.to = to; - } - } - - // ############################ - // - // Destination related - // - // ############################ - - /** Fired after {@link ReachCenter} to determine what sides are the items NOT allowed to go to, and the order of - * priority for the allowed sides. */ - public static class SideCheck extends PipeEventItem { - public final EnumDyeColor colour; - public final EnumFacing from; - @Nonnull - public final ItemStack stack; - - /** The priorities of each side. Stored inversely to the values given, so a higher priority will have a lower - * value than a lower priority. */ - private final int[] priority = new int[6]; - private final EnumSet allowed = EnumSet.allOf(EnumFacing.class); - - public SideCheck(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, @Nonnull ItemStack stack) { - super(holder, flow); - this.colour = colour; - this.from = from; - this.stack = stack; - } - - /** Checks to see if a side if allowed. Note that this may return true even though a later handler might - * disallow a side, so you should only use this to skip checking a side (for example a diamond pipe might not - * check the filters for a specific side if its already been disallowed) */ - public boolean isAllowed(EnumFacing side) { - return allowed.contains(side); - } - - /** Disallows the specific side(s) from being a destination for the item. If no sides are allowed, then - * {@link TryBounce} will be fired to test if the item can bounce back. */ - public void disallow(EnumFacing... sides) { - for (EnumFacing side : sides) { - allowed.remove(side); - } - } - - public void disallowAll(Collection sides) { - allowed.removeAll(sides); - } - - public void disallowAllExcept(EnumFacing... sides) { - allowed.retainAll(Lists.newArrayList(sides)); - } - - public void disallowAll() { - allowed.clear(); - } - - public void increasePriority(EnumFacing side) { - increasePriority(side, 1); - } - - public void increasePriority(EnumFacing side, int by) { - priority[side.ordinal()] -= by; - } - - public void decreasePriority(EnumFacing side) { - decreasePriority(side, 1); - } - - public void decreasePriority(EnumFacing side, int by) { - increasePriority(side, -by); - } - - public List> getOrder() { - // Skip the calculations if the size is simple - switch (allowed.size()) { - case 0: - return ImmutableList.of(); - case 1: - return ImmutableList.of(allowed); - } - outer_loop: while (true) { - int val = priority[0]; - for (int i = 1; i < priority.length; i++) { - if (priority[i] != val) { - break outer_loop; - } - } - // No need to work out the order when all destinations have the same priority - return ImmutableList.of(allowed); - } - - int[] ordered = Arrays.copyOf(priority, 6); - Arrays.sort(ordered); - int last = 0; - List> list = Lists.newArrayList(); - for (int i = 0; i < 6; i++) { - int current = ordered[i]; - if (i != 0 && current == last) { - continue; - } - last = current; - EnumSet set = EnumSet.noneOf(EnumFacing.class); - for (EnumFacing face : EnumFacing.VALUES) { - if (allowed.contains(face)) { - if (priority[face.ordinal()] == current) { - set.add(face); - } - } - } - if (set.size() > 0) { - list.add(set); - } - } - return list; - } - } - - /** Fired after {@link SideCheck} (if all sides were disallowed) to see if the item is allowed to bounce back to - * where it was inserted. */ - public static class TryBounce extends PipeEventItem { - public final EnumDyeColor colour; - public final EnumFacing from; - @Nonnull - public final ItemStack stack; - public boolean canBounce = false; - - public TryBounce(IPipeHolder holder, IFlowItems flow, EnumDyeColor colour, EnumFacing from, @Nonnull ItemStack stack) { - super(holder, flow); - this.colour = colour; - this.from = from; - this.stack = stack; - } - } - - public static class Drop extends PipeEventItem { - private final EntityItem entity; - - public Drop(IPipeHolder holder, IFlowItems flow, EntityItem entity) { - super(holder, flow); - this.entity = entity; - } - - @Nonnull - public ItemStack getStack() { - ItemStack item = entity.getEntityItem(); - return item.isEmpty() ? ItemStack.EMPTY : item; - } - - public void setStack(ItemStack stack) { - if (stack == null) { - throw new NullPointerException("stack"); - } else if (stack.isEmpty()) { - entity.setEntityItemStack(ItemStack.EMPTY); - } else { - entity.setEntityItemStack(stack); - } - } - - public EntityItem getEntity() { - return this.entity; - } - } - - /** Base class for {@link Split} and {@link FindDest}. Do not listen to this directly! */ - public static abstract class OrderedEvent extends PipeEventItem { - public final List> orderedDestinations; - - public OrderedEvent(IPipeHolder holder, IFlowItems flow, List> orderedDestinations) { - super(holder, flow); - this.orderedDestinations = orderedDestinations; - } - - public EnumSet getAllPossibleDestinations() { - EnumSet set = EnumSet.noneOf(EnumFacing.class); - for (EnumSet e : orderedDestinations) { - set.addAll(e); - } - return set; - } - - public ImmutableList generateRandomOrder() { - ImmutableList.Builder builder = ImmutableList.builder(); - for (EnumSet set : orderedDestinations) { - List faces = new ArrayList<>(set); - Collections.shuffle(faces); - builder.addAll(faces); - } - return builder.build(); - } - } - - /** Fired after {@link SideCheck} (if at least one valid side was found) or after {@link TryBounce} if no valid - * sides were detected, but it was allowed to bounce back. This event is for splitting up (or modifying) the input - * itemstack. This is most helpful for implementing full round-robin behaviour, or diamond-pipe based splitting. If - * you need to generate a random facing for each one then use {@link OrderedEvent#generateRandomOrder()}. */ - public static class Split extends OrderedEvent { - public final List items = new ArrayList<>(); - - public Split(IPipeHolder holder, IFlowItems flow, List> order, ItemEntry toSplit) { - super(holder, flow, order); - items.add(toSplit); - } - } - - /** Fired after {@link Split}. This event is for assigning a destination to each {@link ItemEntry} in - * {@link Split#items}. If you need to generate a random facing for each one then use - * {@link OrderedEvent#generateRandomOrder()}. */ - public static class FindDest extends OrderedEvent { - public final ImmutableList items; - - public FindDest(IPipeHolder holder, IFlowItems flow, List> orderedDestinations, ImmutableList items) { - super(holder, flow, orderedDestinations); - this.items = items; - } - } - - /** Fired after {@link FindDest}. */ - public static class ModifySpeed extends PipeEventItem { - public final ItemEntry item; - public final double currentSpeed; - public double targetSpeed = 0; - public double maxSpeedChange = 0; - - public ModifySpeed(IPipeHolder holder, IFlowItems flow, ItemEntry item, double initSpeed) { - super(holder, flow); - this.item = item; - currentSpeed = initSpeed; - } - - public void modifyTo(double target, double maxDelta) { - targetSpeed = target; - maxSpeedChange = maxDelta; - } - } - - /** Mostly immutable holding class for item stacks. */ - public static class ItemEntry { - public final EnumDyeColor colour; - @Nonnull - public final ItemStack stack; - public final EnumFacing from; - /** The list of the destinations to try, in order. */ - @Nullable - public List to; - - public ItemEntry(EnumDyeColor colour, @Nonnull ItemStack stack, EnumFacing from) { - this.colour = colour; - this.stack = stack; - this.from = from; - } - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java deleted file mode 100755 index 1a91c517c..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventPower.java +++ /dev/null @@ -1,73 +0,0 @@ -package buildcraft.api.transport.pipe; - -import buildcraft.api.mj.MjAPI; - -public abstract class PipeEventPower extends PipeEvent { - public final IFlowPower flow; - - protected PipeEventPower(IPipeHolder holder, IFlowPower flow) { - super(holder); - this.flow = flow; - } - - protected PipeEventPower(boolean canBeCancelled, IPipeHolder holder, IFlowPower flow) { - super(canBeCancelled, holder); - this.flow = flow; - } - - public static class Configure extends PipeEventPower { - private long maxPower = 10 * MjAPI.MJ; - /** The percentage resistance of the power pipe (as in, percentage of current power going through the pipe). - * Should be a number between 0 and {@link MjAPI#MJ} */ - private long powerResistance = -1; - /** The absolute loss of the power pipe. Negative numbers mean that this field will be populated from a default, - * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ - private long powerLoss = -1; - private boolean receiver = false; - - public Configure(IPipeHolder holder, IFlowPower flow) { - super(holder, flow); - } - - public long getMaxPower() { - return this.maxPower; - } - - public void setMaxPower(long maxPower) { - this.maxPower = maxPower; - } - - /** The absolute loss of the power pipe. Negative numbers mean that this field will be populated from a default, - * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ - public long getPowerLoss() { - return this.powerLoss; - } - - /** The absolute loss of the power pipe. Negative numbers mean that this field will be populated from a default, - * or by {@link #powerResistance} if it is set. This is capped at the value given in {@link #getMaxPower()} */ - public void setPowerLoss(long powerLoss) { - this.powerLoss = powerLoss; - } - - /** The percentage resistance of the power pipe (percentage of current power going through the pipe that will be - * lost). Should be a number between 0 and {@link MjAPI#MJ} */ - public long getPowerResistance() { - return this.powerResistance; - } - - /** The percentage resistance of the power pipe (percentage of current power going through the pipe that will be - * lost). Should be a number between 0 and {@link MjAPI#MJ} */ - public void setPowerResistance(long powerResistance) { - this.powerResistance = powerResistance; - } - - public boolean isReceiver() { - return this.receiver; - } - - /** Sets this pipe to be one that receives power from external sources. */ - public void setReceiver(boolean receiver) { - this.receiver = receiver; - } - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java deleted file mode 100755 index 21f78937a..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventPriority.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.transport.pipe; - -public enum PipeEventPriority { - PRE, - NORMAL, - POST -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java b/src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java deleted file mode 100755 index 5d96cafc2..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeEventStatement.java +++ /dev/null @@ -1,66 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.util.Collection; - -import javax.annotation.Nonnull; - -import net.minecraft.util.EnumFacing; - -import buildcraft.api.statements.IActionInternal; -import buildcraft.api.statements.IActionInternalSided; -import buildcraft.api.statements.ITriggerInternal; -import buildcraft.api.statements.ITriggerInternalSided; - -public abstract class PipeEventStatement extends PipeEvent { - public PipeEventStatement(IPipeHolder holder) { - super(holder); - } - - /** Fired when a pipe should add internal triggers to the list of all possible triggers */ - public static class AddTriggerInternal extends PipeEventStatement { - public final Collection triggers; - - public AddTriggerInternal(IPipeHolder holder, Collection triggers) { - super(holder); - this.triggers = triggers; - } - } - - /** Fired when a pipe should add internal sided triggers to the list of all possible triggers */ - public static class AddTriggerInternalSided extends PipeEventStatement { - public final Collection triggers; - - @Nonnull - public final EnumFacing side; - - public AddTriggerInternalSided(IPipeHolder holder, Collection triggers, @Nonnull EnumFacing side) { - super(holder); - this.triggers = triggers; - this.side = side; - } - } - - /** Fired when a pipe should add internal actions to the list of all possible actions */ - public static class AddActionInternal extends PipeEventStatement { - public final Collection actions; - - public AddActionInternal(IPipeHolder holder, Collection actions) { - super(holder); - this.actions = actions; - } - } - - /** Fired when a pipe should add internal actions to the list of all possible actions */ - public static class AddActionInternalSided extends PipeEventStatement { - public final Collection actions; - - @Nonnull - public final EnumFacing side; - - public AddActionInternalSided(IPipeHolder holder, Collection actions, @Nonnull EnumFacing side) { - super(holder); - this.actions = actions; - this.side = side; - } - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java b/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java deleted file mode 100755 index b941b4e73..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeFlow.java +++ /dev/null @@ -1,81 +0,0 @@ -package buildcraft.api.transport.pipe; - -import java.io.IOException; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.RayTraceResult; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.relauncher.Side; - -import buildcraft.api.core.EnumPipePart; -import buildcraft.api.transport.pipe.IPipeHolder.IWriter; -import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; - -public abstract class PipeFlow implements ICapabilityProvider { - /** The ID for completely refreshing the state of this flow. */ - public static final int NET_ID_FULL_STATE = 0; - /** The ID for updating what has changed since the last NET_ID_FULL_STATE or NET_ID_UPDATE has been sent. */ - // Wait, what? How is that a good idea or even sensible to make updates work this way? - public static final int NET_ID_UPDATE = 1; - - public final IPipe pipe; - - public PipeFlow(IPipe pipe) { - this.pipe = pipe; - } - - public PipeFlow(IPipe pipe, NBTTagCompound nbt) { - this.pipe = pipe; - } - - public NBTTagCompound writeToNbt() { - return new NBTTagCompound(); - } - - /** Writes a payload with the specified id. Standard ID's are NET_ID_FULL_STATE and NET_ID_UPDATE. */ - public void writePayload(int id, PacketBuffer buffer, Side side) {} - - /** Reads a payload with the specified id. Standard ID's are NET_ID_FULL_STATE and NET_ID_UPDATE. */ - public void readPayload(int id, PacketBuffer buffer, Side side) throws IOException {} - - public void sendPayload(int id) { - final Side side = pipe.getHolder().getPipeWorld().isRemote ? Side.CLIENT : Side.SERVER; - sendCustomPayload(id, (buf) -> writePayload(id, buf, side)); - } - - public final void sendCustomPayload(int id, IWriter writer) { - pipe.getHolder().sendMessage(PipeMessageReceiver.FLOW, buffer -> { - buffer.writeBoolean(true); - buffer.writeShort(id); - writer.write(buffer); - }); - } - - public abstract boolean canConnect(EnumFacing face, PipeFlow other); - - public abstract boolean canConnect(EnumFacing face, TileEntity oTile); - - public void onTick() {} - - public boolean onFlowActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ, EnumPipePart part) { - return false; - } - - @Override - public final boolean hasCapability(@Nonnull Capability capability, EnumFacing facing) { - return getCapability(capability, facing) != null; - } - - @Override - public T getCapability(@Nonnull Capability capability, EnumFacing facing) { - return null; - } -} diff --git a/src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java b/src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java deleted file mode 100755 index 290517012..000000000 --- a/src/api/java/buildcraft/api/transport/pipe/PipeFlowType.java +++ /dev/null @@ -1,23 +0,0 @@ -package buildcraft.api.transport.pipe; - -import net.minecraft.nbt.NBTTagCompound; - -public final class PipeFlowType { - public final IFlowCreator creator; - public final IFlowLoader loader; - - public PipeFlowType(IFlowCreator creator, IFlowLoader loader) { - this.creator = creator; - this.loader = loader; - } - - @FunctionalInterface - public interface IFlowCreator { - PipeFlow createFlow(IPipe t); - } - - @FunctionalInterface - public interface IFlowLoader { - PipeFlow loadFlow(IPipe t, NBTTagCompound u); - } -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java deleted file mode 100755 index a3ad9f329..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/IFacadePluggable.java +++ /dev/null @@ -1,11 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import net.minecraft.block.state.IBlockState; - -public interface IFacadePluggable { - IBlockState getCurrentState(); - - boolean isTransparent(); - - boolean isHollow(); -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java b/src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java deleted file mode 100755 index 916f4fe69..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/IPlugDynamicRenderer.java +++ /dev/null @@ -1,7 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import net.minecraft.client.renderer.VertexBuffer; - -public interface IPlugDynamicRenderer

    { - void render(P plug, double x, double y, double z, float partialTicks, VertexBuffer vb); -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java b/src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java deleted file mode 100755 index 300b575bf..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/IPluggableRegistry.java +++ /dev/null @@ -1,9 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import net.minecraft.util.ResourceLocation; - -public interface IPluggableRegistry { - void register(PluggableDefinition definition); - - PluggableDefinition getDefinition(ResourceLocation identifier); -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java b/src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java deleted file mode 100755 index a3f001214..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/IPluggableStaticBaker.java +++ /dev/null @@ -1,13 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import java.util.List; - -import net.minecraft.client.renderer.block.model.BakedQuad; - -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public interface IPluggableStaticBaker { - List bake(K key); -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java b/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java deleted file mode 100755 index 8ddb478bf..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/PipePluggable.java +++ /dev/null @@ -1,149 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import java.io.IOException; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.world.Explosion; -import net.minecraft.world.World; - -import net.minecraftforge.common.capabilities.Capability; -import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -import buildcraft.api.transport.pipe.IPipeHolder; -import buildcraft.api.transport.pipe.IPipeHolder.PipeMessageReceiver; - -public abstract class PipePluggable { - public final PluggableDefinition definition; - public final IPipeHolder holder; - public final EnumFacing side; - - public PipePluggable(PluggableDefinition definition, IPipeHolder holder, EnumFacing side) { - this.definition = definition; - this.holder = holder; - this.side = side; - } - - public NBTTagCompound writeToNbt() { - NBTTagCompound nbt = new NBTTagCompound(); - return nbt; - } - - /** Writes the payload that will be passed into - * {@link PluggableDefinition#loadFromBuffer(IPipeHolder, EnumFacing, PacketBuffer)} on the client. (This is called - * on the server and sent to the client). Note that this will be called *instead* of write and read payload. */ - public void writeCreationPayload(PacketBuffer buffer) { - - } - - public void writePayload(PacketBuffer buffer, Side side) { - - } - - public void readPayload(PacketBuffer buffer, Side side, MessageContext ctx) throws IOException { - - } - - public final void scheduleNetworkUpdate() { - holder.scheduleNetworkUpdate(PipeMessageReceiver.PLUGGABLES[side.ordinal()]); - } - - public void onTick() {} - - /** @return A bounding box that will be used for collisions and raytracing. */ - public abstract AxisAlignedBB getBoundingBox(); - - /** @return True if the pipe cannot connect outwards (it is blocked), or False if this does not block the pipe. */ - public boolean isBlocking() { - return false; - } - - /** Gets the value of a specified capability key, or null if the given capability is not supported at the call time. - * This is effectively {@link ICapabilityProvider}, but where - * {@link ICapabilityProvider#hasCapability(Capability, EnumFacing)} will return true when this returns a non-null - * value. */ - public T getCapability(@Nonnull Capability cap) { - return null; - } - - /** Gets the {@link Capability} that is accessible from the pipe that this is attached to. - * - * @param cap - * @return */ - public T getInternalCapability(@Nonnull Capability cap) { - return null; - } - - /** Called whenever this pluggable is removed from the pipe. */ - public void onRemove() {} - - /** @param toDrop A list containing all the items to drop (so you should add your items to this list) * */ - public void getDrops(NonNullList toDrop) { - ItemStack stack = getPickStack(); - if (!stack.isEmpty()) { - toDrop.add(stack); - } - } - - /** Called whenever this pluggable is picked by the player (similar to Block.getPickBlock) - * - * @return The stack that should be picked, or ItemStack.EMPTY if no stack can be picked from this pluggable. */ - public ItemStack getPickStack() { - return ItemStack.EMPTY; - } - - public boolean onPluggableActivate(EntityPlayer player, RayTraceResult trace, float hitX, float hitY, float hitZ) { - return false; - } - - @Nullable - public PluggableModelKey getModelRenderKey(BlockRenderLayer layer) { - return null; - } - - /** Called if the {@link IPluggableStaticBaker} returns quads with tint indexes set to - * data * 6 + key.side.ordinal(). "data" is passed in here as "tintIndex". - * - * @return The tint index to render the quad with, or -1 for default. */ - @SideOnly(Side.CLIENT) - public int getBlockColor(int tintIndex) { - return -1; - } - - /** PipePluggable version of - * {@link Block#canBeConnectedTo(net.minecraft.world.IBlockAccess, net.minecraft.util.math.BlockPos, EnumFacing)}. */ - public boolean canBeConnected() { - return false; - } - - /** PipePluggable version of - * {@link Block#isBlockSolid(net.minecraft.world.IBlockAccess, net.minecraft.util.math.BlockPos, EnumFacing)} */ - public boolean isSideSolid() { - return false; - } - - /** PipePluggable version of {@link Block#getExplosionResistance(World, BlockPos, Entity, Explosion)} */ - public float getExplosionResistance(@Nullable Entity exploder, Explosion explosion) { - return 0; - } - - public boolean canConnectToRedstone(@Nullable EnumFacing to) { - return false; - } -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java b/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java deleted file mode 100755 index 61884a668..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/PluggableDefinition.java +++ /dev/null @@ -1,69 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import javax.annotation.Nullable; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; - -import buildcraft.api.transport.pipe.IPipeHolder; - -public final class PluggableDefinition { - public final ResourceLocation identifier; - - public final IPluggableNetLoader loader; - public final IPluggableNbtReader reader; - - @Nullable - public final IPluggableCreator creator; - - public PluggableDefinition(ResourceLocation identifier, IPluggableNbtReader reader, IPluggableNetLoader loader) { - this.identifier = identifier; - this.reader = reader; - this.loader = loader; - this.creator = null; - } - - public PluggableDefinition(ResourceLocation identifier, @Nullable IPluggableCreator creator) { - this.identifier = identifier; - this.reader = creator; - this.loader = creator; - this.creator = creator; - } - - public PipePluggable readFromNbt(IPipeHolder holder, EnumFacing side, NBTTagCompound nbt) { - return reader.readFromNbt(this, holder, side, nbt); - } - - public PipePluggable loadFromBuffer(IPipeHolder holder, EnumFacing side, PacketBuffer buffer) { - return loader.loadFromBuffer(this, holder, side, buffer); - } - - // FIXME: J8 API usage + J8 default interfaces - - @FunctionalInterface - public interface IPluggableNbtReader { - PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, NBTTagCompound nbt); - } - - @FunctionalInterface - public interface IPluggableNetLoader { - PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, PacketBuffer buffer); - } - - @FunctionalInterface - public interface IPluggableCreator extends IPluggableNbtReader, IPluggableNetLoader { - @Override - default PipePluggable loadFromBuffer(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, PacketBuffer buffer) { - return createSimplePluggable(definition, holder, side); - } - - @Override - default PipePluggable readFromNbt(PluggableDefinition definition, IPipeHolder holder, EnumFacing side, NBTTagCompound nbt) { - return createSimplePluggable(definition, holder, side); - } - - PipePluggable createSimplePluggable(PluggableDefinition definition, IPipeHolder holder, EnumFacing side); - } -} diff --git a/src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java b/src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java deleted file mode 100755 index 7c832c195..000000000 --- a/src/api/java/buildcraft/api/transport/pluggable/PluggableModelKey.java +++ /dev/null @@ -1,38 +0,0 @@ -package buildcraft.api.transport.pluggable; - -import java.util.Objects; - -import net.minecraft.util.BlockRenderLayer; -import net.minecraft.util.EnumFacing; - -public abstract class PluggableModelKey { - public final BlockRenderLayer layer; - public final EnumFacing side; - private final int hash; - - public PluggableModelKey(BlockRenderLayer layer, EnumFacing side) { - if (layer != BlockRenderLayer.CUTOUT && layer != BlockRenderLayer.TRANSLUCENT) { - throw new IllegalArgumentException("Can only use CUTOUT or TRANSLUCENT at the moment (was " + layer + ")"); - } - if (side == null) throw new NullPointerException("side"); - this.layer = layer; - this.side = side; - this.hash = Objects.hash(layer, side); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; - PluggableModelKey other = (PluggableModelKey) obj; - if (layer != other.layer) return false; - if (side != other.side) return false; - return true; - } - - @Override - public int hashCode() { - return hash; - } -} diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index 9e84541cf..23fa9e84c 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -1,5 +1,6 @@ package mekanism.generators.common; +import buildcraft.api.mj.MjAPI; import io.netty.buffer.ByteBuf; import java.io.IOException; @@ -107,7 +108,7 @@ public class MekanismGenerators implements IModule } } - BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), 240, 40 * Fluid.BUCKET_VOLUME); + BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), 240 * MjAPI.MJ, 40 * Fluid.BUCKET_VOLUME); } //Update the config-dependent recipes after the recipes have actually been added in the first place From 16d2ef3960bdac5c1c93c0767cc3b7a6c305c3aa Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 10 Jul 2017 19:02:02 +0200 Subject: [PATCH 06/36] Fix wrong BC value --- src/main/java/mekanism/common/FuelHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/mekanism/common/FuelHandler.java b/src/main/java/mekanism/common/FuelHandler.java index 5c5e954a6..c00cc8f64 100644 --- a/src/main/java/mekanism/common/FuelHandler.java +++ b/src/main/java/mekanism/common/FuelHandler.java @@ -58,7 +58,7 @@ public class FuelHandler public FuelGas(IFuel bcFuel) { burnTicks = bcFuel.getTotalBurningTime() / Fluid.BUCKET_VOLUME; - energyPerTick = bcFuel.getPowerPerCycle() * MjAPI.MJ; + energyPerTick = bcFuel.getPowerPerCycle() / MjAPI.MJ; } } From f9c6dc011b59c3744ca7641f7fe2228e0cc8e99a Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 17 Jul 2017 15:30:19 +0200 Subject: [PATCH 07/36] Fix conversion rate BC-RF-Mekanism --- src/main/java/mekanism/common/FuelHandler.java | 5 ++++- .../java/mekanism/generators/common/MekanismGenerators.java | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/mekanism/common/FuelHandler.java b/src/main/java/mekanism/common/FuelHandler.java index c00cc8f64..5f984b3ce 100644 --- a/src/main/java/mekanism/common/FuelHandler.java +++ b/src/main/java/mekanism/common/FuelHandler.java @@ -58,7 +58,10 @@ public class FuelHandler public FuelGas(IFuel bcFuel) { burnTicks = bcFuel.getTotalBurningTime() / Fluid.BUCKET_VOLUME; - energyPerTick = bcFuel.getPowerPerCycle() / MjAPI.MJ; + + // getPowerPerCycle returns value in 1 BuildCraft micro MJ + // 1 BuildCraft MJ equals 20 RF + energyPerTick = bcFuel.getPowerPerCycle() / (double) MjAPI.MJ * 20 * general.FROM_RF; } } diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index 23fa9e84c..c1127992a 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -102,13 +102,13 @@ public class MekanismGenerators implements IModule { for(IFuel s : BuildcraftFuelRegistry.fuel.getFuels()) { - if(!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getFluid().getName()))) + if(s.getFluid() != null && !GasRegistry.containsGas(s.getFluid().getFluid().getName())) { GasRegistry.register(new Gas(s.getFluid().getFluid())); } } - BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), 240 * MjAPI.MJ, 40 * Fluid.BUCKET_VOLUME); + BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), (int)(240 * general.TO_RF / 20 * MjAPI.MJ), 40 * Fluid.BUCKET_VOLUME); } //Update the config-dependent recipes after the recipes have actually been added in the first place From b886d39866360598e6abbd4cf5a664d738618d77 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 17 Jul 2017 15:36:00 +0200 Subject: [PATCH 08/36] Fix wrong cast BC integration --- .../java/mekanism/generators/common/MekanismGenerators.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index c1127992a..a0ae85888 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -108,7 +108,7 @@ public class MekanismGenerators implements IModule } } - BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), (int)(240 * general.TO_RF / 20 * MjAPI.MJ), 40 * Fluid.BUCKET_VOLUME); + BuildcraftFuelRegistry.fuel.addFuel(MekanismFluids.Ethene.getFluid(), (long)(240 * general.TO_RF / 20 * MjAPI.MJ), 40 * Fluid.BUCKET_VOLUME); } //Update the config-dependent recipes after the recipes have actually been added in the first place From f6c126af4442e094816c6dc369f19e09fb65d5d4 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Mon, 17 Jul 2017 20:27:05 +0200 Subject: [PATCH 09/36] Add max energy to tooltips --- .../client/gui/GuiChemicalDissolutionChamber.java | 2 +- .../mekanism/client/gui/GuiChemicalInfuser.java | 2 +- .../mekanism/client/gui/GuiChemicalOxidizer.java | 2 +- .../java/mekanism/client/gui/GuiChemicalWasher.java | 2 +- .../java/mekanism/client/gui/GuiDigitalMiner.java | 2 +- .../java/mekanism/client/gui/GuiElectricPump.java | 2 +- .../java/mekanism/client/gui/GuiEnergyCube.java | 2 +- src/main/java/mekanism/client/gui/GuiFactory.java | 2 +- .../mekanism/client/gui/GuiFluidicPlenisher.java | 2 +- .../mekanism/client/gui/GuiInductionMatrix.java | 4 ++-- .../java/mekanism/client/gui/GuiLaserAmplifier.java | 2 +- .../java/mekanism/client/gui/GuiMatrixStats.java | 2 +- src/main/java/mekanism/client/gui/GuiRobitMain.java | 4 ++-- .../client/gui/GuiRotaryCondensentrator.java | 2 +- .../java/mekanism/client/gui/GuiTeleporter.java | 4 ++-- .../mekanism/client/gui/element/GuiEnergyGauge.java | 2 +- .../mekanism/client/gui/element/GuiPowerBar.java | 2 +- .../java/mekanism/common/item/ItemBlockMachine.java | 2 +- .../java/mekanism/common/item/ItemEnergized.java | 2 +- .../java/mekanism/common/item/ItemFreeRunners.java | 2 +- .../java/mekanism/common/util/MekanismUtils.java | 13 +++++++++++++ .../generators/client/gui/GuiIndustrialTurbine.java | 2 +- .../generators/client/gui/GuiReactorController.java | 2 +- .../generators/client/gui/GuiReactorFuel.java | 2 +- .../generators/client/gui/GuiReactorHeat.java | 2 +- .../generators/client/gui/GuiReactorStats.java | 2 +- .../generators/client/gui/GuiSolarGenerator.java | 2 +- .../generators/client/gui/GuiTurbineStats.java | 2 +- .../generators/client/gui/GuiWindGenerator.java | 2 +- .../generators/common/item/ItemBlockGenerator.java | 2 +- 30 files changed, 45 insertions(+), 32 deletions(-) diff --git a/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java b/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java index e432a9907..078ec2ec4 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java @@ -90,7 +90,7 @@ public class GuiChemicalDissolutionChamber extends GuiMekanism if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); diff --git a/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java b/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java index d235ac86d..d6b911fdc 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java @@ -106,7 +106,7 @@ public class GuiChemicalInfuser extends GuiMekanism if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); diff --git a/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java b/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java index eb2b69d9c..4bd2f30ef 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java @@ -83,7 +83,7 @@ public class GuiChemicalOxidizer extends GuiMekanism if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); diff --git a/src/main/java/mekanism/client/gui/GuiChemicalWasher.java b/src/main/java/mekanism/client/gui/GuiChemicalWasher.java index 950fae1f5..7abd33f09 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalWasher.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalWasher.java @@ -102,7 +102,7 @@ public class GuiChemicalWasher extends GuiMekanism if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java index 0b8f092b5..33f57d2c7 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java @@ -205,7 +205,7 @@ public class GuiDigitalMiner extends GuiMekanism if(xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) diff --git a/src/main/java/mekanism/client/gui/GuiElectricPump.java b/src/main/java/mekanism/client/gui/GuiElectricPump.java index 64e3ef792..958ddc9c4 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricPump.java +++ b/src/main/java/mekanism/client/gui/GuiElectricPump.java @@ -69,7 +69,7 @@ public class GuiElectricPump extends GuiMekanism { fontRendererObj.drawString(tileEntity.getName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, 0x00CD00); String text = tileEntity.fluidTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount : LangUtils.localize("gui.noFluid"); renderScaledText(text, 51, 35, 0x00CD00, 74); diff --git a/src/main/java/mekanism/client/gui/GuiEnergyCube.java b/src/main/java/mekanism/client/gui/GuiEnergyCube.java index 27ee6dd34..58334e8f7 100644 --- a/src/main/java/mekanism/client/gui/GuiEnergyCube.java +++ b/src/main/java/mekanism/client/gui/GuiEnergyCube.java @@ -53,7 +53,7 @@ public class GuiEnergyCube extends GuiMekanism public List getInfo() { return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); diff --git a/src/main/java/mekanism/client/gui/GuiFactory.java b/src/main/java/mekanism/client/gui/GuiFactory.java index f215b84ed..d34d19e4f 100644 --- a/src/main/java/mekanism/client/gui/GuiFactory.java +++ b/src/main/java/mekanism/client/gui/GuiFactory.java @@ -76,7 +76,7 @@ public class GuiFactory extends GuiMekanism if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } if(xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83) diff --git a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java index 86137ec1c..16d879c59 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java +++ b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java @@ -69,7 +69,7 @@ public class GuiFluidicPlenisher extends GuiMekanism { fontRendererObj.drawString(tileEntity.getName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getName()) / 2), 6, 0x404040); fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.finished") + ": " + LangUtils.transYesNo(tileEntity.finishedCalc), 51, 35, 0x00CD00); fontRendererObj.drawString(tileEntity.fluidTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount : LangUtils.localize("gui.noFluid"), 51, 44, 0x00CD00); diff --git a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java index 747fe2813..8213293f3 100644 --- a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java +++ b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java @@ -35,7 +35,7 @@ public class GuiInductionMatrix extends GuiMekanism public List getInfo() { return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"); } @@ -57,7 +57,7 @@ public class GuiInductionMatrix extends GuiMekanism if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } super.drawGuiContainerForegroundLayer(mouseX, mouseY); diff --git a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java index 495bdec52..22febb852 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java +++ b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java @@ -64,7 +64,7 @@ public class GuiLaserAmplifier extends GuiMekanism @Override public String getText(double level) { - return LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(level); + return LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(level, tileEntity.getMaxEnergy()); } }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 6, 10)); guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); diff --git a/src/main/java/mekanism/client/gui/GuiMatrixStats.java b/src/main/java/mekanism/client/gui/GuiMatrixStats.java index e0559be97..dd631b4c6 100644 --- a/src/main/java/mekanism/client/gui/GuiMatrixStats.java +++ b/src/main/java/mekanism/client/gui/GuiMatrixStats.java @@ -75,7 +75,7 @@ public class GuiMatrixStats extends GuiMekanism public List getInfo() { return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"); } diff --git a/src/main/java/mekanism/client/gui/GuiRobitMain.java b/src/main/java/mekanism/client/gui/GuiRobitMain.java index 8f7086a6e..bf10d97d2 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitMain.java +++ b/src/main/java/mekanism/client/gui/GuiRobitMain.java @@ -111,7 +111,7 @@ public class GuiRobitMain extends GuiMekanism { CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); fontRendererObj.drawString(LangUtils.localize("gui.robit.greeting") + " " + robit.getName() + "!", 29, 18, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.energy") + ": " + MekanismUtils.getEnergyDisplay(robit.getEnergy()), 29, 36-4, 0x00CD00); + fontRendererObj.drawString(LangUtils.localize("gui.energy") + ": " + MekanismUtils.getEnergyDisplay(robit.getEnergy(), robit.MAX_ELECTRICITY), 29, 36-4, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.robit.following") + ": " + robit.getFollowing(), 29, 45-4, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.robit.dropPickup") + ": " + robit.getDropPickup(), 29, 54-4, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.robit.owner") + ": " + owner, 29, 63-4, 0x00CD00); @@ -122,7 +122,7 @@ public class GuiRobitMain extends GuiMekanism if(xAxis >= 28 && xAxis <= 148 && yAxis >= 75 && yAxis <= 79) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(robit.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(robit.getEnergy(), robit.MAX_ELECTRICITY), xAxis, yAxis); } else if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { diff --git a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java index 38ad90d36..4cac49aba 100644 --- a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java @@ -124,7 +124,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); + drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), xAxis, yAxis); } if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) diff --git a/src/main/java/mekanism/client/gui/GuiTeleporter.java b/src/main/java/mekanism/client/gui/GuiTeleporter.java index 7c7a00cfa..0113b1997 100644 --- a/src/main/java/mekanism/client/gui/GuiTeleporter.java +++ b/src/main/java/mekanism/client/gui/GuiTeleporter.java @@ -92,7 +92,7 @@ public class GuiTeleporter extends GuiMekanism @Override public String getTooltip() { - return MekanismUtils.getEnergyDisplay(getEnergy()); + return MekanismUtils.getEnergyDisplay(getEnergy(), getMaxEnergy()); } @Override @@ -124,7 +124,7 @@ public class GuiTeleporter extends GuiMekanism @Override public String getTooltip() { - return MekanismUtils.getEnergyDisplay(getEnergy()); + return MekanismUtils.getEnergyDisplay(getEnergy(), getMaxEnergy()); } @Override diff --git a/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java b/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java index 0f14e864f..e4105fc40 100644 --- a/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java @@ -52,7 +52,7 @@ public class GuiEnergyGauge extends GuiGauge @Override public String getTooltipText() { - return infoHandler.getEnergyStorage().getEnergy() > 0 ? MekanismUtils.getEnergyDisplay(infoHandler.getEnergyStorage().getEnergy()) : LangUtils.localize("gui.empty"); + return infoHandler.getEnergyStorage().getEnergy() > 0 ? MekanismUtils.getEnergyDisplay(infoHandler.getEnergyStorage().getEnergy(), infoHandler.getEnergyStorage().getMaxEnergy()) : LangUtils.localize("gui.empty"); } public static interface IEnergyInfoHandler diff --git a/src/main/java/mekanism/client/gui/element/GuiPowerBar.java b/src/main/java/mekanism/client/gui/element/GuiPowerBar.java index 8e07de717..98f513b84 100644 --- a/src/main/java/mekanism/client/gui/element/GuiPowerBar.java +++ b/src/main/java/mekanism/client/gui/element/GuiPowerBar.java @@ -31,7 +31,7 @@ public class GuiPowerBar extends GuiElement @Override public String getTooltip() { - return MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()); + return MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()); } @Override diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index b89a13254..57709b239 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -244,7 +244,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec if(type.isElectric) { - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); } if(hasTank(itemstack) && type != MachineType.FLUID_TANK) diff --git a/src/main/java/mekanism/common/item/ItemEnergized.java b/src/main/java/mekanism/common/item/ItemEnergized.java index be5b11559..301eba34c 100644 --- a/src/main/java/mekanism/common/item/ItemEnergized.java +++ b/src/main/java/mekanism/common/item/ItemEnergized.java @@ -66,7 +66,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpec @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); } public ItemStack getUnchargedItem() diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index 49574a28c..2f952f890 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -82,7 +82,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci @Override public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); } public ItemStack getUnchargedItem() diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index cdb259d81..a5c2204dd 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -1098,6 +1098,19 @@ public final class MekanismUtils return "error"; } + + public static String getEnergyDisplay(double energy, double max) + { + if(energy == Double.MAX_VALUE) + { + return LangUtils.localize("gui.infinite"); + } + + String energyString = getEnergyDisplay(energy); + String maxString = getEnergyDisplay(max); + + return energyString + "/" + maxString; + } /** * Convert from the unit defined in the configuration to joules. diff --git a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java index 7b485ac41..069c7b06c 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java +++ b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java @@ -77,7 +77,7 @@ public class GuiIndustrialTurbine extends GuiMekanism double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(tileEntity.structure.blades, tileEntity.structure.coils*generators.turbineBladesPerCoil); return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow*energyMultiplier) + "/t"); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"))); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java index 511179fdd..b1968f619 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java @@ -41,7 +41,7 @@ public class GuiReactorController extends GuiMekanism public List getInfo() { return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java index 53e8b53a6..19b330a31 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java @@ -53,7 +53,7 @@ public class GuiReactorFuel extends GuiMekanism public List getInfo() { return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java index 4fe494ec4..8dbd7e168 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java @@ -58,7 +58,7 @@ public class GuiReactorHeat extends GuiMekanism public List getInfo() { return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java index a538404d3..22a12cfb8 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java @@ -45,7 +45,7 @@ public class GuiReactorStats extends GuiMekanism public List getInfo() { return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); diff --git a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 3692534e6..3f77222e0 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -56,7 +56,7 @@ public class GuiSolarGenerator extends GuiMekanism fontRendererObj.drawString(tileEntity.getName(), !tileEntity.fullName.contains("Advanced") ? 45 : 30, 6, 0x404040); fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.solarGenerator.sun") + ": " + tileEntity.seesSun, 51, 35, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); diff --git a/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java b/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java index 961249ae9..c7a69b862 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java @@ -41,7 +41,7 @@ public class GuiTurbineStats extends GuiMekanism double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(tileEntity.structure.blades, tileEntity.structure.coils*generators.turbineBladesPerCoil); return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow*energyMultiplier) + "/t"); } }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); diff --git a/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java index d4a10d34e..83222dafc 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java @@ -58,7 +58,7 @@ public class GuiWindGenerator extends GuiMekanism { fontRendererObj.drawString(tileEntity.getName(), 45, 6, 0x404040); fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); + fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy(), tileEntity.getMaxEnergy()), 51, 26, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.power") + ": " + powerFormat.format(MekanismUtils.convertToDisplay(generators.windGenerationMin*tileEntity.currentMultiplier)), 51, 35, 0x00CD00); fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index 096990f2b..7c5f5b54f 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -140,7 +140,7 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp } } - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack), getMaxEnergy(itemstack))); if(hasTank(itemstack)) { From cd8cbf43b1fdfbc794613896926177731c6ef564 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Tue, 18 Jul 2017 01:14:35 -0600 Subject: [PATCH 10/36] Commit changes based on feedback --- .../common/block/BlockTransmitter.java | 76 +++++++++---------- .../multipart/MultipartMekanism.java | 20 +++-- .../multipart/MultipartTransmitter.java | 2 +- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index 0419b9011..a02bda69f 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -97,10 +97,10 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - Optional tile = getTileEntitySidedPipe(worldIn.getTileEntity(pos)); - if(tile.isPresent()) + TileEntitySidedPipe tile = getTileEntitySidedPipe(worldIn.getTileEntity(pos)); + if(tile != null) { - state = state.withProperty(BlockStateTransmitter.tierProperty, tile.get().getBaseTier()); + state = state.withProperty(BlockStateTransmitter.tierProperty, tile.getBaseTier()); } return state; @@ -130,11 +130,11 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) { - Optional tile = getTileEntitySidedPipe(w.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(w.getTileEntity(pos)); - if(tile.isPresent()) + if(tile != null) { - return tile.get().getExtendedState(state); + return tile.getExtendedState(state); } else { ConnectionType[] typeArray = new ConnectionType[] {ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, @@ -148,9 +148,9 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile.isPresent() && tile.get().getTransmitterType().getSize() == Size.SMALL) + if(tile != null && tile.getTransmitterType().getSize() == Size.SMALL) { return smallSides[6]; } @@ -161,11 +161,11 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean b) { - Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile.isPresent()) + if(tile != null) { - List boxes = tile.get().getCollisionBoxes(entityBox.offset(-pos.getX(), -pos.getY(), -pos.getZ())); + List boxes = tile.getCollisionBoxes(entityBox.offset(-pos.getX(), -pos.getY(), -pos.getZ())); for(AxisAlignedBB box : boxes) { @@ -177,25 +177,25 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { - return getDefaultForTile(getTileEntitySidedPipe(world.getTileEntity(pos)).orElse(null)).offset(pos); + return getDefaultForTile(getTileEntitySidedPipe(world.getTileEntity(pos))).offset(pos); } @Override public RayTraceResult collisionRayTrace(IBlockState blockState, World world, BlockPos pos, Vec3d start, Vec3d end) { - Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(!tile.isPresent()) + if(tile == null) { return null; } - List boxes = tile.get().getCollisionBoxes(); + List boxes = tile.getCollisionBoxes(); AdvancedRayTraceResult result = MultipartUtils.collisionRayTrace(pos, start, end, boxes); if(result != null && result.valid()) { - setDefaultForTile(tile.get(), result.bounds); + setDefaultForTile(tile, result.bounds); } return result != null ? result.hit : null; @@ -227,15 +227,11 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { - ItemStack itemStack; - Optional tileEntity = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(!tileEntity.isPresent()) + ItemStack itemStack = ItemStack.EMPTY; + TileEntitySidedPipe tileEntity = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tileEntity != null) { - itemStack = ItemStack.EMPTY; - } - else - { - itemStack = new ItemStack(MekanismBlocks.Transmitter, 1, tileEntity.get().getTransmitterType().ordinal()); + itemStack = new ItemStack(MekanismBlocks.Transmitter, 1, tileEntity.getTransmitterType().ordinal()); if(!itemStack.hasTagCompound()) { @@ -243,7 +239,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider } ITierItem tierItem = (ITierItem)itemStack.getItem(); - tierItem.setBaseTier(itemStack, tileEntity.get().getBaseTier()); + tierItem.setBaseTier(itemStack, tileEntity.getBaseTier()); } return itemStack; @@ -295,32 +291,32 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile.isPresent()) + TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tile != null) { - tile.get().onAdded(); + tile.onAdded(); } } @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neighbor) { - Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile.isPresent()) + TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tile != null) { EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); - tile.get().onNeighborBlockChange(side); + tile.onNeighborBlockChange(side); } } @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - Optional tile = getTileEntitySidedPipe(world.getTileEntity(pos)); - if(tile.isPresent()) + TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + if(tile != null) { EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); - tile.get().onNeighborTileChange(side); + tile.onNeighborTileChange(side); } } @@ -443,23 +439,25 @@ public class BlockTransmitter extends Block implements ITileEntityProvider return null; } - private Optional getTileEntitySidedPipe(TileEntity entity) + private TileEntitySidedPipe getTileEntitySidedPipe(TileEntity entity) { + TileEntitySidedPipe tileEntity = null; if(entity instanceof TileEntitySidedPipe) { - return Optional.of((TileEntitySidedPipe)entity); + tileEntity = (TileEntitySidedPipe)entity; } else if(Mekanism.hooks.MCMPLoaded && MultipartMekanism.isMultiPartContainer(entity)) { - for(TileEntity childEntity : MultipartMekanism.getTileEntities(entity)) + for(TileEntity childEntity : MultipartMekanism.getMekanismTileEntities(entity)) { if(childEntity instanceof TileEntitySidedPipe) { - return Optional.of((TileEntitySidedPipe)childEntity); + tileEntity = (TileEntitySidedPipe)childEntity; + break; } } } - return Optional.empty(); + return tileEntity; } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java index b88c945ce..5de3dbab5 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java @@ -6,7 +6,6 @@ import static mekanism.common.block.states.BlockStateMachine.MachineBlock.MACHIN import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -171,17 +170,22 @@ public class MultipartMekanism implements IMCMPAddon return entity instanceof IMultipartContainer; } - public static Collection getTileEntities(TileEntity container) + public static Collection getMekanismTileEntities(TileEntity container) { + ArrayList entities = new ArrayList<>(); + if(container instanceof IMultipartContainer) { - return ((IMultipartContainer)container).getParts().values().stream() - .map(partInfo -> partInfo.getPart()) - .filter(part -> part instanceof MultipartTile) - .map(part -> ((MultipartTile)part).getTileEntity()) - .collect(Collectors.toList()); + for(IPartInfo partInfo : ((IMultipartContainer)container).getParts().values()) + { + IMultipartTile partTile = partInfo.getTile(); + if(partTile instanceof MultipartTile) + { + entities.add(((MultipartTile)partTile).getTileEntity()); + } + } } - return new ArrayList(); + return entities; } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java index 4f48cf92c..d17656e59 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java @@ -37,7 +37,7 @@ public class MultipartTransmitter implements IMultipart if(tile instanceof TileEntitySidedPipe) { - ((TileEntitySidedPipe)tile).onPartChanged(null); + ((TileEntitySidedPipe)tile).onAdded(); } } From 5f2501693f52f2b8ca6348ccb6b438f81df0c613 Mon Sep 17 00:00:00 2001 From: Xander Victory Date: Tue, 18 Jul 2017 17:12:28 +0800 Subject: [PATCH 11/36] add a sanity check for weird ISidedInventorys that give us a slot id that's higher than the inv size they reported. (see #4484) --- .../common/content/transporter/TransporterManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/mekanism/common/content/transporter/TransporterManager.java b/src/main/java/mekanism/common/content/transporter/TransporterManager.java index ca9cd31ed..2fabf0060 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterManager.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterManager.java @@ -9,6 +9,7 @@ import java.util.Set; import mekanism.api.Coord4D; import mekanism.api.EnumColor; +import mekanism.common.Mekanism; import mekanism.common.base.ISideConfiguration; import mekanism.common.content.transporter.TransitRequest.TransitResponse; import mekanism.common.content.transporter.TransporterStack.Path; @@ -113,6 +114,11 @@ public class TransporterManager { int slotID = slots[get]; + if (slotID >= ret.size()){ + Mekanism.logger.error("Inventory {} gave slot number >= the number of slots it reported! {} >= {} ", inv.getClass().getName(), slotID, inv.getSizeInventory()); + continue; + } + ret.set(slotID, !sidedInventory.getStackInSlot(slotID).isEmpty() ? sidedInventory.getStackInSlot(slotID).copy() : ItemStack.EMPTY); } From b24cbb797aea9572a439043538f7393ada0b785d Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Wed, 19 Jul 2017 11:33:17 +0200 Subject: [PATCH 12/36] Make empty containers stackable. Makes Cardboardboxes, gastanks and fluidtanks stackable. Bins are already stackable. Fixes #3802 --- .../common/item/ItemBlockCardboardBox.java | 13 ++++++++++++- .../mekanism/common/item/ItemBlockGasTank.java | 15 +++++++++++++-- .../mekanism/common/item/ItemBlockMachine.java | 14 ++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java index 0c175ea0a..cf30580f7 100644 --- a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java +++ b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java @@ -38,7 +38,7 @@ public class ItemBlockCardboardBox extends ItemBlock public ItemBlockCardboardBox(Block block) { super(block); - setMaxStackSize(1); + setMaxStackSize(16); metaBlock = block; MinecraftForge.EVENT_BUS.register(this); @@ -168,4 +168,15 @@ public class ItemBlockCardboardBox extends ItemBlock event.setCanceled(true); } } + + @Override + public int getItemStackLimit(ItemStack stack) + { + BlockData blockData = getBlockData(stack); + if(blockData != null) + { + return 1; + } + return super.getItemStackLimit(stack); + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockGasTank.java b/src/main/java/mekanism/common/item/ItemBlockGasTank.java index 0464af627..014c708d3 100644 --- a/src/main/java/mekanism/common/item/ItemBlockGasTank.java +++ b/src/main/java/mekanism/common/item/ItemBlockGasTank.java @@ -61,7 +61,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI super(block); metaBlock = block; setHasSubtypes(true); - setMaxStackSize(1); + setMaxStackSize(16); setCreativeTab(Mekanism.tabMekanism); } @@ -333,7 +333,7 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI @Override public boolean showDurabilityBar(ItemStack stack) { - return true; + return getGas(stack) != null; // No bar for empty containers as bars are drawn on top of stack count number } @Override @@ -399,4 +399,15 @@ public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedI { return hasSecurity(stack); } + + @Override + public int getItemStackLimit(ItemStack stack) + { + GasStack gasStack = getGas(stack); + if(gasStack != null) + { + return 1; + } + return super.getItemStackLimit(stack); + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index b89a13254..883d1b6a1 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -971,4 +971,18 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } } + + @Override + public int getItemStackLimit(ItemStack stack) + { + if(MachineType.get(stack) == MachineType.FLUID_TANK) + { + if(getFluidStack(stack) != null) + { + return 1; + } + return 16; + } + return super.getItemStackLimit(stack); + } } From 6ba975b84f792322472582edf21bcf9d65394f5a Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Wed, 19 Jul 2017 11:57:26 +0200 Subject: [PATCH 13/36] Add multiblock structures to cardboard blacklist. Fixes #3613 --- src/main/java/mekanism/common/Mekanism.java | 10 ++++++++++ .../mekanism/generators/common/MekanismGenerators.java | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index a2860b183..4033bc225 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -1426,11 +1426,21 @@ public class Mekanism public void onBlacklistUpdate(BoxBlacklistEvent event) { MekanismAPI.addBoxBlacklist(MekanismBlocks.CardboardBox, OreDictionary.WILDCARD_VALUE); + + // Mekanism multiblock structures MekanismAPI.addBoxBlacklist(MekanismBlocks.BoundingBlock, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(MekanismBlocks.BasicBlock2, 9); // Security Desk + MekanismAPI.addBoxBlacklist(MekanismBlocks.MachineBlock, 4); // Digital Miner + MekanismAPI.addBoxBlacklist(MekanismBlocks.MachineBlock2, 9); // Seismic Vibrator + MekanismAPI.addBoxBlacklist(MekanismBlocks.MachineBlock3, 1); // Solar Neutron Activator + + // Minecraft unobtainable MekanismAPI.addBoxBlacklist(Blocks.BEDROCK, 0); MekanismAPI.addBoxBlacklist(Blocks.PORTAL, OreDictionary.WILDCARD_VALUE); MekanismAPI.addBoxBlacklist(Blocks.END_PORTAL, OreDictionary.WILDCARD_VALUE); MekanismAPI.addBoxBlacklist(Blocks.END_PORTAL_FRAME, OreDictionary.WILDCARD_VALUE); + + // Minecraft multiblock structures MekanismAPI.addBoxBlacklist(Blocks.BED, OreDictionary.WILDCARD_VALUE); MekanismAPI.addBoxBlacklist(Blocks.OAK_DOOR, OreDictionary.WILDCARD_VALUE); MekanismAPI.addBoxBlacklist(Blocks.SPRUCE_DOOR, OreDictionary.WILDCARD_VALUE); diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index b06fb7bc0..0620e12a0 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import java.io.IOException; +import mekanism.api.MekanismAPI; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.infuse.InfuseRegistry; @@ -275,4 +276,12 @@ public class MekanismGenerators implements IModule TypeConfigManager.updateConfigRecipes(GeneratorType.getGeneratorsForConfig(), generators.generatorsManager); } } + + @SubscribeEvent + public void onBlacklistUpdate(MekanismAPI.BoxBlacklistEvent event) + { + // Mekanism Generators multiblock structures + MekanismAPI.addBoxBlacklist(GeneratorsBlocks.Generator, 5); // Advanced Solar Generator + MekanismAPI.addBoxBlacklist(GeneratorsBlocks.Generator, 6); // Wind Generator + } } From 6f78c19cb202b131ec729483678c1ce3e3904146 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Wed, 19 Jul 2017 15:15:35 +0200 Subject: [PATCH 14/36] Add disable toggle to freerunners. Adds feature #3808. --- .../mekanism/client/ClientPlayerTracker.java | 1 + .../mekanism/client/ClientTickHandler.java | 41 ++++- .../java/mekanism/client/MekanismClient.java | 1 + .../mekanism/client/MekanismKeyHandler.java | 31 +++- .../mekanism/common/CommonPlayerTracker.java | 7 +- src/main/java/mekanism/common/Mekanism.java | 10 +- .../java/mekanism/common/PacketHandler.java | 3 + .../mekanism/common/item/ItemFreeRunners.java | 43 +++++- .../common/network/PacketFreeRunnerData.java | 140 ++++++++++++++++++ .../resources/assets/mekanism/lang/en_us.lang | 4 + 10 files changed, 271 insertions(+), 10 deletions(-) create mode 100644 src/main/java/mekanism/common/network/PacketFreeRunnerData.java diff --git a/src/main/java/mekanism/client/ClientPlayerTracker.java b/src/main/java/mekanism/client/ClientPlayerTracker.java index 20ef79bb0..c0e7cc6da 100644 --- a/src/main/java/mekanism/client/ClientPlayerTracker.java +++ b/src/main/java/mekanism/client/ClientPlayerTracker.java @@ -15,5 +15,6 @@ public class ClientPlayerTracker Mekanism.jetpackOn.remove(event.player); Mekanism.gasmaskOn.remove(event.player); Mekanism.flamethrowerActive.remove(event.player); + Mekanism.freeRunnerOn.remove(event.player); } } diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index 83647a516..4a284ffba 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -35,6 +35,7 @@ import mekanism.common.item.ItemJetpack.JetpackMode; import mekanism.common.item.ItemScubaTank; import mekanism.common.network.PacketFlamethrowerData; import mekanism.common.network.PacketFlamethrowerData.FlamethrowerDataMessage; +import mekanism.common.network.PacketFreeRunnerData; import mekanism.common.network.PacketItemStack.ItemStackMessage; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import mekanism.common.network.PacketJetpackData.JetpackPacket; @@ -220,10 +221,24 @@ public class ClientTickHandler } } } - + + if(Mekanism.freeRunnerOn.contains(mc.player.getName()) != isFreeRunnerOn(mc.player)) + { + if(isFreeRunnerOn(mc.player) && mc.currentScreen == null) + { + Mekanism.freeRunnerOn.add(mc.player.getName()); + } + else + { + Mekanism.freeRunnerOn.remove(mc.player.getName()); + } + + Mekanism.packetHandler.sendToServer(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.UPDATE, mc.player.getName(), isFreeRunnerOn(mc.player))); + } + ItemStack bootStack = mc.player.getItemStackFromSlot(EntityEquipmentSlot.FEET); - if(!bootStack.isEmpty() && bootStack.getItem() instanceof ItemFreeRunners) + if(!bootStack.isEmpty() && bootStack.getItem() instanceof ItemFreeRunners && isFreeRunnerOn(mc.player)) { mc.player.stepHeight = 1.002F; } @@ -562,6 +577,28 @@ public class ClientTickHandler return false; } + + public static boolean isFreeRunnerOn(EntityPlayer player) + { + if(player != mc.player) + { + return Mekanism.freeRunnerOn.contains(player.getName()); + } + + ItemStack stack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); + + if(!stack.isEmpty() && stack.getItem() instanceof ItemFreeRunners) + { + ItemFreeRunners freeRunners = (ItemFreeRunners) stack.getItem(); + + if(/*freeRunners.getEnergy(stack) > 0 && */freeRunners.getMode(stack) == ItemFreeRunners.FreeRunnerMode.NORMAL) + { + return true; + } + } + + return false; + } public static boolean isFlamethrowerOn(EntityPlayer player) { diff --git a/src/main/java/mekanism/client/MekanismClient.java b/src/main/java/mekanism/client/MekanismClient.java index b61f107e2..dcbf3beb6 100644 --- a/src/main/java/mekanism/client/MekanismClient.java +++ b/src/main/java/mekanism/client/MekanismClient.java @@ -65,6 +65,7 @@ public class MekanismClient extends Mekanism Mekanism.gasmaskOn.clear(); Mekanism.flamethrowerActive.clear(); Mekanism.activeVibrators.clear(); + Mekanism.freeRunnerOn.clear(); SynchronizedBoilerData.clientHotMap.clear(); diff --git a/src/main/java/mekanism/client/MekanismKeyHandler.java b/src/main/java/mekanism/client/MekanismKeyHandler.java index a9166a75d..cf9fa63f7 100644 --- a/src/main/java/mekanism/client/MekanismKeyHandler.java +++ b/src/main/java/mekanism/client/MekanismKeyHandler.java @@ -10,11 +10,13 @@ import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator.ConfiguratorMode; import mekanism.common.item.ItemElectricBow; import mekanism.common.item.ItemFlamethrower; +import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemJetpack; import mekanism.common.item.ItemJetpack.JetpackMode; import mekanism.common.item.ItemScubaTank; import mekanism.common.item.ItemWalkieTalkie; import mekanism.common.network.PacketFlamethrowerData; +import mekanism.common.network.PacketFreeRunnerData; import mekanism.common.network.PacketItemStack.ItemStackMessage; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import mekanism.common.network.PacketJetpackData.JetpackPacket; @@ -46,17 +48,19 @@ public class MekanismKeyHandler extends MekKeyHandler { public static final String keybindCategory = "Mekanism"; public static KeyBinding modeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.mode"), Keyboard.KEY_M, keybindCategory); - public static KeyBinding armorModeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.armorMode"), Keyboard.KEY_F, keybindCategory); + public static KeyBinding armorModeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.armorMode"), Keyboard.KEY_G, keybindCategory); + public static KeyBinding freeRunnerModeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.feetMode"), Keyboard.KEY_H, keybindCategory); public static KeyBinding voiceKey = new KeyBinding("Mekanism " + LangUtils.localize("key.voice"), Keyboard.KEY_U, keybindCategory); public static KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak; public static KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; public MekanismKeyHandler() { - super(new KeyBinding[] {modeSwitchKey, armorModeSwitchKey, voiceKey}, new boolean[] {false, false, true}); + super(new KeyBinding[] {modeSwitchKey, armorModeSwitchKey, freeRunnerModeSwitchKey, voiceKey}, new boolean[] {false, false, true}); ClientRegistry.registerKeyBinding(modeSwitchKey); ClientRegistry.registerKeyBinding(armorModeSwitchKey); + ClientRegistry.registerKeyBinding(freeRunnerModeSwitchKey); ClientRegistry.registerKeyBinding(voiceKey); MinecraftForge.EVENT_BUS.register(this); @@ -157,6 +161,29 @@ public class MekanismKeyHandler extends MekKeyHandler SoundHandler.playSound(MekanismSounds.HYDRAULIC); } } + else if(kb == freeRunnerModeSwitchKey) + { + EntityPlayer player = FMLClientHandler.instance().getClient().player; + ItemStack feetStack = player.getItemStackFromSlot(EntityEquipmentSlot.FEET); + Item feetItem = StackUtils.getItem(feetStack); + + if(feetItem instanceof ItemFreeRunners) + { + ItemFreeRunners freeRunners = (ItemFreeRunners)feetItem; + + if(player.isSneaking()) + { + freeRunners.setMode(feetStack, ItemFreeRunners.FreeRunnerMode.DISABLED); + } + else + { + freeRunners.incrementMode(feetStack); + } + + Mekanism.packetHandler.sendToServer(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.MODE, null, player.isSneaking())); + SoundHandler.playSound(MekanismSounds.HYDRAULIC); + } + } } @Override diff --git a/src/main/java/mekanism/common/CommonPlayerTracker.java b/src/main/java/mekanism/common/CommonPlayerTracker.java index bc293c82f..be4e60651 100644 --- a/src/main/java/mekanism/common/CommonPlayerTracker.java +++ b/src/main/java/mekanism/common/CommonPlayerTracker.java @@ -2,6 +2,7 @@ package mekanism.common; import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage; import mekanism.common.network.PacketConfigSync.ConfigSyncMessage; +import mekanism.common.network.PacketFreeRunnerData; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import mekanism.common.network.PacketJetpackData.JetpackPacket; import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage; @@ -32,8 +33,9 @@ public class CommonPlayerTracker Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player); Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player); Mekanism.packetHandler.sendTo(new SecurityUpdateMessage(SecurityPacket.FULL, null, null), (EntityPlayerMP)event.player); + Mekanism.packetHandler.sendTo(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.FULL, null, false), (EntityPlayerMP)event.player); - Mekanism.logger.info("Sent config to '" + event.player.getDisplayName() + ".'"); + Mekanism.logger.info("Sent config to '" + event.player.getDisplayNameString() + ".'"); } } @@ -43,6 +45,7 @@ public class CommonPlayerTracker Mekanism.jetpackOn.remove(event.player.getName()); Mekanism.gasmaskOn.remove(event.player.getName()); Mekanism.flamethrowerActive.remove(event.player.getName()); + Mekanism.freeRunnerOn.remove(event.player.getName()); } @SubscribeEvent @@ -51,11 +54,13 @@ public class CommonPlayerTracker Mekanism.jetpackOn.remove(event.player.getName()); Mekanism.gasmaskOn.remove(event.player.getName()); Mekanism.flamethrowerActive.remove(event.player.getName()); + Mekanism.freeRunnerOn.remove(event.player.getName()); if(!event.player.world.isRemote) { Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player); Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player); + Mekanism.packetHandler.sendTo(new PacketFreeRunnerData.FreeRunnerDataMessage(PacketFreeRunnerData.FreeRunnerPacket.FULL, null, false), (EntityPlayerMP)event.player); } } } diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index a2860b183..6d56a5424 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -240,11 +240,12 @@ public class Mekanism public static KeySync keyMap = new KeySync(); - public static Set jetpackOn = new HashSet(); - public static Set gasmaskOn = new HashSet(); - public static Set flamethrowerActive = new HashSet(); + public static Set jetpackOn = new HashSet<>(); + public static Set gasmaskOn = new HashSet<>(); + public static Set freeRunnerOn = new HashSet<>(); + public static Set flamethrowerActive = new HashSet<>(); - public static Set activeVibrators = new HashSet(); + public static Set activeVibrators = new HashSet<>(); static { MekanismFluids.register(); @@ -1202,6 +1203,7 @@ public class Mekanism worldTickHandler.resetRegenChunks(); privateTeleporters.clear(); privateEntangloporters.clear(); + freeRunnerOn.clear(); //Reset consistent managers MultiblockManager.reset(); diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index a4043602c..ab5407453 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -28,6 +28,7 @@ import mekanism.common.network.PacketEntityMove; import mekanism.common.network.PacketEntityMove.EntityMoveMessage; import mekanism.common.network.PacketFlamethrowerData; import mekanism.common.network.PacketFlamethrowerData.FlamethrowerDataMessage; +import mekanism.common.network.PacketFreeRunnerData; import mekanism.common.network.PacketItemStack; import mekanism.common.network.PacketItemStack.ItemStackMessage; import mekanism.common.network.PacketJetpackData; @@ -132,6 +133,8 @@ public class PacketHandler netHandler.registerMessage(PacketDropperUse.class, DropperUseMessage.class, 28, Side.SERVER); netHandler.registerMessage(PacketEntityMove.class, EntityMoveMessage.class, 29, Side.CLIENT); netHandler.registerMessage(PacketSecurityUpdate.class, SecurityUpdateMessage.class, 30, Side.CLIENT); + netHandler.registerMessage(PacketFreeRunnerData.class, PacketFreeRunnerData.FreeRunnerDataMessage.class, 31, Side.CLIENT); + netHandler.registerMessage(PacketFreeRunnerData.class, PacketFreeRunnerData.FreeRunnerDataMessage.class, 31, Side.SERVER); } /** diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index 49574a28c..df113c18c 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -83,6 +83,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) { list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); + list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack).getName()); } public ItemStack getUnchargedItem() @@ -221,7 +222,7 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci { ItemFreeRunners boots = (ItemFreeRunners)stack.getItem(); - if(boots.getEnergy(stack) > 0 && event.getSource() == DamageSource.FALL) + if(boots.getMode(stack) == FreeRunnerMode.NORMAL && boots.getEnergy(stack) > 0 && event.getSource() == DamageSource.FALL) { boots.setEnergy(stack, boots.getEnergy(stack)-event.getAmount()*50); event.setCanceled(true); @@ -234,4 +235,44 @@ public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpeci { return new ItemCapabilityWrapper(stack, new TeslaItemWrapper(), new ForgeEnergyItemWrapper()); } + + public enum FreeRunnerMode + { + NORMAL("tooltip.freerunner.regular", EnumColor.DARK_GREEN), + DISABLED("tooltip.freerunner.disabled", EnumColor.DARK_RED); + + private String unlocalized; + private EnumColor color; + + FreeRunnerMode(String unlocalized, EnumColor color) + { + this.unlocalized = unlocalized; + this.color = color; + } + + public FreeRunnerMode increment() + { + return ordinal() < values().length-1 ? values()[ordinal()+1] : values()[0]; + } + + public String getName() + { + return color + LangUtils.localize(unlocalized); + } + } + + public FreeRunnerMode getMode(ItemStack itemStack) + { + return FreeRunnerMode.values()[ItemDataUtils.getInt(itemStack, "mode")]; + } + + public void setMode(ItemStack itemStack, FreeRunnerMode mode) + { + ItemDataUtils.setInt(itemStack, "mode", mode.ordinal()); + } + + public void incrementMode(ItemStack itemStack) + { + setMode(itemStack, getMode(itemStack).increment()); + } } diff --git a/src/main/java/mekanism/common/network/PacketFreeRunnerData.java b/src/main/java/mekanism/common/network/PacketFreeRunnerData.java new file mode 100644 index 000000000..18e23a93c --- /dev/null +++ b/src/main/java/mekanism/common/network/PacketFreeRunnerData.java @@ -0,0 +1,140 @@ +package mekanism.common.network; + +import io.netty.buffer.ByteBuf; +import mekanism.common.Mekanism; +import mekanism.common.PacketHandler; +import mekanism.common.item.ItemFreeRunners; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.EntityEquipmentSlot; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fml.common.network.simpleimpl.IMessage; +import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; +import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; + +public class PacketFreeRunnerData implements IMessageHandler +{ + @Override + public IMessage onMessage(FreeRunnerDataMessage message, MessageContext ctx) + { + EntityPlayer entityPlayer = PacketHandler.getPlayer(ctx); + + PacketHandler.handlePacket(() -> { + if(message.packetType == FreeRunnerPacket.UPDATE) + { + if(message.value) + { + Mekanism.freeRunnerOn.add(message.username); + } + else + { + Mekanism.freeRunnerOn.remove(message.username); + } + + if(!entityPlayer.world.isRemote) + { + Mekanism.packetHandler.sendToDimension(new FreeRunnerDataMessage(FreeRunnerPacket.UPDATE, message.username, message.value), entityPlayer.world.provider.getDimension()); + } + } + else if(message.packetType == FreeRunnerPacket.MODE) + { + ItemStack stack = entityPlayer.getItemStackFromSlot(EntityEquipmentSlot.FEET); + + if(!stack.isEmpty() && stack.getItem() instanceof ItemFreeRunners) + { + if(!message.value) + { + ((ItemFreeRunners)stack.getItem()).incrementMode(stack); + } + else + { + ((ItemFreeRunners)stack.getItem()).setMode(stack, ItemFreeRunners.FreeRunnerMode.DISABLED); + } + } + } + }, entityPlayer); + + return null; + } + + public static class FreeRunnerDataMessage implements IMessage + { + public FreeRunnerPacket packetType; + + public String username; + public boolean value; + + public FreeRunnerDataMessage() {} + + public FreeRunnerDataMessage(FreeRunnerPacket packetType, String username, boolean value) + { + this.packetType = packetType; + this.value = value; + + if(packetType == FreeRunnerPacket.UPDATE) + { + this.username = username; + } + } + + @Override + public void toBytes(ByteBuf buf) + { + buf.writeInt(packetType.ordinal()); + + if(packetType == FreeRunnerPacket.MODE) + { + buf.writeBoolean(value); + } + else if(packetType == FreeRunnerPacket.UPDATE) + { + PacketHandler.writeString(buf, username); + buf.writeBoolean(value); + } + else if(packetType == FreeRunnerPacket.FULL) + { + buf.writeInt(Mekanism.freeRunnerOn.size()); + + synchronized (Mekanism.freeRunnerOn) + { + for(String usernameToSend : Mekanism.freeRunnerOn) + { + PacketHandler.writeString(buf, usernameToSend); + } + } + } + } + + @Override + public void fromBytes(ByteBuf buf) { + packetType = FreeRunnerPacket.values()[buf.readInt()]; + + if(packetType == FreeRunnerPacket.MODE) + { + value = buf.readBoolean(); + } + else if(packetType == FreeRunnerPacket.UPDATE) + { + username = PacketHandler.readString(buf); + value = buf.readBoolean(); + } + else if(packetType == FreeRunnerPacket.FULL) + { + Mekanism.freeRunnerOn.clear(); + + int amount = buf.readInt(); + + for(int i = 0; i < amount; i++) + { + Mekanism.freeRunnerOn.add(PacketHandler.readString(buf)); + } + } + } + } + + public enum FreeRunnerPacket + { + UPDATE, + FULL, + MODE + } +} diff --git a/src/main/resources/assets/mekanism/lang/en_us.lang b/src/main/resources/assets/mekanism/lang/en_us.lang index eb119a49d..cc727ec0c 100644 --- a/src/main/resources/assets/mekanism/lang/en_us.lang +++ b/src/main/resources/assets/mekanism/lang/en_us.lang @@ -394,6 +394,7 @@ upgrade.anchor.desc=Keeps a machine's chunk loaded. //Key description text key.mode=Item Mode Switch key.armorMode=Armor Mode Switch +key.feetMode=Feet Mode Switch key.voice=Voice //Entities @@ -785,6 +786,9 @@ tooltip.jetpack.regular=Regular tooltip.jetpack.hover=Hover tooltip.jetpack.disabled=Disabled +tooltip.freerunner.regular=Regular +tooltip.freerunner.disabled=Disabled + tooltip.flamethrower.combat=Combat tooltip.flamethrower.heat=Heat tooltip.flamethrower.inferno=Inferno From 0a1da009137cd3f28bb564409998c0b018953dc3 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Wed, 19 Jul 2017 19:00:33 +0200 Subject: [PATCH 15/36] Add bin drops directly to player inventory. If there's no space, drop them in front of the bin. Adds feature #3807 --- .../mekanism/common/block/BlockBasic.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index 6be823ca1..820c805f2 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -51,6 +51,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.SoundEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -59,6 +60,7 @@ import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; +import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; @@ -412,12 +414,27 @@ public abstract class BlockBasic extends Block implements ICTMBlock { if(!bin.bottomStack.isEmpty()) { - if(!player.isSneaking()) + ItemStack stack; + if(player.isSneaking()) { - world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, bin.removeStack().copy())); + stack = bin.remove(1).copy(); } - else { - world.spawnEntity(new EntityItem(world, player.posX, player.posY, player.posZ, bin.remove(1).copy())); + else + { + stack = bin.removeStack().copy(); + } + + if(!player.inventory.addItemStackToInventory(stack)) + { + BlockPos dropPos = pos.offset(bin.facing); + Entity item = new EntityItem(world, dropPos.getX() + .5f, dropPos.getY() + .3f, dropPos.getZ() + .5f, stack); + item.addVelocity(-item.motionX, -item.motionY, -item.motionZ); + world.spawnEntity(item); + } + else + { + world.playSound(null, pos.getX() + .5f, pos.getY() + .5f, pos.getZ() + .5f, + SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); } } } @@ -1044,4 +1061,4 @@ public abstract class BlockBasic extends Block implements ICTMBlock { return BasicBlockType.get(world.getBlockState(pos)).isBeaconBase; } -} \ No newline at end of file +} From 65084f567b14390ce7025d50a0d01c493e29063a Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Fri, 21 Jul 2017 11:21:41 +0200 Subject: [PATCH 16/36] Fix TE access from ChunkCache. Fixes #3534 --- .../java/mekanism/common/block/BlockBasic.java | 12 +++++++----- .../mekanism/common/block/BlockEnergyCube.java | 4 +++- .../java/mekanism/common/block/BlockGasTank.java | 4 +++- .../mekanism/common/block/BlockGlowPanel.java | 12 +++++++----- .../java/mekanism/common/block/BlockMachine.java | 16 ++++++---------- .../java/mekanism/common/block/BlockPlastic.java | 2 -- .../mekanism/common/block/BlockTransmitter.java | 10 ++++++---- .../generators/common/GeneratorsItems.java | 6 +++++- .../generators/common/block/BlockGenerator.java | 6 ++++-- .../generators/common/block/BlockReactor.java | 6 ++++-- 10 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index 6be823ca1..c587b906d 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -63,10 +63,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; @@ -158,7 +160,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -344,7 +346,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock return false; case 9: case 11: - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getTileEntity(pos); + TileEntityDynamicTank tileEntity = world instanceof ChunkCache ? (TileEntityDynamicTank)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityDynamicTank)world.getTileEntity(pos); if(tileEntity != null) { @@ -372,7 +374,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock case 2: case 7: case 8: - TileEntityMultiblock tileEntity = (TileEntityMultiblock)world.getTileEntity(pos); + TileEntityMultiblock tileEntity = world instanceof ChunkCache ? (TileEntityMultiblock)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityMultiblock)world.getTileEntity(pos); if(tileEntity != null) { @@ -716,7 +718,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); int metadata = state.getBlock().getMetaFromState(state); if(tileEntity instanceof IActiveState) @@ -1044,4 +1046,4 @@ public abstract class BlockBasic extends Block implements ICTMBlock { return BasicBlockType.get(world.getBlockState(pos)).isBeaconBase; } -} \ No newline at end of file +} diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index b2afc4857..25680c903 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -40,8 +40,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import buildcraft.api.tools.IToolWrench; @@ -87,7 +89,7 @@ public class BlockEnergyCube extends BlockContainer @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntityEnergyCube) { diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index 64297680f..48967ac1f 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -37,9 +37,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import buildcraft.api.tools.IToolWrench; +import net.minecraft.world.chunk.Chunk; public class BlockGasTank extends BlockContainer { @@ -74,7 +76,7 @@ public class BlockGasTank extends BlockContainer @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntityGasTank) { diff --git a/src/main/java/mekanism/common/block/BlockGlowPanel.java b/src/main/java/mekanism/common/block/BlockGlowPanel.java index 0480378b6..e47fe224e 100644 --- a/src/main/java/mekanism/common/block/BlockGlowPanel.java +++ b/src/main/java/mekanism/common/block/BlockGlowPanel.java @@ -26,8 +26,10 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -71,7 +73,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = world instanceof ChunkCache ? (TileEntityGlowPanel)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityGlowPanel)world.getTileEntity(pos); return tileEntity != null ? state.withProperty(BlockStateFacing.facingProperty, tileEntity.side) : state; } @@ -79,8 +81,8 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); - + TileEntityGlowPanel tileEntity = world instanceof ChunkCache ? (TileEntityGlowPanel)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityGlowPanel)world.getTileEntity(pos); + if(tileEntity != null) { state = state.withProperty(BlockStateFacing.facingProperty, tileEntity.side); @@ -117,7 +119,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = world instanceof ChunkCache ? (TileEntityGlowPanel)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityGlowPanel)world.getTileEntity(pos); if(!tileEntity.getWorld().isRemote && !canStay(tileEntity)) { @@ -137,7 +139,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(tile != null && tile instanceof TileEntityGlowPanel) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 6529f9ed9..b95eab400 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -78,9 +78,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; @@ -206,7 +208,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -383,7 +385,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock { if(client.enableAmbientLighting) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(tileEntity instanceof IActiveState) { @@ -992,7 +994,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); - TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(type == null) { @@ -1025,12 +1027,6 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock { return false; } - - @Override - public AxisAlignedBB getCollisionBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) - { - return super.getCollisionBoundingBox(state, world, pos); - } @Override public boolean isSideSolid(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) @@ -1111,7 +1107,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(tile instanceof TileEntityLaserAmplifier) { diff --git a/src/main/java/mekanism/common/block/BlockPlastic.java b/src/main/java/mekanism/common/block/BlockPlastic.java index 4b10f95f4..43061a2ab 100644 --- a/src/main/java/mekanism/common/block/BlockPlastic.java +++ b/src/main/java/mekanism/common/block/BlockPlastic.java @@ -14,9 +14,7 @@ import net.minecraft.item.EnumDyeColor; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index 7b094a3fd..b6768e8f8 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -49,8 +49,10 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.client.model.obj.OBJModel.OBJProperty; import net.minecraftforge.client.model.obj.OBJModel.OBJState; import net.minecraftforge.common.property.IExtendedBlockState; @@ -95,7 +97,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntitySidedPipe) { @@ -129,7 +131,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)w.getTileEntity(pos); + TileEntitySidedPipe tile = w instanceof ChunkCache ? (TileEntitySidedPipe)((ChunkCache)w).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntitySidedPipe)w.getTileEntity(pos); if(tile != null) { @@ -147,7 +149,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(tile instanceof TileEntitySidedPipe && ((TileEntitySidedPipe)tile).getTransmitterType().getSize() == Size.SMALL) { @@ -301,7 +303,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntitySidedPipe tile = (TileEntitySidedPipe)world.getTileEntity(pos); + TileEntitySidedPipe tile = world instanceof ChunkCache ? (TileEntitySidedPipe)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntitySidedPipe)world.getTileEntity(pos); EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); tile.onNeighborTileChange(side); } diff --git a/src/main/java/mekanism/generators/common/GeneratorsItems.java b/src/main/java/mekanism/generators/common/GeneratorsItems.java index af3d46d50..fdc6544f4 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsItems.java +++ b/src/main/java/mekanism/generators/common/GeneratorsItems.java @@ -6,8 +6,11 @@ import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @@ -20,7 +23,8 @@ public class GeneratorsItems @Override public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) { - return world.getTileEntity(pos) instanceof TileEntityTurbineRotor; + TileEntity entity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + return entity instanceof TileEntityTurbineRotor; } }; diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 03976ab9a..472f88e09 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -57,8 +57,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -169,7 +171,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -254,7 +256,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock { if(client.enableAmbientLighting) { - TileEntity tileEntity = world.getTileEntity(pos); + TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) { diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index 00d86b305..9f81fd6aa 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -37,8 +37,10 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -75,7 +77,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn.getTileEntity(pos); + TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); if(tile instanceof TileEntityReactorController) { @@ -293,7 +295,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti @Override public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - TileEntity tile = world.getTileEntity(pos); + TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); if(tile instanceof TileEntityReactorLogicAdapter) { From 7c1e8b9f813e8842c1dab8fb5eecea0c77bc3633 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Fri, 21 Jul 2017 12:43:39 +0200 Subject: [PATCH 17/36] Change TE access from ChunkCache to Util method --- src/main/java/mekanism/common/block/BlockBasic.java | 12 +++++------- .../java/mekanism/common/block/BlockEnergyCube.java | 4 +--- .../java/mekanism/common/block/BlockGasTank.java | 4 +--- .../java/mekanism/common/block/BlockGlowPanel.java | 11 +++++------ .../java/mekanism/common/block/BlockMachine.java | 10 ++++------ .../java/mekanism/common/block/BlockTransmitter.java | 10 ++++------ .../java/mekanism/common/util/MekanismUtils.java | 7 +++++++ .../mekanism/generators/common/GeneratorsItems.java | 7 ++----- .../generators/common/block/BlockGenerator.java | 6 ++---- .../generators/common/block/BlockReactor.java | 6 ++---- 10 files changed, 33 insertions(+), 44 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index c587b906d..c27b9d65c 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -63,12 +63,10 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; @@ -160,8 +158,8 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); - + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { state = state.withProperty(BlockStateFacing.facingProperty, ((TileEntityBasicBlock)tile).facing); @@ -346,7 +344,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock return false; case 9: case 11: - TileEntityDynamicTank tileEntity = world instanceof ChunkCache ? (TileEntityDynamicTank)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityDynamicTank)world.getTileEntity(pos); + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank) MekanismUtils.getTileEntitySave(world, pos); if(tileEntity != null) { @@ -374,7 +372,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock case 2: case 7: case 8: - TileEntityMultiblock tileEntity = world instanceof ChunkCache ? (TileEntityMultiblock)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityMultiblock)world.getTileEntity(pos); + TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils.getTileEntitySave(world, pos); if(tileEntity != null) { @@ -718,7 +716,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tileEntity = MekanismUtils.getTileEntitySave(world, pos); int metadata = state.getBlock().getMetaFromState(state); if(tileEntity instanceof IActiveState) diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index 25680c903..deb84ea1b 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -40,10 +40,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import buildcraft.api.tools.IToolWrench; @@ -89,7 +87,7 @@ public class BlockEnergyCube extends BlockContainer @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); if(tile instanceof TileEntityEnergyCube) { diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index 48967ac1f..84d936c20 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -37,11 +37,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import buildcraft.api.tools.IToolWrench; -import net.minecraft.world.chunk.Chunk; public class BlockGasTank extends BlockContainer { @@ -76,7 +74,7 @@ public class BlockGasTank extends BlockContainer @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); if(tile instanceof TileEntityGasTank) { diff --git a/src/main/java/mekanism/common/block/BlockGlowPanel.java b/src/main/java/mekanism/common/block/BlockGlowPanel.java index e47fe224e..0eb1bc319 100644 --- a/src/main/java/mekanism/common/block/BlockGlowPanel.java +++ b/src/main/java/mekanism/common/block/BlockGlowPanel.java @@ -9,6 +9,7 @@ import mekanism.common.block.property.PropertyColor; import mekanism.common.block.states.BlockStateFacing; import mekanism.common.block.states.BlockStateGlowPanel; import mekanism.common.tile.TileEntityGlowPanel; +import mekanism.common.util.MekanismUtils; import mekanism.common.util.MultipartUtils; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; @@ -26,10 +27,8 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -73,7 +72,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = world instanceof ChunkCache ? (TileEntityGlowPanel)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySave(world, pos); return tileEntity != null ? state.withProperty(BlockStateFacing.facingProperty, tileEntity.side) : state; } @@ -81,7 +80,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = world instanceof ChunkCache ? (TileEntityGlowPanel)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySave(world, pos); if(tileEntity != null) { @@ -119,7 +118,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntityGlowPanel tileEntity = world instanceof ChunkCache ? (TileEntityGlowPanel)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySave(world, pos); if(!tileEntity.getWorld().isRemote && !canStay(tileEntity)) { @@ -139,7 +138,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); if(tile != null && tile instanceof TileEntityGlowPanel) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index b95eab400..fdeb7962b 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -78,11 +78,9 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.Explosion; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidUtil; @@ -208,7 +206,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -385,7 +383,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock { if(client.enableAmbientLighting) { - TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tileEntity = MekanismUtils.getTileEntitySave(world, pos); if(tileEntity instanceof IActiveState) { @@ -994,7 +992,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); - TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); if(type == null) { @@ -1107,7 +1105,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); if(tile instanceof TileEntityLaserAmplifier) { diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index b6768e8f8..58c70b136 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -49,10 +49,8 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.client.model.obj.OBJModel.OBJProperty; import net.minecraftforge.client.model.obj.OBJModel.OBJState; import net.minecraftforge.common.property.IExtendedBlockState; @@ -97,7 +95,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); if(tile instanceof TileEntitySidedPipe) { @@ -131,7 +129,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) { - TileEntitySidedPipe tile = w instanceof ChunkCache ? (TileEntitySidedPipe)((ChunkCache)w).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntitySidedPipe)w.getTileEntity(pos); + TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySave(w, pos); if(tile != null) { @@ -149,7 +147,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); if(tile instanceof TileEntitySidedPipe && ((TileEntitySidedPipe)tile).getTransmitterType().getSize() == Size.SMALL) { @@ -303,7 +301,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntitySidedPipe tile = world instanceof ChunkCache ? (TileEntitySidedPipe)((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : (TileEntitySidedPipe)world.getTileEntity(pos); + TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySave(world, pos); EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); tile.onNeighborTileChange(side); } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index cdb259d81..5f099fccf 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -82,9 +82,11 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.ChunkCache; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; @@ -1526,4 +1528,9 @@ public final class MekanismUtils return prefix + "/"; } } + + public static TileEntity getTileEntitySave(IBlockAccess worldIn, BlockPos pos) + { + return worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsItems.java b/src/main/java/mekanism/generators/common/GeneratorsItems.java index fdc6544f4..42e28d4c2 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsItems.java +++ b/src/main/java/mekanism/generators/common/GeneratorsItems.java @@ -1,16 +1,14 @@ package mekanism.generators.common; import mekanism.common.item.ItemMekanism; +import mekanism.common.util.MekanismUtils; import mekanism.generators.common.item.ItemHohlraum; import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder; @@ -23,8 +21,7 @@ public class GeneratorsItems @Override public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) { - TileEntity entity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); - return entity instanceof TileEntityTurbineRotor; + return MekanismUtils.getTileEntitySave(world, pos) instanceof TileEntityTurbineRotor; } }; diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 472f88e09..dd3cb096d 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -57,10 +57,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -171,7 +169,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -256,7 +254,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock { if(client.enableAmbientLighting) { - TileEntity tileEntity = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tileEntity = MekanismUtils.getTileEntitySave(world, pos); if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) { diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index 9f81fd6aa..6312da945 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -37,10 +37,8 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.ChunkCache; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.property.IExtendedBlockState; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -77,7 +75,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); if(tile instanceof TileEntityReactorController) { @@ -295,7 +293,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti @Override public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - TileEntity tile = world instanceof ChunkCache ? ((ChunkCache)world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos); + TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); if(tile instanceof TileEntityReactorLogicAdapter) { From 4614c6775059b2533b7427b26a8d9e079f38805c Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Fri, 21 Jul 2017 12:47:38 +0200 Subject: [PATCH 18/36] Fix typo --- src/main/java/mekanism/common/block/BlockBasic.java | 8 ++++---- src/main/java/mekanism/common/block/BlockEnergyCube.java | 2 +- src/main/java/mekanism/common/block/BlockGasTank.java | 2 +- src/main/java/mekanism/common/block/BlockGlowPanel.java | 8 ++++---- src/main/java/mekanism/common/block/BlockMachine.java | 8 ++++---- src/main/java/mekanism/common/block/BlockTransmitter.java | 8 ++++---- src/main/java/mekanism/common/util/MekanismUtils.java | 2 +- .../java/mekanism/generators/common/GeneratorsItems.java | 2 +- .../mekanism/generators/common/block/BlockGenerator.java | 4 ++-- .../mekanism/generators/common/block/BlockReactor.java | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index c27b9d65c..f420ff9d5 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -158,7 +158,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -344,7 +344,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock return false; case 9: case 11: - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank) MekanismUtils.getTileEntitySave(world, pos); + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank) MekanismUtils.getTileEntitySafe(world, pos); if(tileEntity != null) { @@ -372,7 +372,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock case 2: case 7: case 8: - TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils.getTileEntitySave(world, pos); + TileEntityMultiblock tileEntity = (TileEntityMultiblock) MekanismUtils.getTileEntitySafe(world, pos); if(tileEntity != null) { @@ -716,7 +716,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock @Override public int getLightValue(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tileEntity = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos); int metadata = state.getBlock().getMetaFromState(state); if(tileEntity instanceof IActiveState) diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index deb84ea1b..45d337ab6 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -87,7 +87,7 @@ public class BlockEnergyCube extends BlockContainer @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntityEnergyCube) { diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index 84d936c20..f30c2c5c9 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -74,7 +74,7 @@ public class BlockGasTank extends BlockContainer @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntityGasTank) { diff --git a/src/main/java/mekanism/common/block/BlockGlowPanel.java b/src/main/java/mekanism/common/block/BlockGlowPanel.java index 0eb1bc319..7aeea339d 100644 --- a/src/main/java/mekanism/common/block/BlockGlowPanel.java +++ b/src/main/java/mekanism/common/block/BlockGlowPanel.java @@ -72,7 +72,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySave(world, pos); + TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySafe(world, pos); return tileEntity != null ? state.withProperty(BlockStateFacing.facingProperty, tileEntity.side) : state; } @@ -80,7 +80,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySave(world, pos); + TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySafe(world, pos); if(tileEntity != null) { @@ -118,7 +118,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySave(world, pos); + TileEntityGlowPanel tileEntity = (TileEntityGlowPanel) MekanismUtils.getTileEntitySafe(world, pos); if(!tileEntity.getWorld().isRemote && !canStay(tileEntity)) { @@ -138,7 +138,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); if(tile != null && tile instanceof TileEntityGlowPanel) { diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index fdeb7962b..b29cee243 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -206,7 +206,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -383,7 +383,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock { if(client.enableAmbientLighting) { - TileEntity tileEntity = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos); if(tileEntity instanceof IActiveState) { @@ -992,7 +992,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state)); - TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); if(type == null) { @@ -1105,7 +1105,7 @@ public abstract class BlockMachine extends BlockContainer implements ICTMBlock @Override public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); if(tile instanceof TileEntityLaserAmplifier) { diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index 58c70b136..260025099 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -95,7 +95,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntitySidedPipe) { @@ -129,7 +129,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) { - TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySave(w, pos); + TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySafe(w, pos); if(tile != null) { @@ -147,7 +147,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); if(tile instanceof TileEntitySidedPipe && ((TileEntitySidedPipe)tile).getTransmitterType().getSize() == Size.SMALL) { @@ -301,7 +301,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySave(world, pos); + TileEntitySidedPipe tile = (TileEntitySidedPipe) MekanismUtils.getTileEntitySafe(world, pos); EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); tile.onNeighborTileChange(side); } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 5f099fccf..c3abcca99 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -1529,7 +1529,7 @@ public final class MekanismUtils } } - public static TileEntity getTileEntitySave(IBlockAccess worldIn, BlockPos pos) + public static TileEntity getTileEntitySafe(IBlockAccess worldIn, BlockPos pos) { return worldIn instanceof ChunkCache ? ((ChunkCache)worldIn).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : worldIn.getTileEntity(pos); } diff --git a/src/main/java/mekanism/generators/common/GeneratorsItems.java b/src/main/java/mekanism/generators/common/GeneratorsItems.java index 42e28d4c2..70e8fe0f3 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsItems.java +++ b/src/main/java/mekanism/generators/common/GeneratorsItems.java @@ -21,7 +21,7 @@ public class GeneratorsItems @Override public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos pos, EntityPlayer player) { - return MekanismUtils.getTileEntitySave(world, pos) instanceof TileEntityTurbineRotor; + return MekanismUtils.getTileEntitySafe(world, pos) instanceof TileEntityTurbineRotor; } }; diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index dd3cb096d..a02c398a5 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -169,7 +169,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).facing != null) { @@ -254,7 +254,7 @@ public abstract class BlockGenerator extends BlockContainer implements ICTMBlock { if(client.enableAmbientLighting) { - TileEntity tileEntity = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tileEntity = MekanismUtils.getTileEntitySafe(world, pos); if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) { diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index 6312da945..dea26a93b 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -75,7 +75,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntity tile = MekanismUtils.getTileEntitySave(worldIn, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(worldIn, pos); if(tile instanceof TileEntityReactorController) { @@ -293,7 +293,7 @@ public abstract class BlockReactor extends Block implements ICTMBlock, ITileEnti @Override public int getWeakPower(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { - TileEntity tile = MekanismUtils.getTileEntitySave(world, pos); + TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos); if(tile instanceof TileEntityReactorLogicAdapter) { From a5e816dddcdc0e30b182960a71aacee0bd08b923 Mon Sep 17 00:00:00 2001 From: Xander Date: Fri, 21 Jul 2017 20:35:41 +0800 Subject: [PATCH 19/36] Add util method to get Username from UUID, without nulls --- .../mekanism/common/entity/EntityRobit.java | 2 +- .../mekanism/common/frequency/Frequency.java | 3 ++- .../common/network/PacketSecurityUpdate.java | 5 +++-- .../common/tile/TileEntitySecurityDesk.java | 2 +- .../tile/component/TileComponentSecurity.java | 2 +- .../mekanism/common/util/MekanismUtils.java | 19 +++++++++++++++++++ 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index 97cd97567..110c845a9 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -578,7 +578,7 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine public void setOwnerUUID(UUID uuid) { dataManager.set(OWNER_UUID, uuid.toString()); - dataManager.set(OWNER_NAME, UsernameCache.getLastKnownUsername(uuid)); + dataManager.set(OWNER_NAME, MekanismUtils.getLastKnownUsername(uuid)); } public boolean getFollowing() diff --git a/src/main/java/mekanism/common/frequency/Frequency.java b/src/main/java/mekanism/common/frequency/Frequency.java index b4d76e39e..059b80db7 100644 --- a/src/main/java/mekanism/common/frequency/Frequency.java +++ b/src/main/java/mekanism/common/frequency/Frequency.java @@ -9,6 +9,7 @@ import java.util.UUID; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; +import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.UsernameCache; @@ -118,7 +119,7 @@ public class Frequency { data.add(name); data.add(ownerUUID.toString()); - data.add(UsernameCache.getLastKnownUsername(ownerUUID)); + data.add(MekanismUtils.getLastKnownUsername(ownerUUID)); data.add(publicFreq); } diff --git a/src/main/java/mekanism/common/network/PacketSecurityUpdate.java b/src/main/java/mekanism/common/network/PacketSecurityUpdate.java index 4146b91b4..4c4c26e21 100644 --- a/src/main/java/mekanism/common/network/PacketSecurityUpdate.java +++ b/src/main/java/mekanism/common/network/PacketSecurityUpdate.java @@ -13,6 +13,7 @@ import mekanism.common.frequency.Frequency; import mekanism.common.network.PacketSecurityUpdate.SecurityUpdateMessage; import mekanism.common.security.SecurityData; import mekanism.common.security.SecurityFrequency; +import mekanism.common.util.MekanismUtils; import net.minecraftforge.common.UsernameCache; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; @@ -51,7 +52,7 @@ public class PacketSecurityUpdate implements IMessageHandler"; + } + public static enum ResourceType { GUI("gui"), From a39d6245450af9d25f221833f5f009554333e944 Mon Sep 17 00:00:00 2001 From: Xander Date: Fri, 21 Jul 2017 20:46:59 +0800 Subject: [PATCH 20/36] minor fix for log message; return the size of the list we're checking against --- .../mekanism/common/content/transporter/TransporterManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/mekanism/common/content/transporter/TransporterManager.java b/src/main/java/mekanism/common/content/transporter/TransporterManager.java index 2fabf0060..9609b648b 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterManager.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterManager.java @@ -115,7 +115,7 @@ public class TransporterManager int slotID = slots[get]; if (slotID >= ret.size()){ - Mekanism.logger.error("Inventory {} gave slot number >= the number of slots it reported! {} >= {} ", inv.getClass().getName(), slotID, inv.getSizeInventory()); + Mekanism.logger.error("Inventory {} gave slot number >= the number of slots it reported! {} >= {} ", inv.getClass().getName(), slotID, ret.size()); continue; } From 7bf8fedb37150d5c5614cc3c0acc83ac6b52c52c Mon Sep 17 00:00:00 2001 From: Xander Date: Fri, 21 Jul 2017 21:24:12 +0800 Subject: [PATCH 21/36] add a log message the first time a username lookup fails --- src/main/java/mekanism/common/util/MekanismUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 30a73ef95..20967ad7d 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -113,6 +113,8 @@ public final class MekanismUtils public static final Map> classesFound = new HashMap>(); + private static final List warnedFails = new ArrayList<>(); + /** * Checks for a new version of Mekanism. */ @@ -1513,12 +1515,16 @@ public final class MekanismUtils public static String getLastKnownUsername(UUID uuid) { String ret = UsernameCache.getLastKnownUsername(uuid); - if (ret == null && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ // see if MC/Yggdrasil knows about it?! + if (ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ // see if MC/Yggdrasil knows about it?! GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid); if (gp != null){ ret = gp.getName(); } } + if (ret == null && !warnedFails.contains(uuid)){ + Mekanism.logger.warn("Failed to retrieve username for UUID {}, you might want to add it to the JSON cache", uuid); + warnedFails.add(uuid); + } return ret != null ? ret : ""; } From a34bceac00e9a2c5654c9865a96f8fe98e219288 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sat, 22 Jul 2017 05:13:08 -0600 Subject: [PATCH 22/36] Enhancements and improvements to MCMP functionality - Refactored retrieval of tile entities to take advantage of MCMP world wrapping - Added fixes for glow panels - Added single byte ordinal headers to handlePacketData in possible multipart tiles so that packets can be correctly routed - Added MultipartTileNetworkJoiner to route ITileNetwork packets when multiple network tiles are in the same multipart (i.e. glow panel attached to a transmitter) --- .../mekanism/common/block/BlockGlowPanel.java | 66 +++++++++++---- .../common/block/BlockTransmitter.java | 43 +++++----- .../multipart/MultipartGlowPanel.java | 66 ++++++++++++++- .../multipart/MultipartMekanism.java | 51 ++++++++---- .../multipart/MultipartTileNetworkJoiner.java | 83 +++++++++++++++++++ .../multipart/MultipartTransmitter.java | 23 ++++- .../common/tile/TileEntityGlowPanel.java | 16 ++++ .../TileEntityLogisticalTransporter.java | 15 ++++ .../transmitter/TileEntityMechanicalPipe.java | 11 +++ .../TileEntityPressurizedTube.java | 11 +++ .../tile/transmitter/TileEntitySidedPipe.java | 8 ++ .../TileEntityThermodynamicConductor.java | 10 +++ .../transmitter/TileEntityUniversalCable.java | 11 +++ 13 files changed, 358 insertions(+), 56 deletions(-) create mode 100644 src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java diff --git a/src/main/java/mekanism/common/block/BlockGlowPanel.java b/src/main/java/mekanism/common/block/BlockGlowPanel.java index 0480378b6..ab805fa58 100644 --- a/src/main/java/mekanism/common/block/BlockGlowPanel.java +++ b/src/main/java/mekanism/common/block/BlockGlowPanel.java @@ -8,6 +8,7 @@ import mekanism.common.MekanismBlocks; import mekanism.common.block.property.PropertyColor; import mekanism.common.block.states.BlockStateFacing; import mekanism.common.block.states.BlockStateGlowPanel; +import mekanism.common.integration.multipart.MultipartMekanism; import mekanism.common.tile.TileEntityGlowPanel; import mekanism.common.util.MultipartUtils; import net.minecraft.block.Block; @@ -71,7 +72,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); return tileEntity != null ? state.withProperty(BlockStateFacing.facingProperty, tileEntity.side) : state; } @@ -79,7 +80,7 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); if(tileEntity != null) { @@ -97,10 +98,10 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neighbor) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); - if(!world.isRemote && !canStay(tileEntity)) - { + if(tileEntity != null && !world.isRemote && !canStay(world, pos)) + { float motion = 0.7F; double motionX = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionY = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; @@ -117,10 +118,10 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntityGlowPanel tileEntity = (TileEntityGlowPanel)world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); - if(!tileEntity.getWorld().isRemote && !canStay(tileEntity)) - { + if(tileEntity != null && !tileEntity.getWorld().isRemote && !canStay(world, pos)) + { float motion = 0.7F; double motionX = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionY = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; @@ -137,11 +138,11 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntity tile = world.getTileEntity(pos); + TileEntityGlowPanel tileEntity = getTileEntityGlowPanel(world, pos); - if(tile != null && tile instanceof TileEntityGlowPanel) + if(tileEntity != null) { - return bounds[((TileEntityGlowPanel)tile).side.ordinal()]; + return bounds[tileEntity.side.ordinal()]; } return super.getBoundingBox(state, world, pos); @@ -153,10 +154,27 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider return world.isSideSolid(pos.offset(side.getOpposite()), side); } - public static boolean canStay(TileEntityGlowPanel tileEntity) + public static boolean canStay(IBlockAccess world, BlockPos pos) { - Coord4D adj = new Coord4D(tileEntity.getPos().offset(tileEntity.side), tileEntity.getWorld()); - return tileEntity.getWorld().isSideSolid(adj.getPos(), tileEntity.side.getOpposite()); + boolean canStay = false; + + if(Mekanism.hooks.MCMPLoaded) + { + canStay = MultipartMekanism.hasCenterSlot(world, pos); + } + + if(!canStay) + { + TileEntity tileEntity = world.getTileEntity(pos); + if(tileEntity instanceof TileEntityGlowPanel) + { + TileEntityGlowPanel glowPanel = (TileEntityGlowPanel)tileEntity; + Coord4D adj = new Coord4D(glowPanel.getPos().offset(glowPanel.side), glowPanel.getWorld()); + canStay = glowPanel.getWorld().isSideSolid(adj.getPos(), glowPanel.side.getOpposite()); + } + } + + return canStay; } @Override @@ -237,4 +255,24 @@ public class BlockGlowPanel extends Block implements ITileEntityProvider { return false; } + + private static TileEntityGlowPanel getTileEntityGlowPanel(IBlockAccess world, BlockPos pos) + { + TileEntity tileEntity = world.getTileEntity(pos); + TileEntityGlowPanel glowPanel = null; + if(tileEntity instanceof TileEntityGlowPanel) + { + glowPanel = (TileEntityGlowPanel)tileEntity; + } + else if(Mekanism.hooks.MCMPLoaded) + { + TileEntity childEntity = MultipartMekanism.unwrapTileEntity(world); + if(childEntity instanceof TileEntityGlowPanel) + { + glowPanel = (TileEntityGlowPanel)childEntity; + } + } + + return glowPanel; + } } diff --git a/src/main/java/mekanism/common/block/BlockTransmitter.java b/src/main/java/mekanism/common/block/BlockTransmitter.java index a02bda69f..27b4910b1 100644 --- a/src/main/java/mekanism/common/block/BlockTransmitter.java +++ b/src/main/java/mekanism/common/block/BlockTransmitter.java @@ -2,7 +2,6 @@ package mekanism.common.block; import java.util.Arrays; import java.util.List; -import java.util.Optional; import java.util.Random; import javax.annotation.Nullable; @@ -97,7 +96,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(worldIn.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(worldIn, pos); if(tile != null) { state = state.withProperty(BlockStateTransmitter.tierProperty, tile.getBaseTier()); @@ -130,7 +129,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public IBlockState getExtendedState(IBlockState state, IBlockAccess w, BlockPos pos) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(w.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(w, pos); if(tile != null) { @@ -148,7 +147,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if(tile != null && tile.getTransmitterType().getSize() == Size.SMALL) { @@ -161,7 +160,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entityIn, boolean b) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if(tile != null) { @@ -177,13 +176,13 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World world, BlockPos pos) { - return getDefaultForTile(getTileEntitySidedPipe(world.getTileEntity(pos))).offset(pos); + return getDefaultForTile(getTileEntitySidedPipe(world, pos)).offset(pos); } @Override public RayTraceResult collisionRayTrace(IBlockState blockState, World world, BlockPos pos, Vec3d start, Vec3d end) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if(tile == null) { @@ -228,7 +227,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { ItemStack itemStack = ItemStack.EMPTY; - TileEntitySidedPipe tileEntity = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tileEntity = getTileEntitySidedPipe(world, pos); if(tileEntity != null) { itemStack = new ItemStack(MekanismBlocks.Transmitter, 1, tileEntity.getTransmitterType().ordinal()); @@ -291,7 +290,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if(tile != null) { tile.onAdded(); @@ -301,7 +300,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void neighborChanged(IBlockState state, World world, BlockPos pos, Block block, BlockPos neighbor) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if(tile != null) { EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); @@ -312,7 +311,7 @@ public class BlockTransmitter extends Block implements ITileEntityProvider @Override public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor) { - TileEntitySidedPipe tile = getTileEntitySidedPipe(world.getTileEntity(pos)); + TileEntitySidedPipe tile = getTileEntitySidedPipe(world, pos); if(tile != null) { EnumFacing side = EnumFacing.getFacingFromVector(neighbor.getX() - pos.getX(), neighbor.getY() - pos.getY(), neighbor.getZ() - pos.getZ()); @@ -439,25 +438,23 @@ public class BlockTransmitter extends Block implements ITileEntityProvider return null; } - private TileEntitySidedPipe getTileEntitySidedPipe(TileEntity entity) + private static TileEntitySidedPipe getTileEntitySidedPipe(IBlockAccess world, BlockPos pos) { - TileEntitySidedPipe tileEntity = null; - if(entity instanceof TileEntitySidedPipe) + TileEntity tileEntity = world.getTileEntity(pos); + TileEntitySidedPipe sidedPipe = null; + if(tileEntity instanceof TileEntitySidedPipe) { - tileEntity = (TileEntitySidedPipe)entity; + sidedPipe = (TileEntitySidedPipe)tileEntity; } - else if(Mekanism.hooks.MCMPLoaded && MultipartMekanism.isMultiPartContainer(entity)) + else if(Mekanism.hooks.MCMPLoaded) { - for(TileEntity childEntity : MultipartMekanism.getMekanismTileEntities(entity)) + TileEntity childEntity = MultipartMekanism.unwrapTileEntity(world); + if(childEntity instanceof TileEntitySidedPipe) { - if(childEntity instanceof TileEntitySidedPipe) - { - tileEntity = (TileEntitySidedPipe)childEntity; - break; - } + sidedPipe = (TileEntitySidedPipe)childEntity; } } - return tileEntity; + return sidedPipe; } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java b/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java index 7a41b2b8a..3c4a87e91 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartGlowPanel.java @@ -1,13 +1,23 @@ package mekanism.common.integration.multipart; +import java.util.Random; + +import mcmultipart.api.container.IPartInfo; import mcmultipart.api.multipart.IMultipart; import mcmultipart.api.slot.EnumFaceSlot; import mcmultipart.api.slot.IPartSlot; +import mekanism.api.EnumColor; import mekanism.common.MekanismBlocks; +import mekanism.common.block.BlockGlowPanel; import mekanism.common.block.states.BlockStateFacing; +import mekanism.common.tile.TileEntityGlowPanel; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; @@ -15,6 +25,8 @@ import net.minecraft.world.World; public class MultipartGlowPanel implements IMultipart { + private static Random rand = new Random(); + @Override public IPartSlot getSlotForPlacement(World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, float hitY,float hitZ, EntityLivingBase placer) { @@ -28,7 +40,59 @@ public class MultipartGlowPanel implements IMultipart } @Override - public Block getBlock() { + public void onPartPlacedBy(IPartInfo part, EntityLivingBase placer, ItemStack stack) + { + TileEntity tile = part.getTile().getTileEntity(); + if(tile instanceof TileEntityGlowPanel) + { + EnumFacing facing = EnumFacing.values()[((EnumFaceSlot)part.getSlot()).ordinal()]; + EnumColor col = EnumColor.DYES[stack.getItemDamage()]; + + TileEntityGlowPanel glowPanel = (TileEntityGlowPanel)tile; + glowPanel.setOrientation(facing); + glowPanel.setColour(col); + } + } + + @Override + public void onPartRemoved(IPartInfo part, IPartInfo otherPart) + { + TileEntity tile = part.getTile().getTileEntity(); + if(tile instanceof TileEntityGlowPanel && !BlockGlowPanel.canStay(part.getPartWorld(), part.getPartPos())) + { + float motion = 0.7F; + double motionX = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + BlockPos pos = part.getPartPos(); + TileEntityGlowPanel glowPanel = (TileEntityGlowPanel)tile; + ItemStack stack = new ItemStack(MekanismBlocks.GlowPanel, 1, glowPanel.colour.getMetaValue()); + EntityItem entityItem = new EntityItem(glowPanel.getWorld(), pos.getX() + motionX, pos.getY() + motionY, pos.getZ() + motionZ, stack); + + part.getActualWorld().spawnEntity(entityItem); + part.remove(); + } + } + + @Override + public void onPartHarvested(IPartInfo part, EntityPlayer player) + { + TileEntity tile = part.getTile().getTileEntity(); + + if(tile instanceof TileEntityGlowPanel) + { + IBlockState partState = part.getState(); + partState.getBlock().removedByPlayer(partState, part.getPartWorld(), + part.getContainer().getPartPos(), player, true); + } + + IMultipart.super.onPartHarvested(part, player); + } + + @Override + public Block getBlock() + { return MekanismBlocks.GlowPanel; } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java index 5de3dbab5..2d6de8905 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java @@ -3,7 +3,6 @@ package mekanism.common.integration.multipart; import static mekanism.common.block.states.BlockStateMachine.MachineBlock.MACHINE_BLOCK_1; import static mekanism.common.block.states.BlockStateMachine.MachineBlock.MACHINE_BLOCK_2; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -17,12 +16,16 @@ import mcmultipart.api.container.IPartInfo; import mcmultipart.api.multipart.IMultipart; import mcmultipart.api.multipart.IMultipartRegistry; import mcmultipart.api.multipart.IMultipartTile; +import mcmultipart.api.multipart.MultipartCapabilityHelper; import mcmultipart.api.multipart.MultipartOcclusionHelper; import mcmultipart.api.ref.MCMPCapabilities; +import mcmultipart.api.slot.EnumCenterSlot; +import mcmultipart.api.world.IMultipartBlockAccess; import mekanism.common.MekanismBlocks; import mekanism.common.block.BlockTransmitter; import mekanism.common.block.states.BlockStateMachine.MachineType; import mekanism.common.block.states.BlockStateTransmitter.TransmitterType.Size; +import mekanism.common.capabilities.Capabilities; import mekanism.common.tile.TileEntityGlowPanel; import mekanism.common.tile.transmitter.TileEntityTransmitter; import net.minecraft.item.Item; @@ -31,6 +34,8 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilityProvider; @@ -65,6 +70,7 @@ public class MultipartMekanism implements IMCMPAddon registry.registerStackWrapper(Item.getItemFromBlock(MekanismBlocks.Transmitter), s -> true, MekanismBlocks.Transmitter); registry.registerPartWrapper(MekanismBlocks.GlowPanel, new MultipartGlowPanel()); registry.registerStackWrapper(Item.getItemFromBlock(MekanismBlocks.GlowPanel), s -> true, MekanismBlocks.GlowPanel); + MultipartCapabilityHelper.registerCapabilityJoiner(Capabilities.TILE_NETWORK_CAPABILITY, MultipartTileNetworkJoiner::new); } private void register(AttachCapabilitiesEvent e, String id) @@ -165,27 +171,38 @@ public class MultipartMekanism implements IMCMPAddon return Collections.emptyList(); } - public static boolean isMultiPartContainer(TileEntity entity) + public static boolean hasCenterSlot(IBlockAccess world, BlockPos pos) { - return entity instanceof IMultipartContainer; - } - - public static Collection getMekanismTileEntities(TileEntity container) - { - ArrayList entities = new ArrayList<>(); - - if(container instanceof IMultipartContainer) + IMultipartContainer container = null; + if(world instanceof IMultipartBlockAccess) { - for(IPartInfo partInfo : ((IMultipartContainer)container).getParts().values()) + container = ((IMultipartBlockAccess) world).getPartInfo().getContainer(); + } + else + { + TileEntity possibleContainer = world.getTileEntity(pos); + if(possibleContainer instanceof IMultipartContainer) { - IMultipartTile partTile = partInfo.getTile(); - if(partTile instanceof MultipartTile) - { - entities.add(((MultipartTile)partTile).getTileEntity()); - } + container = (IMultipartContainer)possibleContainer; } } - return entities; + boolean hasCenterSlot = false; + if(container != null) + { + hasCenterSlot = container.getPart(EnumCenterSlot.CENTER).isPresent(); + } + + return hasCenterSlot; + } + + public static TileEntity unwrapTileEntity(IBlockAccess world) + { + TileEntity tile = null; + if(world instanceof IMultipartBlockAccess) + { + tile = ((IMultipartBlockAccess)world).getPartInfo().getTile().getTileEntity(); + } + return tile; } } diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java new file mode 100644 index 000000000..ea24d7fcc --- /dev/null +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java @@ -0,0 +1,83 @@ +package mekanism.common.integration.multipart; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import io.netty.buffer.ByteBuf; +import mcmultipart.api.container.IMultipartContainer; +import mcmultipart.api.slot.EnumFaceSlot; +import mcmultipart.api.slot.IPartSlot; +import mcmultipart.api.world.IMultipartBlockAccess; +import mekanism.common.base.ITileNetwork; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; + +public class MultipartTileNetworkJoiner implements ITileNetwork +{ + private final HashMap tileSideMap; + + public MultipartTileNetworkJoiner(List tileList) + { + tileSideMap = new HashMap<>(); + IMultipartContainer container = null; + + TileEntity first = (TileEntity)tileList.get(0); + IBlockAccess world = first.getWorld(); + if(world instanceof IMultipartBlockAccess) + { + container = ((IMultipartBlockAccess)world).getPartInfo().getContainer(); + } + else + { + TileEntity worldTile = first.getWorld().getTileEntity(first.getPos()); + if(worldTile instanceof IMultipartContainer) + { + container = (IMultipartContainer)worldTile; + } + } + + if(container != null) + { + for(IPartSlot slot : container.getParts().keySet()) + { + int tileIndex = tileList.indexOf(container.getPartTile(slot).get().getTileEntity()); + if(tileIndex >= 0) + { + byte slotValue = slot instanceof EnumFaceSlot ? (byte)((EnumFaceSlot)slot).ordinal() : 6; + tileSideMap.put(slotValue, tileList.get(tileIndex)); + } + } + } + } + + @Override + public void handlePacketData(ByteBuf dataStream) throws Exception + { + while(dataStream.readableBytes() > 0) + { + dataStream.markReaderIndex(); + byte side = dataStream.readByte(); + dataStream.resetReaderIndex(); + + ITileNetwork networkTile = tileSideMap.get(side); + if(networkTile == null) + { + break; + } + + networkTile.handlePacketData(dataStream); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) + { + for(byte slotValue : tileSideMap.keySet()) + { + tileSideMap.get(slotValue).getNetworkedData(data); + } + + return data; + } +} diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java index d17656e59..d897cabab 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTransmitter.java @@ -5,11 +5,13 @@ import mcmultipart.api.multipart.IMultipart; import mcmultipart.api.slot.EnumCenterSlot; import mcmultipart.api.slot.IPartSlot; import mekanism.common.MekanismBlocks; +import mekanism.common.Tier.BaseTier; import mekanism.common.tile.transmitter.TileEntitySidedPipe; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; @@ -49,6 +51,7 @@ public class MultipartTransmitter implements IMultipart if(tile instanceof TileEntitySidedPipe) { tile.validate(); + ((TileEntitySidedPipe)tile).notifyTileChange(); } } @@ -79,7 +82,25 @@ public class MultipartTransmitter implements IMultipart } @Override - public Block getBlock() { + public void onPartPlacedBy(IPartInfo part, EntityLivingBase placer, ItemStack stack) + { + TileEntity tile = part.getTile().getTileEntity(); + + if(tile instanceof TileEntitySidedPipe) + { + BaseTier baseTier = BaseTier.BASIC; + if(stack.hasTagCompound()) + { + baseTier = BaseTier.values()[stack.getTagCompound().getInteger("tier")]; + } + + ((TileEntitySidedPipe)tile).setBaseTier(baseTier); + } + } + + @Override + public Block getBlock() + { return MekanismBlocks.Transmitter; } } diff --git a/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java b/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java index 39d712c7d..9fc3554f9 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java +++ b/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java @@ -37,6 +37,11 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork @Override public void handlePacketData(ByteBuf dataStream) throws Exception { + if(Mekanism.hooks.MCMPLoaded) + { + dataStream.readByte(); + } + side = EnumFacing.getFront(dataStream.readInt()); colour = EnumColor.DYES[dataStream.readInt()]; @@ -46,6 +51,11 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork @Override public ArrayList getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)side.ordinal()); + } + data.add(side.ordinal()); data.add(colour.getMetaValue()); @@ -73,6 +83,12 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork return nbt; } + + @Override + public NBTTagCompound getUpdateTag() + { + return writeToNBT(new NBTTagCompound()); + } @Override public void readFromNBT(NBTTagCompound nbt) diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java index 34e490d9e..499ff5aa0 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java @@ -184,6 +184,11 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)6); + } + data.add(0); super.getNetworkedData(data); @@ -271,6 +281,11 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter getSyncPacket(TransporterStack stack, boolean kill) { ArrayList data = new ArrayList(); + + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)6); + } data.add(1); data.add(kill); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java index a6813e86f..a40bf05a9 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java @@ -6,6 +6,7 @@ import java.util.ArrayList; import java.util.Collection; import mekanism.api.transmitters.TransmissionType; +import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.PipeTier; @@ -314,6 +315,11 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)6); + } + data.add(tier.ordinal()); super.getNetworkedData(data); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java index ba66073c3..a164a4de0 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java @@ -10,6 +10,7 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.transmitters.TransmissionType; +import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.TubeTier; @@ -298,6 +299,11 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)6); + } + data.add(tier.ordinal()); super.getNetworkedData(data); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java b/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java index a12465463..9b84b96d5 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java @@ -412,6 +412,14 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet return nbtTags; } + @Override + public NBTTagCompound getUpdateTag() + { + NBTTagCompound nbtTags = super.getUpdateTag(); + nbtTags.setInteger("tier", getBaseTier().ordinal()); + return nbtTags; + } + protected void onRefresh() {} public void refreshConnections() diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java index fbc28cd84..e12d82f44 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java @@ -140,6 +140,11 @@ public class TileEntityThermodynamicConductor extends TileEntityTransmitter getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)6); + } + data.add(tier.ordinal()); super.getNetworkedData(data); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java index 6fddbf4c4..574d4f077 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java @@ -13,6 +13,7 @@ import mekanism.api.energy.EnergyStack; import mekanism.api.energy.IStrictEnergyAcceptor; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.transmitters.TransmissionType; +import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.CableTier; @@ -392,6 +393,11 @@ public class TileEntityUniversalCable extends TileEntityTransmitter getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + data.add((byte)6); + } + data.add(tier.ordinal()); super.getNetworkedData(data); From 9106ac94a747bf5c59884e470ede5e19cc2a6e24 Mon Sep 17 00:00:00 2001 From: Tom Elfring Date: Sat, 22 Jul 2017 14:40:02 +0200 Subject: [PATCH 23/36] Fix handling of consumabe item fluid containers. Fixes #4539. Also added some null checks and fixed some compiler warnings --- .../common/util/FluidContainerUtils.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/mekanism/common/util/FluidContainerUtils.java b/src/main/java/mekanism/common/util/FluidContainerUtils.java index 330829f5f..37602c11c 100644 --- a/src/main/java/mekanism/common/util/FluidContainerUtils.java +++ b/src/main/java/mekanism/common/util/FluidContainerUtils.java @@ -13,8 +13,10 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.items.ItemHandlerHelper; -public final class FluidContainerUtils +public final class FluidContainerUtils { + private FluidContainerUtils(){} + public static boolean isFluidContainer(ItemStack stack) { return !stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); @@ -27,28 +29,25 @@ public final class FluidContainerUtils public static FluidStack extractFluid(FluidTank tileTank, TileEntityContainerBlock tile, int slotID, FluidChecker checker) { - FluidStack ret = extractFluid(tileTank.getCapacity()-tileTank.getFluidAmount(), tile.inventory.get(slotID), checker); - tile.inventory.set(slotID, FluidUtil.getFluidHandler(tile.inventory.get(slotID)).getContainer()); - return ret; + return extractFluid(tileTank.getCapacity()-tileTank.getFluidAmount(), tile.inventory.get(slotID), checker); } public static FluidStack extractFluid(int needed, ItemStack container, FluidChecker checker) { IFluidHandlerItem handler = FluidUtil.getFluidHandler(container); + FluidStack fluidStack = FluidUtil.getFluidContained(container); - if(handler == null || FluidUtil.getFluidContained(container) == null) + if(handler == null || fluidStack == null) { return null; } - if(checker != null && !checker.isValid(FluidUtil.getFluidContained(container).getFluid())) + if(checker != null && !checker.isValid(fluidStack.getFluid())) { return null; } - FluidStack ret = handler.drain(needed, true); - - return ret; + return handler.drain(needed, true); } public static int insertFluid(FluidTank tileTank, ItemStack container) @@ -60,7 +59,7 @@ public final class FluidContainerUtils { IFluidHandler handler = FluidUtil.getFluidHandler(container); - if(fluid == null) + if(fluid == null || handler == null) { return 0; } @@ -128,8 +127,9 @@ public final class FluidContainerUtils return (checker == null || checker.isValid(f)) && (storedFinal == null || storedFinal == f); } }); - - ItemStack inputCopy = FluidUtil.getFluidHandler(input).getContainer(); + + IFluidHandlerItem iFluidHandlerItem = FluidUtil.getFluidHandler(input); + ItemStack inputCopy = iFluidHandlerItem != null ? iFluidHandlerItem.getContainer() : ItemStack.EMPTY; if(FluidUtil.getFluidContained(inputCopy) == null && !inputCopy.isEmpty()) { From 8145088c4509e65c0a6332f43ed931fce330f860 Mon Sep 17 00:00:00 2001 From: aidancbrady Date: Sat, 22 Jul 2017 20:16:48 -0700 Subject: [PATCH 24/36] Cleanup --- .../java/mekanism/common/util/MekanismUtils.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index ce2b9d4b8..9a49e858a 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -1530,16 +1530,23 @@ public final class MekanismUtils public static String getLastKnownUsername(UUID uuid) { String ret = UsernameCache.getLastKnownUsername(uuid); - if (ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ // see if MC/Yggdrasil knows about it?! + + if(ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) + { // see if MC/Yggdrasil knows about it?! GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid); - if (gp != null){ + + if(gp != null) + { ret = gp.getName(); } } - if (ret == null && !warnedFails.contains(uuid)){ + + if(ret == null && !warnedFails.contains(uuid)) + { Mekanism.logger.warn("Failed to retrieve username for UUID {}, you might want to add it to the JSON cache", uuid); warnedFails.add(uuid); } + return ret != null ? ret : ""; } From f3b4909be96461f4c81af065b7562c3c45c0efa6 Mon Sep 17 00:00:00 2001 From: aidancbrady Date: Sat, 22 Jul 2017 20:26:58 -0700 Subject: [PATCH 25/36] Revert "Fix handling of consumabe item fluid containers." This reverts commit 9106ac94a747bf5c59884e470ede5e19cc2a6e24. --- .../common/util/FluidContainerUtils.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/mekanism/common/util/FluidContainerUtils.java b/src/main/java/mekanism/common/util/FluidContainerUtils.java index 37602c11c..330829f5f 100644 --- a/src/main/java/mekanism/common/util/FluidContainerUtils.java +++ b/src/main/java/mekanism/common/util/FluidContainerUtils.java @@ -13,10 +13,8 @@ import net.minecraftforge.fluids.capability.IFluidHandler; import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.items.ItemHandlerHelper; -public final class FluidContainerUtils +public final class FluidContainerUtils { - private FluidContainerUtils(){} - public static boolean isFluidContainer(ItemStack stack) { return !stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); @@ -29,25 +27,28 @@ public final class FluidContainerUtils public static FluidStack extractFluid(FluidTank tileTank, TileEntityContainerBlock tile, int slotID, FluidChecker checker) { - return extractFluid(tileTank.getCapacity()-tileTank.getFluidAmount(), tile.inventory.get(slotID), checker); + FluidStack ret = extractFluid(tileTank.getCapacity()-tileTank.getFluidAmount(), tile.inventory.get(slotID), checker); + tile.inventory.set(slotID, FluidUtil.getFluidHandler(tile.inventory.get(slotID)).getContainer()); + return ret; } public static FluidStack extractFluid(int needed, ItemStack container, FluidChecker checker) { IFluidHandlerItem handler = FluidUtil.getFluidHandler(container); - FluidStack fluidStack = FluidUtil.getFluidContained(container); - if(handler == null || fluidStack == null) + if(handler == null || FluidUtil.getFluidContained(container) == null) { return null; } - if(checker != null && !checker.isValid(fluidStack.getFluid())) + if(checker != null && !checker.isValid(FluidUtil.getFluidContained(container).getFluid())) { return null; } - return handler.drain(needed, true); + FluidStack ret = handler.drain(needed, true); + + return ret; } public static int insertFluid(FluidTank tileTank, ItemStack container) @@ -59,7 +60,7 @@ public final class FluidContainerUtils { IFluidHandler handler = FluidUtil.getFluidHandler(container); - if(fluid == null || handler == null) + if(fluid == null) { return 0; } @@ -127,9 +128,8 @@ public final class FluidContainerUtils return (checker == null || checker.isValid(f)) && (storedFinal == null || storedFinal == f); } }); - - IFluidHandlerItem iFluidHandlerItem = FluidUtil.getFluidHandler(input); - ItemStack inputCopy = iFluidHandlerItem != null ? iFluidHandlerItem.getContainer() : ItemStack.EMPTY; + + ItemStack inputCopy = FluidUtil.getFluidHandler(input).getContainer(); if(FluidUtil.getFluidContained(inputCopy) == null && !inputCopy.isEmpty()) { From 4691f83274d8a5d7dc8afe6eba6152128ef9ac36 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sat, 22 Jul 2017 21:47:10 -0600 Subject: [PATCH 26/36] Add JavaDoc to MultipartTileNetworkJoiner --- .../multipart/MultipartTileNetworkJoiner.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java index ea24d7fcc..166e4d4fc 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java @@ -13,10 +13,25 @@ import mekanism.common.base.ITileNetwork; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; +/** + * Used to route {@link ITileNetwork} packets sent to multipart containers with more than one possible recipient.
    + *
    + * When MCMP is enabled single byte EnumFacing ordinal headers are added to packets sent by glow panels and + * transmitters that are then used by this class to route packets to the part attached to the appropriate side.
    + *
    + * In this case, since transmitters do not attach to a side and therefore have no matching EnumFacing the special + * value 6 is used to represent the center slot. + */ public class MultipartTileNetworkJoiner implements ITileNetwork { private final HashMap tileSideMap; + /** + * Called by MCMP's multipart container when more than one part implements {@link ITileNetwork}.
    + *
    + * Builds an internal map of part slots to {@link ITileNetwork} implementations in order to route packets. + * @param tileList A list of the tile entities that implement {@link ITileNetwork} in the container. + */ public MultipartTileNetworkJoiner(List tileList) { tileSideMap = new HashMap<>(); From 3815945d1efc4db3a3da7928cc868e1e4d5949a7 Mon Sep 17 00:00:00 2001 From: Xander Date: Sun, 23 Jul 2017 12:50:43 +0800 Subject: [PATCH 27/36] Fix handling of consumable item fluid containers. Fixes #4539. Also added some null checks. --- .../common/util/FluidContainerUtils.java | 53 ++++++++++++------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/main/java/mekanism/common/util/FluidContainerUtils.java b/src/main/java/mekanism/common/util/FluidContainerUtils.java index 330829f5f..7fa9616a0 100644 --- a/src/main/java/mekanism/common/util/FluidContainerUtils.java +++ b/src/main/java/mekanism/common/util/FluidContainerUtils.java @@ -27,40 +27,46 @@ public final class FluidContainerUtils public static FluidStack extractFluid(FluidTank tileTank, TileEntityContainerBlock tile, int slotID, FluidChecker checker) { - FluidStack ret = extractFluid(tileTank.getCapacity()-tileTank.getFluidAmount(), tile.inventory.get(slotID), checker); - tile.inventory.set(slotID, FluidUtil.getFluidHandler(tile.inventory.get(slotID)).getContainer()); + IFluidHandlerItem handler = FluidUtil.getFluidHandler(tile.inventory.get(slotID)); + FluidStack ret = null; + if (handler != null) + { + ret = extractFluid(tileTank.getCapacity() - tileTank.getFluidAmount(), handler, checker); + tile.inventory.set(slotID, handler.getContainer()); + } return ret; } - public static FluidStack extractFluid(int needed, ItemStack container, FluidChecker checker) + public static FluidStack extractFluid(int needed, IFluidHandlerItem handler, FluidChecker checker) { - IFluidHandlerItem handler = FluidUtil.getFluidHandler(container); + if (handler == null) + { + return null; + } + + FluidStack fluidStack = handler.drain(Integer.MAX_VALUE, false); - if(handler == null || FluidUtil.getFluidContained(container) == null) + if(fluidStack == null) { return null; } - if(checker != null && !checker.isValid(FluidUtil.getFluidContained(container).getFluid())) + if(checker != null && !checker.isValid(fluidStack.getFluid())) { return null; } - FluidStack ret = handler.drain(needed, true); - - return ret; + return handler.drain(needed, true); } public static int insertFluid(FluidTank tileTank, ItemStack container) { - return insertFluid(tileTank.getFluid(), container); + return insertFluid(tileTank.getFluid(), FluidUtil.getFluidHandler(container)); } - public static int insertFluid(FluidStack fluid, ItemStack container) + public static int insertFluid(FluidStack fluid, IFluidHandler handler) { - IFluidHandler handler = FluidUtil.getFluidHandler(container); - - if(fluid == null) + if(fluid == null || handler == null) { return 0; } @@ -79,8 +85,13 @@ public final class FluidContainerUtils { ItemStack inputCopy = StackUtils.size(inventory.get(inSlot).copy(), 1); - int drained = insertFluid(stack, inputCopy); - inputCopy = FluidUtil.getFluidHandler(inputCopy).getContainer(); + IFluidHandlerItem handler = FluidUtil.getFluidHandler(inputCopy); + int drained = 0; + if (handler != null) + { + drained = insertFluid(stack, handler); + inputCopy = handler.getContainer(); + } if(!inventory.get(outSlot).isEmpty() && (!ItemHandlerHelper.canItemStacksStack(inventory.get(outSlot), inputCopy) || inventory.get(outSlot).getCount() == inventory.get(outSlot).getMaxStackSize())) { @@ -120,8 +131,14 @@ public final class FluidContainerUtils { final Fluid storedFinal = stored != null ? stored.getFluid() : null; final ItemStack input = StackUtils.size(inventory.get(inSlot).copy(), 1); + final IFluidHandlerItem handler = FluidUtil.getFluidHandler(input); + + if (handler == null) + { + return stored; + } - FluidStack ret = extractFluid(needed, input, new FluidChecker() { + FluidStack ret = extractFluid(needed, handler, new FluidChecker() { @Override public boolean isValid(Fluid f) { @@ -129,7 +146,7 @@ public final class FluidContainerUtils } }); - ItemStack inputCopy = FluidUtil.getFluidHandler(input).getContainer(); + ItemStack inputCopy = handler.getContainer(); if(FluidUtil.getFluidContained(inputCopy) == null && !inputCopy.isEmpty()) { From 8d55f5996b4f18f579d18cfbf5103817c0ab0218 Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sun, 23 Jul 2017 15:56:22 -0600 Subject: [PATCH 28/36] Refactoring multipart packet routing * Added addMultipartHeader to MultipartTileNetworkJoiner to determine whether a header is needed and add it if necessary * Moved individual header addition in transmitter implementations to TileEntitySidedPipe --- .../multipart/MultipartMekanism.java | 8 +++- .../multipart/MultipartTileNetworkJoiner.java | 43 +++++++++++++++++-- .../common/tile/TileEntityGlowPanel.java | 8 +--- .../TileEntityLogisticalTransporter.java | 15 ++----- .../transmitter/TileEntityMechanicalPipe.java | 11 ----- .../TileEntityPressurizedTube.java | 11 ----- .../tile/transmitter/TileEntitySidedPipe.java | 7 ++- .../TileEntityThermodynamicConductor.java | 10 ----- .../transmitter/TileEntityUniversalCable.java | 11 ----- 9 files changed, 57 insertions(+), 67 deletions(-) diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java index 2d6de8905..346662009 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartMekanism.java @@ -171,7 +171,7 @@ public class MultipartMekanism implements IMCMPAddon return Collections.emptyList(); } - public static boolean hasCenterSlot(IBlockAccess world, BlockPos pos) + static IMultipartContainer getContainer(IBlockAccess world, BlockPos pos) { IMultipartContainer container = null; if(world instanceof IMultipartBlockAccess) @@ -187,7 +187,13 @@ public class MultipartMekanism implements IMCMPAddon } } + return container; + } + + public static boolean hasCenterSlot(IBlockAccess world, BlockPos pos) + { boolean hasCenterSlot = false; + IMultipartContainer container = getContainer(world, pos); if(container != null) { hasCenterSlot = container.getPart(EnumCenterSlot.CENTER).isPresent(); diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java index 166e4d4fc..4a4a72af3 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java @@ -6,11 +6,13 @@ import java.util.List; import io.netty.buffer.ByteBuf; import mcmultipart.api.container.IMultipartContainer; +import mcmultipart.api.multipart.IMultipartTile; import mcmultipart.api.slot.EnumFaceSlot; import mcmultipart.api.slot.IPartSlot; import mcmultipart.api.world.IMultipartBlockAccess; import mekanism.common.base.ITileNetwork; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumFacing; import net.minecraft.world.IBlockAccess; /** @@ -24,7 +26,7 @@ import net.minecraft.world.IBlockAccess; */ public class MultipartTileNetworkJoiner implements ITileNetwork { - private final HashMap tileSideMap; + private final HashMap tileSideMap; /** * Called by MCMP's multipart container when more than one part implements {@link ITileNetwork}.
    @@ -71,9 +73,7 @@ public class MultipartTileNetworkJoiner implements ITileNetwork { while(dataStream.readableBytes() > 0) { - dataStream.markReaderIndex(); byte side = dataStream.readByte(); - dataStream.resetReaderIndex(); ITileNetwork networkTile = tileSideMap.get(side); if(networkTile == null) @@ -88,11 +88,46 @@ public class MultipartTileNetworkJoiner implements ITileNetwork @Override public ArrayList getNetworkedData(ArrayList data) { + ArrayList childData = new ArrayList<>(); for(byte slotValue : tileSideMap.keySet()) { - tileSideMap.get(slotValue).getNetworkedData(data); + tileSideMap.get(slotValue).getNetworkedData(childData); + data.addAll(childData); + childData.clear(); } return data; } + + /** + * Determines whether or not an {@link ITileNetwork} joiner is needed and, if so, adds a single byte header + * used to route packets inside multipart containers. + * @param entity The entity for which getNetworkedData is being called + * @param data The network data list + * @param facing The side this part is attached to or null for the center slot + */ + public static void addMultipartHeader(TileEntity entity, ArrayList data, EnumFacing facing) + { + int tileNetworkParts = 0; + IMultipartContainer container = MultipartMekanism.getContainer(entity.getWorld(), entity.getPos()); + if(container != null) + { + for(IPartSlot slot : container.getParts().keySet()) + { + TileEntity part = container.getPartTile(slot) + .map(multiPartTile -> multiPartTile.getTileEntity()) + .orElse(null); + + if(part instanceof ITileNetwork) + { + tileNetworkParts++; + } + } + } + + if(tileNetworkParts > 1) + { + data.add(0, (byte)(facing == null ? 6 : facing.ordinal())); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java b/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java index 9fc3554f9..d10588240 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java +++ b/src/main/java/mekanism/common/tile/TileEntityGlowPanel.java @@ -11,6 +11,7 @@ import mekanism.common.base.ITileNetwork; import mekanism.common.block.property.PropertyColor; import mekanism.common.block.states.BlockStateFacing; import mekanism.common.capabilities.Capabilities; +import mekanism.common.integration.multipart.MultipartTileNetworkJoiner; import mekanism.common.network.PacketDataRequest.DataRequestMessage; import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; @@ -37,11 +38,6 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork @Override public void handlePacketData(ByteBuf dataStream) throws Exception { - if(Mekanism.hooks.MCMPLoaded) - { - dataStream.readByte(); - } - side = EnumFacing.getFront(dataStream.readInt()); colour = EnumColor.DYES[dataStream.readInt()]; @@ -53,7 +49,7 @@ public class TileEntityGlowPanel extends TileEntity implements ITileNetwork { if(Mekanism.hooks.MCMPLoaded) { - data.add((byte)side.ordinal()); + MultipartTileNetworkJoiner.addMultipartHeader(this, data, side); } data.add(side.ordinal()); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java index 499ff5aa0..b1eafdea8 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityLogisticalTransporter.java @@ -21,6 +21,7 @@ import mekanism.common.content.transporter.PathfinderCache; import mekanism.common.content.transporter.TransitRequest; import mekanism.common.content.transporter.TransitRequest.TransitResponse; import mekanism.common.content.transporter.TransporterStack; +import mekanism.common.integration.multipart.MultipartTileNetworkJoiner; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.transmitters.TransporterImpl; import mekanism.common.transmitters.grid.InventoryNetwork; @@ -184,11 +185,6 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter getNetworkedData(ArrayList data) { - if(Mekanism.hooks.MCMPLoaded) - { - data.add((byte)6); - } - data.add(0); super.getNetworkedData(data); @@ -284,7 +275,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter())), new Range4D(new Coord4D(getPos(), getWorld()))); player.sendMessage(new TextComponentString(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.toggleColor") + ": " + (getTransmitter().getColor() != null ? getTransmitter().getColor().getColoredName() : EnumColor.BLACK + LangUtils.localize("gui.none")))); return EnumActionResult.SUCCESS; diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java index a40bf05a9..a6813e86f 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityMechanicalPipe.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.Collection; import mekanism.api.transmitters.TransmissionType; -import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.PipeTier; @@ -315,11 +314,6 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter getNetworkedData(ArrayList data) { - if(Mekanism.hooks.MCMPLoaded) - { - data.add((byte)6); - } - data.add(tier.ordinal()); super.getNetworkedData(data); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java index a164a4de0..ba66073c3 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityPressurizedTube.java @@ -10,7 +10,6 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.api.gas.IGasHandler; import mekanism.api.transmitters.TransmissionType; -import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.TubeTier; @@ -299,11 +298,6 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter getNetworkedData(ArrayList data) { - if(Mekanism.hooks.MCMPLoaded) - { - data.add((byte)6); - } - data.add(tier.ordinal()); super.getNetworkedData(data); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java b/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java index 9b84b96d5..e619fbdc6 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntitySidedPipe.java @@ -22,6 +22,7 @@ import mekanism.common.block.states.BlockStateTransmitter.TransmitterType; import mekanism.common.block.states.BlockStateTransmitter.TransmitterType.Size; import mekanism.common.capabilities.Capabilities; import mekanism.common.integration.multipart.MultipartMekanism; +import mekanism.common.integration.multipart.MultipartTileNetworkJoiner; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.CapabilityUtils; import mekanism.common.util.MekanismUtils; @@ -373,6 +374,11 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet @Override public ArrayList getNetworkedData(ArrayList data) { + if(Mekanism.hooks.MCMPLoaded) + { + MultipartTileNetworkJoiner.addMultipartHeader(this, data, null); + } + data.add(currentTransmitterConnections); data.add(currentAcceptorConnections); @@ -630,7 +636,6 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet for(EnumFacing side : EnumFacing.values()) { - int ord = side.ordinal(); byte connections = getAllCurrentConnections(); if(connectionMapContainsSide(connections, side)) diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java index e12d82f44..fbc28cd84 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityThermodynamicConductor.java @@ -140,11 +140,6 @@ public class TileEntityThermodynamicConductor extends TileEntityTransmitter getNetworkedData(ArrayList data) { - if(Mekanism.hooks.MCMPLoaded) - { - data.add((byte)6); - } - data.add(tier.ordinal()); super.getNetworkedData(data); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java index 574d4f077..6fddbf4c4 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java @@ -13,7 +13,6 @@ import mekanism.api.energy.EnergyStack; import mekanism.api.energy.IStrictEnergyAcceptor; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.transmitters.TransmissionType; -import mekanism.common.Mekanism; import mekanism.common.Tier; import mekanism.common.Tier.BaseTier; import mekanism.common.Tier.CableTier; @@ -393,11 +392,6 @@ public class TileEntityUniversalCable extends TileEntityTransmitter getNetworkedData(ArrayList data) { - if(Mekanism.hooks.MCMPLoaded) - { - data.add((byte)6); - } - data.add(tier.ordinal()); super.getNetworkedData(data); From 491a03cf63a24895df54eeef0c11a0c31ed04eff Mon Sep 17 00:00:00 2001 From: Richard Carter Date: Sun, 23 Jul 2017 19:00:20 -0400 Subject: [PATCH 29/36] TileEntityFluidTank: call getTileEntity once, not twice Another tiny performance improvement. Showed up when profiling. --- .../java/mekanism/common/tile/TileEntityFluidTank.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java index 4258ca120..1c182c82e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java @@ -245,10 +245,10 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public int pushUp(FluidStack fluid, boolean doFill) { Coord4D up = Coord4D.get(this).offset(EnumFacing.UP); - - if(up.getTileEntity(world) instanceof TileEntityFluidTank) + TileEntity tileEntity = up.getTileEntity(world); + if(tileEntity instanceof TileEntityFluidTank) { - IFluidHandler handler = CapabilityUtils.getCapability(up.getTileEntity(world), CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); + IFluidHandler handler = CapabilityUtils.getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN); if(PipeUtils.canFill(handler, fluid)) { @@ -565,7 +565,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc public boolean canFill(EnumFacing from, Fluid fluid) { TileEntity tile = world.getTileEntity(getPos().offset(EnumFacing.DOWN)); - if(from == EnumFacing.DOWN && world != null && getPos() != null) + if(from == EnumFacing.DOWN && world != null) { if(isActive && !(tile instanceof TileEntityFluidTank)) { From 0c0411979d6044e4edf7f4571eac492d234dd616 Mon Sep 17 00:00:00 2001 From: Richard Carter Date: Sun, 23 Jul 2017 16:50:02 -0400 Subject: [PATCH 30/36] Add sideIsOutput and sideIsConsumer methods getOutputtingSides and getConsumingSides both have to construct an EnumSet, but most usages only immediately call contains() on the EnumSet and then discard it. Improve performance by adding a method that can test a side and return a boolean, avoiding the EnumSet creation. --- .../mekanism/common/base/IEnergyWrapper.java | 2 ++ .../forgeenergy/ForgeEnergyIntegration.java | 4 +-- .../common/tile/TileEntityChargepad.java | 5 +++ .../common/tile/TileEntityEnergyCube.java | 10 ++++++ .../common/tile/TileEntityInductionPort.java | 36 +++++++++++++------ .../mekanism/common/tile/TileEntityLaser.java | 7 +++- .../tile/TileEntityLogisticalSorter.java | 5 +++ .../tile/TileEntityQuantumEntangloporter.java | 18 ++++++++++ .../tile/TileEntityResistiveHeater.java | 7 +++- .../tile/TileEntitySeismicVibrator.java | 5 +++ .../tile/prefab/TileEntityBasicMachine.java | 9 +++-- .../tile/prefab/TileEntityElectricBlock.java | 30 ++++++++++------ .../TileEntityAdvancedSolarGenerator.java | 5 +++ .../common/tile/TileEntityGenerator.java | 10 ++++++ .../common/tile/TileEntitySolarGenerator.java | 5 +++ .../tile/reactor/TileEntityReactorBlock.java | 12 ++++++- .../tile/reactor/TileEntityReactorPort.java | 10 ++++++ .../tile/turbine/TileEntityTurbineValve.java | 26 ++++++++++---- 18 files changed, 171 insertions(+), 35 deletions(-) diff --git a/src/main/java/mekanism/common/base/IEnergyWrapper.java b/src/main/java/mekanism/common/base/IEnergyWrapper.java index d4e25adab..9c231c4e6 100644 --- a/src/main/java/mekanism/common/base/IEnergyWrapper.java +++ b/src/main/java/mekanism/common/base/IEnergyWrapper.java @@ -25,8 +25,10 @@ import cofh.api.energy.IEnergyReceiver; public interface IEnergyWrapper extends IStrictEnergyStorage, IEnergyReceiver, IEnergyProvider, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, IStrictEnergyOutputter, IInventory { public EnumSet getOutputtingSides(); + public boolean sideIsOutput(EnumFacing side); public EnumSet getConsumingSides(); + public boolean sideIsConsumer(EnumFacing side); public double getMaxOutput(); } diff --git a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java index 86dfd217a..ded192cf0 100644 --- a/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java +++ b/src/main/java/mekanism/common/integration/forgeenergy/ForgeEnergyIntegration.java @@ -44,13 +44,13 @@ public class ForgeEnergyIntegration implements IEnergyStorage @Override public boolean canExtract() { - return tileEntity.getOutputtingSides().contains(side); + return tileEntity.sideIsOutput(side); } @Override public boolean canReceive() { - return tileEntity.getConsumingSides().contains(side); + return tileEntity.sideIsConsumer(side); } public static int rfToForge(int rf) diff --git a/src/main/java/mekanism/common/tile/TileEntityChargepad.java b/src/main/java/mekanism/common/tile/TileEntityChargepad.java index d769bfe39..51540ed55 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChargepad.java +++ b/src/main/java/mekanism/common/tile/TileEntityChargepad.java @@ -175,6 +175,11 @@ public class TileEntityChargepad extends TileEntityNoisyBlock return EnumSet.of(EnumFacing.DOWN, facing.getOpposite()); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return side == EnumFacing.DOWN || side == facing.getOpposite(); + } + @Override public boolean getActive() { diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index ce9ea8eba..89ad3cfd4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -161,12 +161,22 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 1, side); + } + @Override public EnumSet getOutputtingSides() { return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 2, side); + } + @Override public boolean canSetFacing(int side) { diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java index ff671f414..c7150965e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java @@ -102,6 +102,15 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsOutput(EnumFacing side) { + if (structure != null && mode) + { + return !structure.locations.contains(Coord4D.get(this).offset(side)); + } + return false; + } + @Override public EnumSet getConsumingSides() { @@ -112,7 +121,12 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement return EnumSet.noneOf(EnumFacing.class); } - + + @Override + public boolean sideIsConsumer(EnumFacing side) { + return (structure != null && !mode); + } + @Method(modid = "IC2") public void register() { @@ -241,7 +255,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { - if(getConsumingSides().contains(from)) + if(sideIsConsumer(from)) { double toAdd = (int)Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), maxReceive* general.FROM_RF); @@ -260,7 +274,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - if(getOutputtingSides().contains(from)) + if(sideIsOutput(from)) { double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*general.FROM_RF)); @@ -335,21 +349,21 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public boolean canOutputEnergy(EnumFacing side) { - return getOutputtingSides().contains(side); + return sideIsOutput(side); } @Override @Method(modid = "IC2") public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { - return getConsumingSides().contains(direction); + return sideIsConsumer(direction); } @Override @Method(modid = "IC2") public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { - return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; + return sideIsOutput(direction) && receiver instanceof IEnergyConductor; } @Override @@ -390,7 +404,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public boolean canReceiveEnergy(EnumFacing side) { - return getConsumingSides().contains(side); + return sideIsConsumer(side); } @Override @@ -512,8 +526,8 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY || capability == Capabilities.TESLA_HOLDER_CAPABILITY || capability == Capabilities.CONFIGURABLE_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && getConsumingSides().contains(facing)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getOutputtingSides().contains(facing)) + || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) || capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing); } @@ -531,8 +545,8 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement } if(capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && getConsumingSides().contains(facing)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getOutputtingSides().contains(facing))) + || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { return (T)teslaManager.getWrapper(this, facing); } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index 720666852..2ab5706e5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -123,7 +123,12 @@ public class TileEntityLaser extends TileEntityNoisyBlock implements IActiveStat { return EnumSet.of(facing.getOpposite()); } - + + @Override + public boolean sideIsConsumer(EnumFacing side) { + return side == facing.getOpposite(); + } + @Override public void setActive(boolean active) { diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index ce830d93d..69c2cc5aa 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -558,6 +558,11 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return false; + } + @Override public boolean canSetFacing(int facing) { diff --git a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java index b11ef18d6..4459b21cc 100644 --- a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java @@ -372,12 +372,30 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp return !hasFrequency() ? nothing : configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2); } + @Override + public boolean sideIsOutput(EnumFacing side) { + if (!hasFrequency()) + { + return false; + } + return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 2, side); + } + @Override public EnumSet getConsumingSides() { return !hasFrequency() ? nothing : configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + if (!hasFrequency()) + { + return false; + } + return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 1, side); + } + @Override public double getMaxOutput() { diff --git a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java index be6675b40..951ead305 100644 --- a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java @@ -129,7 +129,12 @@ public class TileEntityResistiveHeater extends TileEntityNoisyBlock implements I { return EnumSet.of(MekanismUtils.getLeft(facing), MekanismUtils.getRight(facing)); } - + + @Override + public boolean sideIsConsumer(EnumFacing side) { + return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); + } + @Override public boolean canSetFacing(int side) { diff --git a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java index 3c67dec50..57a1902c7 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java @@ -213,6 +213,11 @@ public class TileEntitySeismicVibrator extends TileEntityElectricBlock implement return EnumSet.of(facing.getOpposite()); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return side == facing.getOpposite(); + } + @Override public void setControlType(RedstoneControl type) { diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java index e72b39745..1e94bf290 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityBasicMachine.java @@ -30,10 +30,8 @@ public abstract class TileEntityBasicMachine, * The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture. * @param soundPath - location of the sound effect * @param name - full name of this machine - * @param location - GUI texture path of this machine - * @param perTick - the energy this machine consumes every tick in it's active state - * @param baseTicksRequired - how many ticks it takes to run a cycle * @param maxEnergy - how much energy this machine can store + * @param baseTicksRequired - how many ticks it takes to run a cycle */ public TileEntityBasicMachine(String soundPath, String name, double maxEnergy, double baseEnergyUsage, int upgradeSlot, int baseTicksRequired, ResourceLocation location) { @@ -48,6 +46,11 @@ public abstract class TileEntityBasicMachine, return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 1, side); + } + @Override public int[] getSlotsForFace(EnumFacing side) { diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java index c5b417fb9..c39030fea 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java @@ -107,12 +107,22 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return false; + } + @Override public EnumSet getConsumingSides() { return EnumSet.allOf(EnumFacing.class); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return true; + } + @Override public double getMaxOutput() { @@ -235,7 +245,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public boolean canConnectEnergy(EnumFacing from) { - return getConsumingSides().contains(from) || getOutputtingSides().contains(from); + return sideIsConsumer(from) || sideIsOutput(from); } @Override @@ -283,27 +293,27 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public boolean isTeleporterCompatible(EnumFacing side) { - return getOutputtingSides().contains(side); + return sideIsOutput(side); } @Override public boolean canOutputEnergy(EnumFacing side) { - return getOutputtingSides().contains(side); + return sideIsOutput(side); } @Override @Method(modid = "IC2") public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { - return getConsumingSides().contains(direction); + return sideIsConsumer(direction); } @Override @Method(modid = "IC2") public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { - return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; + return sideIsOutput(direction) && receiver instanceof IEnergyConductor; } @Override @@ -344,7 +354,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public boolean canReceiveEnergy(EnumFacing side) { - return getConsumingSides().contains(side); + return sideIsConsumer(side); } @Override @@ -418,8 +428,8 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i || capability == Capabilities.ENERGY_ACCEPTOR_CAPABILITY || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY || capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && getConsumingSides().contains(facing)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getOutputtingSides().contains(facing)) + || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) || capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing); } @@ -437,8 +447,8 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i } if(capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && getConsumingSides().contains(facing)) - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getOutputtingSides().contains(facing))) + || (capability == Capabilities.TESLA_CONSUMER_CAPABILITY && sideIsConsumer(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { return (T)teslaManager.getWrapper(this, facing); } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java index 6f0ba6784..98aa47409 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java @@ -25,6 +25,11 @@ public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator i return EnumSet.of(facing); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return side == facing; + } + @Override public void onPlace() { diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 08c1f5a29..db1b03243 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -122,12 +122,22 @@ public abstract class TileEntityGenerator extends TileEntityNoisyBlock implement return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return false; + } + @Override public EnumSet getOutputtingSides() { return EnumSet.of(facing); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return side == facing; + } + /** * Whether or not this generator can operate. * @return if the generator can operate diff --git a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index 2a60e490a..7d973fb07 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -194,6 +194,11 @@ public class TileEntitySolarGenerator extends TileEntityGenerator return EnumSet.of(EnumFacing.getFront(0)); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return side == EnumFacing.DOWN; + } + @Override public boolean renderUpdate() { diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java index 6f92bf465..3f423e422 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java @@ -82,12 +82,22 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return false; + } + @Override public EnumSet getConsumingSides() { return EnumSet.noneOf(EnumFacing.class); } - + + @Override + public boolean sideIsConsumer(EnumFacing side) { + return false; + } + @Override public void onChunkUnload() { diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index 5495c540c..85895f821 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -290,12 +290,22 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl return EnumSet.allOf(EnumFacing.class); } + @Override + public boolean sideIsOutput(EnumFacing side) { + return true; + } + @Override public EnumSet getConsumingSides() { return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsConsumer(EnumFacing side) { + return false; + } + @Override public double getMaxOutput() { diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java index 0753b2951..f7ddb4cbb 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java @@ -77,7 +77,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I { if(structure != null) { - EnumSet set = EnumSet.allOf(EnumFacing.class); + EnumSet set = EnumSet.allOf(EnumFacing.class); for(EnumFacing side : EnumFacing.VALUES) { @@ -93,11 +93,25 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I return EnumSet.noneOf(EnumFacing.class); } + @Override + public boolean sideIsOutput(EnumFacing side) { + if (structure != null) + { + return !structure.locations.contains(Coord4D.get(this).offset(side)); + } + return false; + } + @Override public EnumSet getConsumingSides() { return EnumSet.noneOf(EnumFacing.class); } + + @Override + public boolean sideIsConsumer(EnumFacing side) { + return false; + } @Method(modid = "IC2") public void register() @@ -183,7 +197,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - if(getOutputtingSides().contains(from)) + if(sideIsOutput(from)) { double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*general.FROM_RF)); @@ -254,7 +268,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Override public boolean canOutputEnergy(EnumFacing side) { - return getOutputtingSides().contains(side); + return sideIsOutput(side); } @Override @@ -268,7 +282,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I @Method(modid = "IC2") public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing direction) { - return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; + return sideIsOutput(direction) && receiver instanceof IEnergyConductor; } @Override @@ -473,7 +487,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I || capability == Capabilities.ENERGY_STORAGE_CAPABILITY || capability == Capabilities.ENERGY_OUTPUTTER_CAPABILITY || capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getOutputtingSides().contains(facing)) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing)) || capability == CapabilityEnergy.ENERGY) { return true; @@ -502,7 +516,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I } if(capability == Capabilities.TESLA_HOLDER_CAPABILITY - || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && getOutputtingSides().contains(facing))) + || (capability == Capabilities.TESLA_PRODUCER_CAPABILITY && sideIsOutput(facing))) { return (T)teslaManager.getWrapper(this, facing); } From a9b023a6b2c40eaf0cec2576f1ced2091462a8c4 Mon Sep 17 00:00:00 2001 From: Richard Carter Date: Sun, 23 Jul 2017 16:55:13 -0400 Subject: [PATCH 31/36] acceptEnergy/pullEnergy: return 0 if machine is full or empty Prior to this change, the machines always updated their energy, which involved a side check and a chunk markDirty; even if the machine is receiving or giving 0 energy. Right upfront, check if the machine needs no energy or has none to give, and if so return 0. I observed greatly increased server tick performance after this change. --- .../common/tile/TileEntityInductionPort.java | 18 +++++++++++------- .../common/tile/TileEntityLaserAmplifier.java | 5 +++++ .../tile/prefab/TileEntityElectricBlock.java | 12 ++++++------ .../transmitter/TileEntityUniversalCable.java | 6 +++--- .../tile/turbine/TileEntityTurbineValve.java | 6 +++--- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java index c7150965e..d14643187 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java @@ -442,13 +442,13 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public double acceptEnergy(EnumFacing side, double amount, boolean simulate) { - if(!getConsumingSides().contains(side)) + double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount); + + if(toUse < 0.0001 || (side != null && !sideIsConsumer(side))) { return 0; } - double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount); - if(!simulate) { setEnergy(getEnergy() + toUse); @@ -461,14 +461,18 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement @Override public double pullEnergy(EnumFacing side, double amount, boolean simulate) { - if(!getOutputtingSides().contains(side)) + double toGive = Math.min(getEnergy(), amount); + + if(toGive < 0.0001 || (side != null && !sideIsOutput(side))) { return 0; } - double toGive = Math.min(getEnergy(), amount); - setEnergy(getEnergy() - toGive); - + if (!simulate) + { + setEnergy(getEnergy() - toGive); + } + return toGive; } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java index 3be4ba8e4..3040715d3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java @@ -196,6 +196,11 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement public double pullEnergy(EnumFacing side, double amount, boolean simulate) { double toGive = Math.min(getEnergy(), amount); + + if (toGive < 0.0001) + { + return 0; + } if(!simulate) { diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java index c39030fea..637d0a596 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityElectricBlock.java @@ -388,12 +388,12 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public double acceptEnergy(EnumFacing side, double amount, boolean simulate) { - if(!(getConsumingSides().contains(side) || side == null)) + double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); + + if(toUse < 0.0001 || (side != null && !sideIsConsumer(side))) { return 0; } - - double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); if(!simulate) { @@ -406,13 +406,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Override public double pullEnergy(EnumFacing side, double amount, boolean simulate) { - if(!(getOutputtingSides().contains(side) || side == null)) + double toGive = Math.min(getEnergy(), amount); + + if(toGive < 0.0001 || (side != null && !sideIsOutput(side))) { return 0; } - double toGive = Math.min(getEnergy(), amount); - if(!simulate) { setEnergy(getEnergy() - toGive); diff --git a/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java b/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java index 6fddbf4c4..4a5245bc2 100644 --- a/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java +++ b/src/main/java/mekanism/common/tile/transmitter/TileEntityUniversalCable.java @@ -287,13 +287,13 @@ public class TileEntityUniversalCable extends TileEntityTransmitter Date: Sun, 23 Jul 2017 16:59:05 -0400 Subject: [PATCH 32/36] TileEntityAdvancedBoundingBlock calls getInv twice as much as needed getInv is a non-trivial getter and doesn't need to be called twice in all of these methods. Refactor the methods to only call it once. --- .../tile/TileEntityAdvancedBoundingBlock.java | 190 +++++++++++------- 1 file changed, 112 insertions(+), 78 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index c7bfee78f..8b89794a4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -32,89 +32,97 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override public boolean isEmpty() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return true; } - return getInv().isEmpty(); + return inv.isEmpty(); } @Override public int getSizeInventory() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return 0; } - return getInv().getSizeInventory(); + return inv.getSizeInventory(); } @Override public ItemStack getStackInSlot(int i) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return ItemStack.EMPTY; } - return getInv().getStackInSlot(i); + return inv.getStackInSlot(i); } @Override public ItemStack decrStackSize(int i, int j) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return ItemStack.EMPTY; } - return getInv().decrStackSize(i, j); + return inv.decrStackSize(i, j); } @Override public ItemStack removeStackFromSlot(int i) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return ItemStack.EMPTY; } - return getInv().removeStackFromSlot(i); + return inv.removeStackFromSlot(i); } @Override public void setInventorySlotContents(int i, ItemStack itemstack) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return; } - getInv().setInventorySlotContents(i, itemstack); + inv.setInventorySlotContents(i, itemstack); } @Override public String getName() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return "null"; } - return getInv().getName(); + return inv.getName(); } @Override public boolean hasCustomName() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return false; } - return getInv().hasCustomName(); + return inv.hasCustomName(); } @Override @@ -126,56 +134,61 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override public int getInventoryStackLimit() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return 0; } - return getInv().getInventoryStackLimit(); + return inv.getInventoryStackLimit(); } @Override public boolean isUsableByPlayer(EntityPlayer entityplayer) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return false; } - return getInv().isUsableByPlayer(entityplayer); + return inv.isUsableByPlayer(entityplayer); } @Override public void openInventory(EntityPlayer player) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return; } - getInv().openInventory(player); + inv.openInventory(player); } @Override public void closeInventory(EntityPlayer player) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return; } - getInv().closeInventory(player); + inv.closeInventory(player); } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return false; } - return getInv().canBoundInsert(getPos(), i, itemstack); + return inv.canBoundInsert(getPos(), i, itemstack); } @Override @@ -202,12 +215,13 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override public int[] getSlotsForFace(EnumFacing side) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return InventoryUtils.EMPTY; } - return getInv().getBoundSlots(getPos(), side); + return inv.getBoundSlots(getPos(), side); } @Override @@ -219,137 +233,138 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp @Override public boolean canExtractItem(int i, ItemStack itemstack, EnumFacing side) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return false; } - return getInv().canBoundExtract(getPos(), i, itemstack, side); + return inv.canBoundExtract(getPos(), i, itemstack, side); } @Override @Method(modid = "IC2") public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing direction) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return false; } - return getInv().acceptsEnergyFrom(emitter, direction); + return inv.acceptsEnergyFrom(emitter, direction); } @Override public int receiveEnergy(EnumFacing from, int maxReceive, boolean simulate) { - if(getInv() == null || !canReceiveEnergy(from)) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null || !canReceiveEnergy(from)) { return 0; } - return getInv().receiveEnergy(from, maxReceive, simulate); + return inv.receiveEnergy(from, maxReceive, simulate); } @Override public int extractEnergy(EnumFacing from, int maxExtract, boolean simulate) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return 0; } - return getInv().extractEnergy(from, maxExtract, simulate); + return inv.extractEnergy(from, maxExtract, simulate); } @Override public boolean canConnectEnergy(EnumFacing from) { - if(getInv() == null) - { - return false; - } - return canReceiveEnergy(from); } @Override public int getEnergyStored(EnumFacing from) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return 0; } - return getInv().getEnergyStored(from); + return inv.getEnergyStored(from); } @Override public int getMaxEnergyStored(EnumFacing from) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return 0; } - return getInv().getMaxEnergyStored(from); + return inv.getMaxEnergyStored(from); } @Override public double acceptEnergy(EnumFacing side, double amount, boolean simulate) { - if(getInv() == null || !canReceiveEnergy(side)) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null || !canReceiveEnergy(side)) { return 0; } - return getInv().acceptEnergy(side, amount, simulate); + return inv.acceptEnergy(side, amount, simulate); } @Override public boolean canReceiveEnergy(EnumFacing side) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return false; } - return getInv().canBoundReceiveEnergy(getPos(), side); + return inv.canBoundReceiveEnergy(getPos(), side); } @Override @Method(modid = "IC2") public double getDemandedEnergy() { - if(getInv() == null) - { - return 0; - } - - return getInv().getDemandedEnergy(); + IAdvancedBoundingBlock inv = getInv(); + return inv == null ? 0 : inv.getDemandedEnergy(); } @Override @Method(modid = "IC2") public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) { - if(getInv() == null || !canReceiveEnergy(directionFrom)) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null || !canReceiveEnergy(directionFrom)) { return amount; } - return getInv().injectEnergy(directionFrom, amount, voltage); + return inv.injectEnergy(directionFrom, amount, voltage); } @Override @Method(modid = "IC2") public int getSinkTier() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return 0; } - return getInv().getSinkTier(); + return inv.getSinkTier(); } public IAdvancedBoundingBlock getInv() @@ -367,7 +382,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp return null; } - return (IAdvancedBoundingBlock)new Coord4D(mainPos, world).getTileEntity(world); + return (IAdvancedBoundingBlock) tile; } @Override @@ -375,9 +390,10 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { super.onPower(); - if(getInv() != null) + IAdvancedBoundingBlock inv = getInv(); + if(inv != null) { - getInv().onPower(); + inv.onPower(); } } @@ -386,86 +402,104 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp { super.onNoPower(); - if(getInv() != null) + IAdvancedBoundingBlock inv = getInv(); + if(inv != null) { - getInv().onNoPower(); + inv.onNoPower(); } } @Override public String[] getMethods() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return new String[] {}; } - return getInv().getMethods(); + return inv.getMethods(); } @Override public Object[] invoke(int method, Object[] arguments) throws Exception { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return new Object[] {}; } - return getInv().invoke(method, arguments); + return inv.invoke(method, arguments); } @Override public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return new NBTTagCompound(); } - return getInv().getConfigurationData(nbtTags); + return inv.getConfigurationData(nbtTags); } @Override public void setConfigurationData(NBTTagCompound nbtTags) { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return; } - getInv().setConfigurationData(nbtTags); + inv.setConfigurationData(nbtTags); } @Override public String getDataType() { - if(getInv() == null) + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return "null"; } - return getInv().getDataType(); + return inv.getDataType(); } @Override public boolean hasCapability(Capability capability, EnumFacing facing) { - if(getInv() == null || capability == Capabilities.TILE_NETWORK_CAPABILITY) + if (capability == Capabilities.TILE_NETWORK_CAPABILITY) + { + return super.hasCapability(capability, facing); + } + + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return super.hasCapability(capability, facing); } - return getInv().hasCapability(capability, facing); + return inv.hasCapability(capability, facing); } @Override public T getCapability(Capability capability, EnumFacing facing) { - if(getInv() == null || capability == Capabilities.TILE_NETWORK_CAPABILITY) + if (capability == Capabilities.TILE_NETWORK_CAPABILITY) + { + return super.getCapability(capability, facing); + } + + IAdvancedBoundingBlock inv = getInv(); + if(inv == null) { return super.getCapability(capability, facing); } - return getInv().getCapability(capability, facing); + return inv.getCapability(capability, facing); } } From bc3274825afbd0340c31df811e8fa01ed3f34016 Mon Sep 17 00:00:00 2001 From: Richard Carter Date: Sun, 23 Jul 2017 17:04:24 -0400 Subject: [PATCH 33/36] Some performance-oriented refactoring of TileComponentConfig Add new type "SideConfig" which is observable, this could come in handy later. Add hasSideForData method in componentConfig, which is much more efficient than calling getSidesForData().contains. Refactor duplicate calls to getConfig into single instances. getConfig is a nontrivial method. --- .../network/PacketConfigurationUpdate.java | 2 +- .../common/tile/TileEntityGasTank.java | 2 +- .../tile/TileEntityMetallurgicInfuser.java | 2 +- .../common/tile/component/SideConfig.java | 56 ++++++++++++ .../tile/component/TileComponentConfig.java | 87 +++++++++++-------- .../tile/component/TileComponentEjector.java | 15 ++-- .../TileEntityAdvancedElectricMachine.java | 8 +- .../prefab/TileEntityElectricMachine.java | 2 +- .../mekanism/common/util/MekanismUtils.java | 59 ++++++++----- 9 files changed, 163 insertions(+), 70 deletions(-) create mode 100644 src/main/java/mekanism/common/tile/component/SideConfig.java diff --git a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java index 05a36b884..5b8b3ed66 100644 --- a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java +++ b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java @@ -60,7 +60,7 @@ public class PacketConfigurationUpdate implements IMessageHandler sideConfigs = new HashMap(); - public Map> sideOutputs = new HashMap>(); - public Map ejecting = new HashMap(); - public Map canEject = new HashMap(); + private Map sideConfigs = new HashMap<>(); + private Map> sideOutputs = new HashMap<>(); + private Map ejecting = new HashMap<>(); + private Map canEject = new HashMap<>(); - public List transmissions = new ArrayList(); + public List transmissions = new ArrayList<>(); public TileComponentConfig(TileEntityContainerBlock tile, TransmissionType... types) { @@ -59,43 +59,48 @@ public class TileComponentConfig implements ITileComponent transmissions.add(type); } - sideOutputs.put(type.ordinal(), new ArrayList()); - ejecting.put(type.ordinal(), false); - canEject.put(type.ordinal(), true); + sideOutputs.put(type, new ArrayList<>()); + ejecting.put(type, false); + canEject.put(type, true); } - + public EnumSet getSidesForData(TransmissionType type, EnumFacing facing, int dataIndex) { EnumSet ret = EnumSet.noneOf(EnumFacing.class); + SideConfig config = getConfig(type); + EnumFacing[] translatedFacings = MekanismUtils.getBaseOrientations(facing); - for(EnumFacing f : EnumFacing.VALUES) + for(int i = 0; i < EnumFacing.VALUES.length; i++) { - EnumFacing side = MekanismUtils.getBaseOrientation(f, facing); - - if(getConfig(type)[side.ordinal()] == dataIndex) + if(config.get(translatedFacings[i]) == dataIndex) { - ret.add(f); + ret.add(translatedFacings[i]); } } return ret; } + + public boolean hasSideForData(TransmissionType type, EnumFacing facing, int dataIndex, EnumFacing sideToTest) + { + return getConfig(type).get(sideToTest) == dataIndex; + } public void setCanEject(TransmissionType type, boolean eject) { - canEject.put(type.ordinal(), eject); + canEject.put(type, eject); } public boolean canEject(TransmissionType type) { - return canEject.get(type.ordinal()); + return canEject.get(type); } public void fillConfig(TransmissionType type, int data) { byte sideData = (byte)data; - setConfig(type, new byte[] {sideData, sideData, sideData, sideData, sideData, sideData}); + setConfig(type, sideData, sideData, sideData, sideData, sideData, sideData); } public void setIOConfig(TransmissionType type) @@ -115,25 +120,31 @@ public class TileComponentConfig implements ITileComponent fillConfig(type, 1); setCanEject(type, false); } - + public void setConfig(TransmissionType type, byte[] config) { - sideConfigs.put(type.ordinal(), config); + assert config.length == EnumFacing.VALUES.length; + setConfig(type, config[0], config[1], config[2], config[3], config[4], config[5]); + } + + public void setConfig(TransmissionType type, byte d, byte u, byte n, byte s, byte w, byte e) + { + sideConfigs.put(type, new SideConfig(d, u, n, s, w, e)); } public void addOutput(TransmissionType type, SideData data) { - sideOutputs.get(type.ordinal()).add(data); + sideOutputs.get(type).add(data); } public ArrayList getOutputs(TransmissionType type) { - return sideOutputs.get(type.ordinal()); + return sideOutputs.get(type); } - public byte[] getConfig(TransmissionType type) + public SideConfig getConfig(TransmissionType type) { - return sideConfigs.get(type.ordinal()); + return sideConfigs.get(type); } public SideData getOutput(TransmissionType type, EnumFacing side, EnumFacing facing) @@ -152,8 +163,9 @@ public class TileComponentConfig implements ITileComponent { return EMPTY; } - - int index = getConfig(type)[side.ordinal()]; + + SideConfig sideConfig = getConfig(type); + int index = sideConfig.get(side); if(index == -1) { @@ -161,7 +173,8 @@ public class TileComponentConfig implements ITileComponent } else if(index > getOutputs(type).size()-1) { - index = getConfig(type)[side.ordinal()] = 0; + sideConfig.set(side, (byte) 0); + index = 0; } return getOutputs(type).get(index); @@ -184,8 +197,8 @@ public class TileComponentConfig implements ITileComponent { if(nbtTags.getByteArray("config" + type.ordinal()).length > 0) { - sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal())); - ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal())); + sideConfigs.put(type, new SideConfig(nbtTags.getByteArray("config" + type.ordinal()))); + ejecting.put(type, nbtTags.getBoolean("ejecting" + type.ordinal())); } } } @@ -207,9 +220,9 @@ public class TileComponentConfig implements ITileComponent { byte[] array = new byte[6]; dataStream.readBytes(array); - - sideConfigs.put(type.ordinal(), array); - ejecting.put(type.ordinal(), dataStream.readBoolean()); + + sideConfigs.put(type, new SideConfig(array)); + ejecting.put(type, dataStream.readBoolean()); } } @@ -218,8 +231,8 @@ public class TileComponentConfig implements ITileComponent { for(TransmissionType type : transmissions) { - nbtTags.setByteArray("config" + type.ordinal(), sideConfigs.get(type.ordinal())); - nbtTags.setBoolean("ejecting" + type.ordinal(), ejecting.get(type.ordinal())); + nbtTags.setByteArray("config" + type.ordinal(), sideConfigs.get(type).asByteArray()); + nbtTags.setBoolean("ejecting" + type.ordinal(), ejecting.get(type)); } nbtTags.setBoolean("sideDataStored", true); @@ -237,8 +250,8 @@ public class TileComponentConfig implements ITileComponent for(TransmissionType type : transmissions) { - data.add(sideConfigs.get(type.ordinal())); - data.add(ejecting.get(type.ordinal())); + data.add(sideConfigs.get(type).asByteArray()); + data.add(ejecting.get(type)); } } @@ -247,12 +260,12 @@ public class TileComponentConfig implements ITileComponent public boolean isEjecting(TransmissionType type) { - return ejecting.get(type.ordinal()); + return ejecting.get(type); } public void setEjecting(TransmissionType type, boolean eject) { - ejecting.put(type.ordinal(), eject); + ejecting.put(type, eject); MekanismUtils.saveChunk(tileEntity); } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java index 0610c9d72..6d49e2873 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java @@ -153,13 +153,18 @@ public class TileComponentEjector implements ITileComponent List outputSides = new ArrayList(); ISideConfiguration configurable = (ISideConfiguration)tileEntity; - for(int i = 0; i < configurable.getConfig().getConfig(type).length; i++) + SideConfig sideConfig = configurable.getConfig().getConfig(type); + ArrayList outputs = configurable.getConfig().getOutputs(type); + + EnumFacing[] facings = MekanismUtils.getBaseOrientations(tileEntity.facing); + + for(int i = 0; i < EnumFacing.VALUES.length; i++) { - EnumFacing side = MekanismUtils.getBaseOrientation(EnumFacing.getFront(i), tileEntity.facing); - - if(configurable.getConfig().getConfig(type)[side.ordinal()] == configurable.getConfig().getOutputs(type).indexOf(data)) + EnumFacing side = facings[i]; + + if(sideConfig.get(side) == outputs.indexOf(data)) { - outputSides.add(EnumFacing.getFront(i)); + outputSides.add(EnumFacing.VALUES[i]); } } diff --git a/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java b/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java index fe3ceccd1..2b1a0d75d 100644 --- a/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/tile/prefab/TileEntityAdvancedElectricMachine.java @@ -60,10 +60,10 @@ public abstract class TileEntityAdvancedElectricMachine outputs = config.getConfig().getOutputs(type); + SideConfig sideConfig = config.getConfig().getConfig(type); + int max = outputs.size() - 1; + int current = outputs.indexOf(outputs.get(sideConfig.get(direction))); if(current < max) { - config.getConfig().getConfig(type)[side] = (byte)(current+1); + sideConfig.set(direction, (byte) (current+1)); } else if(current == max) { - config.getConfig().getConfig(type)[side] = 0; + sideConfig.set(direction, (byte) 0); } - TileEntity tile = (TileEntity)config; - + assert config instanceof TileEntity; + TileEntity tile = (TileEntity) config; tile.markDirty(); } @@ -578,19 +595,21 @@ public final class MekanismUtils */ public static void decrementOutput(ISideConfiguration config, TransmissionType type, EnumFacing direction) { - int side = direction.ordinal(); - int max = config.getConfig().getOutputs(type).size()-1; - int current = config.getConfig().getOutputs(type).indexOf(config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type)[side])); + ArrayList outputs = config.getConfig().getOutputs(type); + SideConfig sideConfig = config.getConfig().getConfig(type); + int max = outputs.size()-1; + int current = outputs.indexOf(outputs.get(sideConfig.get(direction))); if(current > 0) { - config.getConfig().getConfig(type)[side] = (byte)(current-1); + sideConfig.set(direction, (byte)(current - 1)); } else if(current == 0) { - config.getConfig().getConfig(type)[side] = (byte)max; + sideConfig.set(direction, (byte)max); } + assert config instanceof TileEntity; TileEntity tile = (TileEntity)config; tile.markDirty(); } From 7ce1ac4d421add8bb49f85e84d1b62dee5ec442b Mon Sep 17 00:00:00 2001 From: Chris Anderson Date: Sun, 23 Jul 2017 19:02:49 -0600 Subject: [PATCH 34/36] Update addMultipartHeader to stop counting ITileNetwork implementations after 2 --- .../integration/multipart/MultipartTileNetworkJoiner.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java index 4a4a72af3..765e2135d 100644 --- a/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java +++ b/src/main/java/mekanism/common/integration/multipart/MultipartTileNetworkJoiner.java @@ -121,6 +121,10 @@ public class MultipartTileNetworkJoiner implements ITileNetwork if(part instanceof ITileNetwork) { tileNetworkParts++; + if(tileNetworkParts > 1) + { + break; + } } } } From 7db697213c813422f8711e54e0e79c8086943344 Mon Sep 17 00:00:00 2001 From: aidancbrady Date: Sun, 23 Jul 2017 18:02:49 -0700 Subject: [PATCH 35/36] Minor cleanup --- .../common/tile/component/SideConfig.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/mekanism/common/tile/component/SideConfig.java b/src/main/java/mekanism/common/tile/component/SideConfig.java index 2c88127a6..7424d7f0b 100644 --- a/src/main/java/mekanism/common/tile/component/SideConfig.java +++ b/src/main/java/mekanism/common/tile/component/SideConfig.java @@ -5,15 +5,15 @@ import net.minecraft.util.EnumFacing; import java.util.Observable; import java.util.Observer; -public class SideConfig { +public class SideConfig +{ private byte[] directions = new byte[EnumFacing.VALUES.length]; private Observable observable = new Observable(); - public SideConfig() - { - } + public SideConfig() {} - public SideConfig(byte[] b) { + public SideConfig(byte[] b) + { this(b[0], b[1], b[2], b[3], b[4], b[5]); assert b.length == EnumFacing.VALUES.length; } @@ -23,34 +23,41 @@ public class SideConfig { setDirections(d, u, n, s, w, e); } - public void setDirections(byte d, byte u, byte n, byte s, byte w, byte e) { + public void setDirections(byte d, byte u, byte n, byte s, byte w, byte e) + { directions[0] = d; directions[1] = u; directions[2] = n; directions[3] = s; directions[4] = w; directions[5] = e; + observable.notifyObservers(this); } - public byte get(EnumFacing f) { + public byte get(EnumFacing f) + { return directions[f.ordinal()]; } - public byte[] asByteArray() { + public byte[] asByteArray() + { return directions; } - public void set(EnumFacing f, byte value) { + public void set(EnumFacing f, byte value) + { directions[f.ordinal()] = value; observable.notifyObservers(this); } - public void addObserver(Observer o) { + public void addObserver(Observer o) + { observable.addObserver(o); } - public void deleteObserver(Observer o) { + public void deleteObserver(Observer o) + { observable.deleteObserver(o); } } From 77e46985ac243728b3210edcac2592852149d628 Mon Sep 17 00:00:00 2001 From: aidancbrady Date: Sun, 23 Jul 2017 20:58:01 -0700 Subject: [PATCH 36/36] Fix crash --- .../java/mekanism/common/tile/TileEntityEnergyCube.java | 6 ++++-- .../mekanism/common/tile/component/TileComponentConfig.java | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index 89ad3cfd4..c6549c176 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -162,7 +162,8 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo } @Override - public boolean sideIsConsumer(EnumFacing side) { + public boolean sideIsConsumer(EnumFacing side) + { return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 1, side); } @@ -173,7 +174,8 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo } @Override - public boolean sideIsOutput(EnumFacing side) { + public boolean sideIsOutput(EnumFacing side) + { return configComponent.hasSideForData(TransmissionType.ENERGY, facing, 2, side); } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentConfig.java b/src/main/java/mekanism/common/tile/component/TileComponentConfig.java index da90931cf..682f2dafb 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentConfig.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentConfig.java @@ -83,6 +83,11 @@ public class TileComponentConfig implements ITileComponent public boolean hasSideForData(TransmissionType type, EnumFacing facing, int dataIndex, EnumFacing sideToTest) { + if(sideToTest == null) + { + return false; + } + return getConfig(type).get(sideToTest) == dataIndex; }