GT6 style concrete speedup (no soulsand like behavior that blocks you from entrances and less OP ice hyperspeed highways)

This commit is contained in:
Blood-Asp 2017-11-25 22:41:41 +01:00
parent 0305f8626e
commit b96180ac4f
3 changed files with 34 additions and 2 deletions

View file

@ -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);
}

View file

@ -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) {

View file

@ -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);
}
**/
}