Skip to content

Commit

Permalink
Add setting for Foxes spawning with Glow Berries
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorrell committed Jul 21, 2021
1 parent 83da516 commit 66d6287
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ skyblock setDefault renewableDragonHeads true
skyblock setDefault shulkerSpawning true
skyblock setDefault renewableDiamonds true
skyblock setDefault rammingWart true
skyblock setDefault foxesSpawnWithGlowBerries true
carpet setDefault desertShrubs true
carpet setDefault renewableSponges true
6 changes: 6 additions & 0 deletions src/main/java/com/jsorrell/skyblock/SkyBlockSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public class SkyBlockSettings {
category = {SKYBLOCK, FEATURE})
public static boolean rammingWart = false;

/* Foxes Spawn With Glow Berries */
@Rule(
desc = "A spawned fox has a chance to hold glow berries",
category = {SKYBLOCK, FEATURE})
public static boolean foxesSpawnWithGlowBerries = false;

/* Useful Composters */
public static boolean doUsefulComposters = false;
public static boolean usefulCompostersNeedRedstone = false;
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/com/jsorrell/skyblock/mixin/FoxEntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import net.minecraft.world.LocalDifficulty;
import net.minecraft.world.World;

import com.jsorrell.skyblock.SkyBlockSettings;

@Mixin(FoxEntity.class)
public abstract class FoxEntityMixin extends Entity {
private FoxEntityMixin(EntityType<?> type, World world) {
Expand All @@ -28,12 +30,14 @@ private FoxEntityMixin(EntityType<?> type, World world) {
cancellable = true,
at = @At(value = "INVOKE", target = "Ljava/util/Random;nextFloat()F", ordinal = 1))
private void addFoxHeldItem(LocalDifficulty difficulty, CallbackInfo ci) {
float f = this.random.nextFloat();
ItemStack equippedItem;
if (f < GLOW_BERRY_CHANCE) {
equippedItem = new ItemStack(Items.GLOW_BERRIES);
this.equipStack(EquipmentSlot.MAINHAND, equippedItem);
ci.cancel();
if (SkyBlockSettings.foxesSpawnWithGlowBerries) {
float f = this.random.nextFloat();
ItemStack equippedItem;
if (f < GLOW_BERRY_CHANCE) {
equippedItem = new ItemStack(Items.GLOW_BERRIES);
this.equipStack(EquipmentSlot.MAINHAND, equippedItem);
ci.cancel();
}
}
}
}

0 comments on commit 66d6287

Please sign in to comment.