diff --git a/src/main/java/com/adccadc/rust/RustConfig.java b/src/main/java/com/adccadc/rust/RustConfig.java index 9f8d744..351155b 100644 --- a/src/main/java/com/adccadc/rust/RustConfig.java +++ b/src/main/java/com/adccadc/rust/RustConfig.java @@ -47,14 +47,14 @@ public class RustConfig { private static boolean affectEntity = true; // 是否影响实体 // 各种铁傀儡的生物属性 - private static final List default_IG = new ArrayList<>(Arrays.asList((double) 0.25F, (double) 15.0F)); //原版铁傀儡属性(移动速度,攻击伤害) - private static List exposed_IG = new ArrayList<>(Arrays.asList((double) 0.22F, (double) 14.0F)); - private static List weathered_IG = new ArrayList<>(Arrays.asList((double) 0.19F, (double) 13.0F)); - private static List oxidized_IG = new ArrayList<>(Arrays.asList((double) 0.16F, (double) 12.0F)); - private static List waxed_IG = new ArrayList<>(Arrays.asList((double) 0.23F, (double) 14.5F)); - private static List waxed_exposed_IG = new ArrayList<>(Arrays.asList((double) 0.20F, (double) 13.5F)); - private static List waxed_weathered_IG = new ArrayList<>(Arrays.asList((double) 0.17F, (double) 12.5F)); - private static List waxed_oxidized_IG = new ArrayList<>(Arrays.asList((double) 0.14F, (double) 11.5F)); + private static final List default_IG = new ArrayList(Arrays.asList(0.25F, 15.0F)); //原版铁傀儡属性(移动速度,攻击伤害) + private static List exposed_IG = new ArrayList(Arrays.asList(0.22F, 14.0F)); + private static List weathered_IG = new ArrayList(Arrays.asList(0.19F, 13.0F)); + private static List oxidized_IG = new ArrayList(Arrays.asList(0.16F, 12.0F)); + private static List waxed_IG = new ArrayList(Arrays.asList(0.23F, 14.5F)); + private static List waxed_exposed_IG = new ArrayList(Arrays.asList(0.20F, 13.5F)); + private static List waxed_weathered_IG = new ArrayList(Arrays.asList(0.17F, 12.5F)); + private static List waxed_oxidized_IG = new ArrayList(Arrays.asList(0.14F, 11.5F)); private RustConfig() {} @@ -75,7 +75,7 @@ protected static List convertWithRegex(String input) { return result; } - protected static String formatWithF(List list) { + protected static String formatWithF(List list) { return list.stream() .map(obj -> { if (obj instanceof Number) { @@ -195,11 +195,11 @@ private static void createDefaultConfig(File configFile) { public static Integer getWaxed_weathered_WPPB() {return affectRedstone ? waxed_weathered_WPPB : 150;} public static Integer getWaxed_oxidized_WPPB() {return affectRedstone ? waxed_oxidized_WPPB : 150;} - public static List getExposed_IG() {return affectEntity ? exposed_IG : default_IG;} - public static List getWeathered_IG() {return affectEntity ? weathered_IG : default_IG;} - public static List getOxidized_IG() {return affectEntity ? oxidized_IG : default_IG;} - public static List getWaxed_IG() {return affectEntity ? waxed_IG : default_IG;} - public static List getWaxed_exposed_IG() {return affectEntity ? waxed_exposed_IG : default_IG;} - public static List getWaxed_weathered_IG() {return affectEntity ? waxed_weathered_IG : default_IG;} - public static List getWaxed_oxidized_IG() {return affectEntity ? waxed_oxidized_IG : default_IG;} + public static List getExposed_IG() {return affectEntity ? exposed_IG : default_IG;} + public static List getWeathered_IG() {return affectEntity ? weathered_IG : default_IG;} + public static List getOxidized_IG() {return affectEntity ? oxidized_IG : default_IG;} + public static List getWaxed_IG() {return affectEntity ? waxed_IG : default_IG;} + public static List getWaxed_exposed_IG() {return affectEntity ? waxed_exposed_IG : default_IG;} + public static List getWaxed_weathered_IG() {return affectEntity ? waxed_weathered_IG : default_IG;} + public static List getWaxed_oxidized_IG() {return affectEntity ? waxed_oxidized_IG : default_IG;} } diff --git a/src/main/java/com/adccadc/rust/manager/RustManager.java b/src/main/java/com/adccadc/rust/manager/RustManager.java index c7c586f..f402c88 100644 --- a/src/main/java/com/adccadc/rust/manager/RustManager.java +++ b/src/main/java/com/adccadc/rust/manager/RustManager.java @@ -73,6 +73,10 @@ public boolean tryWaxed(){ return true; } + public boolean canRusted(){ + return !this.state.isWaxed && this.state.level < this.maxLevel; + } + public RustState getState(){ return state; } diff --git a/src/main/java/com/adccadc/rust/mixin/entity/iromGolem/IronGolemEntityMixin.java b/src/main/java/com/adccadc/rust/mixin/entity/iromGolem/IronGolemEntityMixin.java index bae5152..c877f5b 100644 --- a/src/main/java/com/adccadc/rust/mixin/entity/iromGolem/IronGolemEntityMixin.java +++ b/src/main/java/com/adccadc/rust/mixin/entity/iromGolem/IronGolemEntityMixin.java @@ -43,15 +43,13 @@ public abstract class IronGolemEntityMixin extends GolemEntity implements IronGo @Unique public RustManager rust = new RustManager(new ItemStack(Moditems.IRON_RUST, 4), 3); + @Unique + public int rustLayTime = 9000; + public IronGolemEntityMixin(EntityType entityType, World world) { super(entityType, world); } - @Unique - public IronGolemEntityProxy proxy(){ - return this; - } - @Unique public RustManager getRust(){ return this.rust; @@ -109,7 +107,7 @@ private void readCustomDataWithRust(ReadView view, CallbackInfo info){ ) protected void interactMobWithRustActions(PlayerEntity player, Hand hand, CallbackInfoReturnable cir){ ItemStack itemStack = player.getStackInHand(hand); - /* + if (itemStack.isOf(Items.WATER_BUCKET)){ // 处理物品 if(!player.isCreative()){ @@ -126,7 +124,7 @@ protected void interactMobWithRustActions(PlayerEntity player, Hand hand, Callba } } - */ + // 物品是否含有斧头标签 if (itemStack.isIn(ItemTags.AXES)){ // 执行一次除锈 @@ -206,6 +204,7 @@ private void getAttackDamage(CallbackInfoReturnable cir) { public void tryAttack(ServerWorld world, Entity target, CallbackInfoReturnable cir) { float f1 = AttackDamage(); float g1 = (int)f1 > 0 ? f1 / 2.0F + (float)this.random.nextInt((int)f1) : f1; + Rust.LOGGER.info("铁傀儡伤害:{}", g1); DamageSource damageSource = this.getDamageSources().mobAttack(this); boolean bl1 = target.damage(world, damageSource, g1); if (bl1 && target instanceof LivingEntity livingEntity) { @@ -229,36 +228,30 @@ protected Text getDefaultName(){ @Override public float getMovementSpeed() { - float movementspeed = super.getMovementSpeed(); - if (!this.rust.getState().isWaxed) { - switch (this.rust.getState().level) { - case 0 -> movementspeed = (float) this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED); - case 1 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getExposed_IG().getFirst())); - case 2 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getWeathered_IG().getFirst())); - case 3 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getOxidized_IG().getFirst())); - } - } else { - switch (this.rust.getState().level) { - case 0 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getWaxed_IG().getFirst())); - case 1 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getWaxed_exposed_IG().getFirst())); - case 2 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getWaxed_weathered_IG().getFirst())); - case 3 -> movementspeed = (float) (this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED) - (0.25F - (float) RustConfig.getWaxed_oxidized_IG().getFirst())); - } - } - return movementspeed; + float[] speed = { + (float) this.getAttributeValue(EntityAttributes.MOVEMENT_SPEED), + RustConfig.getExposed_IG().getFirst(), + RustConfig.getWeathered_IG().getFirst(), + RustConfig.getOxidized_IG().getFirst() + }; + float[] waxed_speed = { + RustConfig.getWaxed_IG().getFirst(), + RustConfig.getWaxed_exposed_IG().getFirst(), + RustConfig.getWaxed_weathered_IG().getFirst(), + RustConfig.getWaxed_oxidized_IG().getFirst(), + }; + return this.rust.getState().isWaxed ? waxed_speed[this.rust.getState().level] : speed[this.rust.getState().level]; } - @Override - public void tick() { - super.tick(); - if (!this.getWorld().isClient && this.age % 5 == 0) { - this.updateGoalControls(); - } - if (this.getWorld().isClient) { - if (RustTick.CanRusty("client_entity")) {RustTick.Client_Entity_Can_Rusty = false ;this.rust.tryRusted();} - } - if (!this.getWorld().isClient) { - if (RustTick.CanRusty("server_entity")) {RustTick.Server_Entity_Can_Rusty = false ;this.rust.tryRusted();} + @Inject( + method = "tickMovement", + at = @At("TAIL") + ) + public void tickMovementWithRust(CallbackInfo ci){ + int multiply = this.isTouchingWater() ? 2 : 1; + if(this.rust.canRusted() && (this.rustLayTime -= multiply) <= 0){ + this.rust.tryRusted(); + this.rustLayTime = 9000; } } }