diff --git a/src/main/java/com/github/alexmodguy/alexscaves/server/block/GingerbarrelBlock.java b/src/main/java/com/github/alexmodguy/alexscaves/server/block/GingerbarrelBlock.java index f3d16fab..f7d0e229 100644 --- a/src/main/java/com/github/alexmodguy/alexscaves/server/block/GingerbarrelBlock.java +++ b/src/main/java/com/github/alexmodguy/alexscaves/server/block/GingerbarrelBlock.java @@ -1,6 +1,7 @@ package com.github.alexmodguy.alexscaves.server.block; import com.github.alexmodguy.alexscaves.server.block.blockentity.GingerbarrelBlockEntity; +import com.github.alexmodguy.alexscaves.server.entity.living.GingerbreadManEntity; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -10,6 +11,7 @@ import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; +import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.monster.piglin.PiglinAi; import net.minecraft.world.entity.player.Player; @@ -25,8 +27,10 @@ import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; +import org.spongepowered.asm.mixin.Unique; import javax.annotation.Nullable; +import java.util.Iterator; public class GingerbarrelBlock extends BarrelBlock { @@ -42,16 +46,31 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP if (level.isClientSide) { return InteractionResult.SUCCESS; } else { - BlockEntity blockentity = level.getBlockEntity(blockPos); - if (blockentity instanceof GingerbarrelBlockEntity) { - player.openMenu((GingerbarrelBlockEntity) blockentity); + BlockEntity blockEntity = level.getBlockEntity(blockPos); + if (blockEntity instanceof GingerbarrelBlockEntity gingerbarrelBlockEntity) { + if (!player.isSpectator() && !player.isCreative()) { + angerGingerbreadMen(level, player); + } + player.openMenu((GingerbarrelBlockEntity) gingerbarrelBlockEntity); player.awardStat(Stats.OPEN_BARREL); - PiglinAi.angerNearbyPiglins(player, true); } return InteractionResult.CONSUME; } } + @Unique + private void angerGingerbreadMen(Level level, Entity opener) { + if (opener instanceof Player player) { + Iterator var4 = level.getEntitiesOfClass(GingerbreadManEntity.class, player.getBoundingBox().inflate(10, 5, 10)).iterator(); + while (var4.hasNext()) { + LivingEntity entity = var4.next(); + if (entity instanceof GingerbreadManEntity gingerbreadMan && !gingerbreadMan.isOvenSpawned()) { + gingerbreadMan.setTarget(player); + } + } + } + } + public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource randomSource) { BlockEntity blockentity = level.getBlockEntity(pos); if (blockentity instanceof GingerbarrelBlockEntity) { diff --git a/src/main/java/com/github/alexmodguy/alexscaves/server/entity/living/GummyBearEntity.java b/src/main/java/com/github/alexmodguy/alexscaves/server/entity/living/GummyBearEntity.java index 3619306a..ceef307e 100644 --- a/src/main/java/com/github/alexmodguy/alexscaves/server/entity/living/GummyBearEntity.java +++ b/src/main/java/com/github/alexmodguy/alexscaves/server/entity/living/GummyBearEntity.java @@ -83,6 +83,7 @@ public class GummyBearEntity extends Animal implements IDancesToJukebox, IAnimat private static final EntityDataAccessor STOMACH_BLUE = SynchedEntityData.defineId(GummyBearEntity.class, EntityDataSerializers.FLOAT); private static final EntityDataAccessor HELD_MOB_ID = SynchedEntityData.defineId(GummyBearEntity.class, EntityDataSerializers.INT); private static final EntityDataAccessor POSSESSOR_LICOWITCH_ID = SynchedEntityData.defineId(GummyBearEntity.class, EntityDataSerializers.INT); + private static final EntityDataAccessor JELLYBEANS = SynchedEntityData.defineId(GummyBearEntity.class, EntityDataSerializers.INT); public static final Animation ANIMATION_FISH = Animation.create(35); public static final Animation ANIMATION_EAT = Animation.create(40); @@ -107,8 +108,7 @@ public class GummyBearEntity extends Animal implements IDancesToJukebox, IAnimat private int standFor = 0; private int sitFor = 0; private int sleepFor = 0; - - private int jellybeansToMake = 5; + private int jellybeansToMake; public GummyBearEntity(EntityType entityType, Level level) { super(entityType, level); @@ -125,6 +125,7 @@ protected void defineSynchedData() { this.entityData.define(STOMACH_RED, 0.0F); this.entityData.define(STOMACH_GREEN, 0.0F); this.entityData.define(STOMACH_BLUE, 0.0F); + this.entityData.define(JELLYBEANS, 0); this.entityData.define(HELD_MOB_ID, -1); this.entityData.define(POSSESSOR_LICOWITCH_ID, -1); } @@ -186,6 +187,7 @@ public void addAdditionalSaveData(CompoundTag compound) { compound.putBoolean("BearSitting", this.isSitting()); compound.putInt("SleepTime", sleepFor); compound.putInt("SitTime", sitFor); + compound.putInt("Jellybeans", jellybeansToMake); } public void readAdditionalSaveData(CompoundTag compound) { @@ -198,6 +200,7 @@ public void readAdditionalSaveData(CompoundTag compound) { this.setStanding(compound.getBoolean("BearSitting")); this.sleepFor = compound.getInt("SleepTime"); this.sitFor = compound.getInt("SitTime"); + this.jellybeansToMake = compound.getInt("Jellybeans"); } @Override diff --git a/src/main/java/com/github/alexmodguy/alexscaves/server/item/DreadbowItem.java b/src/main/java/com/github/alexmodguy/alexscaves/server/item/DreadbowItem.java index b7ecb54c..8faa5bb4 100644 --- a/src/main/java/com/github/alexmodguy/alexscaves/server/item/DreadbowItem.java +++ b/src/main/java/com/github/alexmodguy/alexscaves/server/item/DreadbowItem.java @@ -21,6 +21,8 @@ import net.minecraft.world.entity.projectile.Arrow; import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.item.*; +import net.minecraft.world.item.enchantment.EnchantmentHelper; +import net.minecraft.world.item.enchantment.Enchantments; import net.minecraft.world.level.Level; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; @@ -210,13 +212,15 @@ public void releaseUsing(ItemStack itemStack, Level level, LivingEntity livingEn int maxArrows = darkArrows ? 30 : 8; abstractArrow.pickup = AbstractArrow.Pickup.ALLOWED; for(int j = 0; j < Math.ceil(maxArrows * f); j++){ + double power = 1; + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, itemStack) > 0) power = EnchantmentHelper.getItemEnchantmentLevel(Enchantments.POWER_ARROWS, itemStack) * 0.5 + 0.5; if(darkArrows){ DarkArrowEntity darkArrowEntity = new DarkArrowEntity(level, livingEntity); - darkArrowEntity.setShadowArrowDamage(precise ? 2.0F : 3.0F); + darkArrowEntity.setShadowArrowDamage(precise ? (float) (2.0F * power) : (float) (3.0F * power)); darkArrowEntity.setPerfectShot(perfectShot); abstractArrow = darkArrowEntity; }else if(perfectShot){ - abstractArrow.setBaseDamage(abstractArrow.getBaseDamage() * 2.0F); + abstractArrow.setBaseDamage(abstractArrow.getBaseDamage() * 2.0F * power); } Vec3 vec3 = mutableSkyPos.getCenter().add(level.random.nextFloat() * 16 - 8, level.random.nextFloat() * 4 - 2, level.random.nextFloat() * 16 - 8); int clearTries = 0;