Merged Main Repo NextGen, disabled Filler Block Breaking in this branch.
This commit is contained in:
commit
e931f9b4e5
75 changed files with 777 additions and 407 deletions
|
@ -14,7 +14,7 @@ buildscript {
|
|||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ group= "com.mod-buildcraft"
|
|||
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
|
||||
|
||||
minecraft {
|
||||
version = "1.7.2-10.12.0.1047" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
|
||||
version = "1.7.2-10.12.1.1060" // McVersion-ForgeVersion this variable is later changed to contain only the MC version, while the apiVersion variable is used for the forge version. Yeah its stupid, and will be changed eentually.
|
||||
|
||||
assetDir = "run/assets" // the place for ForgeGradle to download the assets. The assets that the launcher gets and stuff
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ gui.heat=Heat
|
|||
gui.assemblyRate=Energy Rate
|
||||
gui.assemblyCurrentRequired=Energy Required
|
||||
gui.clickcraft=-Click to Craft-
|
||||
gui.pipes.emerald.title=Filters
|
||||
gui.pipes.emerald.blocking=Blocking
|
||||
gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing
|
||||
gui.pipes.emerald.nonblocking=Non Blocking
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 1.8 KiB |
|
@ -190,13 +190,13 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
public static Achievement timeForSomeLogicAchievement;
|
||||
public static Achievement refineAndRedefineAchievement;
|
||||
public static Achievement tinglyLaserAchievement;
|
||||
|
||||
|
||||
public static Achievement architectAchievement;
|
||||
public static Achievement builderAchievement;
|
||||
public static Achievement blueprintAchievement;
|
||||
public static Achievement templateAchievement;
|
||||
public static Achievement libraryAchievement;
|
||||
|
||||
|
||||
public static AchievementPage BuildcraftAchievements;
|
||||
|
||||
@Mod.EventHandler
|
||||
|
@ -306,6 +306,8 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
|
||||
@Mod.EventHandler
|
||||
public void initialize(FMLInitializationEvent evt) {
|
||||
BuildCraftAPI.proxy = CoreProxy.proxy;
|
||||
|
||||
channels = NetworkRegistry.INSTANCE.newChannel
|
||||
(DefaultProps.NET_CHANNEL_NAME + "-CORE", new PacketHandler());
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
BuildcraftRecipes.assemblyTable.addRecipe(10000, ItemGate.makeGateItem(GateMaterial.REDSTONE, GateLogic.AND), Chipset.RED.getStack(), PipeWire.RED.getStack());
|
||||
|
||||
addGateRecipe(20000, GateMaterial.IRON, Chipset.IRON, PipeWire.RED, PipeWire.BLUE);
|
||||
addGateRecipe(40000, GateMaterial.GOLD, Chipset.GOLD, PipeWire.RED, PipeWire.BLUE, PipeWire.YELLOW);
|
||||
addGateRecipe(80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, PipeWire.YELLOW, PipeWire.GREEN);
|
||||
addGateRecipe(40000, GateMaterial.GOLD, Chipset.GOLD, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN);
|
||||
addGateRecipe(80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN, PipeWire.YELLOW);
|
||||
|
||||
// REVERSAL RECIPES
|
||||
EnumSet<GateMaterial> materials = EnumSet.allOf(GateMaterial.class);
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.entity.Entity;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public class MappingRegistry {
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class MappingRegistry {
|
|||
|
||||
public void read (NBTTagCompound nbt) {
|
||||
NBTTagList blocksMapping = nbt.getTagList("blocksMapping",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < blocksMapping.tagCount(); ++i) {
|
||||
NBTTagCompound sub = blocksMapping.getCompoundTagAt(i);
|
||||
|
@ -144,7 +144,7 @@ public class MappingRegistry {
|
|||
}
|
||||
|
||||
NBTTagList itemsMapping = nbt.getTagList("itemsMapping",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < itemsMapping.tagCount(); ++i) {
|
||||
NBTTagCompound sub = itemsMapping.getCompoundTagAt(i);
|
||||
|
@ -154,7 +154,7 @@ public class MappingRegistry {
|
|||
}
|
||||
|
||||
NBTTagList entitiesMapping = nbt.getTagList("entitiesMapping",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < entitiesMapping.tagCount(); ++i) {
|
||||
NBTTagCompound sub = entitiesMapping.getCompoundTagAt(i);
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
/**
|
||||
* This class allow to specify specific behavior for blocks stored in
|
||||
|
@ -194,7 +194,7 @@ public abstract class Schematic {
|
|||
}
|
||||
|
||||
NBTTagList list = nbt.getTagList(nbtName,
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound invSlot = list.getCompoundTagAt(i);
|
||||
|
@ -213,7 +213,7 @@ public abstract class Schematic {
|
|||
}
|
||||
|
||||
NBTTagList list = nbt.getTagList(nbtName,
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound invSlot = list.getCompoundTagAt(i);
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
public class SchematicBlock extends SchematicBlockBase implements Comparable<SchematicBlock> {
|
||||
|
||||
|
@ -182,7 +182,7 @@ public class SchematicBlock extends SchematicBlockBase implements Comparable<Sc
|
|||
block = registry.getBlockForId(nbt.getInteger("blockId"));
|
||||
meta = nbt.getInteger("blockMeta");
|
||||
|
||||
NBTTagList rq = nbt.getTagList("rq", Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList rq = nbt.getTagList("rq", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class SchematicEntity extends Schematic {
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class SchematicEntity extends Schematic {
|
|||
cpt = nbt.getCompoundTag("entity");
|
||||
|
||||
NBTTagList rq = nbt.getTagList("rq",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
ArrayList<ItemStack> rqs = new ArrayList<ItemStack>();
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
*/
|
||||
package buildcraft.api.blueprints;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class SchematicFactoryBlock extends SchematicFactory <SchematicBlock> {
|
||||
|
@ -15,15 +17,24 @@ public class SchematicFactoryBlock extends SchematicFactory <SchematicBlock> {
|
|||
@Override
|
||||
protected SchematicBlock loadSchematicFromWorldNBT (NBTTagCompound nbt, MappingRegistry registry) {
|
||||
int blockId = nbt.getInteger("blockId");
|
||||
SchematicBlock s = SchematicRegistry.newSchematicBlock(registry.getBlockForId(blockId));
|
||||
Block b = registry.getBlockForId(blockId);
|
||||
|
||||
if (s != null) {
|
||||
s.readFromNBT(nbt, registry);
|
||||
if (b == Blocks.air) {
|
||||
SchematicBlock s = new SchematicBlock();
|
||||
s.meta = 0;
|
||||
s.block = Blocks.air;
|
||||
|
||||
return s;
|
||||
} else {
|
||||
return null;
|
||||
SchematicBlock s = SchematicRegistry.newSchematicBlock(b);
|
||||
|
||||
if (s != null) {
|
||||
s.readFromNBT(nbt, registry);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,8 +13,7 @@ import java.util.LinkedList;
|
|||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
|
||||
public class SchematicMask extends SchematicBlockBase {
|
||||
|
||||
|
@ -31,7 +30,7 @@ public class SchematicMask extends SchematicBlockBase {
|
|||
@Override
|
||||
public void writeToWorld(IBuilderContext context, int x, int y, int z, LinkedList <ItemStack> stacks) {
|
||||
if (isConcrete) {
|
||||
if (stacks.size() == 0 || !BlockUtil.isSoftBlock(context.world(), x, y, z)) {
|
||||
if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), x, y, z)) {
|
||||
return;
|
||||
} else {
|
||||
ItemStack stack = stacks.getFirst();
|
||||
|
@ -41,7 +40,7 @@ public class SchematicMask extends SchematicBlockBase {
|
|||
context.world().setBlock(x, y, z, Blocks.air, 0, 3);
|
||||
|
||||
stack.tryPlaceItemIntoWorld(
|
||||
CoreProxy.proxy.getBuildCraftPlayer(context.world()),
|
||||
BuildCraftAPI.proxy.getBuildCraftPlayer(context.world()),
|
||||
context.world(), x, y, z, 1, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
} else {
|
||||
|
@ -52,9 +51,9 @@ public class SchematicMask extends SchematicBlockBase {
|
|||
@Override
|
||||
public boolean isAlreadyBuilt(IBuilderContext context, int x, int y, int z) {
|
||||
if (isConcrete) {
|
||||
return !BlockUtil.isSoftBlock(context.world(), x, y, z);
|
||||
return !BuildCraftAPI.isSoftBlock(context.world(), x, y, z);
|
||||
} else {
|
||||
return BlockUtil.isSoftBlock(context.world(), x, y, z);
|
||||
return BuildCraftAPI.isSoftBlock(context.world(), x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.api.core.JavaTools;
|
||||
|
||||
public class SchematicTile extends SchematicBlock {
|
||||
|
||||
|
@ -88,7 +88,7 @@ public class SchematicTile extends SchematicBlock {
|
|||
}
|
||||
}
|
||||
|
||||
storedRequirements = Utils.concat(storedRequirements,
|
||||
storedRequirements = JavaTools.concat(storedRequirements,
|
||||
rqs.toArray(new ItemStack[rqs.size()]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,11 +12,20 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public class BuildCraftAPI {
|
||||
|
||||
public static final int LAST_ORIGINAL_BLOCK = 122;
|
||||
public static final int LAST_ORIGINAL_ITEM = 126;
|
||||
public static ICoreProxy proxy;
|
||||
|
||||
public static final Set <Block> softBlocks = new HashSet<Block>();
|
||||
|
||||
public static boolean isSoftBlock(IBlockAccess world, int x, int y, int z) {
|
||||
return isSoftBlock(world.getBlock(x, y, z), world, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isSoftBlock(Block block, IBlockAccess world, int x, int y, int z) {
|
||||
return block == null || BuildCraftAPI.softBlocks.contains(block) || block.isReplaceable(world, x, y, z) || block.isAir(world, x, y, z);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
16
common/buildcraft/api/core/ICoreProxy.java
Executable file
16
common/buildcraft/api/core/ICoreProxy.java
Executable file
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ICoreProxy {
|
||||
public EntityPlayer getBuildCraftPlayer(World world);
|
||||
}
|
33
common/buildcraft/api/core/JavaTools.java
Executable file
33
common/buildcraft/api/core/JavaTools.java
Executable file
|
@ -0,0 +1,33 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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 java.util.Arrays;
|
||||
|
||||
public class JavaTools {
|
||||
|
||||
public static <T> 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* 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.core.network;
|
||||
package buildcraft.api.core;
|
||||
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
|
@ -11,7 +11,6 @@ package buildcraft.api.core;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
|
||||
public class Position {
|
||||
|
||||
|
|
|
@ -8,13 +8,7 @@
|
|||
*/
|
||||
package buildcraft.api.filler;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.blueprints.Blueprint;
|
||||
import buildcraft.core.blueprints.BptBuilderTemplate;
|
||||
import buildcraft.core.blueprints.Template;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -26,11 +20,4 @@ public interface IFillerPattern {
|
|||
public IIcon getIcon();
|
||||
|
||||
public String getDisplayName();
|
||||
|
||||
public Template getTemplate (Box box, World world);
|
||||
|
||||
public Blueprint getBlueprint (Box box, World world, Block block);
|
||||
|
||||
public BptBuilderTemplate getTemplateBuilder (Box box, World world);
|
||||
|
||||
}
|
||||
|
|
|
@ -42,12 +42,15 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
if (entityplayer.isSneaking())
|
||||
return false;
|
||||
|
||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileBlueprintLibrary) {
|
||||
TileBlueprintLibrary tileBlueprint = (TileBlueprintLibrary)tile;
|
||||
if (!tileBlueprint.locked || entityplayer.getDisplayName().equals(tileBlueprint.owner))
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tile.locked || entityplayer.getDisplayName().equals(tile.owner))
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -71,8 +74,9 @@ public class BlockBlueprintLibrary extends BlockContainer {
|
|||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
||||
if (!world.isRemote && entityliving instanceof EntityPlayer) {
|
||||
TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k);
|
||||
tile.owner = ((EntityPlayer) entityliving).getDisplayName();
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileBlueprintLibrary)
|
||||
((TileBlueprintLibrary)tile).owner = ((EntityPlayer) entityliving).getDisplayName();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,9 @@ public class BlockMarker extends BlockContainer {
|
|||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) {
|
||||
((TileMarker) world.getTileEntity(i, j, k)).tryConnection();
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileMarker)
|
||||
((TileMarker) tile).tryConnection();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -112,7 +114,9 @@ public class BlockMarker extends BlockContainer {
|
|||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
((TileMarker) world.getTileEntity(x, y, z)).updateSignals();
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileMarker)
|
||||
((TileMarker) tile).updateSignals();
|
||||
dropTorchIfCantStay(world, x, y, z);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,16 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.MappingRegistry;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.blueprints.BuildingSlot;
|
||||
import buildcraft.core.blueprints.BuildingSlotBlock;
|
||||
import buildcraft.core.blueprints.BuildingSlotEntity;
|
||||
import buildcraft.core.blueprints.IBuilder;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
|
||||
public class BuildingItem implements IBuilder {
|
||||
|
@ -194,11 +194,11 @@ public class BuildingItem implements IBuilder {
|
|||
destX, destY, destZ,
|
||||
Block.getIdFromBlock(block) + (meta << 12));
|
||||
|
||||
if (BlockUtil.isToughBlock(context.world(), destX, destY, destZ)) {
|
||||
/*if (BlockUtil.isToughBlock(context.world(), destX, destY, destZ)) {
|
||||
BlockUtil.breakBlock(context.world(), destX, destY, destZ, BuildCraftBuilders.fillerLifespanTough);
|
||||
} else {
|
||||
BlockUtil.breakBlock(context.world(), destX, destY, destZ, BuildCraftBuilders.fillerLifespanNormal);
|
||||
}
|
||||
}*/
|
||||
|
||||
slotToBuild.writeToWorld(context);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class BuildingItem implements IBuilder {
|
|||
destination.writeToNBT(destinationNBT);
|
||||
nbt.setTag ("destination", destinationNBT);
|
||||
|
||||
nbt.setDouble("lifeTime", lifetime);
|
||||
nbt.setDouble("lifetime", lifetime);
|
||||
|
||||
NBTTagList items = new NBTTagList();
|
||||
|
||||
|
@ -274,7 +274,7 @@ public class BuildingItem implements IBuilder {
|
|||
lifetime = nbt.getDouble("lifetime");
|
||||
|
||||
NBTTagList items = nbt.getTagList("items",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < items.tagCount(); ++i) {
|
||||
stacksToBuild.add(ItemStack.loadItemStackFromNBT(items
|
||||
|
|
|
@ -13,12 +13,12 @@ import java.util.LinkedList;
|
|||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.api.mj.MjBattery;
|
||||
import buildcraft.core.IBoxProvider;
|
||||
import buildcraft.core.LaserData;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.network.RPCMessageInfo;
|
||||
|
|
|
@ -14,10 +14,12 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.Translation;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.BlockScanner;
|
||||
import buildcraft.core.Box;
|
||||
|
@ -29,7 +31,6 @@ import buildcraft.core.blueprints.BlueprintBase;
|
|||
import buildcraft.core.blueprints.BlueprintReadConfiguration;
|
||||
import buildcraft.core.blueprints.BptContext;
|
||||
import buildcraft.core.blueprints.Template;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.network.RPCSide;
|
||||
|
@ -246,7 +247,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory, IBoxPro
|
|||
}
|
||||
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList("Items",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
items = new ItemStack[getSizeInventory()];
|
||||
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
|
|
|
@ -17,11 +17,11 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.builders.blueprints.BlueprintId;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.blueprints.BlueprintBase;
|
||||
import buildcraft.core.inventory.InvUtils;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.network.RPCSide;
|
||||
|
|
|
@ -19,9 +19,11 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.WorldSettings.GameType;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.Translation;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.core.BlockIndex;
|
||||
|
@ -35,7 +37,6 @@ import buildcraft.core.blueprints.BptBuilderBase;
|
|||
import buildcraft.core.blueprints.BptBuilderBlueprint;
|
||||
import buildcraft.core.blueprints.BptBuilderTemplate;
|
||||
import buildcraft.core.blueprints.BptContext;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.network.RPCSide;
|
||||
|
@ -459,7 +460,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine {
|
|||
if (nbttagcompound.hasKey("path")) {
|
||||
path = new LinkedList<BlockIndex>();
|
||||
NBTTagList list = nbttagcompound.getTagList("path",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
path.add(new BlockIndex(list.getCompoundTagAt(i)));
|
||||
|
|
|
@ -19,9 +19,9 @@ import net.minecraft.util.AxisAlignedBB;
|
|||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionReceptor;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.builders.filler.pattern.PatternFill;
|
||||
import buildcraft.builders.triggers.ActionFiller;
|
||||
import buildcraft.core.Box;
|
||||
|
@ -41,7 +41,7 @@ import buildcraft.core.utils.Utils;
|
|||
|
||||
public class TileFiller extends TileAbstractBuilder implements IMachine, IActionReceptor {
|
||||
|
||||
public IFillerPattern currentPattern = PatternFill.INSTANCE;
|
||||
public FillerPattern currentPattern = PatternFill.INSTANCE;
|
||||
|
||||
private BptBuilderTemplate currentTemplate;
|
||||
private BptContext context;
|
||||
|
@ -162,7 +162,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
|||
inv.readFromNBT(nbt);
|
||||
|
||||
if (nbt.hasKey("pattern")) {
|
||||
currentPattern = FillerManager.registry.getPattern(nbt.getString("pattern"));
|
||||
currentPattern = (FillerPattern) FillerManager.registry.getPattern(nbt.getString("pattern"));
|
||||
}
|
||||
|
||||
if (currentPattern == null) {
|
||||
|
@ -216,7 +216,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
|||
destroy();
|
||||
}
|
||||
|
||||
public void setPattern(IFillerPattern pattern) {
|
||||
public void setPattern(FillerPattern pattern) {
|
||||
if (pattern != null && currentPattern != pattern) {
|
||||
currentPattern = pattern;
|
||||
currentTemplate = null;
|
||||
|
@ -243,7 +243,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
|||
boolean initialized = box.isInitialized();
|
||||
box.readFromStream(data);
|
||||
done = data.readBoolean();
|
||||
setPattern(FillerManager.registry.getPattern(Utils.readUTF(data)));
|
||||
setPattern((FillerPattern) FillerManager.registry.getPattern(Utils.readUTF(data)));
|
||||
|
||||
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction
|
|||
|
||||
@RPC (RPCSide.SERVER)
|
||||
public void setPatternFromString (String name) {
|
||||
setPattern(FillerManager.registry.getPattern(name));
|
||||
setPattern((FillerPattern) FillerManager.registry.getPattern(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,10 +14,10 @@ import net.minecraft.world.World;
|
|||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.core.LaserKind;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.EntityBlock;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
|
|
@ -16,10 +16,10 @@ import java.util.TreeSet;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.LaserData;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
|
||||
public class TilePathMarker extends TileMarker {
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
|
||||
public final class BlueprintId implements Comparable<BlueprintId> {
|
||||
|
||||
|
|
|
@ -8,14 +8,16 @@
|
|||
*/
|
||||
package buildcraft.builders.filler;
|
||||
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.filler.IFillerRegistry;
|
||||
import buildcraft.builders.triggers.ActionFiller;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.filler.IFillerRegistry;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.builders.triggers.ActionFiller;
|
||||
|
||||
public class FillerRegistry implements IFillerRegistry {
|
||||
|
||||
private TreeMap<String, IFillerPattern> patterns = new TreeMap<String, IFillerPattern>();
|
||||
|
@ -24,7 +26,7 @@ public class FillerRegistry implements IFillerRegistry {
|
|||
@Override
|
||||
public void addPattern(IFillerPattern pattern) {
|
||||
patterns.put(pattern.getUniqueTag(), pattern);
|
||||
patternActions.add(new ActionFiller(pattern));
|
||||
patternActions.add(new ActionFiller((FillerPattern) pattern));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -35,16 +37,18 @@ public class FillerRegistry implements IFillerRegistry {
|
|||
@Override
|
||||
public IFillerPattern getNextPattern(IFillerPattern currentPattern) {
|
||||
Entry<String, IFillerPattern> pattern = patterns.higherEntry(currentPattern.getUniqueTag());
|
||||
if (pattern == null)
|
||||
if (pattern == null) {
|
||||
pattern = patterns.firstEntry();
|
||||
}
|
||||
return pattern.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFillerPattern getPreviousPattern(IFillerPattern currentPattern) {
|
||||
Entry<String, IFillerPattern> pattern = patterns.lowerEntry(currentPattern.getUniqueTag());
|
||||
if (pattern == null)
|
||||
if (pattern == null) {
|
||||
pattern = patterns.lastEntry();
|
||||
}
|
||||
return pattern.getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import buildcraft.api.blueprints.SchematicRegistry;
|
|||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.blueprints.Blueprint;
|
||||
import buildcraft.core.blueprints.BlueprintBase;
|
||||
import buildcraft.core.blueprints.BptBuilderTemplate;
|
||||
import buildcraft.core.blueprints.Template;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
@ -68,7 +69,9 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int y = yMin; y <= yMax; ++y) {
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
template.contents[x][y][z] = new SchematicMask(true);
|
||||
if (isValid(x, y, z, template)) {
|
||||
template.contents[x][y][z] = new SchematicMask(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +86,9 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int y = yMax; y >= yMin; y--) {
|
||||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
template.contents[x][y][z] = null;
|
||||
if (isValid(x, y, z, template)) {
|
||||
template.contents[x][y][z] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,13 +103,16 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
for (int x = xMin; x <= xMax; ++x) {
|
||||
for (int z = zMin; z <= zMax; ++z) {
|
||||
for (int y = yMax; y >= yMin; --y) {
|
||||
template.contents [x][y][z] = new SchematicMask(true);
|
||||
if (isValid(x, y, z, template)) {
|
||||
template.contents [x][y][z] = new SchematicMask(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract Template getTemplate (Box box, World world);
|
||||
|
||||
public Blueprint getBlueprint (Box box, World world, Block block) {
|
||||
Blueprint result = new Blueprint (box.sizeX(), box.sizeY(), box.sizeZ());
|
||||
|
||||
|
@ -128,4 +136,8 @@ public abstract class FillerPattern implements IFillerPattern {
|
|||
public BptBuilderTemplate getTemplateBuilder (Box box, World world) {
|
||||
return new BptBuilderTemplate(getTemplate(box, world), world, box.xMin, box.yMin, box.zMin);
|
||||
}
|
||||
|
||||
private static boolean isValid (int x, int y, int z, BlueprintBase bpt) {
|
||||
return x >= 0 && y >= 0 && z >= 0 && x < bpt.sizeX && y < bpt.sizeY && z < bpt.sizeZ;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,19 +55,21 @@ public class PatternCylinder extends FillerPattern {
|
|||
int stoppingX = twoBSquare * xRadius;
|
||||
int stoppingZ = 0;
|
||||
|
||||
while (stoppingX >= stoppingZ) {
|
||||
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||
yMax, result);
|
||||
if (twoASquare > 0) {
|
||||
while (stoppingX >= stoppingZ) {
|
||||
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||
yMax, result);
|
||||
|
||||
++dz;
|
||||
stoppingZ += twoASquare;
|
||||
ellipseError += zChange;
|
||||
zChange += twoASquare;
|
||||
if (2 * ellipseError + xChange > 0) {
|
||||
--dx;
|
||||
stoppingX -= twoBSquare;
|
||||
ellipseError += xChange;
|
||||
xChange += twoBSquare;
|
||||
++dz;
|
||||
stoppingZ += twoASquare;
|
||||
ellipseError += zChange;
|
||||
zChange += twoASquare;
|
||||
if (2 * ellipseError + xChange > 0) {
|
||||
--dx;
|
||||
stoppingX -= twoBSquare;
|
||||
ellipseError += xChange;
|
||||
xChange += twoBSquare;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,19 +81,21 @@ public class PatternCylinder extends FillerPattern {
|
|||
stoppingX = 0;
|
||||
stoppingZ = twoASquare * zRadius;
|
||||
|
||||
while (stoppingX <= stoppingZ) {
|
||||
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||
yMax, result);
|
||||
if (twoBSquare > 0) {
|
||||
while (stoppingX <= stoppingZ) {
|
||||
fillFourColumns(xCenter, zCenter, dx, dz, xFix, zFix, yMin,
|
||||
yMax, result);
|
||||
|
||||
++dx;
|
||||
stoppingX += twoBSquare;
|
||||
ellipseError += xChange;
|
||||
xChange += twoBSquare;
|
||||
if (2 * ellipseError + zChange > 0) {
|
||||
--dz;
|
||||
stoppingZ -= twoASquare;
|
||||
ellipseError += zChange;
|
||||
zChange += twoASquare;
|
||||
++dx;
|
||||
stoppingX += twoBSquare;
|
||||
ellipseError += xChange;
|
||||
xChange += twoBSquare;
|
||||
if (2 * ellipseError + zChange > 0) {
|
||||
--dz;
|
||||
stoppingZ -= twoASquare;
|
||||
ellipseError += zChange;
|
||||
zChange += twoASquare;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.builders.TileFiller;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.gui.GuiTools;
|
||||
|
@ -50,9 +51,9 @@ public class GuiFiller extends GuiBuildCraft {
|
|||
super.actionPerformed(button);
|
||||
|
||||
if (button.id == 0) {
|
||||
filler.currentPattern = FillerManager.registry.getPreviousPattern(filler.currentPattern);
|
||||
filler.currentPattern = (FillerPattern) FillerManager.registry.getPreviousPattern(filler.currentPattern);
|
||||
} else if (button.id == 1) {
|
||||
filler.currentPattern = FillerManager.registry.getNextPattern(filler.currentPattern);
|
||||
filler.currentPattern = (FillerPattern) FillerManager.registry.getNextPattern(filler.currentPattern);
|
||||
}
|
||||
|
||||
filler.rpcSetPatternFromString(filler.currentPattern.getUniqueTag());
|
||||
|
|
|
@ -9,15 +9,15 @@
|
|||
package buildcraft.builders.triggers;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import buildcraft.api.filler.IFillerPattern;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.core.triggers.BCAction;
|
||||
|
||||
public class ActionFiller extends BCAction {
|
||||
|
||||
public final IFillerPattern pattern;
|
||||
public final FillerPattern pattern;
|
||||
|
||||
public ActionFiller(IFillerPattern pattern) {
|
||||
public ActionFiller(FillerPattern pattern) {
|
||||
super("filler:" + pattern.getUniqueTag());
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
package buildcraft.builders.urbanism;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
|
||||
public class AnchoredBox {
|
||||
@NetworkData
|
||||
|
|
|
@ -19,11 +19,11 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.Box.Kind;
|
||||
import buildcraft.core.IBoxesProvider;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.RPC;
|
||||
import buildcraft.core.network.RPCHandler;
|
||||
import buildcraft.core.network.RPCSide;
|
||||
|
|
|
@ -18,8 +18,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.AxisAlignedBB;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.core.IBox;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class Box implements IBox {
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
package buildcraft.core;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
|
||||
public class LaserData {
|
||||
@NetworkData
|
||||
|
|
|
@ -84,6 +84,10 @@ public class ReflectMjAPI {
|
|||
}
|
||||
|
||||
public static BatteryObject getMjBattery (Object o) {
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BatteryField f = getMjBattery (o.getClass());
|
||||
|
||||
if (f == null) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
|
@ -24,7 +25,6 @@ import buildcraft.api.blueprints.SchematicRegistry;
|
|||
import buildcraft.api.blueprints.Translation;
|
||||
import buildcraft.core.utils.BCLog;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class Blueprint extends BlueprintBase {
|
||||
public LinkedList <SchematicEntity> entities = new LinkedList <SchematicEntity> ();
|
||||
|
@ -159,7 +159,7 @@ public class Blueprint extends BlueprintBase {
|
|||
mapping.read (nbt.getCompoundTag("idMapping"));
|
||||
|
||||
NBTTagList nbtContents = nbt.getTagList("contents",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
@ -182,7 +182,7 @@ public class Blueprint extends BlueprintBase {
|
|||
}
|
||||
|
||||
NBTTagList entitiesNBT = nbt.getTagList("entities",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < entitiesNBT.tagCount(); ++i) {
|
||||
NBTTagCompound cpt = entitiesNBT.getCompoundTagAt(i);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
package buildcraft.core.blueprints;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
|
||||
public class BlueprintReadConfiguration {
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.api.blueprints.IBuilderContext;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
|
@ -25,7 +26,6 @@ import buildcraft.builders.BuildingItem;
|
|||
import buildcraft.builders.TileAbstractBuilder;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public abstract class BptBuilderBase implements IAreaProvider {
|
||||
|
||||
|
@ -198,7 +198,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
|||
}
|
||||
|
||||
public void loadBuildStateToNBT (NBTTagCompound nbt, TileAbstractBuilder builder) {
|
||||
NBTTagList clearList = nbt.getTagList("clearList", Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList clearList = nbt.getTagList("clearList", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < clearList.tagCount(); ++i) {
|
||||
NBTTagCompound cpt = clearList.getCompoundTagAt(i);
|
||||
|
@ -206,7 +206,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
|||
clearedLocations.add (new BlockIndex(cpt));
|
||||
}
|
||||
|
||||
NBTTagList builtList = nbt.getTagList("builtList", Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList builtList = nbt.getTagList("builtList", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < builtList.tagCount(); ++i) {
|
||||
NBTTagCompound cpt = builtList.getCompoundTagAt(i);
|
||||
|
@ -216,7 +216,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
|||
|
||||
NBTTagList buildingList = nbt
|
||||
.getTagList("buildersInAction",
|
||||
Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < buildingList.tagCount(); ++i) {
|
||||
BuildingItem item = new BuildingItem();
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.world.WorldSettings.GameType;
|
|||
import buildcraft.api.blueprints.Schematic;
|
||||
import buildcraft.api.blueprints.SchematicBlock;
|
||||
import buildcraft.api.blueprints.SchematicEntity;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.core.StackKey;
|
||||
import buildcraft.builders.TileAbstractBuilder;
|
||||
import buildcraft.core.BlockIndex;
|
||||
|
@ -219,7 +220,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
|
||||
if (getNext) {
|
||||
if (slot.mode == Mode.ClearIfInvalid) {
|
||||
if (BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||
|| BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
|
@ -231,7 +232,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||
&& checkRequirements(builder,
|
||||
slot.schematic)) {
|
||||
useRequirements(builder, slot);
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.api.blueprints.SchematicBlockBase;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.builders.TileAbstractBuilder;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.blueprints.BuildingSlotBlock.Mode;
|
||||
|
@ -143,7 +144,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
}
|
||||
|
||||
if (slot.mode == Mode.ClearIfInvalid) {
|
||||
if (BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||
if (BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)
|
||||
|| BlockUtil.isUnbreakableBlock(world, slot.x, slot.y, slot.z)) {
|
||||
iterator.remove();
|
||||
clearedLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
||||
|
@ -157,7 +158,7 @@ public class BptBuilderTemplate extends BptBuilderBase {
|
|||
}
|
||||
}
|
||||
} else if (slot.mode == Mode.Build) {
|
||||
if (!BlockUtil.isSoftBlock(world, slot.x, slot.y, slot.z)) {
|
||||
if (!BuildCraftAPI.isSoftBlock(world, slot.x, slot.y, slot.z)) {
|
||||
iterator.remove();
|
||||
builtLocations.add(new BlockIndex(slot.x, slot.y, slot.z));
|
||||
} else {
|
||||
|
|
154
common/buildcraft/core/gui/buttons/GuiImageButton.java
Normal file
154
common/buildcraft/core/gui/buttons/GuiImageButton.java
Normal file
|
@ -0,0 +1,154 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.core.gui.buttons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiImageButton extends GuiButton implements IButtonClickEventTrigger {
|
||||
|
||||
public enum ButtonImage {
|
||||
BLANK(1, 19),
|
||||
WHITE_LIST(19, 19),
|
||||
BLACK_LIST(37, 19),
|
||||
ROUND_ROBIN(55, 19);
|
||||
|
||||
private final int u, v;
|
||||
|
||||
ButtonImage(int u, int v) {
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
public int getU(){
|
||||
return u;
|
||||
}
|
||||
|
||||
public int getV(){
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
public static final ResourceLocation ICON_BUTTON_TEXTURES = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/icon_button.png");
|
||||
|
||||
public static final int SIZE = 18;
|
||||
|
||||
private ArrayList<IButtonClickEventListener> listeners = new ArrayList<IButtonClickEventListener>();
|
||||
private ButtonImage image = ButtonImage.BLANK;
|
||||
private boolean active = false;
|
||||
|
||||
public GuiImageButton(int id, int x, int y, ButtonImage image) {
|
||||
super(id, x, y, SIZE, SIZE, "");
|
||||
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public boolean IsActive()
|
||||
{
|
||||
return active;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
active = true;
|
||||
}
|
||||
|
||||
public void DeActivate()
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft minecraft, int x, int y) {
|
||||
|
||||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
minecraft.renderEngine.bindTexture(ICON_BUTTON_TEXTURES);
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
int buttonState = getButtonState(x, y);
|
||||
|
||||
drawTexturedModalRect(xPosition, yPosition, buttonState * SIZE, 0, SIZE, SIZE);
|
||||
|
||||
drawTexturedModalRect(xPosition + 1, yPosition + 1, image.getU(), image.getV(), SIZE - 2, SIZE - 2);
|
||||
|
||||
mouseDragged(minecraft, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mousePressed(Minecraft par1Minecraft, int par2, int par3) {
|
||||
boolean pressed = super.mousePressed(par1Minecraft, par2, par3);
|
||||
|
||||
if (pressed) {
|
||||
active = !active;
|
||||
notifyAllListeners();
|
||||
}
|
||||
|
||||
return pressed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener(IButtonClickEventListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(IButtonClickEventListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAllListeners() {
|
||||
for (IButtonClickEventListener listener : listeners) {
|
||||
listener.handleButtonClick(this, this.id);
|
||||
}
|
||||
}
|
||||
|
||||
private int getButtonState(int mouseX, int mouseY) {
|
||||
if (!this.enabled) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isMouseOverButton(mouseX, mouseY)) {
|
||||
if (!this.active) {
|
||||
return 2;
|
||||
}
|
||||
else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.active) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isMouseOverButton(int mouseX, int mouseY) {
|
||||
return mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + SIZE && mouseY < yPosition + SIZE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.core.gui.buttons;
|
||||
|
||||
public interface IButtonClickEventListener {
|
||||
public void handleButtonClick(IButtonClickEventTrigger button, int buttonId);
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, 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.core.gui.buttons;
|
||||
|
||||
public interface IButtonClickEventTrigger {
|
||||
public void registerListener(IButtonClickEventListener listener);
|
||||
public void removeListener(IButtonClickEventListener listener);
|
||||
public void notifyAllListeners();
|
||||
}
|
|
@ -8,10 +8,6 @@
|
|||
*/
|
||||
package buildcraft.core.inventory;
|
||||
|
||||
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
|
||||
import buildcraft.core.inventory.filters.ArrayStackFilter;
|
||||
import buildcraft.core.inventory.filters.IStackFilter;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryLargeChest;
|
||||
|
@ -21,7 +17,11 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.core.inventory.InventoryIterator.IInvSlot;
|
||||
import buildcraft.core.inventory.filters.ArrayStackFilter;
|
||||
import buildcraft.core.inventory.filters.IStackFilter;
|
||||
|
||||
public class InvUtils {
|
||||
|
||||
|
@ -97,8 +97,9 @@ public class InvUtils {
|
|||
|
||||
/* STACK DROPS */
|
||||
public static void dropItems(World world, ItemStack stack, int i, int j, int k) {
|
||||
if (stack == null || stack.stackSize <= 0)
|
||||
if (stack == null || stack.stackSize <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float f1 = 0.7F;
|
||||
double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D;
|
||||
|
@ -139,7 +140,7 @@ public class InvUtils {
|
|||
NBTTagCompound nbt = getItemData(stack);
|
||||
NBTTagCompound display = nbt.getCompoundTag("display");
|
||||
nbt.setTag("display", display);
|
||||
NBTTagList lore = display.getTagList("Lore", Utils.NBTTag_Types.NBTTagString.ordinal());
|
||||
NBTTagList lore = display.getTagList("Lore", Constants.NBT.TAG_STRING);
|
||||
display.setTag("Lore", lore);
|
||||
lore.appendTag(new NBTTagString(msg));
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ public class InvUtils {
|
|||
}
|
||||
|
||||
public static void readInvFromNBT(IInventory inv, String tag, NBTTagCompound data) {
|
||||
NBTTagList list = data.getTagList(tag, Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList list = data.getTagList(tag, Constants.NBT.TAG_COMPOUND);
|
||||
for (byte entry = 0; entry < list.tagCount(); entry++) {
|
||||
NBTTagCompound itemTag = list.getCompoundTagAt(entry);
|
||||
int slot = itemTag.getByte("Slot");
|
||||
|
@ -171,7 +172,7 @@ public class InvUtils {
|
|||
}
|
||||
|
||||
public static void readStacksFromNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) {
|
||||
NBTTagList nbttaglist = nbt.getTagList(name, Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList nbttaglist = nbt.getTagList(name, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
if (i < nbttaglist.tagCount()) {
|
||||
|
@ -187,11 +188,11 @@ public class InvUtils {
|
|||
public static void writeStacksToNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
for (ItemStack stack : stacks) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
nbttaglist.appendTag(cpt);
|
||||
if (stacks[i] != null) {
|
||||
stacks[i].writeToNBT(cpt);
|
||||
if (stack != null) {
|
||||
stack.writeToNBT(cpt);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
*/
|
||||
package buildcraft.core.inventory;
|
||||
|
||||
import buildcraft.core.utils.INBTTagable;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -19,6 +16,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.core.utils.INBTTagable;
|
||||
|
||||
public class SimpleInventory implements IInventory, INBTTagable {
|
||||
|
||||
|
@ -100,7 +99,7 @@ public class SimpleInventory implements IInventory, INBTTagable {
|
|||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound data, String tag) {
|
||||
NBTTagList nbttaglist = data.getTagList(tag, Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList nbttaglist = data.getTagList(tag, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
|
||||
NBTTagCompound slot = nbttaglist.getCompoundTagAt(j);
|
||||
|
|
|
@ -25,7 +25,7 @@ import net.minecraft.item.Item;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,7 @@ import net.minecraft.util.IChatComponent;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import buildcraft.api.core.ICoreProxy;
|
||||
import buildcraft.api.core.LaserKind;
|
||||
import buildcraft.core.EntityBlock;
|
||||
import buildcraft.core.ItemBlockBuildCraft;
|
||||
|
@ -38,7 +39,7 @@ import cpw.mods.fml.common.Loader;
|
|||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class CoreProxy {
|
||||
public class CoreProxy implements ICoreProxy {
|
||||
|
||||
@SidedProxy(clientSide = "buildcraft.core.proxy.CoreProxyClient", serverSide = "buildcraft.core.proxy.CoreProxy")
|
||||
public static CoreProxy proxy;
|
||||
|
@ -169,6 +170,7 @@ public class CoreProxy {
|
|||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getBuildCraftPlayer(World world) {
|
||||
if (CoreProxy.buildCraftPlayer == null) {
|
||||
CoreProxy.buildCraftPlayer = createNewPlayer(world);
|
||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.network.play.server.S27PacketExplosion;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.fluids.BlockFluidBase;
|
||||
|
@ -31,7 +30,6 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
|
@ -119,14 +117,6 @@ public class BlockUtil {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean isSoftBlock(IBlockAccess world, int x, int y, int z) {
|
||||
return isSoftBlock(world.getBlock(x, y, z), world, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isSoftBlock(Block block, IBlockAccess world, int x, int y, int z) {
|
||||
return block == null || BuildCraftAPI.softBlocks.contains(block) || block.isReplaceable(world, x, y, z) || block.isAir(world, x, y, z);
|
||||
}
|
||||
|
||||
public static boolean isUnbreakableBlock(World world, int x, int y, int z) {
|
||||
Block b = world.getBlock(x, y, z);
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
|
@ -62,13 +63,6 @@ public class Utils {
|
|||
public static final Random RANDOM = new Random();
|
||||
private static final List<ForgeDirection> directions = new ArrayList<ForgeDirection>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
|
||||
|
||||
public enum NBTTag_Types {
|
||||
NBTTagEnd, NBTTagByte, NBTTagShort,
|
||||
NBTTagInt, NBTTagLong, NBTTagFloat,
|
||||
NBTTagDouble, NBTTagByteArray, NBTTagString,
|
||||
NBTTagList, NBTTagCompound, NBTTagIntArray
|
||||
}
|
||||
|
||||
/* IINVENTORY HELPERS */
|
||||
/**
|
||||
* Tries to add the passed stack to any valid inventories around the given
|
||||
|
@ -425,24 +419,6 @@ public class Utils {
|
|||
|
||||
}
|
||||
|
||||
public static <T> 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 int[] createSlotArray(int first, int count) {
|
||||
int[] slots = new int[count];
|
||||
for (int k = first; k < first + count; k++) {
|
||||
|
@ -537,7 +513,7 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static void readStacksFromNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) {
|
||||
NBTTagList nbttaglist = nbt.getTagList(name, NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList nbttaglist = nbt.getTagList(name, Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < stacks.length; ++i) {
|
||||
if (i < nbttaglist.tagCount()) {
|
||||
|
|
|
@ -8,13 +8,11 @@
|
|||
*/
|
||||
package buildcraft.energy;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.ICustomHighlight;
|
||||
import buildcraft.core.IItemPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import static net.minecraft.util.AxisAlignedBB.getBoundingBox;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
|
@ -31,11 +29,13 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static net.minecraft.util.AxisAlignedBB.getBoundingBox;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.CreativeTabBuildCraft;
|
||||
import buildcraft.core.ICustomHighlight;
|
||||
import buildcraft.core.IItemPipe;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int side, float par7, float par8, float par9) {
|
||||
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
// REMOVED DUE TO CREATIVE ENGINE REQUIREMENTS - dmillerw
|
||||
// Drop through if the player is sneaking
|
||||
|
@ -137,7 +137,7 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
}
|
||||
|
||||
if (tile instanceof TileEngine) {
|
||||
return tile.onBlockActivated(player, ForgeDirection.getOrientation(side));
|
||||
return ((TileEngine) tile).onBlockActivated(player, ForgeDirection.getOrientation(side));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -204,11 +204,13 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
|
||||
@Override
|
||||
public void onPostBlockPlaced(World world, int x, int y, int z, int par5) {
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
||||
tile.orientation = ForgeDirection.UP;
|
||||
|
||||
if (!tile.isOrientationValid()) {
|
||||
tile.switchOrientation(true);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if (tile instanceof TileEngine) {
|
||||
TileEngine engine = (TileEngine)tile;
|
||||
engine.orientation = ForgeDirection.UP;
|
||||
if (!engine.isOrientationValid()) {
|
||||
engine.switchOrientation(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,9 +222,9 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
@SuppressWarnings({"all"})
|
||||
@Override
|
||||
public void randomDisplayTick(World world, int i, int j, int k, Random random) {
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
|
||||
if (!tile.isBurning()) {
|
||||
if (tile instanceof TileEngine && !((TileEngine) tile).isBurning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -252,10 +254,10 @@ public class BlockEngine extends BlockBuildCraft implements ICustomHighlight {
|
|||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
|
||||
if (tile != null) {
|
||||
tile.checkRedstonePower();
|
||||
if (tile instanceof TileEngine) {
|
||||
((TileEngine) tile).checkRedstonePower();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package buildcraft.energy;
|
||||
|
||||
import buildcraft.BuildCraftEnergy;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IOverrideDefaultTriggers;
|
||||
import buildcraft.api.gates.ITrigger;
|
||||
import buildcraft.api.power.IPowerEmitter;
|
||||
|
@ -24,7 +25,6 @@ import buildcraft.core.ReflectMjAPI;
|
|||
import buildcraft.core.ReflectMjAPI.BatteryObject;
|
||||
import buildcraft.core.TileBuffer;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.energy.gui.ContainerEngine;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
*/
|
||||
package buildcraft.energy;
|
||||
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.pipes.PipePowerIron;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFlower;
|
||||
import net.minecraft.block.BlockStaticLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -260,7 +261,7 @@ public class OilPopulate {
|
|||
|
||||
private boolean isReplaceableFluid(World world, int x, int y, int z) {
|
||||
Block block = world.getBlock(x, y, z);
|
||||
return (block instanceof BlockFluidBase || block instanceof IFluidBlock) && block.getMaterial() != Material.lava;
|
||||
return (block instanceof BlockStaticLiquid || block instanceof BlockFluidBase || block instanceof IFluidBlock) && block.getMaterial() != Material.lava;
|
||||
}
|
||||
|
||||
private boolean isOil(World world, int x, int y, int z) {
|
||||
|
@ -357,6 +358,10 @@ public class OilPopulate {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (block instanceof BlockStaticLiquid) {
|
||||
return y;
|
||||
}
|
||||
|
||||
if (block instanceof BlockFluidBase) {
|
||||
return y;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,9 @@ public class BlockQuarry extends BlockBuildCraft {
|
|||
|
||||
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
|
||||
if (entityliving instanceof EntityPlayer) {
|
||||
TileQuarry tq = (TileQuarry) world.getTileEntity(i, j, k);
|
||||
tq.placedBy = (EntityPlayer) entityliving;
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileQuarry)
|
||||
((TileQuarry) tile).placedBy = (EntityPlayer) entityliving;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,44 +89,47 @@ public class BlockTank extends BlockContainer {
|
|||
if (current != null) {
|
||||
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current);
|
||||
|
||||
TileTank tank = (TileTank) world.getTileEntity(i, j, k);
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if(tile instanceof TileTank)
|
||||
{
|
||||
TileTank tank = (TileTank)tile;
|
||||
// Handle filled containers
|
||||
if (liquid != null) {
|
||||
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
|
||||
// Handle filled containers
|
||||
if (liquid != null) {
|
||||
int qty = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
|
||||
if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
|
||||
if (qty != 0 && !BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
return true;
|
||||
|
||||
return true;
|
||||
// Handle empty containers
|
||||
} else {
|
||||
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
|
||||
|
||||
// Handle empty containers
|
||||
} else {
|
||||
FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
|
||||
if (available != null) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
|
||||
|
||||
if (available != null) {
|
||||
ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current);
|
||||
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
|
||||
liquid = FluidContainerRegistry.getFluidForFilledItem(filled);
|
||||
|
||||
if (liquid != null) {
|
||||
if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize > 1) {
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled))
|
||||
return false;
|
||||
else {
|
||||
if (liquid != null) {
|
||||
if (!BuildCraftCore.debugMode && !entityplayer.capabilities.isCreativeMode) {
|
||||
if (current.stackSize > 1) {
|
||||
if (!entityplayer.inventory.addItemStackToInventory(filled)) {
|
||||
return false;
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
}
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled);
|
||||
}
|
||||
} else {
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, InvUtils.consumeItem(current));
|
||||
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled);
|
||||
}
|
||||
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraftforge.fluids.FluidRegistry;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.core.BlockIndex;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.fluids.FluidUtils;
|
||||
|
@ -211,7 +212,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler {
|
|||
}
|
||||
|
||||
private boolean canPlaceFluidAt(Block block, int x, int y, int z) {
|
||||
return BlockUtil.isSoftBlock(block, worldObj, x, y, z) && !BlockUtil.isFullFluidBlock(block, worldObj, x, y, z);
|
||||
return BuildCraftAPI.isSoftBlock(block, worldObj, x, y, z) && !BlockUtil.isFullFluidBlock(block, worldObj, x, y, z);
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(Block block) {
|
||||
|
|
|
@ -26,10 +26,13 @@ import net.minecraftforge.common.ForgeChunkManager.Type;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.BuildCraftFactory;
|
||||
import buildcraft.api.core.BuildCraftAPI;
|
||||
import buildcraft.api.core.IAreaProvider;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.filler.FillerManager;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.builders.TileAbstractBuilder;
|
||||
import buildcraft.builders.filler.pattern.FillerPattern;
|
||||
import buildcraft.core.Box;
|
||||
import buildcraft.core.Box.Kind;
|
||||
import buildcraft.core.CoreConstants;
|
||||
|
@ -38,7 +41,6 @@ import buildcraft.core.IMachine;
|
|||
import buildcraft.core.blueprints.Blueprint;
|
||||
import buildcraft.core.blueprints.BptBuilderBase;
|
||||
import buildcraft.core.blueprints.BptBuilderBlueprint;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.network.PacketUpdate;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
|
@ -218,7 +220,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
|||
if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes
|
||||
for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) {
|
||||
Block block = worldObj.getBlock(nextTarget[0], y, nextTarget[2]);
|
||||
if (BlockUtil.isAnObstructingBlock(block, worldObj, nextTarget[0], y, nextTarget[2]) || !BlockUtil.isSoftBlock(block, worldObj, nextTarget[0], y, nextTarget[2])) {
|
||||
if (BlockUtil.isAnObstructingBlock(block, worldObj, nextTarget[0], y, nextTarget[2]) || !BuildCraftAPI.isSoftBlock(block, worldObj, nextTarget[0], y, nextTarget[2])) {
|
||||
createColumnVisitList();
|
||||
columnVisitListIsUpdated = true;
|
||||
nextTarget = null;
|
||||
|
@ -290,7 +292,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
|||
|
||||
if (!BlockUtil.canChangeBlock(block, worldObj, bx, by, bz)) {
|
||||
blockedColumns[searchX][searchZ] = true;
|
||||
} else if (!BlockUtil.isSoftBlock(block, worldObj, bx, by, bz)) {
|
||||
} else if (!BuildCraftAPI.isSoftBlock(block, worldObj, bx, by, bz)) {
|
||||
visitList.add(new int[]{bx, by, bz});
|
||||
}
|
||||
|
||||
|
@ -452,7 +454,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
|||
|
||||
private boolean isQuarriableBlock(int bx, int by, int bz) {
|
||||
Block block = worldObj.getBlock(bx, by, bz);
|
||||
return BlockUtil.canChangeBlock(block, worldObj, bx, by, bz) && !BlockUtil.isSoftBlock(block, worldObj, bx, by, bz);
|
||||
return BlockUtil.canChangeBlock(block, worldObj, bx, by, bz) && !BuildCraftAPI.isSoftBlock(block, worldObj, bx, by, bz);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -576,7 +578,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine {
|
|||
}
|
||||
|
||||
private void initializeBlueprintBuilder() {
|
||||
Blueprint bpt = FillerManager.registry.getPattern("buildcraft:frame")
|
||||
Blueprint bpt = ((FillerPattern) FillerManager.registry.getPattern("buildcraft:frame"))
|
||||
.getBlueprint(box, worldObj, BuildCraftFactory.frameBlock);
|
||||
|
||||
builder = new BptBuilderBlueprint(bpt, worldObj, box.xMin, yCoord, box.zMin);
|
||||
|
|
|
@ -8,19 +8,6 @@
|
|||
*/
|
||||
package buildcraft.silicon;
|
||||
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.core.recipes.AssemblyRecipeManager;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketNBT;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -32,7 +19,19 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.IMachine;
|
||||
import buildcraft.core.network.PacketIds;
|
||||
import buildcraft.core.network.PacketNBT;
|
||||
import buildcraft.core.recipes.AssemblyRecipeManager;
|
||||
import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileAssemblyTable extends TileLaserTableBase implements IMachine, IInventory {
|
||||
|
||||
|
@ -64,8 +63,9 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
|
|||
List<AssemblyRecipe> result = new LinkedList<AssemblyRecipe>();
|
||||
|
||||
for (AssemblyRecipe recipe : AssemblyRecipeManager.INSTANCE.getRecipes()) {
|
||||
if (recipe.canBeDone(this))
|
||||
if (recipe.canBeDone(this)) {
|
||||
result.add(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -78,14 +78,16 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
|
|||
|
||||
@Override
|
||||
public void updateEntity() { // WARNING: run only server-side, see canUpdate()
|
||||
if (currentRecipe == null)
|
||||
if (currentRecipe == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentRecipe.canBeDone(this)) {
|
||||
setNextCurrentRecipe();
|
||||
|
||||
if (currentRecipe == null)
|
||||
if (currentRecipe == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getEnergy() >= currentRecipe.getEnergyCost()) {
|
||||
|
@ -137,7 +139,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
|
|||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
NBTTagList list = nbt.getTagList("planned", Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList list = nbt.getTagList("planned", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int i = 0; i < list.tagCount(); ++i) {
|
||||
NBTTagCompound cpt = list.getCompoundTagAt(i);
|
||||
|
@ -186,8 +188,9 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I
|
|||
}
|
||||
|
||||
public boolean isPlanned(AssemblyRecipe recipe) {
|
||||
if (recipe == null)
|
||||
if (recipe == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return plannedOutput.contains(recipe);
|
||||
}
|
||||
|
|
|
@ -1123,9 +1123,12 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
boolean placed = world.setBlock(i, j, k, block, meta, 3);
|
||||
|
||||
if (placed) {
|
||||
TileGenericPipe tile = (TileGenericPipe) world.getTileEntity(i, j, k);
|
||||
tile.initialize(pipe);
|
||||
tile.sendUpdateToClient();
|
||||
TileEntity tile = world.getTileEntity(i, j, k);
|
||||
if (tile instanceof TileGenericPipe) {
|
||||
TileGenericPipe tilePipe = (TileGenericPipe) tile;
|
||||
tilePipe.initialize(pipe);
|
||||
tilePipe.sendUpdateToClient();
|
||||
}
|
||||
}
|
||||
|
||||
return placed;
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
package buildcraft.transport;
|
||||
|
||||
import buildcraft.transport.pipes.PipeFluidsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeFluidsEmerald;
|
||||
import buildcraft.transport.pipes.PipeFluidsStone;
|
||||
import buildcraft.transport.pipes.PipeFluidsWood;
|
||||
import buildcraft.transport.pipes.PipeItemsCobblestone;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsEmzuli;
|
||||
import buildcraft.transport.pipes.PipeItemsObsidian;
|
||||
import buildcraft.transport.pipes.PipeItemsQuartz;
|
||||
|
@ -33,11 +35,15 @@ public class PipeConnectionBans {
|
|||
banConnection(PipeFluidsStone.class, PipeFluidsCobblestone.class);
|
||||
|
||||
banConnection(PipeFluidsWood.class);
|
||||
|
||||
banConnection(PipeFluidsEmerald.class);
|
||||
|
||||
// Item Pipes
|
||||
banConnection(PipeItemsStone.class, PipeItemsCobblestone.class, PipeItemsQuartz.class);
|
||||
|
||||
banConnection(PipeItemsWood.class);
|
||||
|
||||
banConnection(PipeItemsEmerald.class);
|
||||
|
||||
banConnection(PipeItemsObsidian.class);
|
||||
|
||||
|
|
|
@ -337,7 +337,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler
|
|||
private void moveFluids() {
|
||||
short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay);
|
||||
|
||||
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot);
|
||||
short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot > 0 && newTimeSlot < travelDelay ? newTimeSlot : 0);
|
||||
moveFromPipe(outputCount);
|
||||
moveFromCenter(outputCount);
|
||||
moveToCenter();
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.Position;
|
||||
|
@ -31,7 +32,6 @@ import buildcraft.core.inventory.Transactor;
|
|||
import buildcraft.core.utils.BCLog;
|
||||
import buildcraft.core.utils.BlockUtil;
|
||||
import buildcraft.core.utils.MathUtils;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.network.PacketPipeTransportItemStackRequest;
|
||||
import buildcraft.transport.network.PacketPipeTransportTraveler;
|
||||
import buildcraft.transport.pipes.events.PipeEventItem;
|
||||
|
@ -391,7 +391,7 @@ public class PipeTransportItems extends PipeTransport {
|
|||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
NBTTagList nbttaglist = nbt.getTagList("travelingEntities", Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList nbttaglist = nbt.getTagList("travelingEntities", Constants.NBT.TAG_COMPOUND);
|
||||
|
||||
for (int j = 0; j < nbttaglist.tagCount(); ++j) {
|
||||
try {
|
||||
|
|
|
@ -8,17 +8,17 @@
|
|||
*/
|
||||
package buildcraft.transport.gates;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.api.gates.GateExpansionController;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Gate;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.gates.GateDefinition.GateLogic;
|
||||
import buildcraft.transport.gates.GateDefinition.GateMaterial;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
public class GateFactory {
|
||||
|
||||
|
@ -27,8 +27,9 @@ public class GateFactory {
|
|||
}
|
||||
|
||||
public static Gate makeGate(Pipe pipe, ItemStack stack) {
|
||||
if (stack == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemGate))
|
||||
if (stack == null || stack.stackSize <= 0 || !(stack.getItem() instanceof ItemGate)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Gate gate = makeGate(pipe, ItemGate.getMaterial(stack), ItemGate.getLogic(stack));
|
||||
|
||||
|
@ -95,7 +96,7 @@ public class GateFactory {
|
|||
gate.expansions.put(GateExpansionPulsar.INSTANCE, pulsarCon);
|
||||
}
|
||||
|
||||
NBTTagList exList = nbt.getTagList("expansions", Utils.NBTTag_Types.NBTTagCompound.ordinal());
|
||||
NBTTagList exList = nbt.getTagList("expansions", Constants.NBT.TAG_COMPOUND);
|
||||
for (int i = 0; i < exList.tagCount(); i++) {
|
||||
NBTTagCompound conNBT = exList.getCompoundTagAt(i);
|
||||
IGateExpansion ex = GateExpansions.getExpansion(conNBT.getString("type"));
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.nbt.NBTTagList;
|
|||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.gates.ActionManager;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
|
@ -33,7 +34,6 @@ import buildcraft.core.CreativeTabBuildCraft;
|
|||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.inventory.InvUtils;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.Gate;
|
||||
import buildcraft.transport.gates.GateDefinition.GateLogic;
|
||||
import buildcraft.transport.gates.GateDefinition.GateMaterial;
|
||||
|
@ -98,7 +98,7 @@ public class ItemGate extends ItemBuildCraft {
|
|||
return;
|
||||
}
|
||||
|
||||
NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Utils.NBTTag_Types.NBTTagString.ordinal());
|
||||
NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Constants.NBT.TAG_STRING);
|
||||
expansionList.appendTag(new NBTTagString(expansion.getUniqueIdentifier()));
|
||||
nbt.setTag(NBT_TAG_EX, expansionList);
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ public class ItemGate extends ItemBuildCraft {
|
|||
}
|
||||
|
||||
try {
|
||||
NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Utils.NBTTag_Types.NBTTagString.ordinal());
|
||||
NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Constants.NBT.TAG_STRING);
|
||||
|
||||
for (int i = 0; i < expansionList.tagCount(); i++) {
|
||||
String ex = expansionList.getStringTagAt(i);
|
||||
|
@ -135,12 +135,13 @@ public class ItemGate extends ItemBuildCraft {
|
|||
}
|
||||
|
||||
try {
|
||||
NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Utils.NBTTag_Types.NBTTagString.ordinal());
|
||||
NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Constants.NBT.TAG_STRING);
|
||||
for (int i = 0; i < expansionList.tagCount(); i++) {
|
||||
String exTag = expansionList.getStringTagAt(i);
|
||||
IGateExpansion ex = GateExpansions.getExpansion(exTag);
|
||||
if (ex != null)
|
||||
if (ex != null) {
|
||||
expansions.add(ex);
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException error) {
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ public class ContainerEmeraldPipe extends BuildCraftContainer {
|
|||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 50 + l * 18));
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 79 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; i1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 108));
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 137));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,30 +15,42 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.GuiBuildCraft;
|
||||
import buildcraft.core.gui.buttons.GuiMultiButton;
|
||||
import buildcraft.core.gui.buttons.GuiImageButton;
|
||||
import buildcraft.core.gui.buttons.IButtonClickEventTrigger;
|
||||
import buildcraft.core.gui.buttons.IButtonClickEventListener;
|
||||
import buildcraft.core.network.PacketGuiReturn;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald.EmeraldPipeSettings;
|
||||
import buildcraft.transport.pipes.PipeItemsEmerald.FilterMode;
|
||||
|
||||
public class GuiEmeraldPipe extends GuiBuildCraft {
|
||||
public class GuiEmeraldPipe extends GuiBuildCraft implements IButtonClickEventListener {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filter_2.png");
|
||||
private GuiMultiButton button;
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emerald.png");
|
||||
|
||||
private static final int WHITE_LIST_BUTTON_ID = 1;
|
||||
private static final int BLACK_LIST_BUTTON_ID = 2;
|
||||
private static final int ROUND_ROBIN_BUTTON_ID = 3;
|
||||
|
||||
private GuiImageButton whiteListButton;
|
||||
private GuiImageButton blackListButton;
|
||||
private GuiImageButton roundRobinButton;
|
||||
|
||||
IInventory playerInventory;
|
||||
IInventory filterInventory;
|
||||
|
||||
PipeItemsEmerald pipe;
|
||||
|
||||
public GuiEmeraldPipe(IInventory playerInventory, PipeItemsEmerald pipe) {
|
||||
super(new ContainerEmeraldPipe(playerInventory, pipe), pipe.getFilters(), TEXTURE);
|
||||
|
||||
this.pipe = pipe;
|
||||
|
||||
this.playerInventory = playerInventory;
|
||||
this.filterInventory = pipe.getFilters();
|
||||
|
||||
xSize = 175;
|
||||
ySize = 132;
|
||||
ySize = 161;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -46,24 +58,74 @@ public class GuiEmeraldPipe extends GuiBuildCraft {
|
|||
super.initGui();
|
||||
|
||||
this.buttonList.clear();
|
||||
this.button = new GuiMultiButton(0, this.guiLeft + this.xSize - (80 + 6), this.guiTop + 34, 80, this.pipe.getStateController().copy());
|
||||
this.buttonList.add(this.button);
|
||||
|
||||
this.whiteListButton = new GuiImageButton(WHITE_LIST_BUTTON_ID, this.guiLeft + 7, this.guiTop + 41, GuiImageButton.ButtonImage.WHITE_LIST);
|
||||
this.whiteListButton.registerListener(this);
|
||||
this.buttonList.add(this.whiteListButton);
|
||||
|
||||
this.blackListButton = new GuiImageButton(BLACK_LIST_BUTTON_ID, this.guiLeft + 7 + 18, this.guiTop + 41, GuiImageButton.ButtonImage.BLACK_LIST);
|
||||
this.blackListButton.registerListener(this);
|
||||
this.buttonList.add(this.blackListButton);
|
||||
|
||||
this.roundRobinButton = new GuiImageButton(ROUND_ROBIN_BUTTON_ID, this.guiLeft + 7 + 36, this.guiTop + 41, GuiImageButton.ButtonImage.ROUND_ROBIN);
|
||||
this.roundRobinButton.registerListener(this);
|
||||
this.buttonList.add(this.roundRobinButton);
|
||||
|
||||
switch (pipe.getSettings().getFilterMode()) {
|
||||
case WHITE_LIST:
|
||||
this.whiteListButton.Activate();
|
||||
break;
|
||||
case BLACK_LIST:
|
||||
this.blackListButton.Activate();
|
||||
break;
|
||||
case ROUND_ROBIN:
|
||||
this.roundRobinButton.Activate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
if (pipe.getWorld().isRemote) {
|
||||
pipe.getStateController().setCurrentState(button.getController().getCurrentState());
|
||||
PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer());
|
||||
pkt.sendPacket();
|
||||
}
|
||||
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleButtonClick(IButtonClickEventTrigger sender, int buttonId) {
|
||||
switch (buttonId) {
|
||||
case WHITE_LIST_BUTTON_ID:
|
||||
whiteListButton.Activate();
|
||||
blackListButton.DeActivate();
|
||||
roundRobinButton.DeActivate();
|
||||
|
||||
pipe.getSettings().setFilterMode(FilterMode.WHITE_LIST);
|
||||
break;
|
||||
case BLACK_LIST_BUTTON_ID:
|
||||
whiteListButton.DeActivate();
|
||||
blackListButton.Activate();
|
||||
roundRobinButton.DeActivate();
|
||||
|
||||
pipe.getSettings().setFilterMode(FilterMode.BLACK_LIST);
|
||||
break;
|
||||
case ROUND_ROBIN_BUTTON_ID:
|
||||
whiteListButton.DeActivate();
|
||||
blackListButton.DeActivate();
|
||||
roundRobinButton.Activate();
|
||||
|
||||
pipe.getSettings().setFilterMode(FilterMode.ROUND_ROBIN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
fontRendererObj.drawString(filterInventory.getInventoryName(), getCenteredOffset(filterInventory.getInventoryName()), 6, 0x404040);
|
||||
String title = StringUtils.localize("gui.pipes.emerald.title");
|
||||
|
||||
fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040);
|
||||
fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,10 +18,10 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.mj.MjBattery;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.PipeManager;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
import buildcraft.transport.PipeTransportFluids;
|
||||
|
|
|
@ -10,9 +10,9 @@ package buildcraft.transport.pipes;
|
|||
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.IIconProvider;
|
||||
import buildcraft.api.core.NetworkData;
|
||||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import buildcraft.core.network.NetworkData;
|
||||
import buildcraft.core.utils.EnumColor;
|
||||
import buildcraft.transport.Pipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
|
@ -25,9 +25,11 @@ import buildcraft.transport.triggers.ActionPipeColor;
|
|||
import buildcraft.transport.triggers.ActionPipeDirection;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
|
|
|
@ -12,62 +12,58 @@ import io.netty.buffer.ByteBuf;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.gui.buttons.IButtonTextureSet;
|
||||
import buildcraft.core.gui.buttons.IMultiButtonState;
|
||||
import buildcraft.core.gui.buttons.MultiButtonController;
|
||||
import buildcraft.core.gui.buttons.StandardButtonTextureSets;
|
||||
import buildcraft.core.gui.tooltips.ToolTip;
|
||||
import buildcraft.core.gui.tooltips.ToolTipLine;
|
||||
import buildcraft.core.inventory.InvUtils;
|
||||
import buildcraft.core.inventory.InventoryWrapper;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.network.IClientState;
|
||||
import buildcraft.core.network.IGuiReturnHandler;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
import buildcraft.core.utils.Utils;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
import buildcraft.transport.PipeIconProvider;
|
||||
|
||||
public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGuiReturnHandler {
|
||||
|
||||
public static enum ButtonState implements IMultiButtonState {
|
||||
|
||||
BLOCKING("gui.pipes.emerald.blocking"), NONBLOCKING("gui.pipes.emerald.nonblocking");
|
||||
private final String label;
|
||||
|
||||
private ButtonState(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return StringUtils.localize(this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IButtonTextureSet getTextureSet() {
|
||||
return StandardButtonTextureSets.SMALL_BUTTON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolTip getToolTip() {
|
||||
return this.tip;
|
||||
}
|
||||
private final ToolTip tip = new ToolTip(500) {
|
||||
@Override
|
||||
public void refresh() {
|
||||
clear();
|
||||
tip.add(new ToolTipLine(StringUtils.localize(label + ".tip")));
|
||||
}
|
||||
};
|
||||
public enum FilterMode {
|
||||
WHITE_LIST, BLACK_LIST, ROUND_ROBIN;
|
||||
}
|
||||
private final MultiButtonController stateController = MultiButtonController.getController(ButtonState.BLOCKING.ordinal(), ButtonState.values());
|
||||
|
||||
public class EmeraldPipeSettings {
|
||||
|
||||
private FilterMode filterMode;
|
||||
|
||||
public EmeraldPipeSettings() {
|
||||
filterMode = FilterMode.WHITE_LIST;
|
||||
}
|
||||
|
||||
public FilterMode getFilterMode() {
|
||||
return filterMode;
|
||||
}
|
||||
|
||||
public void setFilterMode(FilterMode mode) {
|
||||
filterMode = mode;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
filterMode = FilterMode.values()[nbt.getByte("filterMode")];
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setByte("filterMode", (byte) filterMode.ordinal());
|
||||
}
|
||||
}
|
||||
|
||||
private EmeraldPipeSettings settings = new EmeraldPipeSettings();
|
||||
|
||||
private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1);
|
||||
|
||||
private int currentFilter = 0;
|
||||
|
||||
public PipeItemsEmerald(Item item) {
|
||||
|
@ -96,34 +92,100 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the itemstack that can be if something can be extracted from this
|
||||
* inventory, null if none. On certain cases, the extractable slot depends
|
||||
* on the position of the pipe.
|
||||
*/
|
||||
@Override
|
||||
public ItemStack[] checkExtract(IInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
IInventory inv = InvUtils.getInventory(inventory);
|
||||
ItemStack result = checkExtractGeneric(inv, doRemove, from);
|
||||
|
||||
// check through every filter once if non-blocking
|
||||
if (doRemove
|
||||
&& stateController.getButtonState() == ButtonState.NONBLOCKING
|
||||
&& result == null) {
|
||||
int count = 1;
|
||||
while (result == null && count < filters.getSizeInventory()) {
|
||||
incrementFilter();
|
||||
result = checkExtractGeneric(inv, doRemove, from);
|
||||
count++;
|
||||
}
|
||||
if (inventory == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
return new ItemStack[] { result };
|
||||
// Handle possible double chests and wrap it in the ISidedInventory interface.
|
||||
ISidedInventory sidedInventory = InventoryWrapper.getWrappedInventory(InvUtils.getInventory(inventory));
|
||||
|
||||
if (settings.getFilterMode() == FilterMode.ROUND_ROBIN) {
|
||||
return checkExtractRoundRobin(sidedInventory, doRemove, from);
|
||||
}
|
||||
|
||||
return checkExtractFiltered(sidedInventory, doRemove, from);
|
||||
}
|
||||
|
||||
private ItemStack[] checkExtractFiltered(ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int k : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(k);
|
||||
|
||||
if (stack == null || stack.stackSize <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!inventory.canExtractItem(k, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean matches = isFiltered(stack);
|
||||
boolean isBlackList = settings.getFilterMode() == FilterMode.BLACK_LIST;
|
||||
|
||||
if ((isBlackList && matches) || (!isBlackList && !matches)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (doRemove) {
|
||||
double energyUsed = mjStored > stack.stackSize ? stack.stackSize : mjStored;
|
||||
mjStored -= energyUsed;
|
||||
|
||||
stack = inventory.decrStackSize(k, (int) Math.floor(energyUsed));
|
||||
}
|
||||
|
||||
return new ItemStack[]{ stack };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemStack[] checkExtractRoundRobin(ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
ItemStack filter = getCurrentFilter();
|
||||
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!StackHelper.instance().isMatchingItem(filter, stack, true, false)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!inventory.canExtractItem(i, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (doRemove) {
|
||||
// In Round Robin mode, extract only 1 item regardless of power level.
|
||||
stack = inventory.decrStackSize(i, 1);
|
||||
incrementFilter();
|
||||
}
|
||||
|
||||
return new ItemStack[]{ stack };
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isFiltered(ItemStack stack) {
|
||||
for (int i = 0; i < filters.getSizeInventory(); i++) {
|
||||
ItemStack filter = filters.getStackInSlot(i);
|
||||
|
||||
if (filter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StackHelper.instance().isMatchingItem(filter, stack, true, false)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void incrementFilter() {
|
||||
|
@ -143,56 +205,14 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
return filters.getStackInSlot(currentFilter % filters.getSizeInventory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack checkExtractGeneric(net.minecraft.inventory.ISidedInventory inventory, boolean doRemove, ForgeDirection from) {
|
||||
for (int i : inventory.getAccessibleSlotsFromSide(from.ordinal())) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
ItemStack filter = getCurrentFilter();
|
||||
if (filter == null) {
|
||||
return null;
|
||||
}
|
||||
if (!filter.isItemEqual(stack)) {
|
||||
continue;
|
||||
}
|
||||
if (!inventory.canExtractItem(i, stack, from.ordinal())) {
|
||||
continue;
|
||||
}
|
||||
if (doRemove) {
|
||||
incrementFilter();
|
||||
double energyUsed = mjStored > stack.stackSize ? stack.stackSize : mjStored;
|
||||
mjStored -= energyUsed;
|
||||
|
||||
return inventory.decrStackSize(i, (int) energyUsed);
|
||||
} else {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
/* SAVING & LOADING */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
filters.readFromNBT(nbt);
|
||||
currentFilter = nbt.getInteger("currentFilter");
|
||||
|
||||
stateController.readFromNBT(nbt, "state");
|
||||
public EmeraldPipeSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
filters.writeToNBT(nbt);
|
||||
nbt.setInteger("currentFilter", currentFilter);
|
||||
|
||||
stateController.writeToNBT(nbt, "state");
|
||||
}
|
||||
|
||||
// ICLIENTSTATE
|
||||
@Override
|
||||
public void writeData(ByteBuf data) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
@ -206,21 +226,33 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu
|
|||
readFromNBT(nbt);
|
||||
}
|
||||
|
||||
public IInventory getFilters() {
|
||||
return filters;
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
filters.readFromNBT(nbt);
|
||||
settings.readFromNBT(nbt);
|
||||
|
||||
currentFilter = nbt.getInteger("currentFilter");
|
||||
}
|
||||
|
||||
public MultiButtonController getStateController() {
|
||||
return stateController;
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
filters.writeToNBT(nbt);
|
||||
settings.writeToNBT(nbt);
|
||||
|
||||
nbt.setInteger("currentFilter", currentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGuiData(ByteBuf data) {
|
||||
data.writeByte(stateController.getCurrentState());
|
||||
data.writeByte((byte)settings.getFilterMode().ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readGuiData(ByteBuf data, EntityPlayer sender) {
|
||||
stateController.setCurrentState(data.readByte());
|
||||
settings.setFilterMode(FilterMode.values()[data.readByte()]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue