Skip to content

Commit

Permalink
1.19.2 - 1.0.5: Fixed calls to deprecated GeckoLib methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrix25633 committed Jan 9, 2023
1 parent 681479d commit bb2443c
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public Identifier getAnimationResource(BlastlingEntity animatable) {
return new Identifier(ImprovedEnd.MOD_ID, "animations/blastling.animations.json");
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings("unchecked")
@Override
public void setLivingAnimations(BlastlingEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
public void setCustomAnimations(BlastlingEntity entity, int uniqueID, AnimationEvent customPredicate) {
super.setCustomAnimations(entity, uniqueID, customPredicate);
IBone head = this.getAnimationProcessor().getBone("head");

EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public Identifier getAnimationResource(IndigoSquidEntity animatable) {
}

@Override
public void setLivingAnimations(IndigoSquidEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
public void setCustomAnimations(IndigoSquidEntity entity, int uniqueID, AnimationEvent customPredicate) {
super.setCustomAnimations(entity, uniqueID, customPredicate);
IBone head = this.getAnimationProcessor().getBone("body");

if (head != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import net.minecraft.util.Identifier;
import net.rupyber_studios.improved_end.ImprovedEnd;
import net.rupyber_studios.improved_end.entity.custom.BlastlingEntity;
import net.rupyber_studios.improved_end.entity.custom.MawlingEntity;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.processor.IBone;
Expand All @@ -25,10 +24,10 @@ public Identifier getAnimationResource(MawlingEntity animatable) {
return new Identifier(ImprovedEnd.MOD_ID, "animations/mawling.animations.json");
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings("unchecked")
@Override
public void setLivingAnimations(MawlingEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
public void setCustomAnimations(MawlingEntity entity, int uniqueID, AnimationEvent customPredicate) {
super.setCustomAnimations(entity, uniqueID, customPredicate);
IBone head = this.getAnimationProcessor().getBone("head");

EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public Identifier getAnimationResource(SnarelingEntity animatable) {
return new Identifier(ImprovedEnd.MOD_ID, "animations/snareling.animations.json");
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings("unchecked")
@Override
public void setLivingAnimations(SnarelingEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
public void setCustomAnimations(SnarelingEntity entity, int uniqueID, AnimationEvent customPredicate) {
super.setCustomAnimations(entity, uniqueID, customPredicate);
IBone head = this.getAnimationProcessor().getBone("head");

EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public Identifier getAnimationResource(WatchlingEntity animatable) {
return new Identifier(ImprovedEnd.MOD_ID, "animations/watchling.animations.json");
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings("unchecked")
@Override
public void setLivingAnimations(WatchlingEntity entity, Integer uniqueID, AnimationEvent customPredicate) {
super.setLivingAnimations(entity, uniqueID, customPredicate);
public void setCustomAnimations(WatchlingEntity entity, int uniqueID, AnimationEvent customPredicate) {
super.setCustomAnimations(entity, uniqueID, customPredicate);
IBone head = this.getAnimationProcessor().getBone("head");

EntityModelData extraData = (EntityModelData) customPredicate.getExtraDataOfType(EntityModelData.class).get(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;

public class BlastlingEntity extends HostileEntity implements IAnimatable, Angerable {
private final AnimationFactory factory = new AnimationFactory(this);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);

private static final UUID ATTACKING_SPEED_BOOST_ID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
private static final EntityAttributeModifier ATTACKING_SPEED_BOOST;
private static final TrackedData<Boolean> ANGRY;
Expand Down Expand Up @@ -93,17 +95,17 @@ protected void initGoals() {

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
if(event.isMoving()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.blastling.walk", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.blastling.walk"));
return PlayState.CONTINUE;
}
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.blastling.idle", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.blastling.idle"));
return PlayState.CONTINUE;
}

private <E extends IAnimatable> PlayState attackPredicate(AnimationEvent<E> event) {
if(this.isAttacking() && event.getController().getAnimationState().equals(AnimationState.Stopped)) {
event.getController().markNeedsReload();
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.blastling.attack", false));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.blastling.attack"));
}
return PlayState.CONTINUE;
}
Expand All @@ -127,10 +129,12 @@ public void setTarget(@Nullable LivingEntity target) {
this.ageWhenTargetSet = 0;
this.dataTracker.set(ANGRY, false);
this.dataTracker.set(PROVOKED, false);
assert entityAttributeInstance != null;
entityAttributeInstance.removeModifier(ATTACKING_SPEED_BOOST);
} else {
this.ageWhenTargetSet = this.age;
this.dataTracker.set(ANGRY, true);
assert entityAttributeInstance != null;
if (!entityAttributeInstance.hasModifier(ATTACKING_SPEED_BOOST)) {
entityAttributeInstance.addTemporaryModifier(ATTACKING_SPEED_BOOST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

import java.util.Objects;

public class IndigoSquidEntity extends WaterCreatureEntity implements IAnimatable {
private final AnimationFactory factory = new AnimationFactory(this);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
public float tiltAngle;
public float prevTiltAngle;
public float rollAngle;
Expand All @@ -48,7 +51,7 @@ public class IndigoSquidEntity extends WaterCreatureEntity implements IAnimatabl

public IndigoSquidEntity(EntityType<? extends WaterCreatureEntity> entityType, World world) {
super(entityType, world);
this.random.setSeed((long) this.getId());
this.random.setSeed(this.getId());
this.thrustTimerSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
setAttributes();
initGoals();
Expand All @@ -66,7 +69,7 @@ protected void initGoals() {
}

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.indigo_squid.swim", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.indigo_squid.swim"));
return PlayState.CONTINUE;
}

Expand Down Expand Up @@ -156,7 +159,7 @@ public void tickMovement() {
this.turningSpeed *= 0.99F;
}
if (!this.world.isClient) {
this.setVelocity((this.swimX * this.swimVelocityScale), (double) (this.swimY * this.swimVelocityScale), (this.swimZ * this.swimVelocityScale));
this.setVelocity((this.swimX * this.swimVelocityScale), (this.swimY * this.swimVelocityScale), (this.swimZ * this.swimVelocityScale));
}
Vec3d vec3d = this.getVelocity();
double d = vec3d.horizontalLength();
Expand All @@ -169,7 +172,7 @@ public void tickMovement() {
if (!this.world.isClient) {
double e = this.getVelocity().y;
if (this.hasStatusEffect(StatusEffects.LEVITATION)) {
e = 0.05 * (double) (this.getStatusEffect(StatusEffects.LEVITATION).getAmplifier() + 1);
e = 0.05 * (double) (Objects.requireNonNull(this.getStatusEffect(StatusEffects.LEVITATION)).getAmplifier() + 1);
} else if (!this.hasNoGravity()) {
e -= 0.08;
}
Expand Down Expand Up @@ -238,7 +241,7 @@ public boolean hasSwimmingVector() {
return this.swimX != 0.0F || this.swimY != 0.0F || this.swimZ != 0.0F;
}

class SwimGoal extends Goal {
static class SwimGoal extends Goal {
private final IndigoSquidEntity squid;

public SwimGoal(IndigoSquidEntity squid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;

public class MawlingEntity extends HostileEntity implements IAnimatable, Angerable {
private final AnimationFactory factory = new AnimationFactory(this);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
private static final UUID ATTACKING_SPEED_BOOST_ID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
private static final EntityAttributeModifier ATTACKING_SPEED_BOOST;
private static final TrackedData<Boolean> ANGRY;
Expand Down Expand Up @@ -93,17 +94,17 @@ protected void initGoals() {

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
if(event.isMoving()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mawling.walk", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mawling.walk"));
return PlayState.CONTINUE;
}
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mawling.idle", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mawling.idle"));
return PlayState.CONTINUE;
}

private <E extends IAnimatable> PlayState attackPredicate(AnimationEvent<E> event) {
if(this.isAttacking() && event.getController().getAnimationState().equals(AnimationState.Stopped)) {
event.getController().markNeedsReload();
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mawling.attack", false));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.mawling.attack"));
}
return PlayState.CONTINUE;
}
Expand All @@ -127,10 +128,12 @@ public void setTarget(@Nullable LivingEntity target) {
this.ageWhenTargetSet = 0;
this.dataTracker.set(ANGRY, false);
this.dataTracker.set(PROVOKED, false);
assert entityAttributeInstance != null;
entityAttributeInstance.removeModifier(ATTACKING_SPEED_BOOST);
} else {
this.ageWhenTargetSet = this.age;
this.dataTracker.set(ANGRY, true);
assert entityAttributeInstance != null;
if (!entityAttributeInstance.hasModifier(ATTACKING_SPEED_BOOST)) {
entityAttributeInstance.addTemporaryModifier(ATTACKING_SPEED_BOOST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

import java.util.*;
import java.util.function.Predicate;

public class SnarelingEntity extends HostileEntity implements IAnimatable, Angerable {
private final AnimationFactory factory = new AnimationFactory(this);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
private static final UUID ATTACKING_SPEED_BOOST_ID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
private static final EntityAttributeModifier ATTACKING_SPEED_BOOST;
private static final TrackedData<Boolean> ANGRY;
Expand Down Expand Up @@ -87,17 +88,17 @@ protected void initGoals() {

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
if(event.isMoving()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.snareling.walk", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.snareling.walk"));
return PlayState.CONTINUE;
}
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.snareling.idle", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.snareling.idle"));
return PlayState.CONTINUE;
}

private <E extends IAnimatable> PlayState attackPredicate(AnimationEvent<E> event) {
if(this.isAttacking() && event.getController().getAnimationState().equals(AnimationState.Stopped)) {
event.getController().markNeedsReload();
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.snareling.attack", false));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.snareling.attack"));
}
return PlayState.CONTINUE;
}
Expand All @@ -121,10 +122,12 @@ public void setTarget(@Nullable LivingEntity target) {
this.ageWhenTargetSet = 0;
this.dataTracker.set(ANGRY, false);
this.dataTracker.set(PROVOKED, false);
assert entityAttributeInstance != null;
entityAttributeInstance.removeModifier(ATTACKING_SPEED_BOOST);
} else {
this.ageWhenTargetSet = this.age;
this.dataTracker.set(ANGRY, true);
assert entityAttributeInstance != null;
if (!entityAttributeInstance.hasModifier(ATTACKING_SPEED_BOOST)) {
entityAttributeInstance.addTemporaryModifier(ATTACKING_SPEED_BOOST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;
import software.bernie.geckolib3.util.GeckoLibUtil;

import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;

public class WatchlingEntity extends HostileEntity implements IAnimatable, Angerable {
private final AnimationFactory factory = new AnimationFactory(this);
private final AnimationFactory factory = GeckoLibUtil.createFactory(this);
private static final UUID ATTACKING_SPEED_BOOST_ID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
private static final EntityAttributeModifier ATTACKING_SPEED_BOOST;
private static final TrackedData<Boolean> ANGRY;
Expand Down Expand Up @@ -93,17 +94,17 @@ protected void initGoals() {

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) {
if(event.isMoving()) {
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.watchling.walk", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.watchling.walk"));
return PlayState.CONTINUE;
}
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.watchling.idle", true));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.watchling.idle"));
return PlayState.CONTINUE;
}

private <E extends IAnimatable> PlayState attackPredicate(AnimationEvent<E> event) {
if(this.isAttacking() && event.getController().getAnimationState().equals(AnimationState.Stopped)) {
event.getController().markNeedsReload();
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.watchling.attack", false));
event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.watchling.attack"));
}
return PlayState.CONTINUE;
}
Expand All @@ -127,10 +128,12 @@ public void setTarget(@Nullable LivingEntity target) {
this.ageWhenTargetSet = 0;
this.dataTracker.set(ANGRY, false);
this.dataTracker.set(PROVOKED, false);
assert entityAttributeInstance != null;
entityAttributeInstance.removeModifier(ATTACKING_SPEED_BOOST);
} else {
this.ageWhenTargetSet = this.age;
this.dataTracker.set(ANGRY, true);
assert entityAttributeInstance != null;
if (!entityAttributeInstance.hasModifier(ATTACKING_SPEED_BOOST)) {
entityAttributeInstance.addTemporaryModifier(ATTACKING_SPEED_BOOST);
}
Expand Down

0 comments on commit bb2443c

Please sign in to comment.