From 1b968e34cb959b5c29b64b9c186dfc56c80f9057 Mon Sep 17 00:00:00 2001 From: Rin Date: Mon, 11 Nov 2024 21:55:26 -0600 Subject: [PATCH] 1.1.4 --- gradle.properties | 2 +- src/main/java/mizurin/shieldmod/Recipes.java | 2 +- .../shieldmod/entities/EntityIceBall.java | 7 +- .../mixins/BorealLabyrinthMixin.java | 173 ++++++++++++++++++ .../mizurin/shieldmod/mixins/DazedMixin.java | 9 + .../mizurin/shieldmod/mixins/SoundMixin.java | 20 +- .../shieldmod/mixins/SpiderWebMixin.java | 21 +++ .../mixins/WorldFeatureLabyrinthMixin.java | 36 +++- .../mizurin/shieldmod/mixins/ZombieMixin.java | 28 +++ src/main/resources/shieldmod.mixins.json | 5 +- 10 files changed, 283 insertions(+), 20 deletions(-) create mode 100644 src/main/java/mizurin/shieldmod/mixins/BorealLabyrinthMixin.java create mode 100644 src/main/java/mizurin/shieldmod/mixins/SpiderWebMixin.java create mode 100644 src/main/java/mizurin/shieldmod/mixins/ZombieMixin.java diff --git a/gradle.properties b/gradle.properties index ed5675c..00716d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,6 @@ halplibe_version=4.1.3 terrain_api_version=1.4.4-7.2-pre1 # Mod -mod_version=1.1.2 +mod_version=1.1.4 mod_group=Mizuri-n mod_name=Rin's Fortress diff --git a/src/main/java/mizurin/shieldmod/Recipes.java b/src/main/java/mizurin/shieldmod/Recipes.java index 6d572bc..030a6be 100644 --- a/src/main/java/mizurin/shieldmod/Recipes.java +++ b/src/main/java/mizurin/shieldmod/Recipes.java @@ -37,7 +37,7 @@ public void onRecipesReady() { RecipeBuilder.Shaped(MOD_ID) .setShape(" P ","PLP"," P ") - .addInput('P', Block.cobbleStone) + .addInput('P', "minecraft:cobblestones") .addInput('L',"minecraft:planks") .create("stoneShield", Shields.stoneShield.getDefaultStack()); diff --git a/src/main/java/mizurin/shieldmod/entities/EntityIceBall.java b/src/main/java/mizurin/shieldmod/entities/EntityIceBall.java index 68349f6..3927abb 100644 --- a/src/main/java/mizurin/shieldmod/entities/EntityIceBall.java +++ b/src/main/java/mizurin/shieldmod/entities/EntityIceBall.java @@ -32,7 +32,12 @@ public void onHit(HitResult hitResult) { if (hitResult.entity != null) { hitResult.entity.hurt(this.owner, this.damage, DamageType.COMBAT); ((IDazed) hitResult.entity).shieldmod$freezeHurt(20); - + if (this.modelItem != null) { + for(int j = 0; j < 8; ++j) { + this.world.spawnParticle("item", this.x, this.y, this.z, 0.0, 0.0, 0.0, Item.ammoSnowball.id); + } + } + this.remove(); //Applies my custom status effect from the IFreeze interface. } } diff --git a/src/main/java/mizurin/shieldmod/mixins/BorealLabyrinthMixin.java b/src/main/java/mizurin/shieldmod/mixins/BorealLabyrinthMixin.java new file mode 100644 index 0000000..7a2b1e2 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/mixins/BorealLabyrinthMixin.java @@ -0,0 +1,173 @@ +package mizurin.shieldmod.mixins; + +import net.minecraft.core.block.Block; +import net.minecraft.core.block.material.Material; +import net.minecraft.core.world.World; +import net.minecraft.core.world.biome.Biome; +import net.minecraft.core.world.biome.Biomes; +import net.minecraft.core.world.generate.feature.WorldFeatureLabyrinth; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.util.Random; + +@Mixin(value = WorldFeatureLabyrinth.class, remap = false) +public class BorealLabyrinthMixin { + + @Shadow + int wallBlockA; + @Shadow + int wallBlockB; + @Shadow + int brickBlockA; + @Shadow + int brickBlockB; + @Shadow + int slabBlock; + + @Unique + private boolean isBoreal; + + @Unique + private boolean isHot; + + @Inject(method = "generate", at = @At("HEAD")) + public void generate(World world, Random random, int x, int y, int z, CallbackInfoReturnable cir) { + Biome biome = world.getBlockBiome(x, y, z); + if (biome == Biomes.OVERWORLD_BOREAL_FOREST || biome == Biomes.OVERWORLD_MEADOW){ + this.wallBlockA = Block.basalt.id; + this.wallBlockB = Block.cobbleBasalt.id; + this.brickBlockA = Block.brickBasalt.id; + this.brickBlockB = Block.brickBasalt.id; + this.slabBlock = Block.slabPlanksOak.id; + isBoreal = true; + } + + if(biome == Biomes.OVERWORLD_CAATINGA || biome == Biomes.OVERWORLD_DESERT || biome == Biomes.OVERWORLD_OUTBACK || biome == Biomes.OVERWORLD_OUTBACK_GRASSY){ + isHot = true; + } + } + @Inject(method = "pickMobSpawner(Ljava/util/Random;)Ljava/lang/String;", at = @At("HEAD"), cancellable = true) + private void pickMobSpawner(Random random, CallbackInfoReturnable cir) { + int r = random.nextInt(2); + if(isBoreal) { + cir.setReturnValue("Spider"); +// switch (r) { +// case 0: +// cir.setReturnValue("ArmouredZombie"); +// break; +// case 1: +// cir.setReturnValue("Spider"); +// break; +// } + } + } + + @Inject(method = "generateCorridor(Lnet/minecraft/core/world/World;Ljava/util/Random;IIIII)V", at = @At(value = "HEAD")) + private void injectCobWeb(World world, Random random, int blockX, int blockY, int blockZ, int rot, int corridorIteration, CallbackInfo ci) { + byte height = 2; + int width = 2; + int length = 2; + + for (int x = blockX - width; x <= blockX + width; ++x) { + boolean xWallCheck = x == blockX - width || x == blockX + width; + + for (int y = blockY - height; y <= blockY + (height - 1); ++y) { + boolean yWallCheck = y == blockY - height; + + for (int z = blockZ - length; z <= blockZ + length; ++z) { + boolean zWallCheck = z == blockZ - length || z == blockZ + length; + if (this.canReplace(world, x, y, z) && (!xWallCheck && !zWallCheck && !yWallCheck || world.getBlockId(x, y + 1, z) != 0 || random.nextInt(3) <= 0)) { + if (rot == 0) { + if (xWallCheck) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (z == blockZ + length) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (yWallCheck) { + if (random.nextInt(3) == 0) { + world.setBlockWithNotify(x, y, z, this.wallBlockB); + } else { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } + } else { + world.setBlockWithNotify(x, y, z, 0); + } + } else if (rot == 1) { + if (x == blockX - width) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (zWallCheck) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (yWallCheck) { + if (random.nextInt(3) == 0) { + world.setBlockWithNotify(x, y, z, this.wallBlockB); + } else { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } + } else { + world.setBlockWithNotify(x, y, z, 0); + } + } else if (rot == 2) { + if (xWallCheck) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (z == blockZ - length) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (yWallCheck) { + if (random.nextInt(3) == 0) { + world.setBlockWithNotify(x, y, z, this.wallBlockB); + } else { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } + } else { + world.setBlockWithNotify(x, y, z, 0); + } + } else if (x == blockX + width) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (zWallCheck) { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } else if (yWallCheck) { + if (random.nextInt(3) == 0) { + world.setBlockWithNotify(x, y, z, this.wallBlockB); + } else { + world.setBlockWithNotify(x, y, z, this.wallBlockA); + } + } else { + world.setBlockWithNotify(x, y, z, 0); + } + if(isBoreal){ + if (y == blockY + (height - 3) && !zWallCheck && !xWallCheck && random.nextInt(5) == 0) { + world.setBlockWithNotify(x, y, z, Block.cobweb.id); + } + } else { + if (y == blockY + (height - 1) && !zWallCheck && !xWallCheck && random.nextInt(20) == 0) { + world.setBlockWithNotify(x, y, z, Block.cobweb.id); + } + } + } + } + } + } + } + + @Unique + private boolean canReplace(World world, int x, int y, int z) { + if (y <= 11) { + return false; + } else if (world.getBlockId(x, y, z) != this.brickBlockA && world.getBlockId(x, y, z) != Block.planksOak.id && world.getBlockId(x, y, z) != Block.cobweb.id && world.getBlockId(x, y, z) != Block.bookshelfPlanksOak.id && world.getBlockId(x, y, z) != Block.mobspawner.id && world.getBlockId(x, y, z) != this.brickBlockB) { + if (world.getBlockId(x, y, z) != Block.motionsensorIdle.id && world.getBlockId(x, y, z) != Block.dispenserCobbleStone.id && world.getBlockId(x, y, z) != Block.motionsensorActive.id) { + return world.getBlockMaterial(x, y, z) == Material.grass || world.getBlockMaterial(x, y, z) == Material.dirt || world.getBlockMaterial(x, y, z) == Material.stone || world.getBlockMaterial(x, y, z) == Material.sand || world.getBlockMaterial(x, y, z) == Material.moss; + } else { + world.removeBlockTileEntity(x, y, z); + world.setBlockWithNotify(x, y, z, 0); + return true; + } + } else { + return false; + } + } +} + diff --git a/src/main/java/mizurin/shieldmod/mixins/DazedMixin.java b/src/main/java/mizurin/shieldmod/mixins/DazedMixin.java index 6893868..86df835 100644 --- a/src/main/java/mizurin/shieldmod/mixins/DazedMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/DazedMixin.java @@ -33,6 +33,15 @@ public boolean hurt(Entity attacker, int damage, DamageType type) { return false; } + @Shadow + public abstract int getMaxHealth(); + + @Shadow + public int bonusHealth; + + @Shadow + public abstract void setHealthRaw(int health); + @Inject(method = "", at = @At("TAIL")) public void defineSyncStatus(CallbackInfo ci){ entityData.define(DATA_DAZE, 0); diff --git a/src/main/java/mizurin/shieldmod/mixins/SoundMixin.java b/src/main/java/mizurin/shieldmod/mixins/SoundMixin.java index 766d39c..6140afa 100644 --- a/src/main/java/mizurin/shieldmod/mixins/SoundMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/SoundMixin.java @@ -13,24 +13,30 @@ public class SoundMixin { @ModifyVariable(method = "playSound(Ljava/lang/String;Lnet/minecraft/core/sound/SoundCategory;FF)V", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) private String changeSoundId1(String soundPath) { - if (ShieldMod.hurtSound && soundPath.equals("random.hurt")) { - soundPath = "damage.hurtflesh"; - } + if (soundPath != null){ + if (ShieldMod.hurtSound && soundPath.equals("random.hurt")) { + soundPath = "damage.hurtflesh"; + } + } return soundPath; } @ModifyVariable(method = "playSound(Ljava/lang/String;Lnet/minecraft/core/sound/SoundCategory;FFLjava/lang/String;)V", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) private String changeSoundId2(String soundPath) { - if (ShieldMod.hurtSound && soundPath.equals("random.hurt")) { - soundPath = "damage.hurtflesh"; + if (soundPath != null) { + if (ShieldMod.hurtSound && soundPath.equals("random.hurt")) { + soundPath = "damage.hurtflesh"; + } } return soundPath; } @ModifyVariable(method = "playSound(Ljava/lang/String;Lnet/minecraft/core/sound/SoundCategory;FFFFF)V", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) private String changeSoundId3(String soundPath) { - if (ShieldMod.hurtSound && soundPath.equals("random.hurt")) { - soundPath = "damage.hurtflesh"; + if (soundPath != null) { + if (ShieldMod.hurtSound && soundPath.equals("random.hurt")) { + soundPath = "damage.hurtflesh"; + } } return soundPath; } diff --git a/src/main/java/mizurin/shieldmod/mixins/SpiderWebMixin.java b/src/main/java/mizurin/shieldmod/mixins/SpiderWebMixin.java new file mode 100644 index 0000000..4bfbe1a --- /dev/null +++ b/src/main/java/mizurin/shieldmod/mixins/SpiderWebMixin.java @@ -0,0 +1,21 @@ +package mizurin.shieldmod.mixins; + +import net.minecraft.core.block.BlockCobweb; +import net.minecraft.core.entity.Entity; +import net.minecraft.core.entity.monster.EntitySpider; +import net.minecraft.core.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = BlockCobweb.class, remap = false) +public class SpiderWebMixin { + + @Inject(method = "onEntityCollidedWithBlock(Lnet/minecraft/core/world/World;IIILnet/minecraft/core/entity/Entity;)V", at = @At("HEAD"), cancellable = true) + public void injectWeb(World world, int x, int y, int z, Entity entity, CallbackInfo ci){ + if(entity instanceof EntitySpider){ + ci.cancel(); + } + } +} diff --git a/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java b/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java index 0f0c90a..cba4470 100644 --- a/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java +++ b/src/main/java/mizurin/shieldmod/mixins/WorldFeatureLabyrinthMixin.java @@ -19,9 +19,15 @@ public class WorldFeatureLabyrinthMixin { @Shadow boolean isCold; - @Unique private boolean isHot; + private boolean isBoreal; + + public WorldFeatureLabyrinthMixin(boolean isHot, boolean isBoreal) { + this.isHot = isHot; + this.isBoreal = isBoreal; + } + @Inject(method = "pickCheckLootItem(Ljava/util/Random;)Lnet/minecraft/core/item/ItemStack;", at = @At(value = "FIELD", target = "Lnet/minecraft/core/world/generate/feature/WorldFeatureLabyrinth;treasureGenerated:Z", ordinal = 1, shift = At.Shift.AFTER), cancellable = true) private void addTreasure(Random random, CallbackInfoReturnable cir) { @@ -31,18 +37,30 @@ private void addTreasure(Random random, CallbackInfoReturnable cir) { } } else if(isHot){ - if (random.nextInt(2)== 0) { cir.setReturnValue(new ItemStack(Shields.rockyHelmet)); + } else if(isBoreal){ + int r = random.nextInt(5); + switch (r){ + case 0: + case 1: + cir.setReturnValue(new ItemStack(Shields.tearShield)); + break; + case 2: + case 3: + cir.setReturnValue(new ItemStack(Shields.rockyHelmet)); + break; + case 4: + cir.setReturnValue(new ItemStack(Shields.regenAmulet)); + break; } - } else { - if (random.nextInt(2) == 0) { + } + else if (random.nextInt(3) == 0) { cir.setReturnValue(new ItemStack(Shields.regenAmulet)); } - } - } - @Inject(method = "generate(Lnet/minecraft/core/world/World;Ljava/util/Random;III)Z", at = @At(value = "FIELD", target = "net/minecraft/core/world/generate/feature/WorldFeatureLabyrinth.slabBlock : I", ordinal = 0)) - private void addBiome(World world, Random random, int x, int y, int z, CallbackInfoReturnable cir){ - this.isHot = true; } +// @Inject(method = "generate(Lnet/minecraft/core/world/World;Ljava/util/Random;III)Z", at = @At(value = "FIELD", target = "net/minecraft/core/world/generate/feature/WorldFeatureLabyrinth.slabBlock : I", ordinal = 0)) +// private void addBiome(World world, Random random, int x, int y, int z, CallbackInfoReturnable cir){ +// this.isHot = true; +// } } diff --git a/src/main/java/mizurin/shieldmod/mixins/ZombieMixin.java b/src/main/java/mizurin/shieldmod/mixins/ZombieMixin.java new file mode 100644 index 0000000..6e062d5 --- /dev/null +++ b/src/main/java/mizurin/shieldmod/mixins/ZombieMixin.java @@ -0,0 +1,28 @@ +package mizurin.shieldmod.mixins; + +import net.minecraft.core.entity.Entity; +import net.minecraft.core.entity.monster.EntityMonster; +import net.minecraft.core.entity.monster.EntityZombie; +import net.minecraft.core.entity.player.EntityPlayer; +import net.minecraft.core.world.World; +import org.spongepowered.asm.mixin.Mixin; + +import static mizurin.shieldmod.ShieldMod.expertMode; + +@Mixin(value = EntityZombie.class, remap = false) +public class ZombieMixin extends EntityMonster { + public ZombieMixin(World world) { + super(world); + } + + @Override + protected Entity findPlayerToAttack() { + if(expertMode){ + EntityPlayer entityplayer = this.world.getClosestPlayerToEntity(this, 32.0); + return entityplayer != null && entityplayer.getGamemode().areMobsHostile() ? entityplayer : null; + } else { + EntityPlayer entityplayer = this.world.getClosestPlayerToEntity(this, 16.0); + return entityplayer != null && this.canEntityBeSeen(entityplayer) && entityplayer.getGamemode().areMobsHostile() ? entityplayer : null; + } + } +} diff --git a/src/main/resources/shieldmod.mixins.json b/src/main/resources/shieldmod.mixins.json index e84479b..83367b6 100644 --- a/src/main/resources/shieldmod.mixins.json +++ b/src/main/resources/shieldmod.mixins.json @@ -5,6 +5,7 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "BlockFarmlandMixin", + "BorealLabyrinthMixin", "DazedMixin", "EntityLivingMixin", "EntitySkeletonMixin", @@ -14,8 +15,10 @@ "FieldMixin", "KnockBackMixin", "ShieldMixin", + "SpiderWebMixin", "WorldFeatureLabyrinthMixin", - "WorldMixin" + "WorldMixin", + "ZombieMixin" ], "client": [ "BipedRendererMixin",