diff --git a/src/main/java/team/chisel/block/BlockConcrete.java b/src/main/java/team/chisel/block/BlockConcrete.java index 32ba888e..5cb40c04 100644 --- a/src/main/java/team/chisel/block/BlockConcrete.java +++ b/src/main/java/team/chisel/block/BlockConcrete.java @@ -1,35 +1,45 @@ package team.chisel.block; -import team.chisel.client.GeneralChiselClient; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovementInput; +import net.minecraft.util.MovementInputFromOptions; import team.chisel.config.Configurations; -import net.minecraft.entity.Entity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class BlockConcrete extends BlockCarvable { public BlockConcrete() { super(); + FMLCommonHandler.instance().bus().register(this); } - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { - if (Configurations.fullBlockConcrete) - return AxisAlignedBB.getBoundingBox(par2, par3, par4, (par2 + 1), ((par3 + 1)), (par4 + 1)); - else - return AxisAlignedBB.getBoundingBox(par2, par3, par4, (par2 + 1), ((par3 + 1) - 0.125F), (par4 + 1)); + @SideOnly(Side.CLIENT) + private static MovementInput manualInputCheck; + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void speedupPlayer(PlayerTickEvent event) { + if (event.phase == Phase.START && event.side.isClient() && event.player.onGround) { + if (manualInputCheck == null) { + manualInputCheck = new MovementInputFromOptions(Minecraft.getMinecraft().gameSettings); + } + EntityPlayerSP player = (EntityPlayerSP) event.player; + Block below = player.worldObj.getBlock(MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY) - 2, MathHelper.floor_double(player.posZ)); + if (below == this) { + manualInputCheck.updatePlayerMoveState(); + if (manualInputCheck.moveForward != 0 || manualInputCheck.moveStrafe != 0) { + player.motionX *= Configurations.concreteVelocityMult + 0.05; + player.motionZ *= Configurations.concreteVelocityMult + 0.05; + } + } + } } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { - if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) - return; - if (Configurations.concreteVelocity == 0) - return; - - GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity); - } - } diff --git a/src/main/java/team/chisel/client/GeneralChiselClient.java b/src/main/java/team/chisel/client/GeneralChiselClient.java index bd54ea65..5cc2f71a 100644 --- a/src/main/java/team/chisel/client/GeneralChiselClient.java +++ b/src/main/java/team/chisel/client/GeneralChiselClient.java @@ -2,6 +2,13 @@ package team.chisel.client; import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.client.particle.EntityDiggingFX; +import net.minecraft.client.particle.EntityLavaFX; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import team.chisel.block.BlockGrimstone; import team.chisel.block.BlockHolystone; import team.chisel.block.BlockLavastone; @@ -14,15 +21,6 @@ import team.chisel.entity.fx.EntityGrimstoneFX; import team.chisel.entity.fx.EntityHolystoneFX; import team.chisel.entity.fx.EntitySnakestoneObsidianFX; import team.chisel.utils.GeneralClient; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.particle.EffectRenderer; -import net.minecraft.client.particle.EntityDiggingFX; -import net.minecraft.client.particle.EntityLavaFX; -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class GeneralChiselClient { @@ -236,25 +234,6 @@ public class GeneralChiselClient { GeneralClient.playChiselSound(world, x, y, z, sound); } - public static void speedupPlayer(World world, Entity entity, double concreteVelocity) { - double velocity = Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ); - - if (!(entity instanceof EntityPlayerSP)) - return; - if (velocity == 0) - return; - if (velocity >= Configurations.concreteVelocity) - return; - - EntityPlayerSP player = (EntityPlayerSP) entity; - - if (Math.abs(player.movementInput.moveForward) < 0.75f && Math.abs(player.movementInput.moveStrafe) < 0.75f) - return; - - entity.motionX = Configurations.concreteVelocity * entity.motionX / velocity; - entity.motionZ = Configurations.concreteVelocity * entity.motionZ / velocity; - } - public static void spawnAutoChiselFX(TileEntityAutoChisel te, ItemStack base) { if (base != null && Minecraft.getMinecraft().gameSettings.particleSetting == 0) { for (int i = 0; i < 10; i++) { diff --git a/src/main/java/team/chisel/config/Configurations.java b/src/main/java/team/chisel/config/Configurations.java index e843817e..52ea33e5 100644 --- a/src/main/java/team/chisel/config/Configurations.java +++ b/src/main/java/team/chisel/config/Configurations.java @@ -17,7 +17,7 @@ public class Configurations { public static boolean configExists; - public static double concreteVelocity; + public static double concreteVelocityMult; public static boolean ghostCloud; public static int factoryBlockAmount; public static boolean allowMossy; @@ -65,8 +65,7 @@ public class Configurations { /* general */ category = "general"; - concreteVelocity = config.get(category, "concreteVelocity", 0.45, - "Traversing concrete roads, players will acceleration to this velocity. For reference, normal running speed is about 0.28. Set to 0 to disable acceleration.").getDouble(0.45); + concreteVelocityMult = config.get(category, "concreteVelocityMult", 1.35, "The factor that concrete increases your velocity. Default is 1.35, set to 1 for no change.").getDouble(); fullBlockConcrete = config.get(category, "fullBlockConcrete", false, "Should concrete be a full block. This will also unavoidably disable speed increase if set to true.").getBoolean(false); ghostCloud = config.get(category, "doesCloudRenderLikeGhost", true).getBoolean(true); factoryBlockAmount = config.get(category, "amountYouGetFromFactoryBlockCrafting", 32).getInt(32);