Skip to content

Commit

Permalink
1.1.4 pain2
Browse files Browse the repository at this point in the history
  • Loading branch information
Rin committed Nov 15, 2024
1 parent a60252d commit 26aa885
Show file tree
Hide file tree
Showing 15 changed files with 66 additions and 73 deletions.
57 changes: 42 additions & 15 deletions src/main/java/mizurin/shieldmod/SpiderLabyrinth.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mizurin.shieldmod;

import mizurin.shieldmod.item.Shields;
import net.minecraft.core.WeightedRandomBag;
import net.minecraft.core.WeightedRandomLootObject;
import net.minecraft.core.block.Block;
Expand Down Expand Up @@ -35,25 +36,25 @@ public SpiderLabyrinth() {
this.wallBlockB = Block.cobbleBasalt.id;
this.brickBlockA = Block.brickBasalt.id;
this.brickBlockB = Block.brickBasalt.id;
this.slabBlock = Block.slabPlanksOak.id;
this.slabBlock = Block.slabPlanksOakPainted.id;
}

public boolean generate(World world, Random random, int x, int y, int z) {

this.chestLoot = new WeightedRandomBag();
this.chestLoot = new WeightedRandomBag<>();
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.ingotIron.getDefaultStack(), 1, 6), 100.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.ingotGold.getDefaultStack(), 1, 4), 100.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.sulphur.getDefaultStack(), 3, 8), 100.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.diamond.getDefaultStack(), 1, 4), 2.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.foodAppleGold.getDefaultStack()), 1.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.foodAppleGold.getDefaultStack()), 2.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.dustRedstone.getDefaultStack(), 1, 4), 100.0);

for(int i = 0; i < 9; ++i) {
this.chestLoot.addEntry(new WeightedRandomLootObject(new ItemStack(Item.itemsList[Item.record13.id + i])), 1.0);
}

this.chestLoot.addEntry(new WeightedRandomLootObject(Item.foodApple.getDefaultStack()), 100.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Block.wool.getDefaultStack(), 1, 4), 100.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Block.wool.getDefaultStack(), 1, 2), 100.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.handcannonLoaded.getDefaultStack()), 0.5);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.handcannonUnloaded.getDefaultStack()), 4.5);
this.chestLoot.addEntry((new WeightedRandomLootObject(Item.armorHelmetChainmail.getDefaultStack())).setRandomMetadata(Item.armorHelmetChainmail.getMaxDamage() / 2, Item.armorHelmetChainmail.getMaxDamage()), 20.0);
Expand All @@ -62,16 +63,28 @@ public boolean generate(World world, Random random, int x, int y, int z) {
this.chestLoot.addEntry((new WeightedRandomLootObject(Item.armorBootsChainmail.getDefaultStack())).setRandomMetadata(Item.armorBootsChainmail.getMaxDamage() / 2, Item.armorBootsChainmail.getMaxDamage()), 20.0);
this.chestLoot.addEntry(new WeightedRandomLootObject(Item.ingotSteelCrude.getDefaultStack()), 10.0);
this.chestLoot.addEntry(new WeightedRandomLootObject((ItemStack)null), 892.0);
this.dispenserLoot = new WeightedRandomBag();
this.dispenserLoot = new WeightedRandomBag<>();
this.dispenserLoot.addEntry(new WeightedRandomLootObject(Item.ammoArrow.getDefaultStack(), 5, 7), 300.0);
this.dispenserLoot.addEntry(new WeightedRandomLootObject(Item.ammoArrowGold.getDefaultStack()), 10.0);
this.dispenserLoot.addEntry(new WeightedRandomLootObject(Item.ammoChargeExplosive.getDefaultStack()), 0.5);
this.dispenserLoot.addEntry(new WeightedRandomLootObject((ItemStack)null), 289.5);
this.spawnerMonsters = new WeightedRandomBag();


this.spawnerMonsters = new WeightedRandomBag<>();
this.spawnerMonsters.addEntry("Spider", 3.0);
this.spawnerMonsters.addEntry("ArmouredZombie", 1.0);
int r = random.nextInt(5);
switch (r) {
case 0:
case 1:
this.treasureItem = (new ItemStack(Shields.tearShield));
break;
case 2:
case 3:
this.treasureItem = (new ItemStack(Shields.rockyHelmet));
break;
case 4:
this.treasureItem = (new ItemStack(Shields.regenAmulet));
break;
}

if (this.canReplace(world, x, y, z)) {
this.dungeonLimit = 1;
Expand Down Expand Up @@ -160,7 +173,7 @@ public void generateDrop(World world, Random random, int blockX, int blockY, int
world.setBlockWithNotify(x, y + 1, z, Block.spikes.id);
}
} else if (x != blockX && z != blockZ && random.nextInt(20) == 0 && world.getBlockId(x, y + 1, z) != this.slabBlock) {
world.setBlockWithNotify(x, y, z, this.slabBlock);
world.setBlockAndMetadataWithNotify(x, y, z, this.slabBlock, 12 << 4);
} else {
world.setBlockWithNotify(x, y, z, 0);
}
Expand All @@ -186,7 +199,7 @@ public void generateDrop(World world, Random random, int blockX, int blockY, int
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) {
} else if (world.getBlockId(x, y, z) != this.brickBlockA && world.getBlockId(x, y, z) != Block.planksOakPainted.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 {
Expand Down Expand Up @@ -272,6 +285,9 @@ private void generateCorridor(World world, Random random, int blockX, int blockY
if (y == blockY + (height - 3) && !zWallCheck && !xWallCheck && random.nextInt(5) == 0) {
world.setBlockWithNotify(x, y, z, Block.cobweb.id);
}
if (y == blockY + (height - 2) && !zWallCheck && !xWallCheck && random.nextInt(20) == 0) {
world.setBlockWithNotify(x, y, z, Block.cobweb.id);
}
}
}
}
Expand Down Expand Up @@ -317,6 +333,7 @@ private void createCorridor(World world, Random random, int blockX, int blockY,

private void generateDungeon(World world, Random random, int blockX, int blockY, int blockZ, boolean doSpawner) {
int size = 4;
byte height = 2;
if (blockY >= 10) {
int x;
int y;
Expand All @@ -340,6 +357,12 @@ private void generateDungeon(World world, Random random, int blockX, int blockY,
} else {
world.setBlockWithNotify(x, y, z, this.wallBlockB);
}
if (y == blockY + (height - 3) && !zWallCheck && !xWallCheck && random.nextInt(5) == 0) {
world.setBlockWithNotify(x, y, z, Block.cobweb.id);
}
if (y == blockY + (height - 2) && !zWallCheck && !xWallCheck && random.nextInt(20) == 0) {
world.setBlockWithNotify(x, y, z, Block.cobweb.id);
}
}
}
}
Expand All @@ -348,7 +371,7 @@ private void generateDungeon(World world, Random random, int blockX, int blockY,
x = blockX + random.nextInt(size - 1) - (size - 1);
y = blockZ + random.nextInt(size - 1) - (size - 1);
if (this.canReplace(world, x, blockY - 2, y)) {
world.setBlockWithNotify(x, blockY - 1, y, Block.chestPlanksOak.id);
world.setBlockAndMetadataWithNotify(x, blockY - 1, y, Block.chestPlanksOakPainted.id, 12 << 4);
TileEntityChest tileentitychest = (TileEntityChest)world.getBlockTileEntity(x, blockY - 1, y);

for(int k4 = 0; k4 < 10; ++k4) {
Expand Down Expand Up @@ -403,7 +426,7 @@ private void generateLibrary(World world, Random random, int blockX, int blockY,
world.setBlockWithNotify(x, y, z, this.wallBlockA);
}
} else {
world.setBlockWithNotify(x, y, z, Block.planksOak.id);
world.setBlockAndMetadataWithNotify(x, y, z, Block.planksOakPainted.id, 12);
}

if (x > blockX - 3 && x < blockX + 3 && z > blockZ - 3 && z < blockZ + 3) {
Expand All @@ -420,9 +443,10 @@ private void generateLibrary(World world, Random random, int blockX, int blockY,
if (xRoom % 2 == 0) {
world.setBlockWithNotify(x, y, z, Block.bookshelfPlanksOak.id);
} else if (random.nextInt(5) == 0) {
world.setBlockWithNotify(x, y, z, Block.logOakMossy.id);
} else {
world.setBlockWithNotify(x, y, z, Block.logOak.id);
world.setBlockWithNotify(x, y, z, Block.logPine.id);
}
else {
world.setBlockWithNotify(x, y, z, Block.logPine.id);
}
} else {
world.setBlockWithNotify(x, y, z, 0);
Expand All @@ -434,6 +458,9 @@ private void generateLibrary(World world, Random random, int blockX, int blockY,
if (zRoom % 2 == 0 && (x == blockX - 2 || x == blockX + 2) && (z == blockZ - 2 || z == blockZ + 2)) {
world.setBlockWithNotify(x, y, z, this.brickBlockA);
}
if (y == blockY + (2) && !zWallCheck && !xWallCheck && random.nextInt(20) == 0) {
world.setBlockWithNotify(x, y, z, Block.cobweb.id);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mizurin/shieldmod/item/Shields.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void initializeItems(){
.setStackSize(1)
.setItemModel(item -> new ItemModelShield(item, new ItemModelColored.ColoredTextureEntry[]
{
new ItemModelColored.ColoredTextureEntry(TextureRegistry.getTexture("shieldmod:item/wooden_shield"), (s) -> -1)
new ItemModelColored.ColoredTextureEntry(TextureRegistry.getTexture("shieldmod:item/wooden_shield_test"), (s) -> -1)
}).setFull3D())
.build(new ShieldItem("wooden.shield", ++itemID, ShieldMaterials.TOOL_WOOD))
.withTags(ItemTags.PREVENT_CREATIVE_MINING);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/mizurin/shieldmod/mixins/EntitySpiderMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void attackEntity(Entity entity, float distance) {
if (brightness > 0.5F && this.random.nextInt(100) == 0) {
this.entityToAttack = null;
} else {
if (distance < 10.0F && distance > 6.0F) {
if ((distance < 10.0F && distance > 6.0F && this.random.nextInt(10) == 0)) {
double dX = entity.x - this.x;
double dZ = entity.z - this.z;
if (this.attackTime == 0) {
Expand All @@ -55,9 +55,10 @@ public void attackEntity(Entity entity, float distance) {
web.setHeading(dX, d2 + (double) f1, dZ, 1F, 1.0F);
this.world.entityJoinedWorld(web);


}

this.attackTime = 60;
this.attackTime = 30;
}

this.yRot = (float)(Math.atan2(dZ, dX) * 180.0 / Math.PI) - 90.0F;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/mizurin/shieldmod/mixins/ShieldMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInf
if(attacker != null) { //need this or you will get a null pointer.
if (!this.gamemode.isPlayerInvulnerable()) {
if ((helmet_item != null && helmet_item.getItem().equals(Shields.rockyHelmet)) && attacker != this) {
attacker.hurt(attacker, 2, DamageType.COMBAT);
if(getHealth() < getMaxHealth()){
damage *= 0;
}
attacker.hurt(this, 2, DamageType.FALL);
}
}
}
Expand All @@ -260,8 +263,8 @@ public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInf
World world = attacker.world;

if (!this.gamemode.isPlayerInvulnerable()) {
if(shield.tool == ShieldMaterials.TOOL_TEAR && getHealth() <= getMaxHealth() * 0.3){
damage = Math.round(damage * 0.5f);
if(shield.tool == ShieldMaterials.TOOL_TEAR && getHealth() <= getMaxHealth() * 0.5){
damage = Math.round(damage * 0.7f);
}
//tear shield provides a damage resistance when the player is low health. it can stack with blocking too.
if (shieldmod$getIsBlock()) {
Expand All @@ -282,7 +285,7 @@ public void injectHurt(Entity attacker, int damage, DamageType type, CallbackInf
}
if (shield.tool == ShieldMaterials.TOOL_STONE && attacker != this){
if ((helmet_item != null && helmet_item.getItem().equals(Shields.rockyHelmet))) {
attacker.hurt(attacker, 5, DamageType.FALL);
attacker.hurt(this, 5, DamageType.FALL);
} else {
attacker.hurt(this, 3, DamageType.FALL);
}
Expand Down Expand Up @@ -346,8 +349,8 @@ public void tickMixin(CallbackInfo ci){

ShieldItem shield = ((ShieldItem) stack.getItem());
if (shieldmod$getIsBlock() && (shield.tool == ShieldMaterials.TOOL_LEATHER || shield.tool == ShieldMaterials.TOOL_WOOD)) {
this.xd *= 0.65D;
this.zd *= 0.65D;
this.xd *= 0.80D;
this.zd *= 0.80D;
}
else if (shieldmod$getIsBlock() && shield.tool == ShieldMaterials.TOOL_DIAMOND){
this.xd *= 0.20D;
Expand Down
39 changes: 11 additions & 28 deletions src/main/java/mizurin/shieldmod/mixins/SpiderLabyrinthMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,29 @@
import com.llamalad7.mixinextras.sugar.Local;
import mizurin.shieldmod.SpiderLabyrinth;
import net.minecraft.core.world.World;
import net.minecraft.core.world.chunk.Chunk;
import net.minecraft.core.world.biome.Biome;
import net.minecraft.core.world.biome.Biomes;
import net.minecraft.core.world.generate.chunk.perlin.overworld.ChunkDecoratorOverworld;
import org.spongepowered.asm.mixin.Final;
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.Redirect;

import java.util.Random;

@Mixin(value = ChunkDecoratorOverworld.class, remap = false)
public class SpiderLabyrinthMixin {
@Final
@Shadow
private World world;

@Unique
int treeDensity;

@Unique
int i11;




@Inject(method = "decorate(Lnet/minecraft/core/world/chunk/Chunk;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/world/chunk/Chunk;getChunkRandom(J)Ljava/util/Random;", shift = At.Shift.AFTER), cancellable = true)
public void injectLabyrinth(Chunk chunk, CallbackInfo ci, @Local(name = "x") int x, @Local(name = "z") int z){
// Random rand = new Random(this.world.getRandomSeed());
// treeDensity = x + rand.nextInt(16) + 8;
// i11 = z + rand.nextInt(16) + 8;
// i11 = this.world.getHeightValue(treeDensity, i11) - (rand.nextInt(2) + 2);
//
// Random lRand = chunk.getChunkRandom(75644760L);
if(isBoreal){
(new SpiderLabyrinth()).generate(this.world, lRand, treeDensity, i11, i11);
} else {
ci.cancel();
@Redirect(method = "decorate", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/world/generate/feature/WorldFeatureLabyrinth;generate(Lnet/minecraft/core/world/World;Ljava/util/Random;III)Z"))
public boolean redirect(WorldFeatureLabyrinth instance, World world, Random rand, int x, int y, int z,
@Local(name = "biome") Biome biome) {
boolean isBoreal = (biome == Biomes.OVERWORLD_BOREAL_FOREST || biome == Biomes.OVERWORLD_MEADOW);
if (isBoreal) {
return new SpiderLabyrinth().generate(world, rand, x, y, z);
}

return instance.generate(world, rand, x, y, z);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,6 @@ private void addTreasure(Random random, CallbackInfoReturnable<ItemStack> cir) {
}
else if(isHot){
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(3) == 0) {
cir.setReturnValue(new ItemStack(Shields.regenAmulet));
Expand All @@ -74,11 +59,5 @@ public void generate(World world, Random random, int x, int y, int z, CallbackIn
isHot = true;
}
}
// @Inject(method = "pickMobSpawner(Ljava/util/Random;)Ljava/lang/String;", at = @At("HEAD"), cancellable = true)
// private void pickMobSpawner(Random random, CallbackInfoReturnable<String> cir) {
// if(isBoreal) {
// cir.setReturnValue("Spider");
// }
// }
}

Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 26aa885

Please sign in to comment.