mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +01:00
More tweaks.
This commit is contained in:
parent
ecb8d46f50
commit
2fbf2984ab
4 changed files with 16 additions and 8 deletions
|
@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
|
@ -231,11 +232,9 @@ public class DrillItem extends ItemEnergy {
|
||||||
: 1);
|
: 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Block hit
|
//Block hit
|
||||||
HitResult ray = player.pick(8f, 1f, false);
|
HitResult ray = player.pick(Util.getReachDistance(player), 1f, false);
|
||||||
if (ray != null && ray.getType() == HitResult.Type.BLOCK) {
|
if (ray instanceof BlockHitResult trace) {
|
||||||
BlockHitResult trace = (BlockHitResult) ray;
|
|
||||||
//Breaks the Blocks
|
//Breaks the Blocks
|
||||||
if (!player.isShiftKeyDown() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) {
|
if (!player.isShiftKeyDown() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) {
|
||||||
if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) {
|
if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.registries.BuiltInRegistries;
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
@ -111,7 +112,7 @@ public class ItemFillingWand extends ItemEnergy {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
boolean clear = true;
|
boolean clear = true;
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
HitResult result = player.pick(8f, 1f, false);
|
HitResult result = player.pick(Util.getReachDistance(player), 1f, false);
|
||||||
if (result instanceof BlockHitResult) {
|
if (result instanceof BlockHitResult) {
|
||||||
CompoundTag compound = stack.getOrCreateTag();
|
CompoundTag compound = stack.getOrCreateTag();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
|
@ -49,8 +49,8 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
public void onPlayerInteractEvent(PlayerInteractEvent.RightClickItem event) {
|
public void onPlayerInteractEvent(PlayerInteractEvent.RightClickItem event) {
|
||||||
if (event.getLevel() != null) {
|
if (event.getLevel() != null) {
|
||||||
if (CommonConfig.Other.WATER_BOWL.get()) {
|
if (CommonConfig.Other.WATER_BOWL.get()) {
|
||||||
if (StackUtil.isValid(event.getItemStack()) && event.getItemStack().getItem() == Items.BOWL) {
|
if (!event.getItemStack().isEmpty() && event.getItemStack().getItem() == Items.BOWL) {
|
||||||
HitResult rayTrace = event.getEntity().pick(8f, 1f, true);
|
HitResult rayTrace = event.getEntity().pick(Util.getReachDistance(event.getEntity()), 1f, true);
|
||||||
if (rayTrace.getType() != HitResult.Type.BLOCK) {
|
if (rayTrace.getType() != HitResult.Type.BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.util;
|
package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.neoforged.fml.loading.FMLLoader;
|
import net.neoforged.fml.loading.FMLLoader;
|
||||||
|
import net.neoforged.neoforge.common.NeoForgeMod;
|
||||||
|
|
||||||
public final class Util {
|
public final class Util {
|
||||||
|
|
||||||
|
@ -40,4 +43,9 @@ public final class Util {
|
||||||
public static String getMajorModVersion() {
|
public static String getMajorModVersion() {
|
||||||
return splitVersion()[1].substring(1);
|
return splitVersion()[1].substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getReachDistance(Player player) {
|
||||||
|
AttributeInstance attribute = player.getAttribute(NeoForgeMod.BLOCK_REACH.value());
|
||||||
|
return attribute == null ? 4.5d : attribute.getValue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue