diff --git a/build.gradle b/build.gradle index f5dd7b3..7c43daf 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } apply plugin: 'net.minecraftforge.gradle.forge' -version = "0.0.3" +version = "0.0.3-1.10.2masafixes.5" group= "com.rwtema.funkylocomotion" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "funky-locomotion-1.10.2-alpha" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b761216..3baa851 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 678d9d8..b430ae5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jul 02 15:54:47 CDT 2014 +#Tue Feb 07 06:54:21 EET 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip diff --git a/gradlew b/gradlew index 91a7e26..27309d9 100644 --- a/gradlew +++ b/gradlew @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/gradlew.bat b/gradlew.bat index 8a0b282..832fdb6 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,7 +46,7 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args diff --git a/src/main/java/com/rwtema/funkylocomotion/EntityMovingEventHandler.java b/src/main/java/com/rwtema/funkylocomotion/EntityMovingEventHandler.java index fcca43b..faa9b42 100644 --- a/src/main/java/com/rwtema/funkylocomotion/EntityMovingEventHandler.java +++ b/src/main/java/com/rwtema/funkylocomotion/EntityMovingEventHandler.java @@ -5,7 +5,6 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; @@ -48,7 +47,7 @@ public static void moveEntity(Entity entity, double dx, double dy, double dz) { boolean flag = entity.onGround && entity.isSneaking() && entity instanceof EntityPlayer; if (flag) { - for (double d6 = 0.05D; dx != 0.0D && entity.worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(dx, -1.0D, 0.0D)).isEmpty(); xspeed = dx) { + for ( ; dx != 0.0D && entity.getEntityWorld().getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(dx, -1.0D, 0.0D)).isEmpty(); xspeed = dx) { if (dx < 0.05D && dx >= -0.05D) { dx = 0.0D; } else if (dx > 0.0D) { @@ -58,7 +57,7 @@ public static void moveEntity(Entity entity, double dx, double dy, double dz) { } } - for (; dz != 0.0D && entity.worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(0.0D, -1.0D, dz)).isEmpty(); zpeed = dz) { + for (; dz != 0.0D && entity.getEntityWorld().getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(0.0D, -1.0D, dz)).isEmpty(); zpeed = dz) { if (dz < 0.05D && dz >= -0.05D) { dz = 0.0D; } else if (dz > 0.0D) { @@ -68,7 +67,7 @@ public static void moveEntity(Entity entity, double dx, double dy, double dz) { } } - for (; dx != 0.0D && dz != 0.0D && entity.worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(dx, -1.0D, dz)).isEmpty(); zpeed = dz) { + for (; dx != 0.0D && dz != 0.0D && entity.getEntityWorld().getCollisionBoxes(entity, entity.getEntityBoundingBox().offset(dx, -1.0D, dz)).isEmpty(); zpeed = dz) { if (dx < 0.05D && dx >= -0.05D) { dx = 0.0D; } else if (dx > 0.0D) { @@ -89,7 +88,7 @@ public static void moveEntity(Entity entity, double dx, double dy, double dz) { } } - List list1 = entity.worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox().addCoord(dx, dy, dz)); + List list1 = entity.getEntityWorld().getCollisionBoxes(entity, entity.getEntityBoundingBox().addCoord(dx, dy, dz)); AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox(); int i = 0; @@ -121,7 +120,7 @@ public static void moveEntity(Entity entity, double dx, double dy, double dz) { AxisAlignedBB axisalignedbb1 = entity.getEntityBoundingBox(); entity.setEntityBoundingBox(axisalignedbb); dy = (double) entity.stepHeight; - List list = entity.worldObj.getCollisionBoxes(entity, entity.getEntityBoundingBox().addCoord(xspeed, dy, zpeed)); + List list = entity.getEntityWorld().getCollisionBoxes(entity, entity.getEntityBoundingBox().addCoord(xspeed, dy, zpeed)); AxisAlignedBB axisalignedbb2 = entity.getEntityBoundingBox(); AxisAlignedBB axisalignedbb3 = axisalignedbb2.addCoord(xspeed, 0.0D, zpeed); double d9 = dy; diff --git a/src/main/java/com/rwtema/funkylocomotion/FunkyLocomotion.java b/src/main/java/com/rwtema/funkylocomotion/FunkyLocomotion.java index 7eced1b..93f57d7 100644 --- a/src/main/java/com/rwtema/funkylocomotion/FunkyLocomotion.java +++ b/src/main/java/com/rwtema/funkylocomotion/FunkyLocomotion.java @@ -28,7 +28,7 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; -@Mod(modid = FunkyLocomotion.MODID, version = FunkyLocomotion.VERSION, dependencies = "after:ThermalExpansion;after:ThermalFoundation;required-after:Forge@[10.13.1.1217,)") +@Mod(modid = FunkyLocomotion.MODID, version = FunkyLocomotion.VERSION) public class FunkyLocomotion { public static final String MODID = "funkylocomotion"; public static final String VERSION = "1.0"; @@ -92,12 +92,12 @@ public void preinit(FMLPreInitializationEvent event) { GameRegistry.register(wrench = WrenchFactory.makeMeAWrench()); - GameRegistry.registerTileEntity(TileMovingServer.class, "funkylocomotion:tileMover"); - GameRegistry.registerTileEntity(TilePusher.class, "funkylocomotion:tilePusher"); - GameRegistry.registerTileEntity(TileSlider.class, "funkylocomotion:tileSlider"); - GameRegistry.registerTileEntity(TileBooster.class, "funkylocomotion:tileBooster"); - GameRegistry.registerTileEntity(TileTeleport.class, "funkylocomotion:tileTeleporter"); - GameRegistry.registerTileEntity(TileFrameProjector.class, "funkylocomotion:tileFrameProjector"); + GameRegistry.registerTileEntity(TileMovingServer.class, "funkylocomotion:tile_mover"); + GameRegistry.registerTileEntity(TilePusher.class, "funkylocomotion:tile_pusher"); + GameRegistry.registerTileEntity(TileSlider.class, "funkylocomotion:tile_slider"); + GameRegistry.registerTileEntity(TileBooster.class, "funkylocomotion:tile_booster"); + GameRegistry.registerTileEntity(TileTeleport.class, "funkylocomotion:tile_teleporter"); + GameRegistry.registerTileEntity(TileFrameProjector.class, "funkylocomotion:tile_frame_projector"); proxy.registerRendering(); diff --git a/src/main/java/com/rwtema/funkylocomotion/api/FunkyCapabilities.java b/src/main/java/com/rwtema/funkylocomotion/api/FunkyCapabilities.java index 8f5cc79..ccb648c 100644 --- a/src/main/java/com/rwtema/funkylocomotion/api/FunkyCapabilities.java +++ b/src/main/java/com/rwtema/funkylocomotion/api/FunkyCapabilities.java @@ -26,7 +26,7 @@ public class FunkyCapabilities { public static Capability ADV_STICKY_BLOCK = null; @CapabilityInject(IItemHandler.class) - public static void initializeCapabilities(Capability ignore) { + public static void initializeCapabilities(Capability ignore) { register(IMoveCheck.class, () -> (worldObj, pos, profile) -> EnumActionResult.PASS); register(IStickyBlock.class, () -> (world, pos, side) -> false); register(ISlipperyBlock.class, () -> (world, pos, dir) -> false); diff --git a/src/main/java/com/rwtema/funkylocomotion/api/IAdvStickyBlock.java b/src/main/java/com/rwtema/funkylocomotion/api/IAdvStickyBlock.java index c47c9b8..6124276 100644 --- a/src/main/java/com/rwtema/funkylocomotion/api/IAdvStickyBlock.java +++ b/src/main/java/com/rwtema/funkylocomotion/api/IAdvStickyBlock.java @@ -3,8 +3,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import java.util.List; - public interface IAdvStickyBlock { Iterable getBlocksToMove(World world, BlockPos pos); } diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockBooster.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockBooster.java index e1ecf68..8e06773 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockBooster.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockBooster.java @@ -31,7 +31,8 @@ public BlockBooster() { } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, + EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { ItemStack item = playerIn.getHeldItem(hand); if (!(ItemHelper.isWrench(item))) @@ -44,13 +45,15 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, side = face.getOpposite(); worldIn.setBlockState(pos, state.withProperty(BlockDirectional.FACING, side), 3); + return true; } - return true; + return false; } @Nonnull @Override - public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { + public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, + float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { IBlockState state = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer); EnumFacing opposite = facing.getOpposite(); if (worldIn.getTileEntity(pos.offset(opposite)) instanceof IMover) { diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFLMultiState.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFLMultiState.java index 64ce34c..72e7074 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFLMultiState.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFLMultiState.java @@ -24,7 +24,6 @@ public BlockFLMultiState(Material materialIn) { @Override public abstract int getMetaFromState(IBlockState state); - @SuppressWarnings("NullableProblems") @Override public abstract IBlockState getStateFromMeta(int meta); } diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrame.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrame.java index e1ad102..3d52285 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrame.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrame.java @@ -20,7 +20,8 @@ public BlockFrame() { @Override public boolean shouldSideBeRendered(IBlockState blockState, @Nonnull IBlockAccess blockAccess, @Nonnull BlockPos pos, EnumFacing side) { - return super.shouldSideBeRendered(blockState, blockAccess, pos, side) && !(blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockFrame); + return super.shouldSideBeRendered(blockState, blockAccess, pos, side) && + !(blockAccess.getBlockState(pos.offset(side)).getBlock() instanceof BlockFrame); } @Override diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrameProjector.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrameProjector.java index acef111..c89efb1 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrameProjector.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockFrameProjector.java @@ -61,7 +61,8 @@ public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState st @Nonnull @Override - public IBlockState getStateForPlacement(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ, int meta, @Nonnull EntityLivingBase placer, ItemStack stack) { + public IBlockState getStateForPlacement(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, + float hitX, float hitY, float hitZ, int meta, @Nonnull EntityLivingBase placer, ItemStack stack) { EnumFacing facingFromEntity = BlockPistonBase.getFacingFromEntity(pos, placer); return getDefaultState().withProperty(BlockDirectional.FACING, facingFromEntity); } @@ -75,7 +76,8 @@ public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, Enti } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, + EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { ItemStack item = playerIn.getHeldItem(hand); if (!(ItemHelper.isWrench(item))) @@ -90,6 +92,7 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, projector.range = 1; } BlockHelper.markBlockForUpdate(worldIn, pos); + return true; } } else { IBlockState blockState = worldIn.getBlockState(pos); @@ -105,6 +108,7 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, projector.facing = side; BlockHelper.markBlockForUpdate(worldIn, pos); } + return true; } } return true; diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockMoving.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockMoving.java index 117c635..e3f864c 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockMoving.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockMoving.java @@ -36,13 +36,13 @@ public BlockMoving() { instance = this; } - @SuppressWarnings("unused") public static boolean _Immoveable() { return true; } @Override - public void addCollisionBoxToList(IBlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, @Nonnull List collidingBoxes, @Nullable Entity entityIn) { + public void addCollisionBoxToList(IBlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, + @Nonnull List collidingBoxes, @Nullable Entity entityIn) { TileEntity tile = worldIn.getTileEntity(pos); if (!(tile instanceof TileMovingBase)) return; @@ -112,7 +112,6 @@ public boolean isNormalCube(IBlockState state, IBlockAccess world, BlockPos pos) return false; } - @SuppressWarnings("ConstantConditions") @Nonnull @Override public ItemStack getPickBlock(@Nonnull IBlockState state, RayTraceResult target, @Nonnull World world, @Nonnull BlockPos pos, EntityPlayer player) { @@ -161,16 +160,18 @@ public int getLightOpacity(IBlockState state, IBlockAccess world, BlockPos pos) } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, + EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) - return true; + return false; TileEntity tile = worldIn.getTileEntity(pos); if (tile instanceof TileMovingServer) { ((TileMovingServer) tile).cacheActivate(playerIn, side, hand, hitX, hitY, hitZ); + return true; } - return true; + return false; } @Override @@ -184,6 +185,7 @@ public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, fakeWorld.offset = mover.offset(true); fakeWorld.dir_id = mover.dir; fakeWorld.dir = mover.getDir(); + @SuppressWarnings("deprecation") IBlockState state = mover.block.getStateFromMeta(mover.meta); mover.block.randomDisplayTick(state, fakeWorld, pos, rand); fakeWorld.offset = 0; diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockPusher.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockPusher.java index a9eeecd..243ab9b 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockPusher.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockPusher.java @@ -5,6 +5,7 @@ import com.rwtema.funkylocomotion.helper.ItemHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockDirectional; +import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; @@ -34,13 +35,15 @@ public BlockPusher() { super(Material.ROCK); this.setCreativeTab(FunkyLocomotion.creativeTabFrames); this.setHardness(1); + this.setSoundType(SoundType.STONE); } @Nonnull @Override - public IBlockState getStateForPlacement(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, float hitX, float hitY, float hitZ, int meta, @Nonnull EntityLivingBase placer, ItemStack stack) { - return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack) - .withProperty(BlockDirectional.FACING, EnumFacing.UP); + public IBlockState getStateForPlacement(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing facing, + float hitX, float hitY, float hitZ, int meta, @Nonnull EntityLivingBase placer, ItemStack stack) { + IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, stack); + return state.withProperty(BlockDirectional.FACING, facing.getOpposite()); } @Override @@ -55,6 +58,11 @@ public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, Enti } } + @Override + public int damageDropped(IBlockState state) { + return state.getValue(PUSH_PULL_TYPE) == PushPullType.PUSHER ? 0 : 1; + } + @Override public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, List list) { list.add(new ItemStack(itemIn, 1, 0)); @@ -62,7 +70,8 @@ public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, List } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, + EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) { ItemStack item = playerIn.getHeldItem(hand); if (!(ItemHelper.isWrench(item))) @@ -75,8 +84,9 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, side = face.getOpposite(); worldIn.setBlockState(pos, state.withProperty(BlockDirectional.FACING, side), 3); + return true; } - return true; + return false; } @Override diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockSlider.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockSlider.java index 122132f..7d7fcd9 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockSlider.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockSlider.java @@ -50,15 +50,20 @@ public void init() { }; } + @Override + public int damageDropped(IBlockState state) { + return 0; + } + @Nonnull @Override public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess worldIn, BlockPos pos) { if (state.getBlock() != this) return state; EnumFacing facing = state.getValue(BlockDirectional.FACING); - TileEntity tile = worldIn.getTileEntity(pos); - if (tile instanceof TileSlider) { - EnumFacing slideDir = ((TileSlider) tile).getSlideDir(); + TileSlider tile = BlockHelper.getTileEntitySafely(worldIn, pos, TileSlider.class); + if (tile != null) { + EnumFacing slideDir = tile.getSlideDir(); init(); int value = map[facing.ordinal()][slideDir.ordinal()]; @@ -70,9 +75,10 @@ public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, + EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { - return true; + return false; } ItemStack item = playerIn.getHeldItem(hand); if (!(ItemHelper.isWrench(item))) @@ -84,6 +90,7 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, if (tile != null && tile.getClass() == TileSlider.class) { ((TileSlider) tile).rotateAboutAxis(); BlockHelper.markBlockForUpdate(worldIn, pos); + return true; } } else { if (side.ordinal() == meta) @@ -95,8 +102,9 @@ public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, ((TileSlider) tile).getSlideDir(); BlockHelper.markBlockForUpdate(worldIn, pos); } + return true; } - return true; + return false; } @Nonnull diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockStickyFrame.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockStickyFrame.java index 99fc7c1..6cb6c39 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockStickyFrame.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockStickyFrame.java @@ -114,7 +114,8 @@ public int getMetaFromState(IBlockState state) { } @Override - public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { + public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, + EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack item = playerIn.getHeldItem(hand); if (!(ItemHelper.isWrench(item))) return false; diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockTeleport.java b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockTeleport.java index e94734a..6f5c7b9 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/BlockTeleport.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/BlockTeleport.java @@ -27,6 +27,11 @@ public BlockTeleport() { this.setUnlocalizedName("funkylocomotion:teleporter"); } + @Override + public int damageDropped(IBlockState state) { + return 0; + } + @Override public void getSubBlocks(@Nonnull Item itemIn, CreativeTabs tab, List list) { list.add(new ItemStack(itemIn, 1, 0)); @@ -41,6 +46,7 @@ public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState st @Nullable @Override public ItemStack getItem(World worldIn, BlockPos pos, @Nonnull IBlockState state) { + @SuppressWarnings("deprecation") ItemStack item = super.getItem(worldIn, pos, state); if (item != null) { TileEntity tileEntity = worldIn.getTileEntity(pos); @@ -57,8 +63,9 @@ public ItemStack getItem(World worldIn, BlockPos pos, @Nonnull IBlockState state return item; } - - public void harvestBlock(@Nonnull World worldIn, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack) { + @Override + public void harvestBlock(@Nonnull World worldIn, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, + @Nullable TileEntity te, @Nonnull ItemStack stack) { if (te instanceof TileTeleport) { ItemStack itemstack = new ItemStack(this, 1); int teleportId = ((TileTeleport) te).teleportId; diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java index 9a62a23..5247519 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingBase.java @@ -41,7 +41,6 @@ public TileMovingBase(Side side) { this.side = side; } - @SuppressWarnings("unused") public static boolean _Immovable() { return true; } @@ -113,8 +112,10 @@ public void readFromNBT(NBTTagCompound tag) { @Nonnull public NBTTagCompound writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); - tag.setTag("BlockTag", block); - tag.setTag("DescTag", desc); + if (block != null) + tag.setTag("BlockTag", block); + if (desc != null) + tag.setTag("DescTag", desc); tag.setInteger("Time", time); tag.setInteger("MaxTime", maxTime); tag.setByte("Dir", (byte) dir); @@ -149,13 +150,12 @@ public Vec3d getMovVec() { return new Vec3d(dir.getFrontOffsetX() * d, dir.getFrontOffsetY() * d, dir.getFrontOffsetZ() * d); } - @SuppressWarnings("unchecked") @Override public void update() { if (maxTime == 0) return; - if (worldObj.isRemote) { + if (getWorld().isRemote) { time = time + 1 - 1; } @@ -166,7 +166,7 @@ public void update() { time++; for (AxisAlignedBB bb : getTransformedColisions()) { - List entities = worldObj.getEntitiesWithinAABB(Entity.class, bb.expand(0, 0.1, 0)); + List entities = getWorld().getEntitiesWithinAABB(Entity.class, bb.expand(0, 0.1, 0)); for (Entity entity : entities) { entityList.add(entity); } @@ -209,7 +209,7 @@ public AxisAlignedBB getCombinedCollisions(boolean renderOffset, boolean shrink) EnumFacing dir = this.getDir(); if (dir != null) { - TileEntity other = worldObj.getTileEntity(pos.offset(dir)); + TileEntity other = getWorld().getTileEntity(pos.offset(dir)); if (other instanceof TileMovingBase) { AxisAlignedBB[] bbs1 = ((TileMovingBase) other).collisions; for (AxisAlignedBB bb1 : bbs1) { diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingClient.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingClient.java index 3f15079..c8f7290 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingClient.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingClient.java @@ -2,7 +2,6 @@ import com.rwtema.funkylocomotion.description.Describer; import com.rwtema.funkylocomotion.fakes.FakeWorldClient; -import com.rwtema.funkylocomotion.helper.BlockHelper; import com.rwtema.funkylocomotion.rendering.ChunkRerenderer; import com.rwtema.funkylocomotion.rendering.PassHandler; import net.minecraft.block.Block; @@ -25,8 +24,8 @@ public class TileMovingClient extends TileMovingBase { public static final HashMap> cachedTiles = new HashMap<>(); - public static final HashSet renderBlackList = new HashSet<>(); - public static final HashSet renderErrorList = new HashSet<>(); + public static final HashSet> renderBlackList = new HashSet<>(); + public static final HashSet> renderErrorList = new HashSet<>(); public final boolean[] skipPass = new boolean[2]; public Block block = Blocks.AIR; public int meta = 0; @@ -89,7 +88,7 @@ public void handleUpdateTag(NBTTagCompound tag) { if (tile != null && FakeWorldClient.isValid(worldObj) && tile.getWorld() == this.worldObj) { rawTile = true; tile.setPos(pos.toImmutable()); - tile.setWorldObj(FakeWorldClient.getFakeWorldWrapper(this.worldObj)); + tile.setWorldObj(FakeWorldClient.getFakeWorldWrapper(this.getWorld())); tile.updateContainingBlockInfo(); this.tile = tile; render = true; @@ -97,7 +96,7 @@ public void handleUpdateTag(NBTTagCompound tag) { render = !tag.getBoolean("DNR"); if (render) { - this.tile = Describer.recreateTileEntity(tag, getState(), pos, FakeWorldClient.getFakeWorldWrapper(this.worldObj)); + this.tile = Describer.recreateTileEntity(tag, getState(), pos, FakeWorldClient.getFakeWorldWrapper(this.getWorld())); } } @@ -110,7 +109,7 @@ public void handleUpdateTag(NBTTagCompound tag) { init = true; - worldObj.markBlockRangeForRenderUpdate(pos, pos); + getWorld().markBlockRangeForRenderUpdate(pos, pos); } public boolean checkClass(Object o) { @@ -138,7 +137,7 @@ public AxisAlignedBB getRenderBoundingBox() { if (tile != null) other = tile.getRenderBoundingBox(); else - other = getState().getCollisionBoundingBox(FakeWorldClient.getFakeWorldWrapper(worldObj), pos); + other = getState().getCollisionBoundingBox(FakeWorldClient.getFakeWorldWrapper(getWorld()), pos); if (other == null) other = Block.FULL_BLOCK_AABB; @@ -162,7 +161,7 @@ public boolean shouldRenderInPass(int pass) { IBlockState state = getState(); - if (block == Blocks.AIR || (tile == null && block.getRenderType(state) == EnumBlockRenderType.INVISIBLE)) + if (block == Blocks.AIR || (tile == null && state.getRenderType() == EnumBlockRenderType.INVISIBLE)) return false; if (tile != null) { @@ -179,6 +178,7 @@ public boolean shouldRenderInPass(int pass) { return false; } + @SuppressWarnings("deprecation") public IBlockState getState() { return block.getStateFromMeta(meta); } diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java index 2fc65e4..2da9952 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileMovingServer.java @@ -26,25 +26,23 @@ public TileMovingServer() { @Override @Nonnull public NBTTagCompound getUpdateTag() { - if (desc == null) + if (this.desc == null) return super.getUpdateTag(); - super.writeToNBT(desc); + this.desc.setInteger("Time", this.time); + this.desc.setInteger("MaxTime", this.maxTime); + this.desc.setByte("Dir", (byte) this.dir); - desc.setInteger("Time", time); - desc.setInteger("MaxTime", maxTime); - desc.setByte("Dir", (byte) dir); + if (this.block != null) + this.desc.setTag("BlockTag", this.block); + if (this.collisions.length > 0) + this.desc.setTag("Collisions", TagsAxis(this.collisions)); + if (this.lightLevel != 0) + this.desc.setByte("Light", (byte) this.lightLevel); + if (this.lightOpacity != 0) + this.desc.setShort("Opacity", (short) this.lightOpacity); - if (lightLevel > 0) - desc.setByte("Light", (byte) lightLevel); - if (lightOpacity > 0) - desc.setShort("Opacity", (short) lightOpacity); - - if (collisions.length > 0) { - desc.setTag("Collisions", TagsAxis(collisions)); - } - - return desc; + return this.desc; } @Override @@ -69,7 +67,7 @@ public void validate() { public void update() { if (time < maxTime) { super.update(); - this.worldObj.markChunkDirty(pos, this); + this.getWorld().markChunkDirty(pos, this); } else { MoverEventHandler.registerFinisher(); // MoveManager.finishMoving(); diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TilePowered.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TilePowered.java index 01c907c..3d4931b 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TilePowered.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TilePowered.java @@ -13,7 +13,7 @@ public class TilePowered extends TileEntity { public final EnergyStorageSerializable energy; - public final IEnergyStorage public_energy_wrapper; + private final IEnergyStorage public_energy_wrapper; public TilePowered(int capacity) { energy = new EnergyStorageSerializable(capacity, capacity, capacity) { @@ -36,31 +36,35 @@ public int extractEnergy(int maxExtract, boolean simulate) { } }; - public_energy_wrapper = new IEnergyStorage() { - public int receiveEnergy(int maxReceive, boolean simulate) { - return energy.receiveEnergy(maxReceive, simulate); - } + if (TilePusher.powerPerTile > 0) { + public_energy_wrapper = new IEnergyStorage() { + public int receiveEnergy(int maxReceive, boolean simulate) { + return energy.receiveEnergy(maxReceive, simulate); + } - public int extractEnergy(int maxExtract, boolean simulate) { - return 0; - } + public int extractEnergy(int maxExtract, boolean simulate) { + return 0; + } - public int getEnergyStored() { - return energy.getEnergyStored(); - } + public int getEnergyStored() { + return energy.getEnergyStored(); + } - public int getMaxEnergyStored() { - return energy.getMaxEnergyStored(); - } + public int getMaxEnergyStored() { + return energy.getMaxEnergyStored(); + } - public boolean canExtract() { - return false; - } + public boolean canExtract() { + return false; + } - public boolean canReceive() { - return true; - } - }; + public boolean canReceive() { + return true; + } + }; + } else { + public_energy_wrapper = null; + } } @Override @@ -81,13 +85,13 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag) { @Override public boolean hasCapability(@Nonnull Capability capability, @Nonnull EnumFacing facing) { - return capability == CapabilityEnergy.ENERGY || super.hasCapability(capability, facing); + return (capability == CapabilityEnergy.ENERGY && TilePusher.powerPerTile > 0) || super.hasCapability(capability, facing); } @Nonnull @Override public T getCapability(@Nonnull Capability capability, @Nonnull EnumFacing facing) { - if (capability == CapabilityEnergy.ENERGY) { + if (capability == CapabilityEnergy.ENERGY && TilePusher.powerPerTile > 0) { return CapabilityEnergy.ENERGY.cast(public_energy_wrapper); } return super.getCapability(capability, facing); diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TilePusher.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TilePusher.java index a6349b5..be09e54 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TilePusher.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TilePusher.java @@ -202,7 +202,7 @@ public void startMoving() { EnumFacing dir = d2.getOpposite(); boolean push = meta < 6; - List posList = getBlocks(worldObj, pos, dir, push); + List posList = getBlocks(getWorld(), pos, dir, push); if (posList != null) { final int energy = posList.size() * powerPerTile; if (this.energy.extractEnergy(energy, true) != energy) @@ -212,12 +212,12 @@ public void startMoving() { for (EnumFacing d : EnumFacing.values()) { if (d != dir) { BlockPos p = pos.offset(d); - IBlockState state = worldObj.getBlockState(p); + IBlockState state = getWorld().getBlockState(p); if (state.getBlock() == FunkyLocomotion.booster) { if (state.getValue(BlockDirectional.FACING) != d.getOpposite()) continue; - TileEntity tile = BlockHelper.getTile(worldObj, p); + TileEntity tile = BlockHelper.getTile(getWorld(), p); if (tile instanceof TileBooster) { TileBooster booster = (TileBooster) tile; if (booster.energy.extractEnergy(energy, true) != energy) @@ -237,13 +237,13 @@ public void startMoving() { this.energy.extractEnergy(energy, false); - MoveManager.startMoving(worldObj, posList, getDirection(), moveTime[boosters.size()]); + MoveManager.startMoving(getWorld(), posList, getDirection(), moveTime[boosters.size()]); } } @Override public boolean stillExists() { - return !tileEntityInvalid && worldObj != null && worldObj.isBlockLoaded(pos) && worldObj.getTileEntity(pos) == this; + return !tileEntityInvalid && getWorld() != null && getWorld().isBlockLoaded(pos) && getWorld().getTileEntity(pos) == this; } @Override @@ -274,8 +274,10 @@ public T getCapability(@Nonnull Capability capability, @Nonnull EnumFacin @Override public void update() { - if (cooldown > 0) { - cooldown--; + if (! this.getWorld().isRemote) { + if (cooldown > 0) { + cooldown--; + } if (cooldown == 0) { MoverEventHandler.registerMover(this); } diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileSlider.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileSlider.java index 5c13ea7..aea5a14 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileSlider.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileSlider.java @@ -97,7 +97,7 @@ public NBTTagCompound getUpdateTag() { @Override public void handleUpdateTag(@Nonnull NBTTagCompound tag) { slideDir = EnumFacing.values()[tag.getByte("dir")]; - worldObj.markBlockRangeForRenderUpdate(pos, pos); + getWorld().markBlockRangeForRenderUpdate(pos, pos); } diff --git a/src/main/java/com/rwtema/funkylocomotion/blocks/TileTeleport.java b/src/main/java/com/rwtema/funkylocomotion/blocks/TileTeleport.java index 0c7ff40..4c2f1a6 100644 --- a/src/main/java/com/rwtema/funkylocomotion/blocks/TileTeleport.java +++ b/src/main/java/com/rwtema/funkylocomotion/blocks/TileTeleport.java @@ -4,7 +4,6 @@ import com.rwtema.funkylocomotion.helper.BlockHelper; import com.rwtema.funkylocomotion.helper.WeakSet; import com.rwtema.funkylocomotion.movers.MoveManager; -import com.rwtema.funkylocomotion.network.FLNetwork; import com.rwtema.funkylocomotion.particles.ObstructionHelper; import gnu.trove.map.hash.TLongObjectHashMap; import net.minecraft.block.BlockDirectional; @@ -43,7 +42,7 @@ public List checkPositions(World srcWorld, EnumFacing moveDir, ArrayLi TileTeleport tile = getTileTeleport(); if (tile == null) return null; - World dstWorld = tile.worldObj; + World dstWorld = tile.getWorld(); boolean fail = false; for (BlockPos pos : posList) { @@ -116,11 +115,11 @@ public void startMoving() { if (dir == null) return; - List posList = getBlocks(worldObj, pos, dir, push); + List posList = getBlocks(getWorld(), pos, dir, push); if (posList != null) { final int energy = posList.size() * powerPerTile; if (this.energy.extractEnergy(energy, true) != energy) { - ObstructionHelper.sendObstructionPacket(worldObj, this.pos, null); + ObstructionHelper.sendObstructionPacket(getWorld(), this.pos, null); return; } @@ -131,12 +130,12 @@ public void startMoving() { for (EnumFacing d : EnumFacing.values()) { if (d != dir) { BlockPos p = pos.offset(d); - IBlockState state = worldObj.getBlockState(p); + IBlockState state = getWorld().getBlockState(p); if (state.getBlock() == FunkyLocomotion.booster) { if (state.getValue(BlockDirectional.FACING) != d.getOpposite()) continue; - TileEntity tile = BlockHelper.getTile(worldObj, p); + TileEntity tile = BlockHelper.getTile(getWorld(), p); if (tile instanceof TileBooster) { TileBooster booster = (TileBooster) tile; if (booster.energy.extractEnergy(energy, true) != energy) @@ -162,7 +161,7 @@ public void startMoving() { links.add(new MoveManager.BlockLink(blockPos, getDestinationPos(tileTeleport, blockPos))); } - MoveManager.startMoving(worldObj, tileTeleport.worldObj, links, null, moveTime[boosters.size()] * 2); + MoveManager.startMoving(getWorld(), tileTeleport.getWorld(), links, null, moveTime[boosters.size()] * 2); } } @@ -180,7 +179,7 @@ public void onChunkUnload() { } private void unCache() { - if (teleportId != 0 && (worldObj == null || !worldObj.isRemote)) { + if (teleportId != 0 && (getWorld() == null || !getWorld().isRemote)) { WeakSet tileTeleports = cache.get(teleportId); if (tileTeleports != null) { tileTeleports.remove(this); @@ -191,7 +190,7 @@ private void unCache() { @Override public void validate() { super.validate(); - if (teleportId != 0 && (worldObj == null || !worldObj.isRemote)) { + if (teleportId != 0 && (getWorld() == null || !getWorld().isRemote)) { WeakSet tileTeleports = cache.get(teleportId); if (tileTeleports == null) { diff --git a/src/main/java/com/rwtema/funkylocomotion/compat/CompatHandler.java b/src/main/java/com/rwtema/funkylocomotion/compat/CompatHandler.java index d22aa57..eb069be 100644 --- a/src/main/java/com/rwtema/funkylocomotion/compat/CompatHandler.java +++ b/src/main/java/com/rwtema/funkylocomotion/compat/CompatHandler.java @@ -33,6 +33,7 @@ public static void initCompat(ASMDataTable asmData) { if (flag) { try { + @SuppressWarnings("unchecked") Class name = (Class) Class.forName(data.getClassName()); CompatHandler compatHandler = name.newInstance(); compatHandler.init(); diff --git a/src/main/java/com/rwtema/funkylocomotion/debug/DebugEventHandler.java b/src/main/java/com/rwtema/funkylocomotion/debug/DebugEventHandler.java index da0d884..241ba97 100644 --- a/src/main/java/com/rwtema/funkylocomotion/debug/DebugEventHandler.java +++ b/src/main/java/com/rwtema/funkylocomotion/debug/DebugEventHandler.java @@ -16,7 +16,6 @@ public class DebugEventHandler { @SubscribeEvent @SideOnly(Side.CLIENT) - @SuppressWarnings("unchecked") public void renderTiles(TickEvent.WorldTickEvent event) { WorldClient clientWorld = Minecraft.getMinecraft().theWorld; diff --git a/src/main/java/com/rwtema/funkylocomotion/helper/BlockHelper.java b/src/main/java/com/rwtema/funkylocomotion/helper/BlockHelper.java index aaabc3a..f3581bd 100644 --- a/src/main/java/com/rwtema/funkylocomotion/helper/BlockHelper.java +++ b/src/main/java/com/rwtema/funkylocomotion/helper/BlockHelper.java @@ -13,14 +13,26 @@ import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.ChunkCache; import net.minecraft.world.EnumSkyBlock; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import javax.annotation.Nullable; +import java.lang.invoke.MethodHandle; +import java.lang.reflect.Field; public class BlockHelper { + private static final MethodHandle methodHandle_Chunk_relightBlock = + MethodHandleUtils.getMethodHandleVirtual(Chunk.class, new String[] { "func_76615_h", "relightBlock" }, int.class, int.class, int.class); + private static final MethodHandle methodHandle_Chunk_propagateSkylightOcclusion = + MethodHandleUtils.getMethodHandleVirtual(Chunk.class, new String[] { "func_76595_e", "propagateSkylightOcclusion" }, int.class, int.class); + private static final Field field_Chunk_precipitationHeightMap = ReflectionHelper.findField(Chunk.class, "field_76638_b", "precipitationHeightMap"); + + @SuppressWarnings("deprecation") public static boolean silentSetBlock(Chunk chunk, BlockPos pos, Block block, int meta) { int dx = pos.getX() & 15; int dz = pos.getZ() & 15; @@ -28,8 +40,18 @@ public static boolean silentSetBlock(Chunk chunk, BlockPos pos, Block block, int int i1 = dz << 4 | dx; - if (y >= chunk.precipitationHeightMap[i1] - 1) { - chunk.precipitationHeightMap[i1] = -999; + try + { + int[] precMap = (int[]) field_Chunk_precipitationHeightMap.get(chunk); + if (y >= precMap[i1] - 1) { + precMap[i1] = -999; + } + //if (y >= chunk.precipitationHeightMap[i1] - 1) { + // chunk.precipitationHeightMap[i1] = -999; + //} + } + catch (Exception e) + { } IBlockState state1 = chunk.getBlockState(dx, y, dz); @@ -46,11 +68,11 @@ public static boolean silentSetBlock(Chunk chunk, BlockPos pos, Block block, int return false; } - extendedblockstorage = chunk.getBlockStorageArray()[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !chunk.worldObj.provider.getHasNoSky()); + extendedblockstorage = chunk.getBlockStorageArray()[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !chunk.getWorld().provider.getHasNoSky()); } extendedblockstorage.set(dx, y & 15, dz, block.getStateFromMeta(meta)); - chunk.isModified = true; + chunk.setModified(true); return true; } @@ -66,11 +88,21 @@ public static void postUpdateBlock(World world, BlockPos pos) { Chunk chunk = world.getChunkFromBlockCoords(pos); - if (pos.getY() >= chunk.precipitationHeightMap[i1] - 1) { - chunk.precipitationHeightMap[i1] = -999; + try + { + int[] precMap = (int[]) field_Chunk_precipitationHeightMap.get(chunk); + if (pos.getY() >= precMap[i1] - 1) { + precMap[i1] = -999; + } + //if (pos.getY() >= chunk.precipitationHeightMap[i1] - 1) { + // chunk.precipitationHeightMap[i1] = -999; + //} + } + catch (Exception e) + { } - int j1 = chunk.heightMap[i1]; + int j1 = chunk.getHeightMap()[i1]; boolean flag = pos.getY() >= j1; IBlockState newState = chunk.getBlockState(pos.getX() & 15, pos.getY(), pos.getZ() & 15); Block newBlock = newState.getBlock(); @@ -81,18 +113,26 @@ public static void postUpdateBlock(World world, BlockPos pos) { } else { int j2 = newBlock.getLightOpacity(newState, world, pos); + try + { if (j2 > 0) { if (pos.getY() >= j1) { - chunk.relightBlock(pos.getX() & 15, pos.getY() + 1, pos.getZ() & 15); + methodHandle_Chunk_relightBlock.invokeExact(chunk, pos.getX() & 15, pos.getY() + 1, pos.getZ() & 15); + //chunk.relightBlock(pos.getX() & 15, pos.getY() + 1, pos.getZ() & 15); } } else if (pos.getY() == j1 - 1) { - - chunk.relightBlock(pos.getX() & 15, pos.getY(), pos.getZ() & 15); + methodHandle_Chunk_relightBlock.invokeExact(chunk, pos.getX() & 15, pos.getY(), pos.getZ() & 15); + //chunk.relightBlock(pos.getX() & 15, pos.getY(), pos.getZ() & 15); } if (j2 != k2 && (j2 < k2 || chunk.getLightFor(EnumSkyBlock.SKY, pos) > 0 || chunk.getLightFor(EnumSkyBlock.BLOCK, pos) > 0)) { - chunk.propagateSkylightOcclusion(pos.getX() & 15, pos.getZ() & 15); + methodHandle_Chunk_propagateSkylightOcclusion.invokeExact(chunk, pos.getX() & 15, pos.getZ() & 15); + //chunk.propagateSkylightOcclusion(pos.getX() & 15, pos.getZ() & 15); + } + } + catch (Throwable t) + { } } @@ -181,4 +221,24 @@ public static void markBlockForUpdate(World world, BlockPos pos) { IBlockState state = world.getBlockState(pos); world.notifyBlockUpdate(pos, state, state, 0); } + + @Nullable + public static T getTileEntitySafely(IBlockAccess world, BlockPos pos, Class tileClass) { + TileEntity te; + + if (world instanceof ChunkCache) { + ChunkCache chunkCache = (ChunkCache) world; + te = chunkCache.getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK); + } + else { + te = world.getTileEntity(pos); + } + + if (tileClass.isInstance(te)) { + return tileClass.cast(te); + } + else { + return null; + } + } } diff --git a/src/main/java/com/rwtema/funkylocomotion/helper/MethodHandleUtils.java b/src/main/java/com/rwtema/funkylocomotion/helper/MethodHandleUtils.java new file mode 100644 index 0000000..fe0b380 --- /dev/null +++ b/src/main/java/com/rwtema/funkylocomotion/helper/MethodHandleUtils.java @@ -0,0 +1,60 @@ +package com.rwtema.funkylocomotion.helper; + +import net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToFindMethodException; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Method; + +public class MethodHandleUtils +{ + public static class UnableToFindMethodHandleException extends RuntimeException + { + private static final long serialVersionUID = 1L; + + public UnableToFindMethodHandleException(String[] methodNames, Exception failed) + { + super(failed); + } + } + + public static MethodHandle getMethodHandleVirtual(Class clazz, String[] methodNames, Class... paramTypes) + { + Exception failed = null; + + try + { + Method method = reflectMethod(clazz, methodNames, paramTypes); + MethodHandle handle = MethodHandles.lookup().unreflect(method); + method.setAccessible(false); + return handle; + } + catch (IllegalAccessException e) + { + failed = e; + } + + throw new UnableToFindMethodHandleException(methodNames, failed); + } + + public static Method reflectMethod(Class clazz, String[] methodNames, Class... methodTypes) + { + Exception failed = null; + + for (String methodName : methodNames) + { + try + { + Method m = clazz.getDeclaredMethod(methodName, methodTypes); + m.setAccessible(true); + return m; + } + catch (Exception e) + { + failed = e; + } + } + + throw new UnableToFindMethodException(methodNames, failed); + } +} diff --git a/src/main/java/com/rwtema/funkylocomotion/helper/WeakSet.java b/src/main/java/com/rwtema/funkylocomotion/helper/WeakSet.java index 44c8d57..c65246d 100644 --- a/src/main/java/com/rwtema/funkylocomotion/helper/WeakSet.java +++ b/src/main/java/com/rwtema/funkylocomotion/helper/WeakSet.java @@ -14,7 +14,6 @@ public boolean add(E e) { return !map.containsKey(e) && map.put(e, BLANK) == null; } - @SuppressWarnings("NullableProblems") @Override public Iterator iterator() { return map.keySet().iterator(); @@ -30,7 +29,6 @@ public boolean isEmpty() { return map.isEmpty(); } - @SuppressWarnings("SuspiciousMethodCalls") @Override public boolean contains(Object o) { return map.containsKey(o); diff --git a/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockFrame.java b/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockFrame.java index 49599cc..10fb0dd 100644 --- a/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockFrame.java +++ b/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockFrame.java @@ -3,9 +3,9 @@ import com.rwtema.funkylocomotion.blocks.BlockStickyFrame; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -23,6 +23,7 @@ public ItemBlockFrame(Block block) { index = ((BlockStickyFrame) block).getRawIndex(); } + @SuppressWarnings("deprecation") @Nonnull @Override public String getItemStackDisplayName(@Nonnull ItemStack itemstack) { @@ -36,27 +37,26 @@ public String getItemStackDisplayName(@Nonnull ItemStack itemstack) { int meta = itemstack.getItemDamage() + index; for (int i = 0; i < 6; i++) if (((meta) & (1 << i)) != 0) - builder.append(I18n.translateToLocal("frame.dir.abbreviations." + i)); + builder.append(net.minecraft.util.text.translation.I18n.translateToLocal("frame.dir.abbreviations." + i)); builder.append(")"); return builder.toString(); } - @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack item, @Nonnull EntityPlayer player, @Nonnull List list, boolean debug) { + public void addInformation(@Nonnull ItemStack item, @Nonnull EntityPlayer player, @Nonnull List list, boolean debug) { super.addInformation(item, player, list, debug); if (index == 0 && item.getItemDamage() == 0) return; - list.add(I18n.translateToLocal("frame.dir.start")); + list.add(I18n.format("frame.dir.start")); String s = ""; boolean flag = false; for (int i = 0; i < 6; i++) { if (((index + item.getItemDamage()) & (1 << i)) != 0) { if (flag) s = s + ", "; - s = s + I18n.translateToLocal("frame.dir.name." + i); + s = s + I18n.format("frame.dir.name." + i); flag = true; } } diff --git a/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockTeleporter.java b/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockTeleporter.java index 461be0c..8853758 100644 --- a/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockTeleporter.java +++ b/src/main/java/com/rwtema/funkylocomotion/items/ItemBlockTeleporter.java @@ -2,6 +2,7 @@ import com.rwtema.funkylocomotion.rendering.WordDictionary; import net.minecraft.block.Block; +import net.minecraft.client.resources.I18n; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; @@ -14,7 +15,6 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentTranslation; -import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -57,9 +57,8 @@ public void onUpdate(ItemStack item, World world, Entity entity, int slot, boole } } - @SuppressWarnings("unchecked") @Override - public void getSubItems(@Nonnull Item item, @Nonnull CreativeTabs tab, @Nonnull List list) { + public void getSubItems(@Nonnull Item item, @Nonnull CreativeTabs tab, @Nonnull List list) { list.add((new ItemStack(item, 1, 0))); } @@ -77,16 +76,15 @@ public EnumActionResult onItemUse(ItemStack stack, @Nonnull EntityPlayer playerI return super.onItemUse(stack, playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); } - @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) - public void addInformation(@Nonnull ItemStack item, @Nonnull EntityPlayer player, @Nonnull List list, boolean debug) { + public void addInformation(@Nonnull ItemStack item, @Nonnull EntityPlayer player, @Nonnull List list, boolean debug) { super.addInformation(item, player, list, debug); NBTTagCompound tagCompound = item.getTagCompound(); if (tagCompound == null || !tagCompound.hasKey(NBT_TELEPORTER_ID)) { - list.add(I18n.translateToLocal("frame.teleport.no_id.0")); - list.add(I18n.translateToLocal("frame.teleport.no_id.1")); + list.add(I18n.format("frame.teleport.no_id.0")); + list.add(I18n.format("frame.teleport.no_id.1")); return; } @@ -98,7 +96,7 @@ public void addInformation(@Nonnull ItemStack item, @Nonnull EntityPlayer player id = id & (0xFFFFF); - StringBuilder builder = new StringBuilder().append(I18n.translateToLocal("frame.teleport.id")).append(": ").append('"'); + StringBuilder builder = new StringBuilder().append(I18n.format("frame.teleport.id")).append(": ").append('"'); String[] words = WordDictionary.getWords(); diff --git a/src/main/java/com/rwtema/funkylocomotion/items/ItemWrench.java b/src/main/java/com/rwtema/funkylocomotion/items/ItemWrench.java index c46569a..0fb693e 100644 --- a/src/main/java/com/rwtema/funkylocomotion/items/ItemWrench.java +++ b/src/main/java/com/rwtema/funkylocomotion/items/ItemWrench.java @@ -6,6 +6,7 @@ import com.rwtema.funkylocomotion.movers.MoverEventHandler; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; +import net.minecraft.client.resources.I18n; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; @@ -16,7 +17,6 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.text.translation.I18n; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @@ -45,10 +45,9 @@ public ItemWrench() { MinecraftForge.EVENT_BUS.register(this); } - @SuppressWarnings("unchecked") @Override @SideOnly(Side.CLIENT) - public void getSubItems(@Nonnull Item item, CreativeTabs tab, List list) { + public void getSubItems(@Nonnull Item item, CreativeTabs tab, List list) { list.add(new ItemStack(item, 1, 0)); list.add(new ItemStack(item, 1, 1)); list.add(new ItemStack(item, 1, 2)); @@ -62,9 +61,9 @@ public boolean doesSneakBypassUse(ItemStack stack, IBlockAccess world, BlockPos @Override public void addInformation(ItemStack stack, EntityPlayer playerIn, List tooltip, boolean advanced) { if (stack.getItemDamage() == metaWrenchEye) - tooltip.add(I18n.translateToLocal("tooltip.funkylocomotion:wrench_eye")); + tooltip.add(I18n.format("tooltip.funkylocomotion:wrench_eye")); else if (stack.getItemDamage() == metaWrenchHammer) - tooltip.add(I18n.translateToLocal("tooltip.funkylocomotion:wrench_hammer")); + tooltip.add(I18n.format("tooltip.funkylocomotion:wrench_hammer")); } @Nonnull @@ -89,7 +88,7 @@ public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, Wor return EnumActionResult.PASS; if (block instanceof BlockStickyFrame) { - state = block.getActualState(state, world, pos); + state = state.getActualState(world, pos); boolean isOpen = state.getValue(BlockStickyFrame.DIR_OPEN_MAP.get(side)); Block otherBlock; @@ -134,7 +133,7 @@ private boolean isInaccessible(World world, EnumFacing side, float hitX, float h if (!blockingBlock.isAir(blockingState, world, blockingPos)) { if (blockingState.getCollisionBoundingBox(world, blockingPos) != null && blockingBlock.canCollideCheck(blockingState, false)) { int face = side.ordinal(); - if (blockingBlock.collisionRayTrace(blockingState, world, blockingPos, + if (blockingState.collisionRayTrace(world, blockingPos, new Vec3d( blockingPos.getX() + (face == 4 ? -0.1 : face == 5 ? 1.1 : hitX), blockingPos.getY() + (face == 0 ? -0.1 : face == 1 ? 1.1 : hitY), @@ -156,8 +155,8 @@ private boolean isInaccessible(World world, EnumFacing side, float hitX, float h @Override public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) { - if (!player.worldObj.isRemote) { - TileEntity tileEntity = player.worldObj.getTileEntity(pos); + if (!player.getEntityWorld().isRemote) { + TileEntity tileEntity = player.getEntityWorld().getTileEntity(pos); if (tileEntity instanceof IMover) { MoverEventHandler.registerMover((IMover) tileEntity); } diff --git a/src/main/java/com/rwtema/funkylocomotion/movers/MoveManager.java b/src/main/java/com/rwtema/funkylocomotion/movers/MoveManager.java index 65c9cc3..3229a8e 100644 --- a/src/main/java/com/rwtema/funkylocomotion/movers/MoveManager.java +++ b/src/main/java/com/rwtema/funkylocomotion/movers/MoveManager.java @@ -17,8 +17,8 @@ import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; import net.minecraft.network.play.server.SPacketBlockChange; +import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.server.management.PlayerChunkMapEntry; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; @@ -55,7 +55,6 @@ public static void startMoving(World world, List posList, EnumFacing d startMoving(world, world, links, dir, maxTime); } - @SuppressWarnings("unchecked") public synchronized static void startMoving(World srcWorld, World dstWorld, List links, @Nullable EnumFacing dir, int maxTime) { String section = "Start"; @@ -109,7 +108,7 @@ public synchronized static void startMoving(World srcWorld, World dstWorld, List Set srcChunks = new HashSet<>(); // HashSet srcWatchingPlayers = new HashSet<>(); - HashSet inventories = new HashSet(); + HashSet inventories = new HashSet<>(); vars.put("srcChunks", srcChunks); // vars.put("srcWatchingPlayers", srcWatchingPlayers); @@ -339,7 +338,7 @@ public synchronized static void startMoving(World srcWorld, World dstWorld, List vars.put("Iterator", tile); PlayerChunkMapEntry watcher = FLNetwork.getChunkWatcher(tile.getWorld(), tile.getPos()); if (watcher != null) { - Packet packet = tile.getUpdatePacket(); + SPacketUpdateTileEntity packet = tile.getUpdatePacket(); vars.put("Iterator2", packet); if (packet != null) watcher.sendPacket(packet); @@ -454,7 +453,7 @@ public static void finishMoving() { section = "Send Update Packets"; for (Chunk chunk : chunks) { vars.put("chunk", chunk); - chunk.isModified = true; + chunk.setModified(true); FLNetwork.updateChunk(chunk); } vars.put("chunk", BLANK); @@ -519,7 +518,9 @@ private static String makeString(Object o, int n) { } } else if (o instanceof Collection) { int i = 0; - Iterator iterator = ((Iterable) o).iterator(); + @SuppressWarnings("unchecked") + Collection c = (Collection) o; + Iterator iterator = c.iterator(); builder.append('\n'); tabs(n, builder); while (iterator.hasNext()) { diff --git a/src/main/java/com/rwtema/funkylocomotion/movers/MoverEventHandler.java b/src/main/java/com/rwtema/funkylocomotion/movers/MoverEventHandler.java index ae5a795..b5fc367 100644 --- a/src/main/java/com/rwtema/funkylocomotion/movers/MoverEventHandler.java +++ b/src/main/java/com/rwtema/funkylocomotion/movers/MoverEventHandler.java @@ -1,7 +1,7 @@ package com.rwtema.funkylocomotion.movers; import com.rwtema.funkylocomotion.helper.WeakSet; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -16,7 +16,7 @@ private MoverEventHandler() { } public static void init() { - FMLCommonHandler.instance().bus().register(new MoverEventHandler()); + MinecraftForge.EVENT_BUS.register(new MoverEventHandler()); } public static void registerFinisher() { diff --git a/src/main/java/com/rwtema/funkylocomotion/network/FLNetwork.java b/src/main/java/com/rwtema/funkylocomotion/network/FLNetwork.java index d1a6360..b9cf016 100644 --- a/src/main/java/com/rwtema/funkylocomotion/network/FLNetwork.java +++ b/src/main/java/com/rwtema/funkylocomotion/network/FLNetwork.java @@ -45,13 +45,13 @@ private static PlayerChunkMap getPlayerManager(World world) { } public static void updateChunk(Chunk chunk) { - World world = chunk.worldObj; + World world = chunk.getWorld(); PlayerChunkMapEntry watcher = getChunkWatcher(chunk, world); if (watcher != null) watcher.update(); } public static PlayerChunkMapEntry getChunkWatcher(Chunk chunk) { - return getChunkWatcher(chunk, chunk.worldObj); + return getChunkWatcher(chunk, chunk.getWorld()); } public static PlayerChunkMapEntry getChunkWatcher(Chunk chunk, World world) { diff --git a/src/main/java/com/rwtema/funkylocomotion/network/MessageClearTile.java b/src/main/java/com/rwtema/funkylocomotion/network/MessageClearTile.java index d20034f..2c6ad55 100644 --- a/src/main/java/com/rwtema/funkylocomotion/network/MessageClearTile.java +++ b/src/main/java/com/rwtema/funkylocomotion/network/MessageClearTile.java @@ -69,7 +69,7 @@ public void handlePacket(MessageContext ctx) { clientWorld.loadedTileEntityList.remove(tile); Chunk chunk = clientWorld.getChunkFromBlockCoords(pos); - chunk.chunkTileEntityMap.remove(pos); + chunk.getTileEntityMap().remove(pos); tile.invalidate(); if (!FakeWorldClient.isValid(clientWorld)) return; diff --git a/src/main/java/com/rwtema/funkylocomotion/particles/ObstructionHelper.java b/src/main/java/com/rwtema/funkylocomotion/particles/ObstructionHelper.java index 9b3560f..50b8db6 100644 --- a/src/main/java/com/rwtema/funkylocomotion/particles/ObstructionHelper.java +++ b/src/main/java/com/rwtema/funkylocomotion/particles/ObstructionHelper.java @@ -13,10 +13,16 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import net.minecraftforge.fml.relauncher.ReflectionHelper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import java.lang.reflect.Field; +import java.util.List; + public class ObstructionHelper { + private static final Field field_PlayerChunkMapEntry_players = ReflectionHelper.findField(PlayerChunkMapEntry.class, "field_187283_c", "players"); + @SideOnly(Side.CLIENT) public static boolean shouldRenderParticles() { return playerHoldingWrench(Minecraft.getMinecraft().thePlayer); @@ -31,13 +37,25 @@ private static boolean isEyeWrench(ItemStack heldItem) { heldItem.getItem() == FunkyLocomotion.wrench && heldItem.getItemDamage() == ItemWrench.metaWrenchEye; } + @SuppressWarnings("unchecked") public static boolean sendObstructionPacket(World world, BlockPos pos, EnumFacing dir) { PlayerChunkMapEntry chunkWatcher = FLNetwork.getChunkWatcher(world, pos); if (chunkWatcher == null) return false; - Packet packet = null; + Packet packet = null; + + List players; + try + { + players = (List) field_PlayerChunkMapEntry_players.get(chunkWatcher); + } + catch (IllegalArgumentException | IllegalAccessException e) + { + return false; + } - for (EntityPlayerMP player : chunkWatcher.players) { + //for (EntityPlayerMP player : chunkWatcher.players) { + for (EntityPlayerMP player : players) { if (playerHoldingWrench(player)) { if (packet == null) packet = FLNetwork.net.getPacketFrom(new MessageObstruction(pos, dir)); player.connection.sendPacket(packet); diff --git a/src/main/java/com/rwtema/funkylocomotion/rendering/PassHandler.java b/src/main/java/com/rwtema/funkylocomotion/rendering/PassHandler.java index 54e04c3..cd28fed 100644 --- a/src/main/java/com/rwtema/funkylocomotion/rendering/PassHandler.java +++ b/src/main/java/com/rwtema/funkylocomotion/rendering/PassHandler.java @@ -1,5 +1,6 @@ package com.rwtema.funkylocomotion.rendering; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.BlockRenderLayer; import org.lwjgl.opengl.GL11; @@ -13,8 +14,8 @@ public enum PassHandler { ONE(1, BlockRenderLayer.TRANSLUCENT) { @Override public void setupRendering() { - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } }; diff --git a/src/main/java/com/rwtema/funkylocomotion/rendering/TESRMoving.java b/src/main/java/com/rwtema/funkylocomotion/rendering/TESRMoving.java index 6e378e3..f662adf 100644 --- a/src/main/java/com/rwtema/funkylocomotion/rendering/TESRMoving.java +++ b/src/main/java/com/rwtema/funkylocomotion/rendering/TESRMoving.java @@ -12,6 +12,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; @@ -33,7 +34,7 @@ public final void renderTileEntityAt(TileMovingClient te, double x, double y, do RenderHelper.disableStandardItemLighting(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.enableBlend(); - GlStateManager.disableCull(); + GlStateManager.enableCull(); if (Minecraft.isAmbientOcclusionEnabled()) { GlStateManager.shadeModel(GL11.GL_SMOOTH); @@ -41,11 +42,9 @@ public final void renderTileEntityAt(TileMovingClient te, double x, double y, do GlStateManager.shadeModel(GL11.GL_FLAT); } - renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, renderer); renderer.setTranslation(0, 0, 0); - RenderHelper.enableStandardItemLighting(); } @@ -53,7 +52,6 @@ public final void renderTileEntityAt(TileMovingClient te, double x, double y, do @Override public void renderTileEntityFast(TileMovingClient te, double x, double y, double z, float partialTicks, int destroyStage, VertexBuffer renderer) { if (blockRenderer == null) blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); - BlockPos pos1 = te.getPos(); if (!te.init) return; @@ -69,13 +67,13 @@ public void renderTileEntityFast(TileMovingClient te, double x, double y, double if (dir == -1) { return; } -// + this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); boolean flag = false; int pass = MinecraftForgeClient.getRenderPass(); if (te.render && te.getState().getRenderType() != EnumBlockRenderType.INVISIBLE) { - GL11.glPushMatrix(); + GlStateManager.pushMatrix(); renderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); setupTranslations(x, y, z, te, h, dir, renderer); flag = renderStatic(te, pass, renderer); @@ -97,8 +95,8 @@ public void renderTileEntityFast(TileMovingClient te, double x, double y, double } tessellator.draw(); - GL11.glPopMatrix(); - GL11.glEnable(GL11.GL_CULL_FACE); + GlStateManager.popMatrix(); + GlStateManager.enableCull(); } flag = flag | renderDynamic(x, y, z, partialTicks, te, h, dir, pass, renderer); @@ -124,13 +122,13 @@ protected boolean renderDynamic(double x, double y, double z, float f, TileMovin } fakeWorldClient.dir_id = mover.dir; - TileEntitySpecialRenderer specialRenderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(mover.tile); + TileEntitySpecialRenderer specialRenderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(mover.tile); if (specialRenderer == null) return false; if (!mover.tile.shouldRenderInPass(pass)) return false; - GL11.glPushMatrix(); + GlStateManager.pushMatrix(); setupTranslations(x, y, z, mover, h, dir, renderer); try { WorldClient prevWorld1 = Minecraft.getMinecraft().theWorld; @@ -168,7 +166,7 @@ protected boolean renderDynamic(double x, double y, double z, float f, TileMovin mover.render = false; } - GL11.glPopMatrix(); + GlStateManager.popMatrix(); return true; } @@ -177,7 +175,7 @@ private void setupTranslations(double x, double y, double z, TileMovingClient mo if (dir < 6) { EnumFacing dir1 = EnumFacing.values()[dir]; renderer.setTranslation(0, 0, 0); - GL11.glTranslated((x - pos.getX() + dir1.getFrontOffsetX() * h), + GlStateManager.translate((x - pos.getX() + dir1.getFrontOffsetX() * h), (y - pos.getY() + dir1.getFrontOffsetY() * h), (z - pos.getZ() + dir1.getFrontOffsetZ() * h)); // renderer.setTranslation( @@ -186,12 +184,12 @@ private void setupTranslations(double x, double y, double z, TileMovingClient mo // z - pos.getZ() + dir1.getFrontOffsetZ() * h); } else { renderer.setTranslation(0, 0, 0); - GL11.glTranslated(x, y, z); - GL11.glTranslated(0.5, 0.5, 0.5); + GlStateManager.translate(x, y, z); + GlStateManager.translate(0.5, 0.5, 0.5); double dh = dir == 6 ? h + 1 : -h; - GL11.glScaled(dh, dh, dh); - GL11.glTranslated(-0.5, -0.5, -0.5); - GL11.glTranslated(-pos.getX(), -pos.getY(), -pos.getZ()); + GlStateManager.scale(dh, dh, dh); + GlStateManager.translate(-0.5, -0.5, -0.5); + GlStateManager.translate(-pos.getX(), -pos.getY(), -pos.getZ()); } } diff --git a/src/main/resources/META-INF/funkylocomotion_at.cfg b/src/main/resources/META-INF/funkylocomotion_at.cfg index f0245ff..8d0011d 100644 --- a/src/main/resources/META-INF/funkylocomotion_at.cfg +++ b/src/main/resources/META-INF/funkylocomotion_at.cfg @@ -1,10 +1,10 @@ #Main Forge Access Transformer configuration file #Chunk -public net.minecraft.world.chunk.Chunk func_76615_h(III)V -public net.minecraft.world.chunk.Chunk func_76595_e(II)V -public net.minecraft.world.chunk.Chunk * +#public net.minecraft.world.chunk.Chunk func_76615_h(III)V +#public net.minecraft.world.chunk.Chunk func_76595_e(II)V +#public net.minecraft.world.chunk.Chunk * -public net.minecraft.server.management.PlayerChunkMapEntry * +#public net.minecraft.server.management.PlayerChunkMapEntry * #Chunk Watcher #public net.minecraft.server.management.PlayerManager$PlayerInstance @@ -30,62 +30,62 @@ public net.minecraft.server.management.PlayerChunkMapEntry * #GLStateManager -public net.minecraft.client.renderer.GlStateManager * -public net.minecraft.client.renderer.GlStateManager$AlphaState -public net.minecraft.client.renderer.GlStateManager$BlendState -public net.minecraft.client.renderer.GlStateManager$BooleanState -public net.minecraft.client.renderer.GlStateManager$ClearState -public net.minecraft.client.renderer.GlStateManager$Color -public net.minecraft.client.renderer.GlStateManager$ColorLogicState -public net.minecraft.client.renderer.GlStateManager$ColorMask -public net.minecraft.client.renderer.GlStateManager$ColorMaterialState -public net.minecraft.client.renderer.GlStateManager$CullState -public net.minecraft.client.renderer.GlStateManager$DepthState -public net.minecraft.client.renderer.GlStateManager$FogState -public net.minecraft.client.renderer.GlStateManager$PolygonOffsetState -public net.minecraft.client.renderer.GlStateManager$StencilFunc -public net.minecraft.client.renderer.GlStateManager$StencilState -public net.minecraft.client.renderer.GlStateManager$TexGenCoord -public net.minecraft.client.renderer.GlStateManager$TexGenState -public net.minecraft.client.renderer.GlStateManager$TextureState - -public net.minecraft.client.renderer.GlStateManager$AlphaState * -public net.minecraft.client.renderer.GlStateManager$BlendState * -public net.minecraft.client.renderer.GlStateManager$BooleanState * -public net.minecraft.client.renderer.GlStateManager$ClearState * -public net.minecraft.client.renderer.GlStateManager$Color * -public net.minecraft.client.renderer.GlStateManager$ColorLogicState * -public net.minecraft.client.renderer.GlStateManager$ColorMask * -public net.minecraft.client.renderer.GlStateManager$ColorMaterialState * -public net.minecraft.client.renderer.GlStateManager$CullState * -public net.minecraft.client.renderer.GlStateManager$DepthState * -public net.minecraft.client.renderer.GlStateManager$FogState * -public net.minecraft.client.renderer.GlStateManager$PolygonOffsetState * -public net.minecraft.client.renderer.GlStateManager$StencilFunc * -#public net.minecraft.client.renderer.GlStateManager$StenincilState * -public net.minecraft.client.renderer.GlStateManager$TexGenCoord * -public net.minecraft.client.renderer.GlStateManager$TexGenState * -public net.minecraft.client.renderer.GlStateManager$TextureState * +#public net.minecraft.client.renderer.GlStateManager * +#public net.minecraft.client.renderer.GlStateManager$AlphaState +#public net.minecraft.client.renderer.GlStateManager$BlendState +#public net.minecraft.client.renderer.GlStateManager$BooleanState +#public net.minecraft.client.renderer.GlStateManager$ClearState +#public net.minecraft.client.renderer.GlStateManager$Color +#public net.minecraft.client.renderer.GlStateManager$ColorLogicState +#public net.minecraft.client.renderer.GlStateManager$ColorMask +#public net.minecraft.client.renderer.GlStateManager$ColorMaterialState +#public net.minecraft.client.renderer.GlStateManager$CullState +#public net.minecraft.client.renderer.GlStateManager$DepthState +#public net.minecraft.client.renderer.GlStateManager$FogState +#public net.minecraft.client.renderer.GlStateManager$PolygonOffsetState +#public net.minecraft.client.renderer.GlStateManager$StencilFunc +#public net.minecraft.client.renderer.GlStateManager$StencilState +#public net.minecraft.client.renderer.GlStateManager$TexGenCoord +#public net.minecraft.client.renderer.GlStateManager$TexGenState +#public net.minecraft.client.renderer.GlStateManager$TextureState + +#public net.minecraft.client.renderer.GlStateManager$AlphaState * +#public net.minecraft.client.renderer.GlStateManager$BlendState * +#public net.minecraft.client.renderer.GlStateManager$BooleanState * +#public net.minecraft.client.renderer.GlStateManager$ClearState * +#public net.minecraft.client.renderer.GlStateManager$Color * +#public net.minecraft.client.renderer.GlStateManager$ColorLogicState * +#public net.minecraft.client.renderer.GlStateManager$ColorMask * +#public net.minecraft.client.renderer.GlStateManager$ColorMaterialState * +#public net.minecraft.client.renderer.GlStateManager$CullState * +#public net.minecraft.client.renderer.GlStateManager$DepthState * +#public net.minecraft.client.renderer.GlStateManager$FogState * +#public net.minecraft.client.renderer.GlStateManager$PolygonOffsetState * +#public net.minecraft.client.renderer.GlStateManager$StencilFunc * +##public net.minecraft.client.renderer.GlStateManager$StenincilState * +#public net.minecraft.client.renderer.GlStateManager$TexGenCoord * +#public net.minecraft.client.renderer.GlStateManager$TexGenState * +#public net.minecraft.client.renderer.GlStateManager$TextureState * #InventoryCrafting -public net.minecraft.inventory.InventoryCrafting * +#public net.minecraft.inventory.InventoryCrafting * #Minecraft -public net.minecraft.client.Minecraft field_71467_ac +#public net.minecraft.client.Minecraft field_71467_ac #EntityItem -public net.minecraft.entity.item.EntityItem func_70289_a(Lnet/minecraft/entity/item/EntityItem;)Z +#public net.minecraft.entity.item.EntityItem func_70289_a(Lnet/minecraft/entity/item/EntityItem;)Z #TextureAtlasSprite -public net.minecraft.client.renderer.texture.TextureAtlasSprite.field_110982_k -public net.minecraft.client.renderer.texture.TextureAtlasSprite.func_130099_d(I)V -public net.minecraft.client.renderer.texture.TextureAtlasSprite.func_180599_n()V -public net.minecraft.client.renderer.texture.TextureAtlasSprite.func_147962_a([[IIII)[[I +#public net.minecraft.client.renderer.texture.TextureAtlasSprite.field_110982_k +#public net.minecraft.client.renderer.texture.TextureAtlasSprite.func_130099_d(I)V +#public net.minecraft.client.renderer.texture.TextureAtlasSprite.func_180599_n()V +#public net.minecraft.client.renderer.texture.TextureAtlasSprite.func_147962_a([[IIII)[[I #rendering -public net.minecraft.client.renderer.RenderItem func_175035_a(Lnet/minecraft/client/renderer/block/model/IBakedModel;I)V # renderModel -public net.minecraft.client.renderer.RenderItem func_175036_a(Lnet/minecraft/client/renderer/block/model/IBakedModel;Lnet/minecraft/item/ItemStack;)V # renderModel +#public net.minecraft.client.renderer.RenderItem func_175035_a(Lnet/minecraft/client/renderer/block/model/IBakedModel;I)V # renderModel +#public net.minecraft.client.renderer.RenderItem func_175036_a(Lnet/minecraft/client/renderer/block/model/IBakedModel;Lnet/minecraft/item/ItemStack;)V # renderModel