diff --git a/common/src/main/java/xyz/faewulf/diversity/mixin/snowGolemProducesPowderSnow/SnowGolemMixin.java b/common/src/main/java/xyz/faewulf/diversity/mixin/snowGolemProducesPowderSnow/SnowGolemMixin.java new file mode 100644 index 0000000..6bafd2b --- /dev/null +++ b/common/src/main/java/xyz/faewulf/diversity/mixin/snowGolemProducesPowderSnow/SnowGolemMixin.java @@ -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 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--; + } +} diff --git a/common/src/main/java/xyz/faewulf/diversity/util/config/ModConfigs.java b/common/src/main/java/xyz/faewulf/diversity/util/config/ModConfigs.java index 4dcfb24..735d392 100644 --- a/common/src/main/java/xyz/faewulf/diversity/util/config/ModConfigs.java +++ b/common/src/main/java/xyz/faewulf/diversity/util/config/ModConfigs.java @@ -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; diff --git a/common/src/main/resources/assets/diversity/lang/en_us.json b/common/src/main/resources/assets/diversity/lang/en_us.json index 36c8f6d..e60ffdc 100644 --- a/common/src/main/resources/assets/diversity/lang/en_us.json +++ b/common/src/main/resources/assets/diversity/lang/en_us.json @@ -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.", diff --git a/common/src/main/resources/diversity.mixins.json b/common/src/main/resources/diversity.mixins.json index 27ab3c9..e8ce0b7 100644 --- a/common/src/main/resources/diversity.mixins.json +++ b/common/src/main/resources/diversity.mixins.json @@ -95,6 +95,7 @@ "shulkerBoxLabel.TextDisplayEntityMixin", "slimeChunkHint.EntityMixin", "smallerBee.BeeEntityMixin", + "snowGolemProducesPowderSnow.SnowGolemMixin", "spyglassWhatIsThat.AbstractFurnaceBlockEntityMixin", "spyglassWhatIsThat.BeaconBlockEntityMixin", "spyglassWhatIsThat.BrewingStandBlockEntityMixin",