mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
Introduce an attribute for step height additions (#8389)
This commit is contained in:
1 parent
c34094ea50
commit
9a11201a9e
9 files changed
+110
-2
No files matched your search
@@ -93,6 +93,7 @@ public class ForgeMod
|
||||
public static final RegistryObject<Attribute> ENTITY_GRAVITY = ATTRIBUTES.register("entity_gravity", () -> new RangedAttribute("forge.entity_gravity", 0.08D, -8.0D, 8.0D).setSyncable(true));
|
||||
|
||||
public static final RegistryObject<Attribute> REACH_DISTANCE = ATTRIBUTES.register("reach_distance", () -> new RangedAttribute("generic.reachDistance", 5.0D, 0.0D, 1024.0D).setSyncable(true));
|
||||
public static final RegistryObject<Attribute> STEP_HEIGHT_ADDITION = ATTRIBUTES.register("step_height_addition", () -> new RangedAttribute("forge.stepHeight", 0.0D, -512.0D, 512.0D).setSyncable(true));
|
||||
|
||||
private static boolean enableMilkFluid = false;
|
||||
public static final RegistryObject<Fluid> MILK = RegistryObject.create(new ResourceLocation("milk"), ForgeRegistries.FLUIDS);
|
||||
|
||||
@@ -8,6 +8,7 @@ package net.minecraftforge.common.extensions;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@@ -19,6 +20,7 @@ import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.ForgeSpawnEggItem;
|
||||
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
|
||||
import net.minecraftforge.entity.PartEntity;
|
||||
@@ -189,4 +191,22 @@ public interface IForgeEntity extends ICapabilitySerializable<CompoundTag>
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@return Return the height in blocks the Entity can step up without needing to jump}
|
||||
* This is the sum of vanilla's {@link Entity#maxUpStep} field and the current value
|
||||
* of the {@link net.minecraftforge.common.ForgeMod#STEP_HEIGHT_ADDITION} attribute,
|
||||
* (if this Entity is a {@link LivingEntity}), clamped at 0.
|
||||
*/
|
||||
default float getStepHeight()
|
||||
{
|
||||
var vanillaStep = self().maxUpStep;
|
||||
if (self() instanceof LivingEntity living)
|
||||
{
|
||||
return (float) Math.max(0, vanillaStep + living.getAttributeValue(ForgeMod.STEP_HEIGHT_ADDITION.get()));
|
||||
} else
|
||||
{
|
||||
return vanillaStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user