From 16ccb2ee4646bd0d5f3ecb6047c1c2d6fcb952ae Mon Sep 17 00:00:00 2001 From: PrototypeTrousers Date: Tue, 8 Nov 2022 23:05:41 -0300 Subject: [PATCH] Fix blocks connecting to ME cables. Give boost to chisel facades --- gradle/scripts/dependencies.gradle | 2 + .../block/networking/BlockCableBus.java | 25 ++++++++++ .../chisel/ChiselBlockSpeedHandler.java | 49 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 src/main/java/appeng/integration/modules/chisel/ChiselBlockSpeedHandler.java diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index 32ab58b60..cf5a82485 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -83,6 +83,8 @@ dependencies { // installable runtime dependencies deobfCompile "curse.maven:gregtechceu-557242:3949406" + compileOnly "curse.maven:chisel-235279:2915375" + //mods "mcp.mobius.waila:Hwyla:${hwyla_version}" mods "curse.maven:hwyla-253449:2568751" mods "net.industrial-craft:industrialcraft-2:${ic2_version}:dev" diff --git a/src/main/java/appeng/block/networking/BlockCableBus.java b/src/main/java/appeng/block/networking/BlockCableBus.java index 9dfb76a8e..c7f8b9c59 100644 --- a/src/main/java/appeng/block/networking/BlockCableBus.java +++ b/src/main/java/appeng/block/networking/BlockCableBus.java @@ -44,6 +44,7 @@ import appeng.tile.networking.TileCableBusTESR; import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; +import net.minecraft.block.state.BlockFaceShape; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -413,6 +414,30 @@ public class BlockCableBus extends AEBaseTileBlock implements IAEFacade { return world.getBlockState(pos); } + @Override + public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing side) { + IFacadeContainer container = this.fc(world, pos); + if (container != null) { + IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(side)); + if (facade != null) { + return BlockFaceShape.SOLID; + } + } + return BlockFaceShape.UNDEFINED; + } + + @Override + public void onEntityWalk(World world, BlockPos pos, Entity entityIn) { + IFacadeContainer container = this.fc(world, pos); + if (container != null) { + IFacadePart facade = container.getFacade(AEPartLocation.fromFacing(EnumFacing.UP)); + if (facade != null) { + facade.getBlockState().getBlock().onEntityWalk(world, pos, entityIn); + } + } + super.onEntityWalk(world, pos, entityIn); + } + public static Class getNoTesrTile() { return noTesrTile; } diff --git a/src/main/java/appeng/integration/modules/chisel/ChiselBlockSpeedHandler.java b/src/main/java/appeng/integration/modules/chisel/ChiselBlockSpeedHandler.java new file mode 100644 index 000000000..21005a8cf --- /dev/null +++ b/src/main/java/appeng/integration/modules/chisel/ChiselBlockSpeedHandler.java @@ -0,0 +1,49 @@ +package appeng.integration.modules.chisel; + +import appeng.block.networking.BlockCableBus; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.MovementInput; +import net.minecraft.util.MovementInputFromOptions; +import net.minecraft.util.math.BlockPos; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Optional; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import team.chisel.common.config.Configurations; + +import static team.chisel.client.handler.BlockSpeedHandler.speedupBlocks; + +@Mod.EventBusSubscriber(Side.CLIENT) +public class ChiselBlockSpeedHandler { + @SideOnly(Side.CLIENT) + private static MovementInput manualInputCheck; + + @Optional.Method(modid = "chisel") + @SubscribeEvent + @SideOnly(Side.CLIENT) + public static void speedupPlayer(TickEvent.PlayerTickEvent event) { + if (event.phase == TickEvent.Phase.START && event.side.isClient() && event.player.onGround && event.player instanceof EntityPlayerSP) { + if (manualInputCheck == null) { + manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); + } + EntityPlayerSP player = (EntityPlayerSP) event.player; + BlockPos blockPosBelow = new BlockPos(player.posX, player.posY - (1 / 16D), player.posZ); + IBlockState below = player.getEntityWorld().getBlockState(blockPosBelow); + if (below.getBlock() instanceof BlockCableBus) { + IBlockState f = ((BlockCableBus) below.getBlock()).getFacadeState(Minecraft.getMinecraft().world, blockPosBelow, EnumFacing.UP); + if (speedupBlocks.contains(f.getBlock())) { + manualInputCheck.updatePlayerMoveState(); + if ((manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) && !player.isInWater()) { + player.motionX *= Configurations.concreteVelocityMult; + player.motionZ *= Configurations.concreteVelocityMult; + } + } + } + } + } +}