Skip to content

Commit

Permalink
more configs for growth enchant
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Jan 24, 2025
1 parent 1fa2696 commit 6f2da19
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 14 deletions.
17 changes: 14 additions & 3 deletions examples/config/cyclic.toml
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,22 @@
enabled = true

[cyclic.enchantment.growth]
# Radius per level. size around player to perform growth logic
# Max number of crops grown per growth per level. Actual is (level * this + 4 bonus when its raining)
#Range: 1 ~ 16
limit = 4
# If true only players can use this (false allows anything with hands ie armor stands, zombies, etc)
player_only = false
# Radius increase per level. Actual radius is (this * level + 1)
#Range: 1 ~ 16
radius = 2
# Chance of trying to grow per tick / 100
#Range: 1 ~ 100
percent = 4
# Set false to stop enchantment from working
enabled = true
# Height of growth enchantment range
#Range: 0 ~ 16
height = 2

[cyclic.enchantment.step]
# Set false to stop enchantment from working
Expand Down Expand Up @@ -517,7 +528,7 @@
[cyclic.blocks.facades]
#
# These blocks are not allowed to be used as Facades for blocks because they look weird (used by cables and Glowstone Facade and Soundproofing Facade and others). If you want to ignore one entire mod use an entry like this : storagenetwork:*
itemsNotAllowed = ["minecraft:ladder", "minecraft:double_plant", "minecraft:waterlily", "minecraft:torch", "minecraft:*_torch", "minecraft:redstone", "minecraft:iron_bars", "minecraft:chest", "minecraft:ender_chest", "minecraft:sculk_vein", "minecraft:string", "minecraft:vine", "minecraft:rail", "minecraft:*_rail", "minecraft:brewing_stand", "minecraft:*_dripleaf", "minecraft:*_pane", "minecraft:*_sapling", "minecraft:*_sign", "minecraft:*_door", "minecraft:*_banner", "minecraft:*_shulker_box", "cyclic:*_pipe", "cyclic:*_bars", "storagenetwork:*"]
itemsNotAllowed = ["minecraft:double_plant", "minecraft:waterlily", "minecraft:torch", "minecraft:*_torch", "minecraft:redstone", "minecraft:iron_bars", "minecraft:chest", "minecraft:ender_chest", "minecraft:sculk_vein", "minecraft:string", "minecraft:vine", "minecraft:brewing_stand", "minecraft:*_dripleaf", "minecraft:*_pane", "minecraft:*_sapling", "minecraft:*_sign", "minecraft:*_door", "minecraft:*_banner", "minecraft:*_shulker_box", "storagenetwork:*"]

[cyclic.blocks.facades.cables]
#
Expand All @@ -534,7 +545,7 @@
#####################################################################################
[cyclic.logging]
# Unblock info logs; very spammy; can be useful for testing certain issues
info = true
info = false

#####################################################################################
# Item specific configs
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.daemon=false

mod_id=cyclic

mod_version=1.13.4
mod_version=1.13.5

curse_id=239286

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,11 @@ private static void initConfig() {
DisarmEnchant.CFG = CFG.comment(" Set false to stop enchantment from working").define(DisarmEnchant.ID + ".enabled", true);
ExcavationEnchant.CFG = CFG.comment(" Set false to stop enchantment from working").define(ExcavationEnchant.ID + ".enabled", true);
GrowthEnchant.CFG = CFG.comment(" Set false to stop enchantment from working").define(GrowthEnchant.ID + ".enabled", true);
GrowthEnchant.RADIUSFACTOR = CFG.comment(" Radius per level. size around player to perform growth logic").defineInRange(GrowthEnchant.ID + ".radius", 2, 1, 16);
GrowthEnchant.RADIUS_FACTOR = CFG.comment(" Radius increase per level. Actual radius is (this * level + 1)").defineInRange(GrowthEnchant.ID + ".radius", 2, 1, 16);
GrowthEnchant.HEIGHT = CFG.comment(" Height of growth enchantment range").defineInRange(GrowthEnchant.ID + ".height", 2, 0, 16);
GrowthEnchant.LIMIT_FACTOR = CFG.comment(" Max number of crops grown per growth per level. Actual is (level * this + 4 bonus when its raining) ").defineInRange(GrowthEnchant.ID + ".limit", 4, 1, 16);
GrowthEnchant.ODDS = CFG.comment(" Chance of trying to grow per tick / 100").defineInRange(GrowthEnchant.ID + ".percent", 4, 1, 100);
GrowthEnchant.PLAYER_ONLY = CFG.comment(" If true only players can use this (false allows anything with hands ie armor stands, zombies, etc) ").define(GrowthEnchant.ID + ".player_only", false);
MultiJumpEnchant.CFG = CFG.comment(" (Multijump) Set false to disable Multi Jump enchantment").define(MultiJumpEnchant.ID + ".enabled", true);
LifeLeechEnchant.CFG = CFG.comment(" Set false to stop enchantment from working").define(LifeLeechEnchant.ID + ".enabled", true);
MagnetEnchant.CFG = CFG.comment(" Set false to stop enchantment from working").define(MagnetEnchant.ID + ".enabled", true);
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/com/lothrazar/cyclic/enchant/GrowthEnchant.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@

public class GrowthEnchant extends EnchantmentFlib {

public static final int HEIGHT = 2;
public static final double ODDS = 0.04;
public static final String ID = "growth";
public static BooleanValue CFG;
public static IntValue RADIUSFACTOR;
public static BooleanValue PLAYER_ONLY;
public static IntValue RADIUS_FACTOR;
public static IntValue LIMIT_FACTOR;
public static IntValue HEIGHT;
public static IntValue ODDS;

public GrowthEnchant(Rarity rarityIn, EnchantmentCategory typeIn, EquipmentSlot... slots) {
super(rarityIn, typeIn, slots);
Expand Down Expand Up @@ -100,22 +102,32 @@ public void onEntityUpdate(LivingTickEvent event) {
LivingEntity entity = event.getEntity();
if (entity instanceof Player player) {
if (player.isSpectator() || !player.isAlive()) {
return;
return; // no dead players
}
}
else {
//entity is NOT a player
if (PLAYER_ONLY.get()) {
return; // config says only players are allowed and we are not a player
}
}
//Ticking
int level = getCurrentLevelTool(entity.getItemInHand(InteractionHand.MAIN_HAND));
if (level > 0 && entity.level() instanceof ServerLevel sw) {
final int growthLimit = level * 2 + (entity.level().isRaining() ? 4 : 1); //faster when raining too
final int growthLimit = level * LIMIT_FACTOR.get() + (entity.level().isRaining() ? 4 : 0); //more when raining too
final int radius = 1 + level * RADIUS_FACTOR.get();
final double odds = ((double) ODDS.get()) / 100.0;
int grown = 0;
List<BlockPos> shape = ShapeUtil.squareHorizontalFull(entity.blockPosition().below(), level + RADIUSFACTOR.get());
shape = ShapeUtil.repeatShapeByHeight(shape, HEIGHT);
List<BlockPos> shape = ShapeUtil.squareHorizontalFull(entity.blockPosition().below(), radius);
shape = ShapeUtil.repeatShapeByHeight(shape, HEIGHT.get());
Collections.shuffle(shape);
for (int i = 0; i < shape.size(); i++) {
if (grown >= growthLimit) {
break;
}
GrowthUtil.tryGrow(sw, shape.get(i), ODDS * 10);
if (GrowthUtil.tryGrow(sw, shape.get(i), odds)) {
grown++;
}
}
if (grown > 0) {
ItemStackUtil.damageItem(entity, entity.getItemInHand(InteractionHand.MAIN_HAND));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/lothrazar/cyclic/util/GrowthUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static boolean isValidGrow(Level world, BlockPos current) {
// return false; //cant grow, or cant bonemeal. no
// }
if (!crop.isValidBonemealTarget(world, current, bState, world.isClientSide)) {//canUseBonemeal // canGrow
ModCyclic.LOGGER.info("terra-grow canUseBonemeal is false " + bState.getBlock());
// ModCyclic.LOGGER.info("terra-grow canUseBonemeal is false " + bState.getBlock());
return false; //cant grow, or cant bonemeal. no
}
}
Expand Down
1 change: 1 addition & 0 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,6 @@
,"1.13.2":"Fix patchouli Guidebook doesn't show in JEI (and creative tab). Fix Sleeping Bag Disconnect with fully charged bow #2446. Two recipes have updated to use tag-ingredients forge:storage_blocks/ender_eye forge:storage_blocks/ender_pearl instead of item ids (this makes no difference to players experience). Re-added/Ported the alternate recipe for Tempered Dark Glass using obsidian and black stained glass"
,"1.13.3":"You can now use a bucket on the Melter machine. Fix Step Height enchantment. Add recipe in the Solidifier for Rooted Dirt"
,"1.13.4": "Flower patches spawned naturally in the world are now 4 times smaller. Merged Pull request from shermanflima https://github.com/Lothrazar/Cyclic/pull/2455 Fix Dormant Creeper Spore Charm Issues. Merged Pull request from Gegy that fixes the following: If a Miner fails to harvest a block (in our case, mining an instanced loot chest from Lootr), it would destroy itself. This seems to have been a mistake in the fallback case when the target fails to be mined, forcing the break on itself rather than the target. Miner destroys itself while in a claimed chunk #2367. Fluid Collectors when unloaded would lose their size/height settings (unlike Miners). Miners when unloaded would lose their current mined progress (unlike Fluid Collectors). The client would crash when trying to render a shapedata block preview without both targets set. Items in cables could be pushed against an extraction cable in the fallback case where they could not travel anywhere else - this could rarely lead to output items ending up back in input slots in an unexpected way. Mattocks behave inconsistently when used in a Miner block - as the fake player is placed at the corner of the Miner, the distance and whether in the negative/negative quadrant relative to the Miner would affect whether it applies"
,"1.13.5": "Added more config options to control the Growth enchantment"
}
}

0 comments on commit 6f2da19

Please sign in to comment.