From e8e899fb8ec40fc2a8094e3a1f65527af23b11e4 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 2 Apr 2019 14:47:39 +1000 Subject: + Added some basis for new redstone things. --- .../core/tileentities/ModTileEntities.java | 2 + .../redstone/TileEntityRedstoneHandler.java | 398 +++++++++++++++++++++ 2 files changed, 400 insertions(+) create mode 100644 src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java (limited to 'src/Java/gtPlusPlus/core/tileentities') 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; + } + + + + + + +} -- cgit From f6a126e4467c5bf7ab72249c7fc55df3bc574d94 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 2 Apr 2019 15:39:02 +1000 Subject: + Added TexturePackages. $ More work on redstone systems. --- .../redstone/TileEntityRedstoneHandler.java | 67 ++++++++++++++++++---- 1 file changed, 56 insertions(+), 11 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java index fbd5f4280d..163c4453b6 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java @@ -17,7 +17,9 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { private BlockPos mTilePos; private boolean mRequiresUpdate = false; private Long mStartTime; - private int mLightValue = 0; + + public boolean mLightMode = false; + public int mLightValue = 0; /** * Sets the Redstone Handler Type. @@ -30,13 +32,26 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { public Block getBlock() { return mTilePos != null ? mTilePos.getBlockAtPos() : Blocks.redstone_block; } + + public final boolean isLight() { + return mLightMode; + } + public final int getLightBrightness() { + if (!isLight()) { + return 0; + } + else { + return mLightValue; + } + } @Override public void readFromNBT(NBTTagCompound aNBT) { mStartTime = aNBT.getLong("mStartTime"); mInvName = aNBT.getString("mInvName"); mLightValue = aNBT.getInteger("mLightValue"); + mLightMode = aNBT.getBoolean("mLightMode"); super.readFromNBT(aNBT); } @@ -46,6 +61,7 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { aNBT.setLong("mStartTime", mStartTime); aNBT.setString("mInvName", mInvName); aNBT.setInteger("mLightValue", mLightValue); + aNBT.setBoolean("mLightMode", mLightMode); super.writeToNBT(aNBT); } @@ -250,6 +266,45 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { } + public boolean providesWeakPower() { + return isProvidingPower(); + } + + public boolean providesStrongPower() { + return isProvidingPower(); + } + + + /** + * Returns the amount of week power this block is providing to a side. + * @param world + * @param x + * @param y + * @param z + * @param side + * @return + */ + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + if (!providesWeakPower()) { + return 0; + } + return getOutputPowerLevel(); + } + /** + * Returns the amount of strong power this block is providing to a side. + * @param world + * @param x + * @param y + * @param z + * @param side + * @return + */ + public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { + if (!providesStrongPower()) { + return 0; + } + return getOutputPowerLevel(); + } @@ -379,16 +434,6 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { 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; - } -- cgit From 70a0df8a68725c16f0c0b959639b8e82cbbcf3a0 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 2 Apr 2019 17:44:13 +1000 Subject: % Work work --- .../core/tileentities/ModTileEntities.java | 1 - .../redstone/TileEntityRedstoneHandler.java | 36 ++++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java index 5a0d2cc256..c3670ef959 100644 --- a/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java +++ b/src/Java/gtPlusPlus/core/tileentities/ModTileEntities.java @@ -32,7 +32,6 @@ 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 index 163c4453b6..152790951a 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java @@ -1,6 +1,8 @@ package gtPlusPlus.core.tileentities.general.redstone; +import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.interfaces.IToolable; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; import net.minecraft.block.Block; @@ -11,7 +13,7 @@ import net.minecraft.util.IIcon; import net.minecraft.world.EnumSkyBlock; import net.minecraft.world.IBlockAccess; -public class TileEntityRedstoneHandler extends TileEntity implements IToolable { +public abstract class TileEntityRedstoneHandler extends TileEntity implements IToolable { private final int mTileType; private BlockPos mTilePos; @@ -19,7 +21,7 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { private Long mStartTime; public boolean mLightMode = false; - public int mLightValue = 0; + public float mLightValue = 0; /** * Sets the Redstone Handler Type. @@ -27,8 +29,17 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { */ public TileEntityRedstoneHandler(int aTileType) { mTileType = aTileType; + registerTileEntity(); } + private void registerTileEntity() { + GameRegistry.registerTileEntity(getTileEntityClass(), getTileEntityNameForRegistration()); + } + + protected abstract Class getTileEntityClass(); + + protected abstract String getTileEntityNameForRegistration(); + public Block getBlock() { return mTilePos != null ? mTilePos.getBlockAtPos() : Blocks.redstone_block; } @@ -37,7 +48,7 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { return mLightMode; } - public final int getLightBrightness() { + public final float getLightBrightness() { if (!isLight()) { return 0; } @@ -50,7 +61,7 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { public void readFromNBT(NBTTagCompound aNBT) { mStartTime = aNBT.getLong("mStartTime"); mInvName = aNBT.getString("mInvName"); - mLightValue = aNBT.getInteger("mLightValue"); + mLightValue = aNBT.getFloat("mLightValue"); mLightMode = aNBT.getBoolean("mLightMode"); super.readFromNBT(aNBT); } @@ -60,8 +71,8 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { aNBT.setInteger("mTileType", mTileType); aNBT.setLong("mStartTime", mStartTime); aNBT.setString("mInvName", mInvName); - aNBT.setInteger("mLightValue", mLightValue); - aNBT.setBoolean("mLightMode", mLightMode); + aNBT.setFloat("mLightValue", getLightBrightness()); + aNBT.setBoolean("mLightMode", isLight()); super.writeToNBT(aNBT); } @@ -94,18 +105,23 @@ public class TileEntityRedstoneHandler extends TileEntity implements IToolable { if (!init()) { return; } - if (mRequiresUpdate) { + if (mRequiresUpdate || mLastUpdate == null) { mRequiresUpdate = false; mHasUpdatedRecently = true; mLastUpdate = System.currentTimeMillis(); - if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != mLightValue) { - mTilePos.world.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); - } + if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != getLightBrightness()) { + mTilePos.getBlockAtPos().setLightLevel(getLightBrightness()); + mTilePos.world.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, (int) (getLightBrightness()/0.625f)); + mTilePos.world.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); + Logger.INFO("Updating Light"); + } + mTilePos.world.scheduleBlockUpdate(xCoord, yCoord, zCoord, mTilePos.getBlockAtPos(), 1); markDirty(); } if (Utils.getMillisSince(mLastUpdate, System.currentTimeMillis()) >= 5000) { if (mHasUpdatedRecently) { mHasUpdatedRecently = false; + this.markForUpdate(); } } -- cgit From af61708010aef717ecc3537fa115547acb9aa9c7 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Tue, 2 Apr 2019 18:20:28 +1000 Subject: $ More fixes. --- .../general/redstone/TileEntityRedstoneHandler.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java index 152790951a..43f2c15251 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java @@ -1,10 +1,16 @@ package gtPlusPlus.core.tileentities.general.redstone; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.Map; + import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.interfaces.IToolable; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.minecraft.EntityUtils; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; @@ -33,7 +39,9 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT } private void registerTileEntity() { - GameRegistry.registerTileEntity(getTileEntityClass(), getTileEntityNameForRegistration()); + if (!EntityUtils.isTileEntityRegistered(getTileEntityClass(), getTileEntityNameForRegistration())) { + GameRegistry.registerTileEntity(getTileEntityClass(), getTileEntityNameForRegistration()); + } } protected abstract Class getTileEntityClass(); @@ -109,9 +117,9 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT mRequiresUpdate = false; mHasUpdatedRecently = true; mLastUpdate = System.currentTimeMillis(); - if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != getLightBrightness()) { - mTilePos.getBlockAtPos().setLightLevel(getLightBrightness()); - mTilePos.world.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, (int) (getLightBrightness()/0.625f)); + if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != getLightBrightness()/0.0625f) { + mTilePos.getBlockAtPos().setLightLevel(getLightBrightness()/0.0625f); + mTilePos.world.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, (int) (getLightBrightness()/0.0625f)); mTilePos.world.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); Logger.INFO("Updating Light"); } -- cgit From 60b9e2b720abca8908a1ac2a7f5767af08bccaf9 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 8 Apr 2019 14:12:52 +1000 Subject: % Allowed Skookum Choocher as a valid Wrench and Hard Hammer. $ Fixed infinite loop between TE and Block functions. --- .../general/redstone/TileEntityRedstoneHandler.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java index 43f2c15251..fa2597eae9 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java @@ -1,16 +1,11 @@ package gtPlusPlus.core.tileentities.general.redstone; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.interfaces.IToolable; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; @@ -233,7 +228,7 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT if (mTilePos == null) { return false; } - return getBlock().canConnectRedstone(world, xCoord, yCoord, zCoord, side); + return canAcceptRedstoneSignal() || canSupplyRedstoneSignal(); } /** @@ -249,7 +244,7 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT if (mTilePos == null) { return false; } - return getBlock().shouldCheckWeakPower(world, xCoord, yCoord, zCoord, side); + return getBlock().isNormalCube(); } /** @@ -268,7 +263,7 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT if (mTilePos == null) { return false; } - return getBlock().getWeakChanges(world, xCoord, yCoord, zCoord); + return false; } -- cgit From 079256e5324a6f72a08a77878685302f7b24dc58 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Mon, 8 Apr 2019 14:23:59 +1000 Subject: $ Fixed another small infinite loop. (Redstone is fucking complicated, damn you Notch) --- .../general/redstone/TileEntityRedstoneHandler.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java index fa2597eae9..eda0c65e46 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java @@ -20,6 +20,7 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT private BlockPos mTilePos; private boolean mRequiresUpdate = false; private Long mStartTime; + private Byte mRedstoneLevel; public boolean mLightMode = false; public float mLightValue = 0; @@ -66,6 +67,7 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT mInvName = aNBT.getString("mInvName"); mLightValue = aNBT.getFloat("mLightValue"); mLightMode = aNBT.getBoolean("mLightMode"); + mRedstoneLevel = aNBT.getByte("mRedstoneLevel"); super.readFromNBT(aNBT); } @@ -76,6 +78,7 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT aNBT.setString("mInvName", mInvName); aNBT.setFloat("mLightValue", getLightBrightness()); aNBT.setBoolean("mLightMode", isLight()); + aNBT.setByte("mRedstoneLevel", mRedstoneLevel); super.writeToNBT(aNBT); } @@ -272,15 +275,18 @@ public abstract class TileEntityRedstoneHandler extends TileEntity implements IT * @return */ public int getRedstoneLevel() { - if (mTilePos == null) { + if (mTilePos == null || mRedstoneLevel == null) { return 0; } - if (canSupplyRedstoneSignal()) { - int aInputPower = getInputPowerLevel(); - if (aInputPower > 0) { - return aInputPower; + else { + if (canSupplyRedstoneSignal()) { + if (this.hasUpdatedRecently()) { + int aInputPower = getInputPowerLevel(); + mRedstoneLevel = (byte) ((aInputPower >= 0 && aInputPower <= 127) ? aInputPower : 0); + } + return mRedstoneLevel; } - } + } return 0; } -- cgit From 95747970ad7d142a2a981119bdfafca5ab5b27d2 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 17 Apr 2019 10:35:07 +1000 Subject: + Added rmb information to Energy Buffers to show current Amperage. % Migrated getFieldFromGregtechProxy() from Meta_GT_Proxy.java to StaticFields59.java. $ Fixed hardness/resistance on a few blocks. $ Fixed bad handling of Item Entities by Fluid Collectors. --- .../machines/TileEntityBaseFluidCollector.java | 12 ++++++------ .../tileentities/machines/TileEntityPooCollector.java | 15 +++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java index 78b8f74799..cdae4cf829 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityBaseFluidCollector.java @@ -2,7 +2,6 @@ package gtPlusPlus.core.tileentities.machines; import java.util.List; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; import gtPlusPlus.api.objects.minecraft.BlockPos; @@ -11,7 +10,6 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -208,9 +206,11 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem this.tank.fill(FluidUtils.getFluidStack(fluidToProvide(), aFluidAmount), true); } else { - ItemStack aDirtStack = ItemUtils.getSimpleStack(itemToSpawnInWorldIfTankIsFull()); - if (aDirtStack != null) - if (!this.mInventory.addItemStack(aDirtStack)) { + ItemStack aDirtStack = ItemUtils.getSimpleStack(itemToSpawnInWorldIfTankIsFull(), 1); + if (!ItemUtils.checkForInvalidItems(aDirtStack)) { + return; + } + if (!this.mInventory.addItemStack(aDirtStack)) { EntityItem entity = new EntityItem(worldObj, xCoord, yCoord+1.5, zCoord, aDirtStack); worldObj.spawnEntityInWorld(entity); } @@ -230,7 +230,7 @@ public abstract class TileEntityBaseFluidCollector extends TileEntityBase implem public abstract Fluid fluidToProvide(); - public abstract Item itemToSpawnInWorldIfTankIsFull(); + public abstract ItemStack itemToSpawnInWorldIfTankIsFull(); diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java index f6570c6cc6..25348a31f8 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityPooCollector.java @@ -12,7 +12,6 @@ import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityMooshroom; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.IAnimals; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -53,7 +52,11 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { } else { return false; + } + if (!ItemUtils.checkForInvalidItems(aPoop)) { + return false; } + //Add poop to world //Logger.INFO("Adding animal waste for "+aPooMaker.getCommandSenderName()); @@ -123,17 +126,17 @@ public class TileEntityPooCollector extends TileEntityBaseFluidCollector { } @Override - public Item itemToSpawnInWorldIfTankIsFull() { + public ItemStack itemToSpawnInWorldIfTankIsFull() { int a = MathUtils.randInt(0, 100); - Item aItem = null; + ItemStack aItem = null; if (a <= 30) { - aItem = AgriculturalChem.dustDirt; + aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); } else if (a <= 40) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1).getItem(); + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); } else if (a <= 55) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1).getItem(); + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustTinyManureByproducts", 1); } return aItem; } -- cgit From 144cd9c09a2dab9461a61b8bfe4d5f4165030e54 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 17 Apr 2019 11:33:21 +1000 Subject: + Added new sifting recipe for Rare Earth, allowing more lanthanides to be obtained. - Removed Rare Earth centrifuge recipe. $ Corrected the spelling of Aluminium and Caesium. --- .../tileentities/machines/TileEntityAdvPooCollector.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/Java/gtPlusPlus/core/tileentities') diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java index 18954f12b6..6bb4c932dc 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityAdvPooCollector.java @@ -1,6 +1,5 @@ package gtPlusPlus.core.tileentities.machines; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.item.chemistry.AgriculturalChem; import gtPlusPlus.core.util.math.MathUtils; @@ -15,7 +14,6 @@ import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.passive.IAnimals; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; @@ -132,17 +130,17 @@ public class TileEntityAdvPooCollector extends TileEntityBaseFluidCollector { } @Override - public Item itemToSpawnInWorldIfTankIsFull() { + public ItemStack itemToSpawnInWorldIfTankIsFull() { int a = MathUtils.randInt(0, 75); - Item aItem = null; + ItemStack aItem = null; if (a <= 30) { - aItem = AgriculturalChem.dustDirt; + aItem = ItemUtils.getSimpleStack(AgriculturalChem.dustDirt); } else if (a <= 40) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1).getItem(); + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustManureByproducts", 1); } else if (a <= 55) { - aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1).getItem(); + aItem = ItemUtils.getItemStackOfAmountFromOreDict("dustSmallManureByproducts", 1); } return aItem; } -- cgit