aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/IToolable.java17
-rw-r--r--src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java349
-rw-r--r--src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java112
-rw-r--r--src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java5
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java2
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java398
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java82
7 files changed, 923 insertions, 42 deletions
diff --git a/src/Java/gtPlusPlus/api/interfaces/IToolable.java b/src/Java/gtPlusPlus/api/interfaces/IToolable.java
new file mode 100644
index 0000000000..24797825a9
--- /dev/null
+++ b/src/Java/gtPlusPlus/api/interfaces/IToolable.java
@@ -0,0 +1,17 @@
+package gtPlusPlus.api.interfaces;
+
+public interface IToolable {
+
+ public boolean isScrewdriverable();
+ public boolean onScrewdriverLMB();
+ public boolean onScrewdriverRMB();
+
+ public boolean isWrenchable();
+ public boolean onWrenchLMB();
+ public boolean onWrenchRMB();
+
+ public boolean isMalletable();
+ public boolean onMalletLMB();
+ public boolean onMalletRMB();
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java
new file mode 100644
index 0000000000..14dac32b63
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstone.java
@@ -0,0 +1,349 @@
+package gtPlusPlus.core.block.general.redstone;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Random;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.common.items.GT_MetaGenerated_Tool_01;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.item.base.itemblock.ItemBlockMeta;
+import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler;
+import gtPlusPlus.core.util.minecraft.InventoryUtils;
+import gtPlusPlus.core.util.minecraft.PlayerUtils;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+
+public abstract class BlockGenericRedstone extends BlockContainer {
+
+
+ @SuppressWarnings("deprecation")
+ public BlockGenericRedstone(String aUnlocalizedSuffix, String aDisplayName) {
+ super(Material.redstoneLight);
+ this.setBlockName("blockGenericRedstone." + aUnlocalizedSuffix);
+ this.setHardness(3f);
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ GameRegistry.registerBlock(this, ItemBlockMeta.class, "blockGenericRedstone." + aUnlocalizedSuffix);
+ LanguageRegistry.addName(this, aDisplayName);
+
+ }
+
+
+ private final HashMap<Integer, HashMap<ForgeDirection, IIcon>> mTextures = new HashMap<Integer, HashMap<ForgeDirection, IIcon>>();
+
+ /**
+ * A map of the textures used for this blocks. The key is the meta, then each internal map holds textures tied to each forge direction. Do not use unknown direction.
+ * @return
+ */
+ public abstract HashMap<Integer, HashMap<ForgeDirection, IIcon>> getTextureArray();
+
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public final void registerBlockIcons(final IIconRegister p_149651_1_) {
+ this.blockIcon = p_149651_1_.registerIcon("redstone_block");
+ }
+
+
+ /**
+ * Called upon block activation (right click on the block.)
+ */
+ @Override
+ public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player,
+ final int side, final float lx, final float ly, final float lz) {
+
+ if (world.isRemote) {
+ return true;
+ }
+
+ boolean mDidTool = false;
+ // Check For Tools
+ try {
+ final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(world, player.getDisplayName());
+ final Item mHandItem = mHandStack.getItem();
+ if (mHandItem instanceof GT_MetaGenerated_Tool_01) {
+
+ final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) world.getTileEntity(x, y, z);
+ if (tile != null) {
+ if (tile.isScrewdriverable()) {
+ if ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)){
+ mDidTool = tile.onScrewdriverRMB();
+ }
+ }
+ if (tile.isMalletable()) {
+ if ((mHandItem.getDamage(mHandStack) == 24) || (mHandItem.getDamage(mHandStack) == 154)){
+ mDidTool = tile.onMalletRMB();
+ }
+ }
+ if (tile.isWrenchable()) {
+ if ((mHandItem.getDamage(mHandStack) == 26) || (mHandItem.getDamage(mHandStack) == 164)){
+ mDidTool = tile.onWrenchRMB();
+ }
+ }
+ }
+ }
+ }
+ catch (final Throwable t) {}
+ if (mDidTool) {
+ return true;
+ }
+
+ return false;
+ }
+
+
+
+ @Override
+ public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) {
+
+ boolean mDidTool = false;
+ // Check For Tools
+ try {
+ final ItemStack mHandStack = PlayerUtils.getItemStackInPlayersHand(aWorld, aPlayer.getDisplayName());
+ final Item mHandItem = mHandStack.getItem();
+ if (mHandItem instanceof GT_MetaGenerated_Tool_01) {
+
+ final TileEntityRedstoneHandler tile = (TileEntityRedstoneHandler) aWorld.getTileEntity(aX, aY, aZ);
+ if (tile != null) {
+ if (tile.isScrewdriverable()) {
+ if ((mHandItem.getDamage(mHandStack) == 22) || (mHandItem.getDamage(mHandStack) == 150)){
+ mDidTool = tile.onScrewdriverLMB();
+ }
+ }
+ if (tile.isMalletable()) {
+ if ((mHandItem.getDamage(mHandStack) == 24) || (mHandItem.getDamage(mHandStack) == 154)){
+ mDidTool = tile.onMalletLMB();
+ }
+ }
+ if (tile.isWrenchable()) {
+ if ((mHandItem.getDamage(mHandStack) == 26) || (mHandItem.getDamage(mHandStack) == 164)){
+ mDidTool = tile.onWrenchLMB();
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable t) {}
+
+ if (!mDidTool) {
+ super.onBlockClicked(aWorld, aX, aY, aZ, aPlayer);
+ }
+ else {
+ return;
+ }
+ }
+
+ @Override
+ public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_);
+
+ @Override
+ public void breakBlock(final World world, final int x, final int y, final int z, final Block block,
+ final int number) {
+ InventoryUtils.dropInventoryItems(world, x, y, z, block);
+ super.breakBlock(world, x, y, z, block, number);
+ }
+
+ @Override
+ public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity,
+ final ItemStack stack) {
+ if (stack.hasDisplayName()) {
+ ((TileEntityRedstoneHandler) world.getTileEntity(x, y, z)).setCustomName(stack.getDisplayName());
+ }
+ }
+
+ @Override
+ public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y,
+ final int z) {
+ return false;
+ }
+
+ @Override
+ public int getLightValue() {
+ return super.getLightValue();
+ }
+
+ @Override
+ public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_,
+ float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) {
+ // TODO Auto-generated method stub
+ return super.onBlockPlaced(p_149660_1_, p_149660_2_, p_149660_3_, p_149660_4_, p_149660_5_, p_149660_6_,
+ p_149660_7_, p_149660_8_, p_149660_9_);
+ }
+
+ @Override
+ public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
+ TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z);
+ if (aThis != null) {
+ return aThis.isProvidingWeakPower(world, x, y, z, side);
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean canProvidePower() {
+ return false;
+ }
+
+ @Override
+ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
+ TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z);
+ if (aThis != null) {
+ return aThis.isProvidingStrongPower(world, x, y, z, side);
+ }
+ return 0;
+ }
+
+ @Override
+ public boolean hasComparatorInputOverride() {
+ // TODO Auto-generated method stub
+ return super.hasComparatorInputOverride();
+ }
+
+ @Override
+ public int getComparatorInputOverride(World p_149736_1_, int p_149736_2_, int p_149736_3_, int p_149736_4_,
+ int p_149736_5_) {
+ // TODO Auto-generated method stub
+ return super.getComparatorInputOverride(p_149736_1_, p_149736_2_, p_149736_3_, p_149736_4_, p_149736_5_);
+ }
+
+ @Override
+ public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
+ TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z);
+ if (aThis != null) {
+ return aThis.canConnectRedstone(world, x, y, z, side);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
+ TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z);
+ if (aThis != null) {
+ return aThis.shouldCheckWeakPower(world, x, y, z, side);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) {
+ TileEntityRedstoneHandler aThis = getTileEntity(world, x, y, z);
+ if (aThis != null) {
+ return aThis.getWeakChanges(world, x, y, z);
+ }
+ return false;
+ }
+
+
+ /**
+ * Gets the block's texture. Args: side, meta
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public abstract IIcon getIcon(final int side, final int meta);
+
+ @Override
+ public int damageDropped(final int damage) {
+ return damage;
+ }
+
+ @Override
+ public abstract void getSubBlocks(final Item item, final CreativeTabs tab, final List list);
+
+
+ /**
+ * Called whenever the block is added into the world. Args: world, x, y, z
+ */
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ);
+
+ if (!aWorld.isRemote) {
+ if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) {
+ aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4);
+ } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) {
+ aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2);
+ }
+ }
+ }
+
+ /**
+ * Lets the block know when one of its neighbor changes. Doesn't know which
+ * neighbor changed (coordinates passed are their own) Args: x, y, z, neighbor
+ * Block
+ */
+ public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) {
+
+ TileEntityRedstoneHandler aThis = getTileEntity(aWorld, aX, aY, aZ);
+
+ if (!aWorld.isRemote) {
+ if (aThis.hasUpdatedRecently() && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) {
+ aWorld.scheduleBlockUpdate(aX, aY, aZ, this, 4);
+ } else if (!aThis.hasUpdatedRecently() && aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) {
+ aWorld.setBlock(aX, aY, aZ, Blocks.lit_redstone_lamp, 0, 2);
+ }
+ }
+ }
+
+ /**
+ * Ticks the block if it's been scheduled
+ */
+ public void updateTick(World aWorld, int aX, int aY, int aZ, Random p_149674_5_) {
+ if (!aWorld.isRemote && !aWorld.isBlockIndirectlyGettingPowered(aX, aY, aZ)) {
+ // aWorld.setBlock(aX, aY, aZ, Blocks.redstone_lamp, 0, 2);
+ }
+ }
+
+ public TileEntityRedstoneHandler getTileEntity(IBlockAccess world, int aX, int aY, int aZ) {
+ TileEntity aTemp = world.getTileEntity(aX, aY, aZ);
+ if (aTemp != null) {
+ if (aTemp instanceof TileEntityRedstoneHandler) {
+ TileEntityRedstoneHandler g = (TileEntityRedstoneHandler) aTemp;
+ if (g != null) {
+ return g;
+ }
+ }
+ }
+ return null;
+ }
+
+
+ /**
+ * Gets an item for the block being called on. Args: world, x, y, z
+ */
+ @SideOnly(Side.CLIENT)
+ @Override
+ public abstract Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_);
+
+ /**
+ * Returns an item stack containing a single instance of the current block type.
+ * 'i' is the block's subtype/damage and is ignored for blocks which do not
+ * support subtypes. Blocks which cannot be harvested should return null.
+ */
+ @Override
+ protected abstract ItemStack createStackedBlock(int p_149644_1_);
+
+ @Override
+ public abstract ArrayList<ItemStack> getDrops(final World world, final int x, final int y, final int z, final int metadata, final int fortune);
+
+ @Override
+ public abstract Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_);
+
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java
new file mode 100644
index 0000000000..3e7816f83a
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneDetector.java
@@ -0,0 +1,112 @@
+package gtPlusPlus.core.block.general.redstone;
+
+import java.util.List;
+import java.util.Random;
+
+import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler;
+import net.minecraft.block.Block;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+public class BlockGenericRedstoneDetector extends BlockGenericRedstone {
+
+ public BlockGenericRedstoneDetector() {
+ super("detector", "Redstone Detector");
+ setTickRandomly(true);
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int p_149915_2_) {
+ return new TileEntityRedstoneDetector();
+ }
+
+ public class TileEntityRedstoneDetector extends TileEntityRedstoneHandler {
+ public TileEntityRedstoneDetector() {
+ super(0);
+ }
+ }
+
+ @Override
+ public void registerBlockIcons(IIconRegister p_149651_1_) {
+ // TODO Auto-generated method stub
+ super.registerBlockIcons(p_149651_1_);
+ }
+
+ @Override
+ public int getLightValue() {
+ // TODO Auto-generated method stub
+ return super.getLightValue();
+ }
+
+ @Override
+ public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_,
+ int p_149709_5_) {
+ return 0;
+ }
+
+ @Override
+ public boolean canProvidePower() {
+ return false;
+ }
+
+ @Override
+ public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_,
+ int p_149748_5_) {
+ return 0;
+ }
+
+ @Override
+ public void getSubBlocks(Item p_149666_1_, CreativeTabs p_149666_2_, List p_149666_3_) {
+ // TODO Auto-generated method stub
+ super.getSubBlocks(p_149666_1_, p_149666_2_, p_149666_3_);
+ }
+
+ @Override
+ public int getLightValue(IBlockAccess world, int x, int y, int z) {
+ // TODO Auto-generated method stub
+ return super.getLightValue(world, x, y, z);
+ }
+
+ @Override
+ public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
+ // TODO Auto-generated method stub
+ return super.shouldCheckWeakPower(world, x, y, z, side);
+ }
+
+ @Override
+ public void updateTick(World aWorld, int aX, int aY, int aZ, Random aRand) {
+
+ TileEntity aThisTile = aWorld.getTileEntity(aX, aY, aZ);
+ if (aThisTile != null) {
+ TileEntityRedstoneHandler aRedstoneTile = (TileEntityRedstoneHandler) aThisTile;
+ aRedstoneTile.setCurrentTextureArray(null);
+ }
+
+
+ super.updateTick(aWorld, aX, aY, aZ, aRand);
+ }
+
+ @Override
+ public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected ItemStack createStackedBlock(int p_149644_1_) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java
new file mode 100644
index 0000000000..df8a929302
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/general/redstone/BlockGenericRedstoneEmitter.java
@@ -0,0 +1,5 @@
+package gtPlusPlus.core.block.general.redstone;
+
+public class BlockGenericRedstoneEmitter {
+
+}
diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
index bb7004350d..5a0d2cc256 100644
--- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
+++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java
@@ -7,6 +7,7 @@ import gtPlusPlus.core.block.general.BlockSuperLight.TileEntitySuperLight;
import gtPlusPlus.core.block.machine.Machine_SuperJukebox.TileEntitySuperJukebox;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.tileentities.general.*;
+import gtPlusPlus.core.tileentities.general.redstone.TileEntityRedstoneHandler;
import gtPlusPlus.core.tileentities.machines.*;
import gtPlusPlus.plugin.villagers.tile.TileEntityGenericSpawner;
@@ -31,6 +32,7 @@ public class ModTileEntities {
GameRegistry.registerTileEntity(TileEntityDecayablesChest.class, "TileDecayablesChest");
GameRegistry.registerTileEntity(TileEntitySuperJukebox.class, "TileEntitySuperJukebox");
GameRegistry.registerTileEntity(TileEntitySuperLight.class, "TileEntitySuperLight");
+ GameRegistry.registerTileEntity(TileEntityRedstoneHandler.class, "TileEntityRedstoneHandler");
//Mod TEs
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java
new file mode 100644
index 0000000000..fbd5f4280d
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java
@@ -0,0 +1,398 @@
+package gtPlusPlus.core.tileentities.general.redstone;
+
+import gtPlusPlus.api.interfaces.IToolable;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.core.util.Utils;
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.EnumSkyBlock;
+import net.minecraft.world.IBlockAccess;
+
+public class TileEntityRedstoneHandler extends TileEntity implements IToolable {
+
+ private final int mTileType;
+ private BlockPos mTilePos;
+ private boolean mRequiresUpdate = false;
+ private Long mStartTime;
+ private int mLightValue = 0;
+
+ /**
+ * Sets the Redstone Handler Type.
+ * @param aTileType - A type of the handler designated by an int. 0 = receiver, 1 = emitter, 2 = both, anything else = nothing.
+ */
+ public TileEntityRedstoneHandler(int aTileType) {
+ mTileType = aTileType;
+ }
+
+ public Block getBlock() {
+ return mTilePos != null ? mTilePos.getBlockAtPos() : Blocks.redstone_block;
+ }
+
+
+ @Override
+ public void readFromNBT(NBTTagCompound aNBT) {
+ mStartTime = aNBT.getLong("mStartTime");
+ mInvName = aNBT.getString("mInvName");
+ mLightValue = aNBT.getInteger("mLightValue");
+ super.readFromNBT(aNBT);
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound aNBT) {
+ aNBT.setInteger("mTileType", mTileType);
+ aNBT.setLong("mStartTime", mStartTime);
+ aNBT.setString("mInvName", mInvName);
+ aNBT.setInteger("mLightValue", mLightValue);
+ super.writeToNBT(aNBT);
+ }
+
+
+ private boolean mHasUpdatedRecently = false;
+
+ private final boolean init() {
+ if (mTilePos == null) {
+ try {
+ mTilePos = new BlockPos(this);
+ } catch (Throwable t) {
+ return false;
+ }
+ }
+ if (mStartTime == null) {
+ try {
+ mStartTime = System.currentTimeMillis();
+ } catch (Throwable t) {
+ return false;
+ }
+ }
+ return true;
+ }
+ private Long mLastUpdate;
+ private String mInvName = "";
+
+ @Override
+ public void updateEntity() {
+ //Handle init
+ if (!init()) {
+ return;
+ }
+ if (mRequiresUpdate) {
+ mRequiresUpdate = false;
+ mHasUpdatedRecently = true;
+ mLastUpdate = System.currentTimeMillis();
+ if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != mLightValue) {
+ mTilePos.world.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue);
+ }
+ markDirty();
+ }
+ if (Utils.getMillisSince(mLastUpdate, System.currentTimeMillis()) >= 5000) {
+ if (mHasUpdatedRecently) {
+ mHasUpdatedRecently = false;
+ }
+ }
+
+ if (Utils.getMillisSince(mStartTime, System.currentTimeMillis()) % 50 == 0) {
+
+ }
+
+
+
+ super.updateEntity();
+ }
+
+ public final void markForUpdate() {
+ mRequiresUpdate = true;
+ }
+
+ public final boolean hasUpdatedRecently() {
+ return mHasUpdatedRecently;
+ }
+
+ @Override
+ public int getBlockMetadata() {
+ return super.getBlockMetadata();
+ }
+
+ @Override
+ public void markDirty() {
+ super.markDirty();
+ }
+
+ @Override
+ public boolean canUpdate() {
+ return true;
+ }
+
+ public void setRedstoneState(boolean aRedstoneActive) {
+
+ }
+
+ public void setCurrentTextureArray(IIcon[] aTextures) {
+
+ }
+
+ /**
+ * Used to see if one of the blocks next to you or your block is getting power from a neighboring block. Used by
+ * items like TNT or Doors so they don't have redstone going straight into them. Args: x, y, z
+ */
+ public boolean isGettingIndirectlyPowered() {
+ if (mTilePos == null) {
+ return false;
+ }
+ return mTilePos.world.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
+ }
+
+ public int getStrongestIndirectPower() {
+ if (mTilePos == null) {
+ return 0;
+ }
+ return mTilePos.world.getStrongestIndirectPower(xCoord, yCoord, zCoord);
+ }
+
+ /**
+ * Gets the power level from a certain block face. Args: x, y, z, direction
+ */
+ public int getIndirectPowerForSide(int aSide) {
+ if (mTilePos == null || aSide <0 || aSide > 5) {
+ return 0;
+ }
+ return mTilePos.world.getIndirectPowerLevelTo(xCoord, yCoord, zCoord, aSide);
+ }
+
+ /**
+ * Returns the highest redstone signal strength powering the given block. Args: X, Y, Z.
+ */
+ public int getBlockPowerInput() {
+ if (mTilePos == null) {
+ return 0;
+ }
+ return mTilePos.world.getBlockPowerInput(xCoord, yCoord, zCoord);
+ }
+
+ /**
+ * Determine if this block can make a redstone connection on the side provided,
+ * Useful to control which sides are inputs and outputs for redstone wires.
+ *
+ * Side:
+ * -1: UP
+ * 0: NORTH
+ * 1: EAST
+ * 2: SOUTH
+ * 3: WEST
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y Position
+ * @param z Z Position
+ * @param side The side that is trying to make the connection
+ * @return True to make the connection
+ */
+ public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) {
+ if (mTilePos == null) {
+ return false;
+ }
+ return getBlock().canConnectRedstone(world, xCoord, yCoord, zCoord, side);
+ }
+
+ /**
+ * Called to determine whether to allow the a block to handle its own indirect power rather than using the default rules.
+ * @param world The world
+ * @param x The x position of this block instance
+ * @param y The y position of this block instance
+ * @param z The z position of this block instance
+ * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side
+ * @return Whether Block#isProvidingWeakPower should be called when determining indirect power
+ */
+ public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) {
+ if (mTilePos == null) {
+ return false;
+ }
+ return getBlock().shouldCheckWeakPower(world, xCoord, yCoord, zCoord, side);
+ }
+
+ /**
+ * If this block should be notified of weak changes.
+ * Weak changes are changes 1 block away through a solid block.
+ * Similar to comparators.
+ *
+ * @param world The current world
+ * @param x X Position
+ * @param y Y position
+ * @param z Z position
+ * @param side The side to check
+ * @return true To be notified of changes
+ */
+ public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) {
+ if (mTilePos == null) {
+ return false;
+ }
+ return getBlock().getWeakChanges(world, xCoord, yCoord, zCoord);
+ }
+
+
+ /**
+ * Override this to change the level of redstone output.
+ * @return
+ */
+ public int getRedstoneLevel() {
+ if (mTilePos == null) {
+ return 0;
+ }
+ if (canSupplyRedstoneSignal()) {
+ int aInputPower = getInputPowerLevel();
+ if (aInputPower > 0) {
+ return aInputPower;
+ }
+ }
+ return 0;
+ }
+
+
+
+
+
+
+
+
+
+ /*
+ * Alk's Simplified Redstone Handling functions (Fuck redstone)
+ */
+
+ /**
+ *
+ * @return - Does this Block supply redstone signal at all?
+ */
+ public final boolean isPowered() {
+ return canAcceptRedstoneSignal() && getInputPowerLevel() > 0;
+ }
+
+ /**
+ *
+ * @return - Can this Block provide redstone signal at all?
+ */
+ public final boolean isProvidingPower() {
+ return canSupplyRedstoneSignal() && getOutputPowerLevel() > 0;
+ }
+
+ /**
+ *
+ * @return - (0-15) Redstone Output signal level
+ */
+ public final int getOutputPowerLevel() {
+ return getRedstoneLevel();
+ }
+
+ /**
+ *
+ * @return (0-15) Redstone Input Signal level
+ */
+ public final int getInputPowerLevel() {
+ return getBlockPowerInput();
+ }
+
+ /**
+ *
+ * @return - Does this Tile Entity support outputting redstone?
+ */
+ public final boolean canSupplyRedstoneSignal() {
+ return mTileType == 1 || mTileType == 2;
+ }
+
+ /**
+ *
+ * @return - Does this Tile Entity support inputting redstone?
+ */
+ public final boolean canAcceptRedstoneSignal() {
+ return mTileType == 0 || mTileType == 2;
+ }
+
+
+ @Override
+ public boolean isScrewdriverable() {
+ return false;
+ }
+
+
+ @Override
+ public boolean onScrewdriverLMB() {
+ return false;
+ }
+
+
+ @Override
+ public boolean onScrewdriverRMB() {
+ return false;
+ }
+
+
+ @Override
+ public boolean isWrenchable() {
+ return false;
+ }
+
+
+ @Override
+ public boolean onWrenchLMB() {
+ return false;
+ }
+
+
+ @Override
+ public boolean onWrenchRMB() {
+ return false;
+ }
+
+
+ @Override
+ public boolean isMalletable() {
+ return false;
+ }
+
+
+ @Override
+ public boolean onMalletLMB() {
+ return false;
+ }
+
+
+ @Override
+ public boolean onMalletRMB() {
+ return false;
+ }
+
+
+ public void setCustomName(String displayName) {
+ this.mInvName = displayName;
+ }
+
+ public String getCustomName() {
+ return this.mInvName;
+ }
+
+ public String getInventoryName() {
+ return this.hasCustomInventoryName() ? this.mInvName : "container.redstone.generic";
+ }
+
+ public boolean hasCustomInventoryName() {
+ return (this.mInvName != null) && !this.mInvName.equals("");
+ }
+
+ public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+
+
+
+
+
+}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java
index 0d4394d773..8f12d20494 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java
@@ -7,54 +7,52 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class InventoryUtils {
private final static Random mRandom = new Random();
- public static void dropInventoryItems(World world, int x, int y, int z, Block block){
- Object tileentity = world.getTileEntity(x, y, z);
-
- if (tileentity != null)
- {
- for (int i1 = 0; i1 < ((IInventory) tileentity).getSizeInventory(); ++i1)
- {
- ItemStack itemstack = ((IInventory) tileentity).getStackInSlot(i1);
-
- if (itemstack != null)
- {
- float f = mRandom.nextFloat() * 0.8F + 0.1F;
- float f1 = mRandom.nextFloat() * 0.8F + 0.1F;
- EntityItem entityitem;
-
- for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
- {
- int j1 = mRandom.nextInt(21) + 10;
-
- if (j1 > itemstack.stackSize)
- {
- j1 = itemstack.stackSize;
- }
-
- itemstack.stackSize -= j1;
- entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
- float f3 = 0.05F;
- entityitem.motionX = (float)mRandom.nextGaussian() * f3;
- entityitem.motionY = (float)mRandom.nextGaussian() * f3 + 0.2F;
- entityitem.motionZ = (float)mRandom.nextGaussian() * f3;
-
- if (itemstack.hasTagCompound())
- {
- entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
- }
- }
- }
- }
-
- world.func_147453_f(x, y, z, block);
- }
-
+ public static void dropInventoryItems(World world, int x, int y, int z, Block block) {
+ TileEntity tileentity = world.getTileEntity(x, y, z);
+
+ if (tileentity != null && tileentity instanceof IInventory
+ && ((IInventory) tileentity).getSizeInventory() > 0) {
+ for (int i1 = 0; i1 < ((IInventory) tileentity).getSizeInventory(); ++i1) {
+ ItemStack itemstack = ((IInventory) tileentity).getStackInSlot(i1);
+
+ if (itemstack != null) {
+ float f = mRandom.nextFloat() * 0.8F + 0.1F;
+ float f1 = mRandom.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) {
+ int j1 = mRandom.nextInt(21) + 10;
+
+ if (j1 > itemstack.stackSize) {
+ j1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= j1;
+ entityitem = new EntityItem(world, x + f, y + f1, z + f2,
+ new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float) mRandom.nextGaussian() * f3;
+ entityitem.motionY = (float) mRandom.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float) mRandom.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound()) {
+ entityitem.getEntityItem()
+ .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
+ }
+ }
+ }
+ }
+
+ world.func_147453_f(x, y, z, block);
+ }
+
}
}