Mobs Are Guaranteed To Have At Least One Piece OF Armor
All checks were successful
Twine/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-06-15 16:55:56 -04:00
parent 7da5501008
commit f93d8932d5
3 changed files with 17 additions and 1 deletions

View File

@ -37,6 +37,7 @@ Each player has a "personal" stage of an area, the highest online player's diffi
- Normal Gameplay - Normal Gameplay
### Stage 2 ### Stage 2
- Mobs Are Guaranteed To Have At Least One Piece OF Armor
### Stage 3 ### Stage 3
- Hostile Mobs Attack Passive Mobs - Hostile Mobs Attack Passive Mobs

View File

@ -49,7 +49,7 @@ public class MixinBoatEntity implements BoatUtil {
} }
} }
@Redirect(at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), method = "updatePassengerPosition") @Redirect(at = @At(value = "INVOKE", target = "Ljava/util/List;size()I"), method = "updatePassengerPosition", allow = 2, require = 2)
public int updatePassengerPosition(List<Entity> list) { public int updatePassengerPosition(List<Entity> list) {
if (hasChest() != BoatChestMode.NONE) { if (hasChest() != BoatChestMode.NONE) {
return list.size() + 1; return list.size() + 1;

View File

@ -19,9 +19,12 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Random;
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
@Mixin(MobEntity.class) @Mixin(MobEntity.class)
public class MixinMobEntity { public class MixinMobEntity {
@ -68,4 +71,16 @@ public class MixinMobEntity {
} }
} }
} }
@Redirect(at = @At(value = "INVOKE", target = "Ljava/util/Random;nextFloat()F", ordinal = 0), method = "initEquipment", allow = 1)
public float initEquipment(Random random) {
StageDataComponent component = StageDataComponent.getFromWorld((ServerWorld) ((MobEntity) (Object) this).getEntityWorld());
BlockPos blockPos = ((MobEntity) (Object) this).getBlockPos();
int stage = component.findEffectiveStageOfChunk((ServerWorld) ((MobEntity) (Object) this).getEntityWorld(), blockPos);
if (stage >= 1) {
return -1f;
} else {
return random.nextFloat();
}
}
} }