Skip to content

Commit

Permalink
1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Rin committed Nov 12, 2024
1 parent 0ddd95e commit 1b968e3
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/main/java/mizurin/shieldmod/Recipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/mizurin/shieldmod/entities/EntityIceBall.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}
Expand Down
173 changes: 173 additions & 0 deletions src/main/java/mizurin/shieldmod/mixins/BorealLabyrinthMixin.java
Original file line number Diff line number Diff line change
@@ -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<Boolean> 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<String> 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;
}
}
}

9 changes: 9 additions & 0 deletions src/main/java/mizurin/shieldmod/mixins/DazedMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<init>", at = @At("TAIL"))
public void defineSyncStatus(CallbackInfo ci){
entityData.define(DATA_DAZE, 0);
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/mizurin/shieldmod/mixins/SoundMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/mizurin/shieldmod/mixins/SpiderWebMixin.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> cir) {
Expand All @@ -31,18 +37,30 @@ private void addTreasure(Random random, CallbackInfoReturnable<ItemStack> 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<Boolean> 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<Boolean> cir){
// this.isHot = true;
// }
}

28 changes: 28 additions & 0 deletions src/main/java/mizurin/shieldmod/mixins/ZombieMixin.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
5 changes: 4 additions & 1 deletion src/main/resources/shieldmod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"BlockFarmlandMixin",
"BorealLabyrinthMixin",
"DazedMixin",
"EntityLivingMixin",
"EntitySkeletonMixin",
Expand All @@ -14,8 +15,10 @@
"FieldMixin",
"KnockBackMixin",
"ShieldMixin",
"SpiderWebMixin",
"WorldFeatureLabyrinthMixin",
"WorldMixin"
"WorldMixin",
"ZombieMixin"
],
"client": [
"BipedRendererMixin",
Expand Down

0 comments on commit 1b968e3

Please sign in to comment.