From b96180ac4f1564bcb7a2e19d16738cfea7fc04a3 Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sat, 25 Nov 2017 22:41:41 +0100 Subject: [PATCH] GT6 style concrete speedup (no soulsand like behavior that blocks you from entrances and less OP ice hyperspeed highways) --- .../gregtech/api/interfaces/IBlockOnWalkOver.java | 8 ++++++++ src/main/java/gregtech/common/GT_Proxy.java | 13 +++++++++++++ .../common/blocks/GT_Block_Concretes.java | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 src/main/java/gregtech/api/interfaces/IBlockOnWalkOver.java diff --git a/src/main/java/gregtech/api/interfaces/IBlockOnWalkOver.java b/src/main/java/gregtech/api/interfaces/IBlockOnWalkOver.java new file mode 100644 index 00000000..a2e7858f --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/IBlockOnWalkOver.java @@ -0,0 +1,8 @@ +package gregtech.api.interfaces; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.world.World; + +public interface IBlockOnWalkOver { + public void onWalkOver(EntityLivingBase aEntity, World aWorld, int aX, int aY, int aZ); +} \ No newline at end of file diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index fa425d5b..bba3c16f 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -11,6 +11,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.interfaces.IBlockOnWalkOver; import gregtech.api.interfaces.IProjectileItem; import gregtech.api.interfaces.internal.IGT_Mod; import gregtech.api.interfaces.internal.IThaumcraftCompat; @@ -25,6 +26,7 @@ import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.items.GT_MetaGenerated_Tool_01; import gregtech.common.items.armor.ModularArmor_Item; import gregtech.common.items.armor.gui.*; +import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; @@ -45,6 +47,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraft.world.WorldSettings.GameType; @@ -53,6 +56,7 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.EnderTeleportEvent; +import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -1197,6 +1201,15 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { e.printStackTrace(GT_Log.err); } } + + @SubscribeEvent + public void onLivingUpdate(LivingUpdateEvent aEvent) { + if (aEvent.entityLiving.onGround) { + int tX = MathHelper.floor_double(aEvent.entityLiving.posX), tY = MathHelper.floor_double(aEvent.entityLiving.boundingBox.minY-0.001F), tZ = MathHelper.floor_double(aEvent.entityLiving.posZ); + Block tBlock = aEvent.entityLiving.worldObj.getBlock(tX, tY, tZ); + if (tBlock instanceof IBlockOnWalkOver) ((IBlockOnWalkOver)tBlock).onWalkOver(aEvent.entityLiving, aEvent.entityLiving.worldObj, tX, tY, tZ); + } + } @SubscribeEvent public void onFluidContainerRegistration(FluidContainerRegistry.FluidContainerRegisterEvent aFluidEvent) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java index 06f7feaa..5ef3f38b 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java @@ -2,6 +2,7 @@ package gregtech.common.blocks; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IBlockOnWalkOver; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.block.Block; @@ -16,11 +17,11 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.IFluidBlock; public class GT_Block_Concretes - extends GT_Block_Stones_Abstract { + extends GT_Block_Stones_Abstract implements IBlockOnWalkOver{ public GT_Block_Concretes() { super(GT_Item_Concretes.class, "gt.blockconcretes"); setResistance(20.0F); - this.slipperiness = 0.9F; + //this.slipperiness = 0.9F; GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Dark Concrete"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Dark Concrete Cobblestone"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Dark Concrete Cobblestone"); @@ -70,6 +71,15 @@ public class GT_Block_Concretes return gregtech.api.enums.Textures.BlockIcons.CONCRETES[0].getIcon(); } + @Override + public void onWalkOver(EntityLivingBase aEntity, World aWorld, int aX, int aY, int aZ) { + if ((aEntity.motionX != 0 || aEntity.motionZ != 0) && !aEntity.isInWater() && !aEntity.isWet() && !aEntity.isSneaking()) { + double tSpeed = (aWorld.getBlock(aX, aY-1, aZ).slipperiness >= 0.8 ? 1.5 : 1.2); + aEntity.motionX *= tSpeed; aEntity.motionZ *= tSpeed; + } + } + + /** public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { Block tBlock = aWorld.getBlock(aX, aY + 1, aZ); if (((aEntity instanceof EntityLivingBase)) && (!(tBlock instanceof IFluidBlock)) && (!(tBlock instanceof BlockLiquid)) && (aEntity.onGround) && (!aEntity.isInWater()) && (!aEntity.isWet())) { @@ -92,4 +102,5 @@ public class GT_Block_Concretes } return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 0.875D, aZ + 1); } + **/ }