From 48ba247ab405beb8813727da9b47b25d6b11fb27 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 15 Apr 2019 09:21:10 +0100 Subject: [PATCH 01/11] Create an IMultipartTile for all BlockPeripheral tiles Fixes #176 --- .../integration/mcmp/MCMPIntegration.java | 14 +++++++++--- ...rtNormalModem.java => PartPeripheral.java} | 22 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) rename src/main/java/dan200/computercraft/shared/integration/mcmp/{PartNormalModem.java => PartPeripheral.java} (73%) diff --git a/src/main/java/dan200/computercraft/shared/integration/mcmp/MCMPIntegration.java b/src/main/java/dan200/computercraft/shared/integration/mcmp/MCMPIntegration.java index 58bc39edd..358fcda92 100644 --- a/src/main/java/dan200/computercraft/shared/integration/mcmp/MCMPIntegration.java +++ b/src/main/java/dan200/computercraft/shared/integration/mcmp/MCMPIntegration.java @@ -10,8 +10,10 @@ import dan200.computercraft.ComputerCraft; import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheralTile; +import dan200.computercraft.shared.peripheral.common.TilePeripheralBase; import dan200.computercraft.shared.peripheral.modem.wireless.TileAdvancedModem; import dan200.computercraft.shared.peripheral.modem.wireless.TileWirelessModem; +import dan200.computercraft.shared.peripheral.monitor.TileMonitor; import mcmultipart.api.addon.IMCMPAddon; import mcmultipart.api.addon.MCMPAddon; import mcmultipart.api.container.IMultipartContainer; @@ -52,7 +54,7 @@ public class MCMPIntegration implements IMCMPAddon public void registerParts( IMultipartRegistry registry ) { // Setup all parts - register( registry, ComputerCraft.Blocks.peripheral, new PartNormalModem() ); + register( registry, ComputerCraft.Blocks.peripheral, new PartPeripheral() ); register( registry, ComputerCraft.Blocks.advancedModem, new PartAdvancedModem() ); // Subscribe to capability events @@ -83,8 +85,11 @@ public class MCMPIntegration implements IMCMPAddon public static void attach( AttachCapabilitiesEvent event ) { TileEntity tile = event.getObject(); - if( tile instanceof TileAdvancedModem || tile instanceof TileWirelessModem ) + if( tile instanceof TileAdvancedModem || tile instanceof TileWirelessModem + || tile instanceof TilePeripheralBase || tile instanceof TileMonitor ) { + // We need to attach to modems (obviously), but also any other tile created by BlockPeripheral. Otherwise + // IMultipart.convertToMultipartTile will error. event.addCapability( CAPABILITY_KEY, new BasicMultipart( tile ) ); } } @@ -94,7 +99,10 @@ public class MCMPIntegration implements IMCMPAddon private final TileEntity tile; private IMultipartTile wrapped; - private BasicMultipart( TileEntity tile ) {this.tile = tile;} + private BasicMultipart( TileEntity tile ) + { + this.tile = tile; + } @Override public boolean hasCapability( @Nonnull Capability capability, @Nullable EnumFacing facing ) diff --git a/src/main/java/dan200/computercraft/shared/integration/mcmp/PartNormalModem.java b/src/main/java/dan200/computercraft/shared/integration/mcmp/PartPeripheral.java similarity index 73% rename from src/main/java/dan200/computercraft/shared/integration/mcmp/PartNormalModem.java rename to src/main/java/dan200/computercraft/shared/integration/mcmp/PartPeripheral.java index 5e5811196..daf25450b 100644 --- a/src/main/java/dan200/computercraft/shared/integration/mcmp/PartNormalModem.java +++ b/src/main/java/dan200/computercraft/shared/integration/mcmp/PartPeripheral.java @@ -10,6 +10,7 @@ import dan200.computercraft.ComputerCraft; import dan200.computercraft.shared.peripheral.common.BlockPeripheral; import dan200.computercraft.shared.peripheral.common.BlockPeripheralVariant; import mcmultipart.api.multipart.IMultipart; +import mcmultipart.api.slot.EnumCenterSlot; import mcmultipart.api.slot.EnumFaceSlot; import mcmultipart.api.slot.IPartSlot; import net.minecraft.block.Block; @@ -20,34 +21,41 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class PartNormalModem implements IMultipart +import javax.annotation.Nonnull; + +public class PartPeripheral implements IMultipart { @Override public IPartSlot getSlotForPlacement( World world, BlockPos pos, IBlockState state, EnumFacing facing, float hitX, float hitY, float hitZ, EntityLivingBase placer ) { - return EnumFaceSlot.fromFace( getFacing( state ) ); + return getSlot( state ); } @Override public IPartSlot getSlotFromWorld( IBlockAccess world, BlockPos pos, IBlockState state ) { - return EnumFaceSlot.fromFace( getFacing( state ) ); + return getSlot( state ); } - private EnumFacing getFacing( IBlockState state ) + @Nonnull + private static IPartSlot getSlot( IBlockState state ) { BlockPeripheralVariant type = state.getValue( BlockPeripheral.VARIANT ); if( type == BlockPeripheralVariant.WirelessModemUpOn || type == BlockPeripheralVariant.WirelessModemUpOff ) { - return EnumFacing.UP; + return EnumFaceSlot.UP; } else if( type == BlockPeripheralVariant.WirelessModemDownOn || type == BlockPeripheralVariant.WirelessModemDownOff ) { - return EnumFacing.UP; + return EnumFaceSlot.DOWN; + } + else if( type == BlockPeripheralVariant.WirelessModemOff || type == BlockPeripheralVariant.WirelessModemOn ) + { + return EnumFaceSlot.fromFace( state.getValue( BlockPeripheral.FACING ) ); } else { - return state.getValue( BlockPeripheral.FACING ); + return EnumCenterSlot.CENTER; } } From 5a8a11185793fcee5f132a6499f9be7689335bb1 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 15 Apr 2019 18:33:59 +0100 Subject: [PATCH 02/11] You didn't see nothing --- .../peripheral/modem/wired/WiredModemLocalPeripheral.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java index 1d90f0200..d7451df90 100644 --- a/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java +++ b/src/main/java/dan200/computercraft/shared/peripheral/modem/wired/WiredModemLocalPeripheral.java @@ -118,7 +118,7 @@ public final class WiredModemLocalPeripheral public void writeNBT( @Nonnull NBTTagCompound tag, @Nonnull String suffix ) { - if( id >= 0 ) tag.setInteger( NBT_PERIPHERAL_TYPE + suffix, id ); + if( id >= 0 ) tag.setInteger( NBT_PERIPHERAL_ID + suffix, id ); if( type != null ) tag.setString( NBT_PERIPHERAL_TYPE + suffix, type ); } From 9e9f199e55ddc3ee47ad95f1ff790032197533b1 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 16 Apr 2019 10:08:12 +0100 Subject: [PATCH 03/11] Remove a couple of over-eager error logs --- src/main/java/dan200/computercraft/ComputerCraft.java | 3 +++ .../dan200/computercraft/core/filesystem/JarMount.java | 4 ++-- .../java/dan200/computercraft/shared/util/IDAssigner.java | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/dan200/computercraft/ComputerCraft.java b/src/main/java/dan200/computercraft/ComputerCraft.java index ae6fca8f4..4661f7ee8 100644 --- a/src/main/java/dan200/computercraft/ComputerCraft.java +++ b/src/main/java/dan200/computercraft/ComputerCraft.java @@ -449,6 +449,9 @@ public class ComputerCraft if( subResource.exists() ) mounts.add( new FileMount( subResource, 0 ) ); } } + catch( FileNotFoundException ignored ) + { + } catch( IOException | RuntimeException e ) { ComputerCraft.log.error( "Could not load resource pack '" + resourcePackName + "'", e ); diff --git a/src/main/java/dan200/computercraft/core/filesystem/JarMount.java b/src/main/java/dan200/computercraft/core/filesystem/JarMount.java index 13af67fe5..941837c94 100644 --- a/src/main/java/dan200/computercraft/core/filesystem/JarMount.java +++ b/src/main/java/dan200/computercraft/core/filesystem/JarMount.java @@ -69,7 +69,7 @@ public class JarMount implements IMount // Cleanup any old mounts. It's unlikely that there will be any, but it's best to be safe. cleanup(); - if( !jarFile.exists() || jarFile.isDirectory() ) throw new FileNotFoundException(); + if( !jarFile.exists() || jarFile.isDirectory() ) throw new FileNotFoundException( "Cannot find " + jarFile ); // Open the zip file try @@ -85,7 +85,7 @@ public class JarMount implements IMount if( zip.getEntry( subPath ) == null ) { zip.close(); - throw new IOException( "Zip does not contain path" ); + throw new FileNotFoundException( "Zip does not contain path" ); } // We now create a weak reference to this mount. This is automatically added to the appropriate queue. diff --git a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java index 34f72c35a..d989b4f84 100644 --- a/src/main/java/dan200/computercraft/shared/util/IDAssigner.java +++ b/src/main/java/dan200/computercraft/shared/util/IDAssigner.java @@ -64,12 +64,11 @@ public final class IDAssigner { try { - int number = Integer.parseInt( content ); - id = Math.max( number + 1, id ); + id = Math.max( Integer.parseInt( content ) + 1, id ); } - catch( NumberFormatException e ) + catch( NumberFormatException ignored ) { - ComputerCraft.log.error( "Unexpected file '" + content + "' in '" + location.getAbsolutePath() + "'", e ); + // Skip files which aren't numbers } } } From 3bf47b529022c52d72f808a392ca0105f3d529ed Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 16 Apr 2019 10:28:10 +0100 Subject: [PATCH 04/11] Make refuelling a little more flexible This removes the link between item size and refuel limit, meaning working with other items (such as FE items) is a little easier. --- .../shared/turtle/apis/TurtleAPI.java | 3 ++- .../lua/rom/programs/turtle/refuel.lua | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java index bb82977bf..2d5863e76 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java +++ b/src/main/java/dan200/computercraft/shared/turtle/apis/TurtleAPI.java @@ -303,7 +303,8 @@ public class TurtleAPI implements ILuaAPI case 31: { // refuel - int count = parseCount( args, 0 ); + int count = optInt( args, 0, Integer.MAX_VALUE ); + if( count < 0 ) throw new LuaException( "Refuel count " + count + " out of range" ); return tryCommand( context, new TurtleRefuelCommand( count ) ); } case 32: diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/refuel.lua b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/refuel.lua index 41956d59c..618b199cb 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/refuel.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/refuel.lua @@ -6,19 +6,27 @@ if #tArgs > 1 then return elseif #tArgs > 0 then if tArgs[1] == "all" then - nLimit = 64 * 16 + nLimit = nil else nLimit = tonumber( tArgs[1] ) + if not nLimit then + print("Invalid limit, expected a number or \"all\"") + return + end end end if turtle.getFuelLevel() ~= "unlimited" then - for n=1,16 do + for n = 1, 16 do + -- Stop if we've reached the limit, or are fully refuelled. + if (nLimit and nLimit <= 0) or turtle.getFuelLevel() >= turtle.getFuelLimit() then + break + end + local nCount = turtle.getItemCount(n) - if nLimit > 0 and nCount > 0 and turtle.getFuelLevel() < turtle.getFuelLimit() then - local nBurn = math.min( nLimit, nCount ) + if nCount > 0 then turtle.select( n ) - if turtle.refuel( nBurn ) then + if turtle.refuel( nLimit ) and nLimit then local nNewCount = turtle.getItemCount(n) nLimit = nLimit - (nCount - nNewCount) end From 48a71e96ebe1a4bd6fba9cd020ac68c50759b138 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 16 Apr 2019 10:32:49 +0100 Subject: [PATCH 05/11] Bump version --- build.gradle | 6 ++++++ gradle.properties | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e41dc1861..b74f7779a 100644 --- a/build.gradle +++ b/build.gradle @@ -302,6 +302,12 @@ githubRelease { releaseAssets.from(jar.archivePath) } +task uploadAll(dependsOn: proguard) { + group "upload" + description "Uploads to all repositories (Maven, Curse, GitHub release)" + dependsOn uploadArchives, curseforge, githubRelease +} + test { useJUnitPlatform() testLogging { diff --git a/gradle.properties b/gradle.properties index b86e88cf1..afc882bbf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.82.1 +mod_version=1.82.2 # Minecraft properties mc_version=1.12.2 From 1210bb8a4d994c29c8cedad12da1721a02c0edae Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 16 Apr 2019 10:43:11 +0100 Subject: [PATCH 06/11] Fix Gradle dependencies I'm not entirely sure why it didn't like the previous version, but there we go. --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index b74f7779a..f318bd443 100644 --- a/build.gradle +++ b/build.gradle @@ -302,10 +302,9 @@ githubRelease { releaseAssets.from(jar.archivePath) } -task uploadAll(dependsOn: proguard) { +task uploadAll(dependsOn: [uploadArchives, "curseforge", "githubRelease"]) { group "upload" description "Uploads to all repositories (Maven, Curse, GitHub release)" - dependsOn uploadArchives, curseforge, githubRelease } test { From f93da7ea51d01ad728e1fd000fafa2e3a449e330 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 18 Apr 2019 09:49:42 +0100 Subject: [PATCH 07/11] Bump Cobalt version I promise! The joys of using -SNAPSHOT I guess... This will now correctly cause orphaned threads to be cleaned up, reducing the risk of thread saturation. --- .../java/dan200/computercraft/core/lua/CobaltLuaMachine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java b/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java index 2de41b96c..55a986e16 100644 --- a/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java +++ b/src/main/java/dan200/computercraft/core/lua/CobaltLuaMachine.java @@ -242,7 +242,7 @@ public class CobaltLuaMachine implements ILuaMachine } catch( InterruptedException e ) { - throw new OrphanedThread(); + throw new InterruptedError( e ); } catch( LuaException e ) { From 2e0ef6385d66061c80cb2c0d3336d6e3a0a7e9ad Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 19 Apr 2019 18:53:39 +0100 Subject: [PATCH 08/11] Fix TurtleCompareCommand throwing exceptions Originally introduced in 173ea720011ea265726d434441f10708a7d798f5, but the underlying cause has been happening for much longer. - Fix order of method name parameters. Looks like this has been broken since 1.11. Woops. - Catch RuntimeExceptions too, as Forge converts checked into unchecked ones. Fixes #179 --- .../shared/turtle/core/TurtleCompareCommand.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java index a7c069a8f..b71c8e901 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java +++ b/src/main/java/dan200/computercraft/shared/turtle/core/TurtleCompareCommand.java @@ -53,19 +53,15 @@ public class TurtleCompareCommand implements ITurtleCommand Block lookAtBlock = lookAtState.getBlock(); if( !lookAtBlock.isAir( lookAtState, world, newPosition ) ) { - // Try createStackedBlock first + // Try getSilkTouchDrop first if( !lookAtBlock.hasTileEntity( lookAtState ) ) { try { - Method method = ReflectionHelper.findMethod( - Block.class, - "func_180643_i", "getSilkTouchDrop", - IBlockState.class - ); + Method method = ReflectionHelper.findMethod( Block.class, "getSilkTouchDrop", "func_180643_i", IBlockState.class ); lookAtStack = (ItemStack) method.invoke( lookAtBlock, lookAtState ); } - catch( ReflectiveOperationException ignored ) + catch( ReflectiveOperationException | RuntimeException ignored ) { } } From 6898f932a0ea1c3eaa5180edf15d749a774eb9d1 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 22 Apr 2019 11:40:19 +0100 Subject: [PATCH 09/11] Remove redstone blocked checks This has been returning false for almost 2 years (since 8abff95441b87df733df839eca6c373513e0487b). At this point, it's probably worth just dropping it entirely. --- .../computer/blocks/TileComputerBase.java | 25 ++++++------------- .../shared/turtle/blocks/TileTurtle.java | 6 ----- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java index 91913ae72..f9d7ae66e 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -124,16 +124,14 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public boolean getRedstoneConnectivity( EnumFacing side ) { - if( side == null ) return false; - ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, side.getOpposite() ) ); - return !isRedstoneBlockedOnSide( localDir ); + return true; } @Override public int getRedstoneOutput( EnumFacing side ) { ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) ); - if( !isRedstoneBlockedOnSide( localDir ) && world != null && !world.isRemote ) + if( world != null && !world.isRemote ) { ServerComputer computer = getServerComputer(); if( computer != null ) return computer.getRedstoneOutput( localDir ); @@ -144,15 +142,14 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT @Override public boolean getBundledRedstoneConnectivity( @Nonnull EnumFacing side ) { - ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) ); - return !isRedstoneBlockedOnSide( localDir ); + return true; } @Override public int getBundledRedstoneOutput( @Nonnull EnumFacing side ) { ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, side ) ); - if( !isRedstoneBlockedOnSide( localDir ) && !world.isRemote ) + if( !world.isRemote ) { ServerComputer computer = getServerComputer(); if( computer != null ) return computer.getBundledRedstoneOutput( localDir ); @@ -259,11 +256,6 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT return false; } - protected boolean isRedstoneBlockedOnSide( ComputerSide localSide ) - { - return false; - } - protected ComputerSide remapLocalSide( ComputerSide localSide ) { return localSide; @@ -273,11 +265,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT { EnumFacing offsetSide = dir.getOpposite(); ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, dir ) ); - if( !isRedstoneBlockedOnSide( localDir ) ) - { - computer.setRedstoneInput( localDir, getWorld().getRedstonePower( offset, dir ) ); - computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) ); - } + + computer.setRedstoneInput( localDir, getWorld().getRedstonePower( offset, dir ) ); + computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) ); + if( !isPeripheralBlockedOnSide( localDir ) ) { computer.setPeripheral( localDir, Peripherals.getPeripheral( getWorld(), offset, offsetSide ) ); diff --git a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java index e36edfbac..b96dd6868 100644 --- a/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java +++ b/src/main/java/dan200/computercraft/shared/turtle/blocks/TileTurtle.java @@ -317,12 +317,6 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default return hasPeripheralUpgradeOnSide( localSide ); } - @Override - protected boolean isRedstoneBlockedOnSide( ComputerSide localSide ) - { - return false; - } - // IDirectionalTile @Override From 7071cc972bb504441dfb583abd1bc1f827f66ea1 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 22 Apr 2019 11:52:01 +0100 Subject: [PATCH 10/11] Make redstone behaviour consistent with repeaters This uses the same behaviour that repeaters and comparators do for determining their input, meaning that redstone directly connected to the computer is read (as you would expect). It's worth noting that this is a shift from previous behaviour. Therefore, it runs the (small) risk of breaking existing builds. However, I believe it is more consistent with the expected behaviour. --- .../computer/blocks/TileComputerBase.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java index f9d7ae66e..c6f796ee4 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -22,7 +22,10 @@ import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.RedstoneUtil; import joptsimple.internal.Strings; import net.minecraft.block.Block; +import net.minecraft.block.BlockRedstoneWire; +import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -34,6 +37,7 @@ import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.IWorldNameable; +import net.minecraft.world.World; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -266,7 +270,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT EnumFacing offsetSide = dir.getOpposite(); ComputerSide localDir = remapLocalSide( DirectionUtil.toLocal( this, dir ) ); - computer.setRedstoneInput( localDir, getWorld().getRedstonePower( offset, dir ) ); + computer.setRedstoneInput( localDir, getRedstoneInput( world, offset, dir ) ); computer.setBundledRedstoneInput( localDir, BundledRedstone.getOutput( getWorld(), offset, offsetSide ) ); if( !isPeripheralBlockedOnSide( localDir ) ) @@ -275,6 +279,26 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT } } + /** + * Gets the redstone input for an adjacent block + * + * @param world The world we exist in + * @param pos The position of the neighbour + * @param side The side we are reading from + * @return The effective redstone power + * @see net.minecraft.block.BlockRedstoneDiode#calculateInputStrength(World, BlockPos, IBlockState) + */ + protected static int getRedstoneInput( World world, BlockPos pos, EnumFacing side ) + { + int power = world.getRedstonePower( pos, side ); + if( power >= 15 ) return power; + + IBlockState neighbour = world.getBlockState( pos ); + return neighbour.getBlock() == Blocks.REDSTONE_WIRE + ? Math.max( power, neighbour.getValue( BlockRedstoneWire.POWER ) ) + : power; + } + public void updateInput() { if( getWorld() == null || getWorld().isRemote ) return; From 978c28a686666d47a194c700d4b619f1739de40d Mon Sep 17 00:00:00 2001 From: SquidDev Date: Wed, 24 Apr 2019 09:48:28 +0100 Subject: [PATCH 11/11] Bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index afc882bbf..95b73b92d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Mod properties -mod_version=1.82.2 +mod_version=1.82.3 # Minecraft properties mc_version=1.12.2