Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depth charge text fix #1475

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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 {

Expand All @@ -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<GingerbreadManEntity> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/alexscaves/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@
"entity.alexscaves.candy_cane_hook": "Candy Cane Hook",
"entity.alexscaves.soda_bottle_rocket": "Purple Soda Bottle Rocket",
"entity.alexscaves.frostmint_spear": "Frostmint Spear",
"entity.alexscaves.depth_charge": "Depth Charge",
"entity.alexscaves.all.command_0": "%s is wandering",
"entity.alexscaves.all.command_1": "%s is staying",
"entity.alexscaves.all.command_2": "%s is following",
Expand Down