Skip to content

Commit

Permalink
+ Add: Snow Golem produces Powder Snow.
Browse files Browse the repository at this point in the history
  • Loading branch information
FaeWulf committed Nov 13, 2024
1 parent 167af16 commit b5e271c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package xyz.faewulf.diversity.mixin.snowGolemProducesPowderSnow;

import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Shearable;
import net.minecraft.world.entity.animal.AbstractGolem;
import net.minecraft.world.entity.animal.SnowGolem;
import net.minecraft.world.entity.monster.RangedAttackMob;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LayeredCauldronBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.gameevent.GameEvent;
import org.spongepowered.asm.mixin.Mixin;
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 xyz.faewulf.diversity.util.config.ModConfigs;

@Mixin(SnowGolem.class)
public abstract class SnowGolemMixin extends AbstractGolem implements Shearable, RangedAttackMob {
protected SnowGolemMixin(EntityType<? extends AbstractGolem> entityType, Level level) {
super(entityType, level);
}

@Unique
private int diversity$coolDown = 0;

@Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;defaultBlockState()Lnet/minecraft/world/level/block/state/BlockState;"))
private void aiStepInject(CallbackInfo ci) {
if (this.level() instanceof ServerLevel serverLevel && ModConfigs.snow_golem_produces_powder_snow && diversity$coolDown <= 0) {
diversity$coolDown = 600;
if (this.random.nextInt(15) == 0) {

BlockState blockState = serverLevel.getBlockState(this.blockPosition());

if (blockState.getBlock() == Blocks.CAULDRON) {
serverLevel.setBlockAndUpdate(this.blockPosition(), Blocks.POWDER_SNOW_CAULDRON.defaultBlockState());
serverLevel.playSound(this, this.blockPosition(), SoundEvents.POWDER_SNOW_BREAK, SoundSource.BLOCKS, 1.0f, 1.0f);
serverLevel.gameEvent(this, GameEvent.ENTITY_PLACE, this.blockPosition());
}

if (blockState.getBlock() == Blocks.POWDER_SNOW_CAULDRON) {
BlockState cycle = blockState.cycle(LayeredCauldronBlock.LEVEL);
serverLevel.setBlockAndUpdate(this.blockPosition(), cycle);
serverLevel.playSound(this, this.blockPosition(), SoundEvents.POWDER_SNOW_BREAK, SoundSource.BLOCKS, 1.0f, 1.0f);
serverLevel.gameEvent(this, GameEvent.ENTITY_PLACE, this.blockPosition());
}
}
}

diversity$coolDown--;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ public class ModConfigs {
@Entry(category = "entity", name = "Smaller bee")
public static boolean smaller_bee = true;

@Entry(category = "entity", name = "Snow Golem produces powder snow")
public static boolean snow_golem_produces_powder_snow = true;

@Entry(category = "entity", name = "Wandering trader announcer")
public static boolean wandering_trader_announcer = true;

Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/assets/diversity/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"diversity.config.prevent_tamed_horse_wandering.tooltip": "- Horses, donkeys, and mules can fit in boats!",
"diversity.config.random_size_fishes.tooltip": "- Fish and squid now come in random sizes.",
"diversity.config.smaller_bee.tooltip": "- Bees are now half their default size.",
"diversity.config.snow_golem_produces_powder_snow.tooltip": "- Snow Golem stands inside a Cauldron will produce Powder snow over time.",
"diversity.config.emote.tooltip": "- Perform sound like meow, purr, purroew, and woof if chat or via /emote command.",
"diversity.config.slime_chunk_check.tooltip": "- Holding 'Slime Ball`, 'Slime Block', or items with the 'diversity:slime_detector' tag will emit particles and sound when in a slime chunk.\n- With a 10% chance while walking/running and 70% chance when sneaking.",
"diversity.config.wet_sponge_dry_in_warm_biome .tooltip": "- Wet sponge placed in warm biome will eventually dried out.",
Expand Down
1 change: 1 addition & 0 deletions common/src/main/resources/diversity.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"shulkerBoxLabel.TextDisplayEntityMixin",
"slimeChunkHint.EntityMixin",
"smallerBee.BeeEntityMixin",
"snowGolemProducesPowderSnow.SnowGolemMixin",
"spyglassWhatIsThat.AbstractFurnaceBlockEntityMixin",
"spyglassWhatIsThat.BeaconBlockEntityMixin",
"spyglassWhatIsThat.BrewingStandBlockEntityMixin",
Expand Down

0 comments on commit b5e271c

Please sign in to comment.