Merge branch '1.10.2' of https://github.com/Blood-Asp/GT5-Unofficial into ic2-2.6.151+

This commit is contained in:
3TUSK 2017-01-26 16:46:27 -05:00
commit fc400ff7af
14 changed files with 222 additions and 108 deletions

View file

@ -23,6 +23,8 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@ -219,8 +221,11 @@ public class GregTech_API {
/** /**
* Adds Biomes to the Biome Lists for World Generation * Adds Biomes to the Biome Lists for World Generation
*/ */
private static int size = 0; /* Used to assign Minecraft IDs to our SoundEvents. We don't use them. */
static { static {
sItemStackMappings.add(sCoverItems); sItemStackMappings.add(sCoverItems);
size = SoundEvent.REGISTRY.getKeys().size();
sDimensionalList.add(-1); sDimensionalList.add(-1);
sDimensionalList.add(0); sDimensionalList.add(0);
@ -230,33 +235,42 @@ public class GregTech_API {
sSoundList.put(1, "block.anvil.use");//SoundEvents.BLOCK_ANVIL_USE.getSoundName().toString()); sSoundList.put(1, "block.anvil.use");//SoundEvents.BLOCK_ANVIL_USE.getSoundName().toString());
sSoundList.put(2, "block.anvil.break");//SoundEvents.BLOCK_ANVIL_BREAK.getSoundName().toString()); sSoundList.put(2, "block.anvil.break");//SoundEvents.BLOCK_ANVIL_BREAK.getSoundName().toString());
sSoundList.put(3, "block.stone_button.click_on");//SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON.getSoundName().toString()); sSoundList.put(3, "block.stone_button.click_on");//SoundEvents.BLOCK_STONE_BUTTON_CLICK_ON.getSoundName().toString());
sSoundList.put(4, "entity.item.break");//SoundEvents.ENTITY_ITEM_BREAK.getSoundName().toString()); sSoundList.put(4, "block.fire.extinguish");//SoundEvents.ENTITY_ITEM_BREAK.getSoundName().toString());
sSoundList.put(5, "entity.generic.explode");//SoundEvents.ENTITY_GENERIC_EXPLODE.getSoundName().toString()); sSoundList.put(5, "entity.generic.explode");//SoundEvents.ENTITY_GENERIC_EXPLODE.getSoundName().toString());
sSoundList.put(6, "item.firecharge.use");//SoundEvents.ITEM_FIRECHARGE_USE.getSoundName().toString()); sSoundList.put(6, "item.firecharge.use");//SoundEvents.ITEM_FIRECHARGE_USE.getSoundName().toString());
sSoundList.put(100, aTextIC2Lower + ":" + "tools.Wrench"); registerSound(100, aTextIC2Lower + ":" + "tools.Wrench");
sSoundList.put(101, aTextIC2Lower + ":" + "tools.RubberTrampoline"); registerSound(101, aTextIC2Lower + ":" + "tools.RubberTrampoline");
sSoundList.put(102, aTextIC2Lower + ":" + "tools.Painter"); registerSound(102, aTextIC2Lower + ":" + "tools.Painter");
sSoundList.put(103, aTextIC2Lower + ":" + "tools.BatteryUse"); registerSound(103, aTextIC2Lower + ":" + "tools.BatteryUse");
sSoundList.put(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne"); registerSound(104, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseOne");
sSoundList.put(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo"); registerSound(105, aTextIC2Lower + ":" + "tools.chainsaw.ChainsawUseTwo");
sSoundList.put(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft"); registerSound(106, aTextIC2Lower + ":" + "tools.drill.DrillSoft");
sSoundList.put(107, aTextIC2Lower + ":" + "tools.drill.DrillHard"); registerSound(107, aTextIC2Lower + ":" + "tools.drill.DrillHard");
sSoundList.put(108, aTextIC2Lower + ":" + "tools.ODScanner"); registerSound(108, aTextIC2Lower + ":" + "tools.ODScanner");
sSoundList.put(200, aTextIC2Lower + ":" + "machines.ExtractorOp"); registerSound(200, aTextIC2Lower + ":" + "machines.ExtractorOp");
sSoundList.put(201, aTextIC2Lower + ":" + "machines.MaceratorOp"); registerSound(201, aTextIC2Lower + ":" + "machines.MaceratorOp");
sSoundList.put(202, aTextIC2Lower + ":" + "machines.InductionLoop"); registerSound(202, aTextIC2Lower + ":" + "machines.InductionLoop");
sSoundList.put(203, aTextIC2Lower + ":" + "machines.CompressorOp"); registerSound(203, aTextIC2Lower + ":" + "machines.CompressorOp");
sSoundList.put(204, aTextIC2Lower + ":" + "machines.RecyclerOp"); registerSound(204, aTextIC2Lower + ":" + "machines.RecyclerOp");
sSoundList.put(205, aTextIC2Lower + ":" + "machines.MinerOp"); registerSound(205, aTextIC2Lower + ":" + "machines.MinerOp");
sSoundList.put(206, aTextIC2Lower + ":" + "machines.PumpOp"); registerSound(206, aTextIC2Lower + ":" + "machines.PumpOp");
sSoundList.put(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop"); registerSound(207, aTextIC2Lower + ":" + "machines.ElectroFurnaceLoop");
sSoundList.put(208, aTextIC2Lower + ":" + "machines.InductionLoop"); registerSound(208, aTextIC2Lower + ":" + "machines.InductionLoop");
sSoundList.put(209, aTextIC2Lower + ":" + "machines.MachineOverload"); registerSound(209, aTextIC2Lower + ":" + "machines.MachineOverload");
sSoundList.put(210, aTextIC2Lower + ":" + "machines.InterruptOne"); registerSound(210, aTextIC2Lower + ":" + "machines.InterruptOne");
sSoundList.put(211, aTextIC2Lower + ":" + "machines.KaChing"); registerSound(211, aTextIC2Lower + ":" + "machines.KaChing");
sSoundList.put(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop"); registerSound(212, aTextIC2Lower + ":" + "machines.MagnetizerLoop");
}
public static void registerSound(int id, String name) {
ResourceLocation loc = new ResourceLocation(name);
SoundEvent e = new SoundEvent(loc);
if(!SoundEvent.REGISTRY.containsKey(loc)) {
SoundEvent.REGISTRY.register(size++, loc, e);
}
sSoundList.put(id, name);
} }
/** /**
@ -373,7 +387,6 @@ public class GregTech_API {
GT_ItemStack stack = new GT_ItemStack(aStack); GT_ItemStack stack = new GT_ItemStack(aStack);
int coverId = stack.hashCode(); int coverId = stack.hashCode();
sCoverItems.put(stack, coverId); sCoverItems.put(stack, coverId);
System.out.println();
sCovers.put(coverId, aCover == null || !aCover.isValidTexture() ? Textures.BlockIcons.ERROR_RENDERING[0] : aCover); sCovers.put(coverId, aCover == null || !aCover.isValidTexture() ? Textures.BlockIcons.ERROR_RENDERING[0] : aCover);
if (aBehavior != null) sCoverBehaviors.put(coverId, aBehavior); if (aBehavior != null) sCoverBehaviors.put(coverId, aBehavior);
} }

View file

@ -34,4 +34,10 @@ public interface IRedstoneEmitter extends IHasWorldObjectAndCoords {
* Gets the Output for the comparator on the given Side * Gets the Output for the comparator on the given Side
*/ */
byte getComparatorValue(byte aSide); byte getComparatorValue(byte aSide);
/**
* Return whether the TileEntity can output redstone to the given side. Used to visually connect
* vanilla redstone wires.
*/
boolean canOutputRedstone(byte aSide);
} }

View file

@ -511,10 +511,8 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
} }
public IToolStats getToolStats(ItemStack aStack) { public IToolStats getToolStats(ItemStack aStack) {
if(isItemStackUsable(aStack)) { // if(isItemStackUsable(aStack)) { // why?
return getToolStatsInternal(aStack); return getToolStatsInternal(aStack);
}
return null;
} }
private IToolStats getToolStatsInternal(ItemStack aStack) { private IToolStats getToolStatsInternal(ItemStack aStack) {
@ -712,7 +710,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack stack, int tintIndex) { public int getColorFromItemStack(ItemStack stack, int tintIndex) {
IToolStats toolStats = getToolStats(stack); IToolStats toolStats = getToolStats(stack);
if(tintIndex == 1) { if(tintIndex > 1) {
short[] colorsHead = toolStats.getRGBa(true, stack); short[] colorsHead = toolStats.getRGBa(true, stack);
if(colorsHead != null) if(colorsHead != null)
return ITexture.color(colorsHead, true); return ITexture.color(colorsHead, true);

View file

@ -293,7 +293,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
} }
if (mNeedsBlockUpdate) { if (mNeedsBlockUpdate) {
worldObj.notifyBlockOfStateChange(getPos(), getBlockType()); worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType());
mNeedsBlockUpdate = false; mNeedsBlockUpdate = false;
} }
} }
@ -494,6 +494,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
return getInternalInputRedstoneSignal(aSide) > 0; return getInternalInputRedstoneSignal(aSide) > 0;
} }
@Override
public boolean canOutputRedstone(byte aSide) {
return (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)
|| getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this));
}
public ITexture getCoverTexture(byte aSide) { public ITexture getCoverTexture(byte aSide) {
return GregTech_API.sCovers.get(getCoverIDAtSide(aSide)); return GregTech_API.sCovers.get(getCoverIDAtSide(aSide));
} }
@ -1017,7 +1023,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
@Override @Override
public byte getInputRedstoneSignal(byte aSide) { public byte getInputRedstoneSignal(byte aSide) {
return (byte) (worldObj.getRedstonePower(getPos(), EnumFacing.VALUES[aSide]) & 15); return (byte) (worldObj.getRedstonePower(getPos().offset(EnumFacing.VALUES[aSide]), EnumFacing.VALUES[aSide]) & 15);
} }
@Override @Override

View file

@ -557,7 +557,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
} }
if (mNeedsBlockUpdate) { if (mNeedsBlockUpdate) {
worldObj.notifyBlockOfStateChange(getPos(), getBlockOffset(0, 0, 0)); worldObj.notifyNeighborsOfStateChange(getPos(), getBlockOffset(0, 0, 0));
mNeedsBlockUpdate = false; mNeedsBlockUpdate = false;
} }
} }
@ -734,6 +734,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
return getInternalInputRedstoneSignal(aSide) > 0; return getInternalInputRedstoneSignal(aSide) > 0;
} }
@Override
public boolean canOutputRedstone(byte aSide) {
return (getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)
|| getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this));
}
public ITexture getCoverTexture(byte aSide) { public ITexture getCoverTexture(byte aSide) {
return GregTech_API.sCovers.get(getCoverIDAtSide(aSide)); return GregTech_API.sCovers.get(getCoverIDAtSide(aSide));
} }
@ -1437,7 +1443,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override @Override
public byte getInputRedstoneSignal(byte aSide) { public byte getInputRedstoneSignal(byte aSide) {
return (byte) (worldObj.getRedstonePower(getPos(), EnumFacing.VALUES[aSide]) & 15); return (byte) (worldObj.getRedstonePower(getPos().offset(EnumFacing.VALUES[aSide]), EnumFacing.VALUES[aSide]) & 15);
} }
@Override @Override

View file

@ -2,6 +2,7 @@ package gregtech.api.metatileentity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
import gregtech.api.net.GT_Packet_Block_Event;
import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -472,7 +473,14 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
@Override @Override
public final void sendBlockEvent(byte aID, byte aValue) { public final void sendBlockEvent(byte aID, byte aValue) {
//NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(getXCoord(), (short) getYCoord(), getZCoord(), aID, aValue), getXCoord(), getZCoord()); NW.sendToAllAround(worldObj, new GT_Packet_Block_Event(getXCoord(),
(short) getYCoord(),
getZCoord(),
aID,
aValue),
getXCoord(),
getYCoord(),
getZCoord());
} }
private boolean crossedChunkBorder(int aX, int aZ) { private boolean crossedChunkBorder(int aX, int aZ) {

View file

@ -1,6 +1,8 @@
package gregtech.api.net; package gregtech.api.net;
import gregtech.GT_Mod; import gregtech.GT_Mod;
import net.minecraft.client.Minecraft;
import net.minecraft.util.IThreadListener;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
@ -14,6 +16,7 @@ public class GT_PacketHandler extends SimpleNetworkWrapper {
super("gregtech_network"); super("gregtech_network");
registerMessage(0, GT_Packet_TileEntity.class, Side.CLIENT); registerMessage(0, GT_Packet_TileEntity.class, Side.CLIENT);
registerMessage(2, GT_Packet_Sound.class, Side.CLIENT); registerMessage(2, GT_Packet_Sound.class, Side.CLIENT);
registerMessage(3, GT_Packet_Block_Event.class, Side.CLIENT);
} }
public void registerMessage(int discriminator, Class packet, Side handleSide) { public void registerMessage(int discriminator, Class packet, Side handleSide) {
@ -32,11 +35,19 @@ public class GT_PacketHandler extends SimpleNetworkWrapper {
@Override @Override
public GT_Packet onMessage(GT_Packet message, MessageContext ctx) { public GT_Packet onMessage(GT_Packet message, MessageContext ctx) {
IThreadListener listener;
World world;
if(ctx.side == Side.SERVER) { if(ctx.side == Side.SERVER) {
message.process(ctx.getServerHandler().playerEntity.worldObj); world = ctx.getServerHandler().playerEntity.worldObj;
listener = world.getMinecraftServer();
} else { } else {
message.process(GT_Mod.gregtechproxy.getThePlayer().worldObj); world = GT_Mod.gregtechproxy.getThePlayer().worldObj;
listener = Minecraft.getMinecraft();
} }
listener.addScheduledTask(() -> {
message.process(world);
});
return null; return null;
} }
} }

View file

@ -0,0 +1,55 @@
package gregtech.api.net;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import io.netty.buffer.ByteBuf;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
/**
* Used to transfer Block Events in a much better fashion
*/
public class GT_Packet_Block_Event extends GT_Packet {
private int mX, mZ;
private short mY;
private byte mID, mValue;
public GT_Packet_Block_Event() {}
public GT_Packet_Block_Event(int aX, short aY, int aZ, byte aID, byte aValue) {
mX = aX;
mY = aY;
mZ = aZ;
mID = aID;
mValue = aValue;
}
@Override
public void encode(ByteBuf buf) {
buf.writeInt(mX);
buf.writeShort(mY);
buf.writeInt(mZ);
buf.writeByte(mID);
buf.writeByte(mValue);
}
@Override
public void decode(ByteBuf buf) {
mX = buf.readInt();
mY = buf.readShort();
mZ = buf.readInt();
mID = buf.readByte();
mValue = buf.readByte();
}
@Override
public void process(World aWorld) {
if (aWorld != null) {
TileEntity tTileEntity = aWorld.getTileEntity(new BlockPos(mX, mY, mZ));
if (tTileEntity != null) tTileEntity.receiveClientEvent(mID, mValue);
}
}
}

View file

@ -33,8 +33,7 @@ public class GT_Runnable_Sound implements Runnable {
public void run() { public void run() {
SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(mSoundLocation); SoundEvent soundEvent = SoundEvent.REGISTRY.getObject(mSoundLocation);
if(soundEvent != null) { if(soundEvent != null) {
PositionedSound sound = new PositionedSound(soundEvent, SoundCategory.BLOCKS) {}; mWorld.playSound((double)mX, (double)mY, (double)mZ, soundEvent, SoundCategory.BLOCKS, 1.0f, 1.0f, false);
Minecraft.getMinecraft().getSoundHandler().playSound(sound);
} }
} }

View file

@ -137,9 +137,15 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
return false; return false;
} }
/**
* NB: Vanilla redstone behavior is that wires will connect to redstone emitters but not consumers.
* Thus we only say we can connect if we are an emitter. (This is usually delegated to a cover behavior.)
*
*/
@Override @Override
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) { public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
return true; IGregTechTileEntity gregTechTileEntity = getGregTile(world, pos);
return gregTechTileEntity != null && gregTechTileEntity.canOutputRedstone((byte) side.getOpposite().getIndex());
} }
@Override @Override
@ -356,7 +362,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { public int getWeakPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos); IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos);
if(gregTechTileEntity != null) { if(gregTechTileEntity != null) {
gregTechTileEntity.getOutputRedstoneSignal((byte) side.getIndex()); return gregTechTileEntity.getOutputRedstoneSignal((byte) side.getOpposite().getIndex());
} }
return 0; return 0;
} }
@ -365,7 +371,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo
public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { public int getStrongPower(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos); IGregTechTileEntity gregTechTileEntity = getGregTile(blockAccess, pos);
if(gregTechTileEntity != null) { if(gregTechTileEntity != null) {
gregTechTileEntity.getStrongOutputRedstoneSignal((byte) side.getIndex()); return gregTechTileEntity.getStrongOutputRedstoneSignal((byte) side.getOpposite().getIndex());
} }
return 0; return 0;
} }

View file

@ -294,11 +294,13 @@ public class ItemRenderer {
public void renderItem(ItemStack item) { public void renderItem(ItemStack item) {
if(item.getItem() instanceof ItemBlock) { if(item.getItem() instanceof ItemBlock) {
renderItem(item, 0); renderItem(item, 0);
} else { } else if (item.getItem() instanceof GT_Generic_Item) {
GT_Generic_Item generic_item = (GT_Generic_Item) item.getItem(); GT_Generic_Item generic_item = (GT_Generic_Item) item.getItem();
for(int i = 0; i < generic_item.getRenderPasses(item); i++) { for(int i = 0; i < generic_item.getRenderPasses(item); i++) {
renderItem(item, i); renderItem(item, i);
} }
} else {
return;
} }
} }

View file

@ -34,8 +34,9 @@ import java.util.List;
public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBase { public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBase {
private static final ItemStack mining_pipe = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1); private static final ItemStack mining_pipe_item = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1);
private static final ItemStack mining_pipe_tip = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip, 1); private static final IBlockState mining_pipe = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe);
private static final IBlockState mining_pipe_tip = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip);
private final ArrayList<BlockPos> mMineList = new ArrayList(); private final ArrayList<BlockPos> mMineList = new ArrayList();
@ -74,15 +75,15 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas
@Override @Override
public boolean checkRecipe(ItemStack aStack) { public boolean checkRecipe(ItemStack aStack) {
if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) { if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe_item) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) {
ArrayList<ItemStack> tItems = getStoredInputs(); ArrayList<ItemStack> tItems = getStoredInputs();
for (ItemStack tStack : tItems) { for (ItemStack tStack : tItems) {
if (tStack.isItemEqual(mining_pipe)) { if (tStack.isItemEqual(mining_pipe_item)) {
tStack.stackSize--; tStack.stackSize--;
if (tStack.stackSize < 1) { if (tStack.stackSize < 1) {
} }
if (mInventory[1] == null) { if (mInventory[1] == null) {
mInventory[1] = mining_pipe; mInventory[1] = mining_pipe_item;
} else { } else {
mInventory[1].stackSize++; mInventory[1].stackSize++;
} }
@ -139,7 +140,6 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas
List<ItemStack> tDrops = new ArrayList(); List<ItemStack> tDrops = new ArrayList();
Block tMineBlock = null; Block tMineBlock = null;
BlockPos mle = null; BlockPos mle = null;
int posX, posY, posZ, offX, offY, offZ;
while ((tMineBlock==null || tMineBlock == Blocks.AIR) && !mMineList.isEmpty()) { while ((tMineBlock==null || tMineBlock == Blocks.AIR) && !mMineList.isEmpty()) {
mle = mMineList.get(0); mle = mMineList.get(0);
mMineList.remove(0); mMineList.remove(0);
@ -147,26 +147,24 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas
} }
if (tMineBlock!=null && tMineBlock!=Blocks.AIR) { if (tMineBlock!=null && tMineBlock!=Blocks.AIR) {
posX = mle.getX() + getBaseMetaTileEntity().getXCoord(); BlockPos pos = new BlockPos(mle.getX() + getBaseMetaTileEntity().getXCoord(),
posY = mle.getY() + getBaseMetaTileEntity().getYCoord(); mle.getY() + getBaseMetaTileEntity().getYCoord(),
posZ = mle.getZ() + getBaseMetaTileEntity().getZCoord(); mle.getZ() + getBaseMetaTileEntity().getZCoord());
offX = mle.getX();
offY = mle.getY();
offZ = mle.getZ();
IBlockState metadata = getBaseMetaTileEntity().getWorldObj().getBlockState(mle);
boolean silkTouch = tMineBlock.canSilkHarvest(getBaseMetaTileEntity().getWorldObj(), new BlockPos(posX, posY, posZ), metadata, null); IBlockState blockState = getBaseMetaTileEntity().getWorldObj().getBlockState(pos);
boolean silkTouch = tMineBlock.canSilkHarvest(getBaseMetaTileEntity().getWorldObj(), pos, blockState, null);
if (silkTouch){ if (silkTouch){
ItemStack IS = new ItemStack(tMineBlock); ItemStack IS = new ItemStack(tMineBlock);
IS.setItemDamage(metadata.getBlock().getMetaFromState(metadata)); IS.setItemDamage(blockState.getBlock().getMetaFromState(blockState));
IS.stackSize=1; IS.stackSize=1;
tDrops.add(IS); tDrops.add(IS);
} }
else{ else{
tDrops = tMineBlock.getDrops(getBaseMetaTileEntity().getWorldObj(), new BlockPos(posX, posY, posZ), metadata, 1); tDrops = tMineBlock.getDrops(getBaseMetaTileEntity().getWorldObj(), pos, blockState, 1);
} }
getBaseMetaTileEntity().getWorldObj().setBlockToAir(getBaseMetaTileEntity().getWorldPos().add(posX, posY, posZ)); getBaseMetaTileEntity().getWorldObj().setBlockToAir(pos);
if (!tDrops.isEmpty()) { if (!tDrops.isEmpty()) {
ItemData tData = GT_OreDictUnificator.getItemData(tDrops.get(0).copy()); ItemData tData = GT_OreDictUnificator.getItemData(tDrops.get(0).copy());
if (tData.mPrefix != OrePrefixes.crushed && tData.mMaterial.mMaterial != Materials.Oilsands) { if (tData.mPrefix != OrePrefixes.crushed && tData.mMaterial.mMaterial != Materials.Oilsands) {
@ -225,7 +223,7 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas
private boolean moveOneDown() { private boolean moveOneDown() {
if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1) if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1)
|| (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe))) { || (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item))) {
stopMachine(); stopMachine();
return false; return false;
} }
@ -241,39 +239,38 @@ public class GT_MetaTileEntity_AdvMiner2 extends GT_MetaTileEntity_MultiBlockBas
return false; return false;
} }
if (!(getBaseMetaTileEntity().getWorldObj().setBlockState( if (!(getBaseMetaTileEntity().getWorldObj().setBlockState(
new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe_tip))) {
GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()))) {
stopMachine(); stopMachine();
return false; return false;
} }
if (yHead != getBaseMetaTileEntity().getYCoord()) { if (yHead != getBaseMetaTileEntity().getYCoord()) {
getBaseMetaTileEntity().getWorldObj().setBlockState( getBaseMetaTileEntity().getWorldObj().setBlockState(
new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe);
GT_Utility.getBlockFromStack(mining_pipe).getDefaultState());
} }
getBaseMetaTileEntity().decrStackSize(1, 1); getBaseMetaTileEntity().decrStackSize(1, 1);
return true; return true;
} }
private int getYOfPumpHead() { private int getYOfPumpHead() {
int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX(); BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(getBaseMetaTileEntity().getWorldPos());
int zDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetZ(); pos.move(EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()]);
int y = getBaseMetaTileEntity().getYCoord() - 1; pos.move(EnumFacing.DOWN);
while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) == GT_Utility.getBlockFromStack(mining_pipe)) {
y--; while (getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe)) {
pos.move(EnumFacing.DOWN);
} }
if (y == getBaseMetaTileEntity().getYCoord() - 1) { if (pos.getY() == getBaseMetaTileEntity().getYCoord() - 1) {
if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility.getBlockFromStack(mining_pipe_tip)) { if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip)) {
return y + 1; return pos.getY() + 1;
} }
} else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility } else if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip)
.getBlockFromStack(mining_pipe_tip) && this.mInventory[1] != null && this.mInventory[1].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe)) { && this.mInventory[1] != null
getBaseMetaTileEntity().getWorldObj().setBlockState( && this.mInventory[1].stackSize > 0
new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir), && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item)) {
GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()); getBaseMetaTileEntity().getWorldObj().setBlockState(pos, mining_pipe_tip);
getBaseMetaTileEntity().decrStackSize(0, 1); getBaseMetaTileEntity().decrStackSize(0, 1);
} }
return y; return pos.getY();
} }
@Override @Override

View file

@ -11,6 +11,7 @@ import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe;
import gregtech.common.tools.GT_Tool; import gregtech.common.tools.GT_Tool;
import gregtech.common.GT_Pollution; import gregtech.common.GT_Pollution;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -140,7 +141,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
if (aX + 1 < 6 && (isWoodLog(tBlock))) { if (aX + 1 < 6 && (isWoodLog(tBlock))) {
if (!aList1.contains(new BlockPos(aX + 1, aY, aZ)) && (!aList2.contains(new BlockPos(aX + 1, aY, aZ)))) if (!aList1.contains(new BlockPos(aX + 1, aY, aZ)) && (!aList2.contains(new BlockPos(aX + 1, aY, aZ))))
p1 = true; p1 = true;
} else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { } else if (!isDirt(tBlock)) {
return false; return false;
} }
@ -148,7 +149,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
if (aX - 1 > -6 && (isWoodLog(tBlock))) { if (aX - 1 > -6 && (isWoodLog(tBlock))) {
if (!aList1.contains(new BlockPos(aX - 1, aY, aZ)) && (!aList2.contains(new BlockPos(aX - 1, aY, aZ)))) if (!aList1.contains(new BlockPos(aX - 1, aY, aZ)) && (!aList2.contains(new BlockPos(aX - 1, aY, aZ))))
p2 = true; p2 = true;
} else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { } else if (!isDirt(tBlock)) {
return false; return false;
} }
@ -156,7 +157,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
if (aY + 1 < 1 && (isWoodLog(tBlock))) { if (aY + 1 < 1 && (isWoodLog(tBlock))) {
if (!aList1.contains(new BlockPos(aX, aY + 1, aZ)) && (!aList2.contains(new BlockPos(aX, aY + 1, aZ)))) if (!aList1.contains(new BlockPos(aX, aY + 1, aZ)) && (!aList2.contains(new BlockPos(aX, aY + 1, aZ))))
p3 = true; p3 = true;
} else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS || (aX == 0 && aY == -1 && aZ == 0 && tBlock == GregTech_API.sBlockMachines))) { } else if (!(isDirt(tBlock) || (aX == 0 && aY == -1 && aZ == 0 && tBlock.getBlock() == GregTech_API.sBlockMachines))) {
return false; return false;
} }
@ -164,7 +165,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
if (aY - 1 > -6 && (isWoodLog(tBlock))) { if (aY - 1 > -6 && (isWoodLog(tBlock))) {
if (!aList1.contains(new BlockPos(aX, aY - 1, aZ)) && (!aList2.contains(new BlockPos(aX, aY - 1, aZ)))) if (!aList1.contains(new BlockPos(aX, aY - 1, aZ)) && (!aList2.contains(new BlockPos(aX, aY - 1, aZ))))
p4 = true; p4 = true;
} else if (tBlock != Blocks.BRICK_BLOCK) { } else if (tBlock.getBlock() != Blocks.BRICK_BLOCK) {
return false; return false;
} }
@ -172,7 +173,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
if (aZ + 1 < 6 && (isWoodLog(tBlock))) { if (aZ + 1 < 6 && (isWoodLog(tBlock))) {
if (!aList1.contains(new BlockPos(aX, aY, aZ + 1)) && (!aList2.contains(new BlockPos(aX, aY, aZ + 1)))) if (!aList1.contains(new BlockPos(aX, aY, aZ + 1)) && (!aList2.contains(new BlockPos(aX, aY, aZ + 1))))
p5 = true; p5 = true;
} else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { } else if (!isDirt(tBlock)) {
return false; return false;
} }
@ -180,7 +181,7 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
if (aZ - 1 > -6 && (isWoodLog(tBlock))) { if (aZ - 1 > -6 && (isWoodLog(tBlock))) {
if (!aList1.contains(new BlockPos(aX, aY, aZ - 1)) && (!aList2.contains(new BlockPos(aX, aY, aZ - 1)))) if (!aList1.contains(new BlockPos(aX, aY, aZ - 1)) && (!aList2.contains(new BlockPos(aX, aY, aZ - 1))))
p6 = true; p6 = true;
} else if (!(tBlock == Blocks.DIRT || tBlock == Blocks.GRASS)) { } else if (!isDirt(tBlock)) {
return false; return false;
} }
aList1.add(new BlockPos(aX, aY, aZ)); aList1.add(new BlockPos(aX, aY, aZ));
@ -200,6 +201,11 @@ public class GT_MetaTileEntity_Charcoal_Pit extends GT_MetaTileEntity_MultiBlock
(log.getMaterial() == Material.WOOD); (log.getMaterial() == Material.WOOD);
} }
private boolean isDirt(IBlockState dirt) {
Block b = dirt.getBlock();
return (b == Blocks.DIRT || b == Blocks.GRASS);
}
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
mWrench = true; mWrench = true;
mScrewdriver = true; mScrewdriver = true;

View file

@ -12,6 +12,7 @@ import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_Utility; import gregtech.api.util.GT_Utility;
import ic2.core.block.machine.BlockMiningPipe; import ic2.core.block.machine.BlockMiningPipe;
import ic2.core.ref.BlockName; import ic2.core.ref.BlockName;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -23,8 +24,9 @@ import java.util.ArrayList;
public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase { public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase {
private static final ItemStack mining_pipe = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1); private static final ItemStack mining_pipe_item = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe, 1);
private static final ItemStack mining_pipe_tip = GT_ModHandler.getIC2Item(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip, 1); private static final IBlockState mining_pipe = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.pipe);
private static final IBlockState mining_pipe_tip = GT_ModHandler.getIC2BlockState(BlockName.mining_pipe, BlockMiningPipe.MiningPipeType.tip);
private boolean completedCycle = false; private boolean completedCycle = false;
@ -61,10 +63,10 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
@Override @Override
public boolean checkRecipe(ItemStack aStack) { public boolean checkRecipe(ItemStack aStack) {
if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) { if (mInventory[1] == null || (mInventory[1].isItemEqual(mining_pipe_item) && mInventory[1].stackSize < mInventory[1].getMaxStackSize())) {
ArrayList<ItemStack> tItems = getStoredInputs(); ArrayList<ItemStack> tItems = getStoredInputs();
for (ItemStack tStack : tItems) { for (ItemStack tStack : tItems) {
if (tStack.isItemEqual(mining_pipe)) { if (tStack.isItemEqual(mining_pipe_item)) {
if (tStack.stackSize < 2) { if (tStack.stackSize < 2) {
tStack = null; tStack = null;
} else { } else {
@ -73,7 +75,7 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
} }
if (mInventory[1] == null) { if (mInventory[1] == null) {
mInventory[1] = mining_pipe; mInventory[1] = mining_pipe_item;
} else { } else {
mInventory[1].stackSize++; mInventory[1].stackSize++;
} }
@ -126,7 +128,7 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
private boolean moveOneDown() { private boolean moveOneDown() {
if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1) if ((this.mInventory[1] == null) || (this.mInventory[1].stackSize < 1)
|| (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe))) { || (!GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item))) {
return false; return false;
} }
int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX(); int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX();
@ -139,38 +141,37 @@ public class GT_MetaTileEntity_OilDrill extends GT_MetaTileEntity_MultiBlockBase
return false; return false;
} }
if (!(getBaseMetaTileEntity().getWorldObj().setBlockState( if (!(getBaseMetaTileEntity().getWorldObj().setBlockState(
new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead - 1, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe_tip))) {
GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()))) {
return false; return false;
} }
if (yHead != getBaseMetaTileEntity().getYCoord()) { if (yHead != getBaseMetaTileEntity().getYCoord()) {
getBaseMetaTileEntity().getWorldObj().setBlockState( getBaseMetaTileEntity().getWorldObj().setBlockState(
new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, yHead, getBaseMetaTileEntity().getZCoord() + zDir), mining_pipe);
GT_Utility.getBlockFromStack(mining_pipe).getDefaultState());
} }
getBaseMetaTileEntity().decrStackSize(1, 1); getBaseMetaTileEntity().decrStackSize(1, 1);
return true; return true;
} }
private int getYOfPumpHead() { private int getYOfPumpHead() {
int xDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetX(); BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(getBaseMetaTileEntity().getWorldPos());
int zDir = EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()].getFrontOffsetZ(); pos.move(EnumFacing.VALUES[getBaseMetaTileEntity().getBackFacing()]);
int y = getBaseMetaTileEntity().getYCoord() - 1; pos.move(EnumFacing.DOWN);
while (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) == GT_Utility.getBlockFromStack(mining_pipe)) {
y--; while (getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe)) {
pos.move(EnumFacing.DOWN);
} }
if (y == getBaseMetaTileEntity().getYCoord() - 1) { if (pos.getY() == getBaseMetaTileEntity().getYCoord() - 1) {
if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility.getBlockFromStack(mining_pipe_tip)) { if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip)) {
return y + 1; return pos.getY() + 1;
} }
} else if (getBaseMetaTileEntity().getBlock(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir) != GT_Utility } else if (!getBaseMetaTileEntity().getBlockState(pos).equals(mining_pipe_tip)
.getBlockFromStack(mining_pipe_tip) && this.mInventory[1] != null && this.mInventory[1].stackSize > 0 && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe)) { && this.mInventory[1] != null
getBaseMetaTileEntity().getWorldObj().setBlockState( && this.mInventory[1].stackSize > 0
new BlockPos(getBaseMetaTileEntity().getXCoord() + xDir, y, getBaseMetaTileEntity().getZCoord() + zDir), && GT_Utility.areStacksEqual(this.mInventory[1], mining_pipe_item)) {
GT_Utility.getBlockFromStack(mining_pipe_tip).getDefaultState()); getBaseMetaTileEntity().getWorldObj().setBlockState(pos, mining_pipe_tip);
getBaseMetaTileEntity().decrStackSize(0, 1); getBaseMetaTileEntity().decrStackSize(0, 1);
} }
return y; return pos.getY();
} }
@Override @Override