@@ -43,15 +43,13 @@ public abstract class IronGolemEntityMixin extends GolemEntity implements IronGo
4343 @ Unique
4444 public RustManager rust = new RustManager (new ItemStack (Moditems .IRON_RUST , 4 ), 3 );
4545
46+ @ Unique
47+ public int rustLayTime = 9000 ;
48+
4649 public IronGolemEntityMixin (EntityType <? extends IronGolemEntity > entityType , World world ) {
4750 super (entityType , world );
4851 }
4952
50- @ Unique
51- public IronGolemEntityProxy proxy (){
52- return this ;
53- }
54-
5553 @ Unique
5654 public RustManager getRust (){
5755 return this .rust ;
@@ -109,7 +107,7 @@ private void readCustomDataWithRust(ReadView view, CallbackInfo info){
109107 )
110108 protected void interactMobWithRustActions (PlayerEntity player , Hand hand , CallbackInfoReturnable <ActionResult > cir ){
111109 ItemStack itemStack = player .getStackInHand (hand );
112- /*
110+
113111 if (itemStack .isOf (Items .WATER_BUCKET )){
114112 // 处理物品
115113 if (!player .isCreative ()){
@@ -126,7 +124,7 @@ protected void interactMobWithRustActions(PlayerEntity player, Hand hand, Callba
126124 }
127125
128126 }
129- */
127+
130128 // 物品是否含有斧头标签
131129 if (itemStack .isIn (ItemTags .AXES )){
132130 // 执行一次除锈
@@ -206,6 +204,7 @@ private void getAttackDamage(CallbackInfoReturnable<Float> cir) {
206204 public void tryAttack (ServerWorld world , Entity target , CallbackInfoReturnable <Boolean > cir ) {
207205 float f1 = AttackDamage ();
208206 float g1 = (int )f1 > 0 ? f1 / 2.0F + (float )this .random .nextInt ((int )f1 ) : f1 ;
207+ Rust .LOGGER .info ("铁傀儡伤害:{}" , g1 );
209208 DamageSource damageSource = this .getDamageSources ().mobAttack (this );
210209 boolean bl1 = target .damage (world , damageSource , g1 );
211210 if (bl1 && target instanceof LivingEntity livingEntity ) {
@@ -229,36 +228,30 @@ protected Text getDefaultName(){
229228
230229 @ Override
231230 public float getMovementSpeed () {
232- float movementspeed = super .getMovementSpeed ();
233- if (!this .rust .getState ().isWaxed ) {
234- switch (this .rust .getState ().level ) {
235- case 0 -> movementspeed = (float ) this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED );
236- case 1 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getExposed_IG ().getFirst ()));
237- case 2 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getWeathered_IG ().getFirst ()));
238- case 3 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getOxidized_IG ().getFirst ()));
239- }
240- } else {
241- switch (this .rust .getState ().level ) {
242- case 0 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getWaxed_IG ().getFirst ()));
243- case 1 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getWaxed_exposed_IG ().getFirst ()));
244- case 2 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getWaxed_weathered_IG ().getFirst ()));
245- case 3 -> movementspeed = (float ) (this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ) - (0.25F - (float ) RustConfig .getWaxed_oxidized_IG ().getFirst ()));
246- }
247- }
248- return movementspeed ;
231+ float [] speed = {
232+ (float ) this .getAttributeValue (EntityAttributes .MOVEMENT_SPEED ),
233+ RustConfig .getExposed_IG ().getFirst (),
234+ RustConfig .getWeathered_IG ().getFirst (),
235+ RustConfig .getOxidized_IG ().getFirst ()
236+ };
237+ float [] waxed_speed = {
238+ RustConfig .getWaxed_IG ().getFirst (),
239+ RustConfig .getWaxed_exposed_IG ().getFirst (),
240+ RustConfig .getWaxed_weathered_IG ().getFirst (),
241+ RustConfig .getWaxed_oxidized_IG ().getFirst (),
242+ };
243+ return this .rust .getState ().isWaxed ? waxed_speed [this .rust .getState ().level ] : speed [this .rust .getState ().level ];
249244 }
250245
251- @ Override
252- public void tick () {
253- super .tick ();
254- if (!this .getWorld ().isClient && this .age % 5 == 0 ) {
255- this .updateGoalControls ();
256- }
257- if (this .getWorld ().isClient ) {
258- if (RustTick .CanRusty ("client_entity" )) {RustTick .Client_Entity_Can_Rusty = false ;this .rust .tryRusted ();}
259- }
260- if (!this .getWorld ().isClient ) {
261- if (RustTick .CanRusty ("server_entity" )) {RustTick .Server_Entity_Can_Rusty = false ;this .rust .tryRusted ();}
246+ @ Inject (
247+ method = "tickMovement" ,
248+ at = @ At ("TAIL" )
249+ )
250+ public void tickMovementWithRust (CallbackInfo ci ){
251+ int multiply = this .isTouchingWater () ? 2 : 1 ;
252+ if (this .rust .canRusted () && (this .rustLayTime -= multiply ) <= 0 ){
253+ this .rust .tryRusted ();
254+ this .rustLayTime = 9000 ;
262255 }
263256 }
264257}
0 commit comments