Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/main/java/com/adccadc/rust/RustConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Float> default_IG = new ArrayList<Float>(Arrays.asList(0.25F, 15.0F)); //原版铁傀儡属性(移动速度,攻击伤害)
private static List<Float> exposed_IG = new ArrayList<Float>(Arrays.asList(0.22F, 14.0F));
private static List<Float> weathered_IG = new ArrayList<Float>(Arrays.asList(0.19F, 13.0F));
private static List<Float> oxidized_IG = new ArrayList<Float>(Arrays.asList(0.16F, 12.0F));
private static List<Float> waxed_IG = new ArrayList<Float>(Arrays.asList(0.23F, 14.5F));
private static List<Float> waxed_exposed_IG = new ArrayList<Float>(Arrays.asList(0.20F, 13.5F));
private static List<Float> waxed_weathered_IG = new ArrayList<Float>(Arrays.asList(0.17F, 12.5F));
private static List<Float> waxed_oxidized_IG = new ArrayList<Float>(Arrays.asList(0.14F, 11.5F));

private RustConfig() {}

Expand All @@ -75,7 +75,7 @@ protected static List<Float> convertWithRegex(String input) {
return result;
}

protected static String formatWithF(List<?> list) {
protected static String formatWithF(List<Float> list) {
return list.stream()
.map(obj -> {
if (obj instanceof Number) {
Expand Down Expand Up @@ -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<Float> getExposed_IG() {return affectEntity ? exposed_IG : default_IG;}
public static List<Float> getWeathered_IG() {return affectEntity ? weathered_IG : default_IG;}
public static List<Float> getOxidized_IG() {return affectEntity ? oxidized_IG : default_IG;}
public static List<Float> getWaxed_IG() {return affectEntity ? waxed_IG : default_IG;}
public static List<Float> getWaxed_exposed_IG() {return affectEntity ? waxed_exposed_IG : default_IG;}
public static List<Float> getWaxed_weathered_IG() {return affectEntity ? waxed_weathered_IG : default_IG;}
public static List<Float> getWaxed_oxidized_IG() {return affectEntity ? waxed_oxidized_IG : default_IG;}
}
4 changes: 4 additions & 0 deletions src/main/java/com/adccadc/rust/manager/RustManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends IronGolemEntity> entityType, World world) {
super(entityType, world);
}

@Unique
public IronGolemEntityProxy proxy(){
return this;
}

@Unique
public RustManager getRust(){
return this.rust;
Expand Down Expand Up @@ -109,7 +107,7 @@ private void readCustomDataWithRust(ReadView view, CallbackInfo info){
)
protected void interactMobWithRustActions(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir){
ItemStack itemStack = player.getStackInHand(hand);
/*

if (itemStack.isOf(Items.WATER_BUCKET)){
// 处理物品
if(!player.isCreative()){
Expand All @@ -126,7 +124,7 @@ protected void interactMobWithRustActions(PlayerEntity player, Hand hand, Callba
}

}
*/

// 物品是否含有斧头标签
if (itemStack.isIn(ItemTags.AXES)){
// 执行一次除锈
Expand Down Expand Up @@ -206,6 +204,7 @@ private void getAttackDamage(CallbackInfoReturnable<Float> cir) {
public void tryAttack(ServerWorld world, Entity target, CallbackInfoReturnable<Boolean> 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) {
Expand All @@ -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;
}
}
}