Skip to content

Commit

Permalink
Tweak worsleya gen 2 and more
Browse files Browse the repository at this point in the history
  • Loading branch information
Mechalopa committed Oct 20, 2024
1 parent 48596c6 commit 3f9d9b3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
14 changes: 3 additions & 11 deletions src/main/java/com/github/mechalopa/jafohana/ModEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.github.mechalopa.jafohana.registry.ModBlocks;
import com.github.mechalopa.jafohana.registry.ModItems;
import com.github.mechalopa.jafohana.util.ModTags;
import com.github.mechalopa.jafohana.util.ModUtils;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand All @@ -13,7 +14,6 @@
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.npc.VillagerTrades.ItemListing;
import net.minecraft.world.item.BoneMealItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
Expand Down Expand Up @@ -43,20 +43,12 @@ public static void onBonemeal(BonemealEvent event)
if (event.getState().is(ModTags.BlockTags.CONVERTABLE_TO_FASCIATED_DANDELION) && fasciate(serverLevel, pos, ModBlocks.FASCIATED_DANDELION.get().defaultBlockState(), r, ModConfigs.cachedServer.DANDELION_FASCIATION_CHANCE))
{
event.setSuccessful(true);

if (event.getStack() != null && !event.getStack().isEmpty() && event.getStack().getItem() != null && event.getStack().getItem() instanceof BoneMealItem)
{
event.getStack().shrink(1);
}
ModUtils.shrink(event.getStack(), serverLevel, event.getPlayer());
}
else if (event.getState().is(ModTags.BlockTags.CONVERTABLE_TO_FASCIATED_OXEYE_DAISY) && fasciate(serverLevel, pos, ModBlocks.FASCIATED_OXEYE_DAISY.get().defaultBlockState(), r, ModConfigs.cachedServer.OXEYE_DAISY_FASCIATION_CHANCE))
{
event.setSuccessful(true);

if (event.getStack() != null && !event.getStack().isEmpty() && event.getStack().getItem() != null && event.getStack().getItem() instanceof BoneMealItem)
{
event.getStack().shrink(1);
}
ModUtils.shrink(event.getStack(), serverLevel, event.getPlayer());
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/github/mechalopa/jafohana/util/ModUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.github.mechalopa.jafohana.util;

import javax.annotation.Nullable;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;

public class ModUtils
{
public static void shrink(ItemStack stack, ServerLevel serverLevel, @Nullable LivingEntity livingEntity)
{
if (stack != null && !stack.isEmpty() && stack.getItem() != null)
{
if (!stack.isDamageableItem())
{
stack.shrink(1);
}
else if (livingEntity != null)
{
EquipmentSlot equipmentslot = stack.equals(livingEntity.getItemBySlot(EquipmentSlot.OFFHAND)) ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND;
stack.hurtAndBreak(1, livingEntity, equipmentslot);
}
else
{
stack.hurtAndBreak(1, serverLevel, null, p -> {});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@
"id": "good_nights_sleep:baby_creeper",
"required": false
},
{
"id": "alexscaves:nucleeper",
"required": false
},
{
"id": "creepycreepers:ghostly_creeper",
"required": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@
},
{
"type": "minecraft:matching_block_tag",
"tag": "jafohana:worsleya_patch_replaceables"
"tag": "jafohana:worsleya_replaceable_world_gen"
}
]
}
}
]
},
"tries": 256,
"xz_spread": 5,
"tries": 196,
"xz_spread": 6,
"y_spread": 3
}
},
Expand Down Expand Up @@ -142,7 +142,7 @@
]
},
"tries": 128,
"xz_spread": 7,
"xz_spread": 6,
"y_spread": 3
}
},
Expand Down Expand Up @@ -181,15 +181,15 @@
-1,
0
],
"tag": "jafohana:worsleya_patch_replaceables"
"tag": "jafohana:worsleya_replaceable_world_gen"
}
]
}
}
]
},
"tries": 64,
"xz_spread": 7,
"xz_spread": 6,
"y_spread": 3
}
},
Expand Down

0 comments on commit 3f9d9b3

Please sign in to comment.