From 101b3500ccf50ee68cba1ca05bdfb18691f6d03f Mon Sep 17 00:00:00 2001 From: SquidDev Date: Sat, 5 Jan 2019 20:57:32 +0000 Subject: [PATCH] Add back several more methods for Plethora While Plethora has been updated to no longer require these, it's probably worth keeping them around a little longer, as people may not upgrade them in sync. --- .../shared/computer/blocks/IComputerTile.java | 4 ++++ .../shared/computer/blocks/TileComputerBase.java | 8 ++++++++ .../shared/computer/core/ClientComputer.java | 7 +++++++ .../computercraft/shared/computer/core/IComputer.java | 3 +++ .../shared/computer/core/ServerComputer.java | 2 ++ .../dan200/computercraft/shared/util/DirectionUtil.java | 6 ++++++ .../dan200/computercraft/shared/util/RedstoneUtil.java | 6 ++++++ .../java/dan200/computercraft/shared/util/WorldUtil.java | 7 +++++++ 8 files changed, 43 insertions(+) diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/IComputerTile.java b/src/main/java/dan200/computercraft/shared/computer/blocks/IComputerTile.java index 868fdceb3..8c341df33 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/IComputerTile.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/IComputerTile.java @@ -7,6 +7,7 @@ package dan200.computercraft.shared.computer.blocks; import dan200.computercraft.shared.computer.core.ComputerFamily; +import dan200.computercraft.shared.computer.core.IComputer; public interface IComputerTile { @@ -19,4 +20,7 @@ public interface IComputerTile void setLabel( String label ); ComputerFamily getFamily(); + + @Deprecated + IComputer getComputer(); } 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 e6afcf202..b5b227e88 100644 --- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java +++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java @@ -13,6 +13,7 @@ import dan200.computercraft.shared.common.IDirectionalTile; import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.computer.core.ClientComputer; import dan200.computercraft.shared.computer.core.ComputerFamily; +import dan200.computercraft.shared.computer.core.IComputer; import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.RedstoneUtil; @@ -407,6 +408,13 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT return ComputerFamily.Normal; } + @Override + @Deprecated + public IComputer getComputer() + { + return getWorld().isRemote ? getClientComputer() : getServerComputer(); + } + public ServerComputer createServerComputer() { if( getWorld().isRemote ) return null; diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java index 960964480..378127717 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java @@ -64,6 +64,13 @@ public class ClientComputer extends ClientTerminal implements IComputer return m_instanceID; } + @Override + @Deprecated + public String getLabel() + { + return null; + } + @Override public boolean isOn() { diff --git a/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java index 69a6ee75a..72157e1e8 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/IComputer.java @@ -13,6 +13,9 @@ public interface IComputer extends ITerminal { int getInstanceID(); + @Deprecated + String getLabel(); + boolean isOn(); boolean isCursorDisplayed(); diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index 918992428..493ea2a66 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -231,6 +231,8 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput return m_computer.getID(); } + @Override + @SuppressWarnings( "deprecation" ) public String getLabel() { return m_computer.getLabel(); diff --git a/src/main/java/dan200/computercraft/shared/util/DirectionUtil.java b/src/main/java/dan200/computercraft/shared/util/DirectionUtil.java index b9c7f4f93..29a9754ee 100644 --- a/src/main/java/dan200/computercraft/shared/util/DirectionUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/DirectionUtil.java @@ -63,4 +63,10 @@ public class DirectionUtil return 0.0f; } } + + @Deprecated + public static float toYawAngle( EnumFacing dir ) + { + return dir.getHorizontalAngle(); + } } diff --git a/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java b/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java index 84783a6d8..2af348148 100644 --- a/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/RedstoneUtil.java @@ -15,6 +15,12 @@ import net.minecraft.world.World; public class RedstoneUtil { + @Deprecated + public static int getRedstoneOutput( World world, BlockPos pos, EnumFacing side ) + { + return world.getRedstonePower( pos, side ); + } + @Deprecated public static int getBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side ) { diff --git a/src/main/java/dan200/computercraft/shared/util/WorldUtil.java b/src/main/java/dan200/computercraft/shared/util/WorldUtil.java index beb880f33..b6a912d2f 100644 --- a/src/main/java/dan200/computercraft/shared/util/WorldUtil.java +++ b/src/main/java/dan200/computercraft/shared/util/WorldUtil.java @@ -25,8 +25,15 @@ import java.util.List; public class WorldUtil { + @SuppressWarnings( "Guava" ) private static final Predicate CAN_COLLIDE = x -> x != null && !x.isDead && x.canBeCollidedWith(); + @Deprecated + public static boolean isBlockInWorld( World world, BlockPos pos ) + { + return world.isValid( pos ); + } + public static boolean isLiquidBlock( World world, BlockPos pos ) { return world.getBlockState( pos ).getMaterial().isLiquid();