diff options
author | nea <romangraef@gmail.com> | 2022-02-15 20:47:34 +0100 |
---|---|---|
committer | nea <romangraef@gmail.com> | 2022-04-14 04:10:06 +0200 |
commit | 83195cbb9d2618e0f913f4d77f76bb5800f8950d (patch) | |
tree | c7e4ee5b52ccd336949ab31e28c307eaa47e5d03 | |
parent | ef5f1b8a2202be5d6c1de8cf19260e7cbf93b757 (diff) | |
download | NotEnoughUpdates-83195cbb9d2618e0f913f4d77f76bb5800f8950d.tar.gz NotEnoughUpdates-83195cbb9d2618e0f913f4d77f76bb5800f8950d.tar.bz2 NotEnoughUpdates-83195cbb9d2618e0f913f4d77f76bb5800f8950d.zip |
more modifiers and entities
9 files changed, 140 insertions, 3 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java new file mode 100644 index 00000000..5884512f --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/AgeModifier.java @@ -0,0 +1,30 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.mixins.AccessorEntityAgeable; +import io.github.moulberry.notenoughupdates.mixins.AccessorEntityArmorStand; +import net.minecraft.entity.EntityAgeable; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityArmorStand; +import net.minecraft.entity.monster.EntityZombie; + +public class AgeModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + boolean baby = info.has("baby") && info.get("baby").getAsBoolean(); + if (base instanceof EntityAgeable) { + ((AccessorEntityAgeable) base).setGrowingAgeDirect(baby ? -1 : 1); + return base; + } + if (base instanceof EntityZombie) { + ((EntityZombie) base).setChild(baby); + return base; + } + if (base instanceof EntityArmorStand) { + ((AccessorEntityArmorStand) base).setSmallDirect(baby); + return base; + } + System.out.println("Cannot apply age to a non ageable entity: " + base); + return null; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java index 7997db02..cf2f0300 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/EntityViewer.java @@ -11,6 +11,8 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.monster.*; import net.minecraft.entity.passive.*; import net.minecraft.util.ResourceLocation; @@ -45,11 +47,15 @@ public class EntityViewer extends GuiScreen { put("Snowman", () -> new EntitySnowman(null)); put("Villager", () -> new EntityVillager(null)); put("Guardian", () -> new EntityGuardian(null)); + put("ArmorStand", () -> new EntityArmorStand(null)); put("Squid", () -> new EntitySquid(null)); put("Bat", () -> new EntityBat(null)); put("Spider", () -> new EntitySpider(null)); put("CaveSpider", () -> new EntityCaveSpider(null)); put("Pigman", () -> new EntityPigZombie(null)); + put("Ghast", () -> new EntityGhast(null)); + put("MagmaCube", () -> new EntityMagmaCube(null)); + put("Wither", () -> new EntityWither(null)); put("Enderman", () -> new EntityEnderman(null)); put("Player", () -> new GUIClientPlayer()); }}; @@ -59,7 +65,9 @@ public class EntityViewer extends GuiScreen { put("equipment", new EquipmentModifier()); put("riding", new RidingModifier()); put("charged", new ChargedModifier()); + put("witherdata", new WitherModifier()); put("invisible", new InvisibleModifier()); + put("age", new AgeModifier()); }}; public int guiLeft = 0; @@ -143,7 +151,7 @@ public class EntityViewer extends GuiScreen { EntityLivingBase stack = entity; while (true) { GuiInventory.drawEntityOnScreen(guiLeft + 90, (int) (guiTop + 75 - bottomOffset * scale), scale, guiLeft - mouseX + 80, guiTop + 60 - mouseY, stack); - bottomOffset += stack.height; + bottomOffset += stack.getMountedYOffset(); if (!(stack.riddenByEntity instanceof EntityLivingBase)) { break; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java new file mode 100644 index 00000000..c5580f17 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/entityviewer/WitherModifier.java @@ -0,0 +1,29 @@ +package io.github.moulberry.notenoughupdates.miscfeatures.entityviewer; + +import com.google.gson.JsonObject; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityWither; + +public class WitherModifier extends EntityViewerModifier { + @Override + public EntityLivingBase applyModifier(EntityLivingBase base, JsonObject info) { + if (!(base instanceof EntityWither)) + return null; + EntityWither wither = (EntityWither) base; + if (info.has("tiny")) { + if (info.get("tiny").getAsBoolean()) { + wither.setInvulTime(800); + } else { + wither.setInvulTime(0); + } + } + if (info.has("armored")) { + if (info.get("armored").getAsBoolean()) { + wither.setHealth(1); + } else { + wither.setHealth(wither.getMaxHealth()); + } + } + return base; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java new file mode 100644 index 00000000..9228f93d --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityAgeable.java @@ -0,0 +1,12 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.entity.EntityAgeable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(EntityAgeable.class) +public interface AccessorEntityAgeable { + @Accessor(value = "growingAge") + void setGrowingAgeDirect(int newValue); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityArmorStand.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityArmorStand.java new file mode 100644 index 00000000..b6a3ca6e --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/AccessorEntityArmorStand.java @@ -0,0 +1,12 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.entity.item.EntityArmorStand; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(EntityArmorStand.class) +public interface AccessorEntityArmorStand { + @Invoker(value = "setSmall") + void setSmallDirect(boolean isSmall); + +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java index b8f07b53..801b9041 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntityAgeable.java @@ -3,6 +3,7 @@ package io.github.moulberry.notenoughupdates.mixins; import net.minecraft.entity.EntityAgeable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntitySkeleton.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntitySkeleton.java new file mode 100644 index 00000000..54fe53f3 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinEntitySkeleton.java @@ -0,0 +1,17 @@ +package io.github.moulberry.notenoughupdates.mixins; + +import net.minecraft.entity.monster.EntitySkeleton; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(EntitySkeleton.class) +public class MixinEntitySkeleton { + @Redirect(method = "setCurrentItemOrArmor", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;isRemote:Z")) + public boolean onSetCurrentItemOrArmor(World instance) { + if (instance == null) + return true; + return instance.isRemote; + } +} diff --git a/src/main/resources/assets/notenoughupdates/dream.json b/src/main/resources/assets/notenoughupdates/dream.json index 3b83e14c..6f27e89e 100644 --- a/src/main/resources/assets/notenoughupdates/dream.json +++ b/src/main/resources/assets/notenoughupdates/dream.json @@ -7,11 +7,36 @@ }, { "type": "riding", - "entity": "Chicken", + "entity": "ArmorStand", "modifiers": [ { + "type": "age", + "baby": true + }, + { "type": "riding", - "entity": "Squid" + "entity": "Zombie", + "modifiers": [ + { + "type": "equipment", + "hand": "BOW", + "feet": "DIAMOND_BOOTS" + }, + { + "type": "age", + "baby": true + }, + { + "type": "riding", + "entity": "Sheep", + "modifiers": [ + { + "type": "age", + "baby": true + } + ] + } + ] } ] }, diff --git a/src/main/resources/mixins.notenoughupdates.json b/src/main/resources/mixins.notenoughupdates.json index 71e10d46..a7018f32 100644 --- a/src/main/resources/mixins.notenoughupdates.json +++ b/src/main/resources/mixins.notenoughupdates.json @@ -3,15 +3,18 @@ "refmap": "mixins.notenoughupdates.refmap.json", "compatibilityLevel": "JAVA_8", "mixins": [ + "AccessorEntityAgeable", "MixinAbstractClientPlayer", "MixinContainer", "MixinEffectRenderer", "MixinEntity", "MixinEntityAgeable", + "AccessorEntityArmorStand", "MixinEntityHorse", "MixinEntityPlayer", "MixinEntityPlayerSP", "MixinEntityRenderer", + "MixinEntitySkeleton", "MixinGuiChest", "MixinGuiContainer", "MixinGuiIngame", |