mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
More 1.21.2/3 updates
This commit is contained in:
parent
d2c4b85965
commit
914f149667
10 changed files with 135 additions and 94 deletions
|
@ -13,7 +13,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
|||
import net.minecraft.entity.vehicle.BoatEntity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class AirBalloonEntityModel extends EntityModel<AirBalloonEntity> {
|
||||
public class AirBalloonEntityModel extends EntityModel<AirBalloonEntityRenderer.State> {
|
||||
|
||||
private final ModelPart root;
|
||||
private ModelPart main;
|
||||
|
@ -29,6 +29,7 @@ public class AirBalloonEntityModel extends EntityModel<AirBalloonEntity> {
|
|||
private final List<ModelPart> sandbags;
|
||||
|
||||
public AirBalloonEntityModel(ModelPart root) {
|
||||
super(root);
|
||||
this.root = root;
|
||||
isBurner = root.hasChild("burner");
|
||||
isSandbags = root.hasChild("sandbag_ne");
|
||||
|
|
|
@ -7,14 +7,17 @@ import java.util.function.Predicate;
|
|||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.entity.collision.MultiBox;
|
||||
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity;
|
||||
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity.BalloonDesign;
|
||||
import com.minelittlepony.unicopia.entity.mob.AirBalloonEntity.BasketType;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.WorldRenderer;
|
||||
import net.minecraft.client.render.VertexRendering;
|
||||
import net.minecraft.client.render.entity.*;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Colors;
|
||||
|
@ -22,66 +25,109 @@ import net.minecraft.util.Hand;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class AirBalloonEntityRenderer extends MobEntityRenderer<AirBalloonEntity, AirBalloonEntityModel> {
|
||||
public class AirBalloonEntityRenderer extends MobEntityRenderer<AirBalloonEntity, AirBalloonEntityRenderer.State, AirBalloonEntityModel> {
|
||||
public AirBalloonEntityRenderer(EntityRendererFactory.Context context) {
|
||||
super(context, new AirBalloonEntityModel(AirBalloonEntityModel.getBasketModelData().createModel()), 0);
|
||||
addFeature(new BalloonFeature(new AirBalloonEntityModel(AirBalloonEntityModel.getBurnerModelData().createModel()), this,
|
||||
AirBalloonEntity::hasBurner, e -> {
|
||||
return getComponentTexture(e.getStackInHand(Hand.MAIN_HAND).isOf(Items.SOUL_LANTERN) ? "soul_burner" : "burner");
|
||||
}, (light, entity) -> entity.isAscending() ? 0xFF00FF : light));
|
||||
i -> i.hasBurner, e -> {
|
||||
return getComponentTexture(e.hasSoulFlame ? "soul_burner" : "burner");
|
||||
}, (light, entity) -> entity.isAscending ? 0xFF00FF : light));
|
||||
addFeature(new BalloonFeature(new AirBalloonEntityModel(AirBalloonEntityModel.getCanopyModelData().createModel()), this,
|
||||
AirBalloonEntity::hasBalloon,
|
||||
e -> getComponentTexture("canopy/" + e.getDesign().asString()),
|
||||
(light, entity) -> entity.hasBurner() && entity.isAscending() ? light | 0x00005F : light)
|
||||
i -> i.hasBalloon,
|
||||
e -> getComponentTexture("canopy/" + e.design.asString()),
|
||||
(light, entity) -> entity.hasBurner && entity.isAscending ? light | 0x00005F : light)
|
||||
);
|
||||
addFeature(new BalloonFeature(new AirBalloonEntityModel(AirBalloonEntityModel.getSandbagsModelData().createModel()),
|
||||
this, e -> e.hasBalloon() && e.getInflation(1) >= 1, e -> getComponentTexture("sandbags"),
|
||||
(light, entity) -> entity.hasBurner() && entity.isAscending() ? light | 0x00003F : light));
|
||||
this, e -> e.hasBalloon && e.inflation >= 1, e -> getComponentTexture("sandbags"),
|
||||
(light, entity) -> entity.hasBurner && entity.isAscending ? light | 0x00003F : light));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(AirBalloonEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertices, int light) {
|
||||
public void render(State entity, MatrixStack matrices, VertexConsumerProvider vertices, int light) {
|
||||
matrices.push();
|
||||
if (entity.hurtTime > 0) {
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(entity.age + tickDelta) * 3));
|
||||
if (entity.hurt) {
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(MathHelper.sin(entity.age) * 3));
|
||||
}
|
||||
super.render(entity, yaw, tickDelta, matrices, vertices, light);
|
||||
super.render(entity, matrices, vertices, light);
|
||||
matrices.pop();
|
||||
|
||||
if (MinecraftClient.getInstance().getEntityRenderDispatcher().shouldRenderHitboxes() && !entity.isInvisible() && !MinecraftClient.getInstance().hasReducedDebugInfo()) {
|
||||
MultiBox.forEach(entity.getBoundingBox(), box -> {
|
||||
WorldRenderer.drawBox(matrices, vertices.getBuffer(RenderLayer.getLines()), box.offset(entity.getPos().multiply(-1)), 1, 1, 1, 1);
|
||||
if (MinecraftClient.getInstance().getEntityRenderDispatcher().shouldRenderHitboxes() && !entity.invisible && !MinecraftClient.getInstance().hasReducedDebugInfo()) {
|
||||
MultiBox.forEach(entity.boundingBox, box -> {
|
||||
VertexRendering.drawBox(matrices, vertices.getBuffer(RenderLayer.getLines()), box.offset(entity.pos.multiply(-1)), 1, 1, 1, 1);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(AirBalloonEntity entity) {
|
||||
return getComponentTexture("basket/" + entity.getBasketType().id().getPath());
|
||||
public State createRenderState() {
|
||||
return new State();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getLyingAngle(AirBalloonEntity entity) {
|
||||
return 0;
|
||||
public void updateRenderState(AirBalloonEntity entity, State state, float tickDelta) {
|
||||
super.updateRenderState(entity, state, tickDelta);
|
||||
state.design = entity.getDesign();
|
||||
state.basket = entity.getBasketType();
|
||||
state.inflation = entity.getInflation(tickDelta);
|
||||
state.hasBurner = entity.hasBurner();
|
||||
state.hasBalloon = entity.hasBalloon();
|
||||
state.isAscending = entity.isAscending();
|
||||
state.boundingBox = entity.getBoundingBox();
|
||||
state.hasSoulFlame = entity.getStackInHand(Hand.MAIN_HAND).isOf(Items.SOUL_LANTERN);
|
||||
state.pos = entity.getPos();
|
||||
}
|
||||
|
||||
public static class State extends LivingEntityRenderState {
|
||||
public BalloonDesign design;
|
||||
public BasketType basket;
|
||||
|
||||
public float inflation;
|
||||
public boolean hasBurner;
|
||||
public boolean hasBalloon;
|
||||
public boolean isAscending;
|
||||
public boolean hasSoulFlame;
|
||||
public Box boundingBox;
|
||||
public Vec3d pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Box getBoundingBox(AirBalloonEntity entity) {
|
||||
if (entity.hasBalloon()) {
|
||||
return entity.getBalloonBoundingBox().withMinY(entity.getY());
|
||||
}
|
||||
return entity.getInteriorBoundingBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getTexture(State entity) {
|
||||
return getComponentTexture("basket/" + entity.basket.id().getPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float method_3919() {
|
||||
return 90.0F;
|
||||
}
|
||||
|
||||
private Identifier getComponentTexture(String componentName) {
|
||||
return Unicopia.id("textures/entity/air_balloon/" + componentName + ".png");
|
||||
}
|
||||
|
||||
final class BalloonFeature extends FeatureRenderer<AirBalloonEntity, AirBalloonEntityModel> {
|
||||
final class BalloonFeature extends FeatureRenderer<State, AirBalloonEntityModel> {
|
||||
private final AirBalloonEntityModel model;
|
||||
private final Predicate<AirBalloonEntity> visibilityTest;
|
||||
private final Function<AirBalloonEntity, Identifier> textureFunc;
|
||||
private final BiFunction<Integer, AirBalloonEntity, Integer> lightFunc;
|
||||
private final Predicate<State> visibilityTest;
|
||||
private final Function<State, Identifier> textureFunc;
|
||||
private final BiFunction<Integer, State, Integer> lightFunc;
|
||||
|
||||
public BalloonFeature(AirBalloonEntityModel model,
|
||||
FeatureRendererContext<AirBalloonEntity, AirBalloonEntityModel> context,
|
||||
Predicate<AirBalloonEntity> visibilityTest,
|
||||
Function<AirBalloonEntity, Identifier> textureFunc,
|
||||
BiFunction<Integer, AirBalloonEntity, Integer> lightFunc) {
|
||||
FeatureRendererContext<State, AirBalloonEntityModel> context,
|
||||
Predicate<State> visibilityTest,
|
||||
Function<State, Identifier> textureFunc,
|
||||
BiFunction<Integer, State, Integer> lightFunc) {
|
||||
super(context);
|
||||
this.model = model;
|
||||
this.visibilityTest = visibilityTest;
|
||||
|
@ -90,16 +136,11 @@ public class AirBalloonEntityRenderer extends MobEntityRenderer<AirBalloonEntity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, AirBalloonEntity entity,
|
||||
float limbAngle, float limbDistance, float tickDelta, float animationProgress, float yaw, float pitch) {
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, State entity, float limbDistance, float limbAngle) {
|
||||
if (visibilityTest.test(entity)) {
|
||||
Identifier texture = textureFunc.apply(entity);
|
||||
var model = this.model;
|
||||
if (texture.getPath().indexOf("sandbags") != -1) {
|
||||
model = new AirBalloonEntityModel(AirBalloonEntityModel.getSandbagsModelData().createModel());
|
||||
}
|
||||
render(getModel(), model, texture, matrices, vertices, lightFunc.apply(light, entity), entity, limbAngle, limbDistance, 0, yaw, pitch, tickDelta, Colors.WHITE);
|
||||
render(model, textureFunc.apply(entity), matrices, vertices, lightFunc.apply(light, entity), entity, Colors.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -12,6 +12,7 @@ import net.minecraft.entity.player.PlayerInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
|
@ -22,18 +23,18 @@ public class ButterfingersStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
amplifier = MathHelper.clamp(amplifier, 0, 5);
|
||||
final int scale = 500 + (int)(((5 - amplifier) / 5F) * 900);
|
||||
|
||||
if (entity.getWorld().random.nextInt(scale / 4) == 0) {
|
||||
applyInstantEffect(null, null, entity, amplifier, entity.getWorld().random.nextInt(scale));
|
||||
applyInstantEffect(world, null, null, entity, amplifier, entity.getWorld().random.nextInt(scale));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
public void applyInstantEffect(ServerWorld world, @Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
|
||||
if (target.getWorld().isClient) {
|
||||
return;
|
||||
|
@ -49,7 +50,7 @@ public class ButterfingersStatusEffect extends StatusEffect {
|
|||
ItemStack stack = target.getMainHandStack();
|
||||
if (!stack.isEmpty()) {
|
||||
target.setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
||||
target.dropStack(stack);
|
||||
target.dropStack(world, stack);
|
||||
target.getWorld().playSound(null, target.getBlockPos(), USounds.ENTITY_GENERIC_BUTTER_FINGERS, target.getSoundCategory());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import com.minelittlepony.unicopia.entity.Living;
|
|||
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||
|
@ -14,6 +15,7 @@ import net.minecraft.entity.effect.StatusEffectInstance;
|
|||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.WorldEvents;
|
||||
|
||||
|
@ -22,12 +24,12 @@ public class CorruptInfluenceStatusEffect extends SimpleStatusEffect {
|
|||
|
||||
CorruptInfluenceStatusEffect(int color) {
|
||||
super(StatusEffectCategory.NEUTRAL, color, false);
|
||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, CORRUPTION_MODIFIER_ID, 15, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, CORRUPTION_MODIFIER_ID, 10, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
addAttributeModifier(EntityAttributes.ATTACK_DAMAGE, CORRUPTION_MODIFIER_ID, 15, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
addAttributeModifier(EntityAttributes.ATTACK_SPEED, CORRUPTION_MODIFIER_ID, 10, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
|
||||
if (entity.getWorld().isClient) {
|
||||
return true;
|
||||
|
@ -53,7 +55,7 @@ public class CorruptInfluenceStatusEffect extends SimpleStatusEffect {
|
|||
|
||||
|
||||
} else if (entity.age % 2000 == 0) {
|
||||
entity.damage(Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2);
|
||||
entity.damage(world, Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -65,22 +67,22 @@ public class CorruptInfluenceStatusEffect extends SimpleStatusEffect {
|
|||
}
|
||||
|
||||
public static void reproduce(HostileEntity mob) {
|
||||
HostileEntity clone = (HostileEntity)mob.getType().create(mob.getWorld());
|
||||
HostileEntity clone = (HostileEntity)mob.getType().create(mob.getWorld(), SpawnReason.BREEDING);
|
||||
clone.copyPositionAndRotation(mob);
|
||||
clone.takeKnockback(0.1, 0.5, 0.5);
|
||||
mob.takeKnockback(0.1, -0.5, -0.5);
|
||||
if (mob.getRandom().nextInt(4) != 0) {
|
||||
mob.clearStatusEffects();
|
||||
} else {
|
||||
if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_MAX_HEALTH)) {
|
||||
if (clone.getAttributes().hasAttribute(EntityAttributes.MAX_HEALTH)) {
|
||||
float maxHealthDifference = mob.getMaxHealth() - clone.getMaxHealth();
|
||||
clone.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 900000, 2));
|
||||
clone.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH)
|
||||
clone.getAttributeInstance(EntityAttributes.MAX_HEALTH)
|
||||
.addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, maxHealthDifference + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||
}
|
||||
if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE)) {
|
||||
clone.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE)
|
||||
.addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, mob.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||
if (clone.getAttributes().hasAttribute(EntityAttributes.ATTACK_DAMAGE)) {
|
||||
clone.getAttributeInstance(EntityAttributes.ATTACK_DAMAGE)
|
||||
.addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, mob.getAttributeValue(EntityAttributes.ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.entity.effect;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.util.TypedActionResult;
|
||||
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.FoodComponent;
|
||||
|
@ -15,8 +16,8 @@ import net.minecraft.entity.effect.StatusEffects;
|
|||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
|
||||
public class FoodPoisoningStatusEffect extends StatusEffect {
|
||||
|
||||
|
@ -25,12 +26,8 @@ public class FoodPoisoningStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
if (entity.getWorld().isClient) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean showParticles = entity.getStatusEffect(entity.getRegistryManager().get(RegistryKeys.STATUS_EFFECT).getEntry(this)).shouldShowParticles();
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
boolean showParticles = entity.getStatusEffect(entity.getRegistryManager().getOrThrow(RegistryKeys.STATUS_EFFECT).getEntry(this)).shouldShowParticles();
|
||||
|
||||
if (!entity.hasStatusEffect(StatusEffects.NAUSEA) && entity.getRandom().nextInt(12) == 0) {
|
||||
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1, true, showParticles, false));
|
||||
|
@ -41,15 +38,15 @@ public class FoodPoisoningStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
if (EffectUtils.isPoisoned(entity) && entity.getRandom().nextInt(12) == 0 && !entity.hasStatusEffect(StatusEffects.POISON)) {
|
||||
StatusEffects.POISON.value().applyUpdateEffect(entity, 1);
|
||||
StatusEffects.POISON.value().applyUpdateEffect(world, entity, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
applyUpdateEffect(target, amplifier);
|
||||
public void applyInstantEffect(ServerWorld world, @Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
applyUpdateEffect(world, target, amplifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.world.World.ExplosionSourceType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.registry.Registries;
|
||||
|
||||
public class RaceChangeStatusEffect extends StatusEffect {
|
||||
|
@ -74,7 +75,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
StatusEffectInstance state = entity.getStatusEffect(forRace(race));
|
||||
|
||||
if (state == null || entity.isDead()) {
|
||||
|
@ -158,7 +159,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
}
|
||||
pony.setSpecies(race);
|
||||
} else if (!pony.asEntity().isCreative()) {
|
||||
if (!entity.damage(Living.living(entity).damageOf(UDamageTypes.TRIBE_SWAP), Float.MAX_VALUE)) {
|
||||
if (!entity.damage(world, Living.living(entity).damageOf(UDamageTypes.TRIBE_SWAP), Float.MAX_VALUE)) {
|
||||
entity.setHealth(0);
|
||||
pony.setRespawnRace(Race.UNSET);
|
||||
pony.setSpecies(race);
|
||||
|
@ -177,8 +178,8 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
applyUpdateEffect(target, amplifier);
|
||||
public void applyInstantEffect(ServerWorld world, @Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||
applyUpdateEffect(world, target, amplifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class SimpleStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
protected RegistryEntry<StatusEffect> getEntry(Entity entity) {
|
||||
return entity.getRegistryManager().get(RegistryKeys.STATUS_EFFECT).getEntry(this);
|
||||
return entity.getRegistryManager().getOrThrow(RegistryKeys.STATUS_EFFECT).getEntry(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.minecraft.entity.LivingEntity;
|
|||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
public class SunBlindnessStatusEffect extends SimpleStatusEffect {
|
||||
public static final int MAX_DURATION = 250;
|
||||
|
@ -21,7 +22,7 @@ public class SunBlindnessStatusEffect extends SimpleStatusEffect {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
public boolean applyUpdateEffect(ServerWorld world, LivingEntity entity, int amplifier) {
|
||||
StatusEffectInstance state = entity.getStatusEffect(getEntry(entity));
|
||||
|
||||
if (state == null || isSunImmune(entity)) {
|
||||
|
@ -32,7 +33,7 @@ public class SunBlindnessStatusEffect extends SimpleStatusEffect {
|
|||
if (!hasSunExposure(entity)) {
|
||||
entity.setStatusEffect(new StatusEffectInstance(getEntry(entity), (int)(state.getDuration() * 0.8F), Math.max(1, amplifier - 1), true, false), entity);
|
||||
} else {
|
||||
entity.damage(Living.living(entity).damageOf(amplifier == 2 ? UDamageTypes.SUN : UDamageTypes.SUNLIGHT), amplifier / 5F);
|
||||
entity.damage(world, Living.living(entity).damageOf(amplifier == 2 ? UDamageTypes.SUN : UDamageTypes.SUNLIGHT), amplifier / 5F);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.network.codec.PacketCodec;
|
|||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundEvent;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
|
@ -228,8 +229,10 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
|||
setInflation(inflation);
|
||||
}
|
||||
|
||||
if (activeFuel <= 0 && !fuelItems.isEmpty()) {
|
||||
activeFuel = FurnaceBlockEntity.createFuelTimeMap().getOrDefault(fuelItems.remove(0).getItem(), 0);
|
||||
if (getWorld() instanceof ServerWorld sw) {
|
||||
if (activeFuel <= 0 && !fuelItems.isEmpty()) {
|
||||
activeFuel = sw.getFuelRegistry().getFuelTicks(fuelItems.remove(0));
|
||||
}
|
||||
}
|
||||
|
||||
if (activeFuel > -6 && age % 2 == 0) {
|
||||
|
@ -329,13 +332,13 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean damage(DamageSource source, float amount) {
|
||||
public boolean damage(ServerWorld world, DamageSource source, float amount) {
|
||||
if (source.getAttacker() instanceof PlayerEntity player && player.getAbilities().creativeMode) {
|
||||
dropInventory();
|
||||
dropInventory(world);
|
||||
remove(RemovalReason.KILLED);
|
||||
return true;
|
||||
}
|
||||
if (super.damage(source, amount)) {
|
||||
if (super.damage(world, source, amount)) {
|
||||
hurtTime = 0;
|
||||
maxHurtTime = 0;
|
||||
return true;
|
||||
|
@ -432,7 +435,9 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
|||
|
||||
if (stack.isIn(ConventionalItemTags.SHEAR_TOOLS) && hasBalloon()) {
|
||||
stack.damage(1, player, getSlotForHand(hand));
|
||||
dropStack(BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true)));
|
||||
if (getWorld() instanceof ServerWorld sw) {
|
||||
dropStack(sw, BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true)));
|
||||
}
|
||||
setDesign(BalloonDesign.NONE);
|
||||
playSound(USounds.ENTITY_HOT_AIR_BALLOON_EQUIP_CANOPY.value(), 1, 1);
|
||||
if (!player.isSneaky()) {
|
||||
|
@ -456,8 +461,8 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
|||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (hasBurner()) {
|
||||
int fuel = FurnaceBlockEntity.createFuelTimeMap().getOrDefault(stack.getItem(), 0);
|
||||
if (hasBurner() && getWorld() instanceof ServerWorld sw) {
|
||||
int fuel = sw.getFuelRegistry().getFuelTicks(stack);
|
||||
if (fuel > 0) {
|
||||
if (fuelItems.size() < 64) {
|
||||
fuelItems.add(stack.splitUnlessCreative(1, player));
|
||||
|
@ -473,17 +478,17 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void dropInventory() {
|
||||
dropStack(getPickBlockStack());
|
||||
if (getWorld().getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
||||
protected void dropInventory(ServerWorld world) {
|
||||
dropStack(world, getPickBlockStack());
|
||||
if (world.getGameRules().getBoolean(GameRules.DO_ENTITY_DROPS)) {
|
||||
ItemStack lantern = getStackInHand(Hand.MAIN_HAND);
|
||||
setStackInHand(Hand.MAIN_HAND, ItemStack.EMPTY);
|
||||
dropStack(lantern);
|
||||
dropStack(world, lantern);
|
||||
if (hasBalloon()) {
|
||||
dropStack(BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true)));
|
||||
dropStack(world, BalloonDesignComponent.set(UItems.GIANT_BALLOON.getDefaultStack(), new BalloonDesignComponent(getDesign(), true)));
|
||||
setDesign(BalloonDesign.NONE);
|
||||
}
|
||||
fuelItems.forEach(this::dropStack);
|
||||
fuelItems.forEach(s -> dropStack(world, s));
|
||||
fuelItems.clear();
|
||||
}
|
||||
}
|
||||
|
@ -612,20 +617,12 @@ public class AirBalloonEntity extends MobEntity implements EntityCollisions.Comp
|
|||
return MultiBox.of(box, boxes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Box getVisibilityBoundingBox() {
|
||||
if (hasBalloon()) {
|
||||
return getBalloonBoundingBox().withMinY(getY());
|
||||
}
|
||||
return getInteriorBoundingBox();
|
||||
}
|
||||
|
||||
protected Box getInteriorBoundingBox() {
|
||||
public Box getInteriorBoundingBox() {
|
||||
Box box = MultiBox.unbox(getBoundingBox());
|
||||
return box.withMinY(box.minY - 0.05).contract(0.15, 0, 0.15);
|
||||
}
|
||||
|
||||
protected Box getBalloonBoundingBox() {
|
||||
public Box getBalloonBoundingBox() {
|
||||
float inflation = getInflation(1);
|
||||
return MultiBox.unbox(getBoundingBox())
|
||||
.offset(0.125, 7.3 * inflation, 0.125)
|
||||
|
|
|
@ -30,7 +30,7 @@ public interface UTreeGen {
|
|||
UniformIntProvider.create(3, 6),
|
||||
0.3f,
|
||||
UniformIntProvider.create(1, 3),
|
||||
Registries.BLOCK.getOrCreateEntryList(BlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH)
|
||||
Registries.BLOCK.getOrThrow(BlockTags.MANGROVE_LOGS_CAN_GROW_THROUGH)
|
||||
), new JungleFoliagePlacer(
|
||||
ConstantIntProvider.create(3),
|
||||
ConstantIntProvider.create(2),
|
||||
|
|
Loading…
Reference in a new issue