优化AnimationController写法

This commit is contained in:
Light_Quanta 2024-05-19 20:41:52 +08:00
parent f386951ab9
commit 72604f1c2f
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
22 changed files with 50 additions and 50 deletions

View file

@ -81,9 +81,9 @@ public class LightSaberItem extends SwordItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 0, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 0, this::idlePredicate);
data.add(idleController);
}

View file

@ -84,9 +84,9 @@ public class Rocket extends Item implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 0, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 0, this::idlePredicate);
data.add(idleController);
}

View file

@ -138,9 +138,9 @@ public class AK47Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -134,9 +134,9 @@ public class Aa12Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -129,9 +129,9 @@ public class Abekiri extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -105,9 +105,9 @@ public class BocekItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -123,9 +123,9 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -133,9 +133,9 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -122,9 +122,9 @@ public class HuntingRifle extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -137,9 +137,9 @@ public class Kraber extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -133,9 +133,9 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 3, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 3, this::idlePredicate);
data.add(idleController);
}

View file

@ -137,9 +137,9 @@ public class M60Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -122,9 +122,9 @@ public class M79Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -141,9 +141,9 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}
@ -186,7 +186,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
}
if (tag.getBoolean("reloading") && player.getMainHandItem().getOrCreateTag().getDouble("id") == id) {
if (tag.getDouble("prepare") == 10 && tag.getBoolean("empty_reload")) {
tag.putInt("ammo", (tag.getInt("ammo") + 1));
tag.putInt("ammo", tag.getInt("ammo") + 1);
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.shotgunAmmo = capability.shotgunAmmo - 1;
capability.syncPlayerVariables(entity);
@ -214,7 +214,7 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
capability.syncPlayerVariables(entity);
});
}
if ((tag.getInt("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo == 0)
if ((tag.getInt("ammo") >= 8 || entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.shotgunAmmo).orElse(0) == 0)
&& tag.getDouble("loading") == 0 || tag.getDouble("stop") == 1) {
tag.putDouble("force_stop", 0);
tag.putDouble("stop", 0);

View file

@ -129,9 +129,9 @@ public class M98bItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -148,9 +148,9 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}
@ -193,7 +193,7 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
}
if (tag.getBoolean("reloading") && player.getMainHandItem().getOrCreateTag().getDouble("id") == id) {
if (tag.getDouble("prepare") == 0 && tag.getDouble("loading") == 0
&& !(tag.getInt("ammo") >= 8 || (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0)) {
&& !(tag.getInt("ammo") >= 8 || entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.rifleAmmo).orElse(0) == 0)) {
if (tag.getDouble("force_stop") == 1) {
tag.putDouble("stop", 1);
} else {
@ -207,9 +207,9 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
}
}
if (tag.getDouble("loading") == 9) {
tag.putInt("ammo", (tag.getInt("ammo") + 1));
tag.putInt("ammo", tag.getInt("ammo") + 1);
entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
capability.rifleAmmo = entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).map(c -> c.rifleAmmo).orElse(0) - 1;
capability.rifleAmmo = capability.rifleAmmo - 1;
capability.syncPlayerVariables(entity);
});
}
@ -227,7 +227,7 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
}
}
if (tag.getDouble("firing") > 0) {
tag.putDouble("firing", (tag.getDouble("firing") - 1));
tag.putDouble("firing", tag.getDouble("firing") - 1);
}
}
}

View file

@ -142,9 +142,9 @@ public class Minigun extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 6, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 6, this::idlePredicate);
data.add(idleController);
}

View file

@ -133,9 +133,9 @@ public class Mk14Item extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -133,9 +133,9 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -157,9 +157,9 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -130,9 +130,9 @@ public class SksItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}

View file

@ -126,9 +126,9 @@ public class SvdItem extends GunItem implements GeoItem, AnimatedItem {
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
AnimationController procedureController = new AnimationController(this, "procedureController", 0, this::procedurePredicate);
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
AnimationController idleController = new AnimationController(this, "idleController", 4, this::idlePredicate);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
}