mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-10-30 06:10:51 +01:00
Sunday code cleaning...
This commit is contained in:
parent
9cfbb61739
commit
6774b08ac5
38 changed files with 155 additions and 437 deletions
|
@ -172,7 +172,7 @@ public abstract class BlockContainerBase extends Block implements EntityBlock {
|
|||
|
||||
protected boolean tryUseItemOnTank(Player player, InteractionHand hand, FluidTank tank) {
|
||||
ItemStack heldItem = player.getItemInHand(hand);
|
||||
return StackUtil.isValid(heldItem) && FluidUtil.interactWithFluidHandler(player, hand, tank);
|
||||
return !heldItem.isEmpty() && FluidUtil.interactWithFluidHandler(player, hand, tank);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
|
@ -29,6 +28,7 @@ import net.minecraft.world.level.material.PushReaction;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -63,8 +63,9 @@ public class BlockPlant extends CropBlock {
|
|||
// }
|
||||
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) {
|
||||
protected ItemInteractionResult useItemOn(@Nonnull ItemStack pStack, @Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult pHitResult) {
|
||||
if (this.getAge(state) < 7) {
|
||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||
}
|
||||
|
@ -73,12 +74,12 @@ public class BlockPlant extends CropBlock {
|
|||
List<ItemStack> drops = Block.getDrops(state, (ServerLevel) world, pos, null);
|
||||
boolean deductedSeedSize = false;
|
||||
for (ItemStack drop : drops) {
|
||||
if (StackUtil.isValid(drop)) {
|
||||
if (!drop.isEmpty()) {
|
||||
if (drop.getItem() == this.seedItem.get() && !deductedSeedSize) {
|
||||
drop.shrink(1);
|
||||
deductedSeedSize = true;
|
||||
}
|
||||
if (StackUtil.isValid(drop)) {
|
||||
if (!drop.isEmpty()) {
|
||||
ItemHandlerHelper.giveItemToPlayer(player, drop);
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +91,7 @@ public class BlockPlant extends CropBlock {
|
|||
return super.useItemOn(pStack, state, world, pos, player, hand, pHitResult);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected ItemLike getBaseSeedId() {
|
||||
return this.seedItem.get();
|
||||
|
|
|
@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|||
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
|
@ -29,14 +28,16 @@ import net.minecraft.world.item.ItemStack;
|
|||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RenderEmpowerer implements BlockEntityRenderer<TileEntityEmpowerer> {
|
||||
public RenderEmpowerer(BlockEntityRendererProvider.Context context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(TileEntityEmpowerer tile, float partialTicks, PoseStack matrices, MultiBufferSource buffer, int combinedLight, int combinedOverlay) {
|
||||
public void render(TileEntityEmpowerer tile, float partialTicks, @Nonnull PoseStack matrices, @Nonnull MultiBufferSource buffer, int combinedLight, int combinedOverlay) {
|
||||
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(stack)) {
|
||||
if (!stack.isEmpty()) {
|
||||
// TODO: [port][refactor] migrate this logic into a single method, most renders use it
|
||||
matrices.pushPose();
|
||||
matrices.translate(0.5F, 1F, 0.5F);
|
||||
|
@ -52,7 +53,7 @@ public class RenderEmpowerer implements BlockEntityRenderer<TileEntityEmpowerer>
|
|||
try {
|
||||
AssetUtil.renderItemInWorld(stack, combinedLight, combinedOverlay, matrices, buffer);
|
||||
} catch (Exception e) {
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is {}!", BuiltInRegistries.ITEM.getKey(stack.getItem()), e);
|
||||
ActuallyAdditions.LOGGER.error("Something went wrong trying to render an item in an empowerer! The item is {}!", BuiltInRegistries.ITEM.getKey(stack.getItem()), e);
|
||||
}
|
||||
|
||||
matrices.popPose();
|
||||
|
|
|
@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
|
|||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -58,13 +57,13 @@ public class RenderLaserRelay implements BlockEntityRenderer<TileEntityLaserRela
|
|||
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
||||
|
||||
ItemStack upgrade = relay.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(upgrade)) {
|
||||
if (!upgrade.isEmpty()) {
|
||||
if (upgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get()) {
|
||||
hasInvis = true;
|
||||
}
|
||||
|
||||
ItemStack hand = player.getMainHandItem();
|
||||
if (hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == CommonConfig.Other.relayConfigureItem || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName().getString())) {
|
||||
if (hasGoggles || !hand.isEmpty() && (hand.getItem() == CommonConfig.Other.relayConfigureItem || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName().getString())) {
|
||||
matrices.pushPose();
|
||||
Direction direction = state.hasProperty(BlockStateProperties.FACING) ?
|
||||
state.getValue(BlockStateProperties.FACING) : Direction.UP;
|
||||
|
@ -92,7 +91,7 @@ public class RenderLaserRelay implements BlockEntityRenderer<TileEntityLaserRela
|
|||
BlockEntity secondTile = tile.getLevel().getBlockEntity(second);
|
||||
if (secondTile instanceof TileEntityLaserRelay) {
|
||||
ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0);
|
||||
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get();
|
||||
boolean otherInvis = !secondUpgrade.isEmpty() && secondUpgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get();
|
||||
|
||||
if (hasGoggles || !hasInvis || !otherInvis) {
|
||||
int color = hasInvis && otherInvis
|
||||
|
|
|
@ -232,7 +232,7 @@ public class ClientEvents {
|
|||
Font font = minecraft.font;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
|
||||
if (StackUtil.isValid(stack)) {
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.getItem() instanceof IHudDisplay) {
|
||||
((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class ClientEvents {
|
|||
}
|
||||
|
||||
if (tileHit instanceof TileEntityBase base) {
|
||||
if (base.isRedstoneToggle()) {
|
||||
if (base.isRedstoneToggle()) {
|
||||
Component component = Component.translatable("info.actuallyadditions.redstoneMode").append(": ")
|
||||
.append(Component.translatable("info.actuallyadditions.redstoneMode." + (base.isPulseMode
|
||||
? "pulse"
|
||||
|
@ -266,7 +266,7 @@ public class ClientEvents {
|
|||
}
|
||||
|
||||
if (tileHit instanceof IEnergyDisplay display) {
|
||||
if (!display.needsHoldShift() || player.isShiftKeyDown()) {
|
||||
if (!display.needsHoldShift() || player.isShiftKeyDown()) {
|
||||
if (energyDisplay == null) {
|
||||
energyDisplay = new EnergyDisplay(0, 0, null);
|
||||
}
|
||||
|
|
|
@ -85,12 +85,12 @@ public class CommonEvents {
|
|||
ItemEntity item = event.getItemEntity();
|
||||
if (item != null && item.isAlive()) {
|
||||
ItemStack stack = item.getItem();
|
||||
if (StackUtil.isValid(stack)) {
|
||||
if (!stack.isEmpty()) {
|
||||
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||
if (i != player.getInventory().selected) {
|
||||
|
||||
ItemStack invStack = player.getInventory().getItem(i);
|
||||
if (StackUtil.isValid(invStack) && (invStack.getItem() instanceof Sack)) {
|
||||
if (!invStack.isEmpty() && (invStack.getItem() instanceof Sack)) {
|
||||
boolean changed = false;
|
||||
boolean isVoid = ((Sack) invStack.getItem()).isVoid;
|
||||
|
||||
|
@ -114,7 +114,7 @@ public class CommonEvents {
|
|||
if (filter.check(stack)) {
|
||||
for (int j = 0; j < inv.getSlots(); j++) {
|
||||
ItemStack bagStack = inv.getStackInSlot(j);
|
||||
if (StackUtil.isValid(bagStack)) {
|
||||
if (!bagStack.isEmpty()) {
|
||||
if (ItemUtil.canBeStacked(bagStack, stack)) {
|
||||
int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize() - bagStack.getCount());
|
||||
if (maxTransfer > 0) {
|
||||
|
@ -145,7 +145,7 @@ public class CommonEvents {
|
|||
}
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(stack)) {
|
||||
if (stack.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ public class CommonEvents {
|
|||
public void onLogInEvent(PlayerEvent.PlayerLoggedInEvent event) {
|
||||
if (!event.getEntity().level().isClientSide && event.getEntity() instanceof ServerPlayer player) {
|
||||
PacketHelperServer.syncPlayerData(player, true);
|
||||
ActuallyAdditions.LOGGER.info("Sending Player Data to player {} with UUID {}.", player.getName(), player.getUUID());
|
||||
ActuallyAdditions.LOGGER.info("Sending Player Data to player {} with UUID {}.", player.getName(), player.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ public class CommonEvents {
|
|||
//checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
|
||||
|
||||
if (CommonConfig.Other.GIVE_BOOKLET_ON_FIRST_CRAFT.get()) {
|
||||
if (!event.getEntity().level().isClientSide && StackUtil.isValid(event.getCrafting()) && event.getCrafting().getItem() != ActuallyItems.ITEM_BOOKLET.get()) {
|
||||
if (!event.getEntity().level().isClientSide && !event.getCrafting().isEmpty() && event.getCrafting().getItem() != ActuallyItems.ITEM_BOOKLET.get()) {
|
||||
|
||||
String name = BuiltInRegistries.ITEM.getKey(event.getCrafting().getItem()).toString();
|
||||
if (name != null && name.toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)) {
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerBioReactor extends AbstractContainerMenu {
|
||||
|
@ -50,8 +50,9 @@ public class ContainerBioReactor extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 8;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -84,7 +85,7 @@ public class ContainerBioReactor extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -101,7 +102,7 @@ public class ContainerBioReactor extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.tile.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerBreaker extends AbstractContainerMenu {
|
||||
|
@ -51,8 +51,9 @@ public class ContainerBreaker extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 9;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -81,7 +82,7 @@ public class ContainerBreaker extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -98,7 +99,7 @@ public class ContainerBreaker extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.breaker.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -22,6 +21,7 @@ import net.minecraft.world.inventory.Slot;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -49,8 +49,9 @@ public class ContainerCanolaPress extends AbstractContainerMenu {
|
|||
return new ContainerCanolaPress(windowId, inv, (TileEntityCanolaPress) Objects.requireNonNull(inv.player.level().getBlockEntity(data.readBlockPos())));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 1;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -84,7 +85,7 @@ public class ContainerCanolaPress extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -101,7 +102,7 @@ public class ContainerCanolaPress extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.press.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerCoalGenerator extends AbstractContainerMenu {
|
||||
|
@ -46,8 +46,9 @@ public class ContainerCoalGenerator extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 1;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -80,7 +81,7 @@ public class ContainerCoalGenerator extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -97,7 +98,7 @@ public class ContainerCoalGenerator extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.generator.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
|||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -24,6 +23,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
||||
|
@ -58,8 +58,9 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 11;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -107,7 +108,7 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -124,7 +125,7 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.machine.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLongRangeBreaker;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
||||
|
@ -50,8 +50,9 @@ public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
|||
return new ContainerDirectionalBreaker(windowId, inv, (TileEntityLongRangeBreaker) Objects.requireNonNull(inv.player.level().getBlockEntity(data.readBlockPos())));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 9;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -80,7 +81,7 @@ public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -97,7 +98,7 @@ public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.breaker.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditio
|
|||
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -24,6 +23,8 @@ import net.minecraft.world.inventory.ClickType;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ContainerDrill extends AbstractContainerMenu {
|
||||
|
||||
public static final int SLOT_AMOUNT = 5;
|
||||
|
@ -62,13 +63,14 @@ public class ContainerDrill extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
ItemStack stack = inventory.getSelected();
|
||||
if (StackUtil.isValid(stack) && stack.getItem() instanceof DrillItem) {
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof DrillItem) {
|
||||
DrillItem.loadSlotsFromNBT(this.drillInventory, inventory.getSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 5;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -101,7 +103,7 @@ public class ContainerDrill extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -118,7 +120,7 @@ public class ContainerDrill extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
||||
public void clicked(int slotId, int dragType, @Nonnull ClickType clickTypeIn, @Nonnull Player player) {
|
||||
if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.selected) {
|
||||
return; //TODO: Check if this is correct, used to return ItemStack.EMPTY
|
||||
} else {
|
||||
|
@ -127,16 +129,16 @@ public class ContainerDrill extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removed(Player player) {
|
||||
public void removed(@Nonnull Player player) {
|
||||
ItemStack stack = this.inventory.getSelected();
|
||||
if (StackUtil.isValid(stack) && stack.getItem() instanceof DrillItem) {
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof DrillItem) {
|
||||
DrillItem.writeSlotsToNBT(this.drillInventory, this.inventory.getSelected());
|
||||
}
|
||||
super.removed(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -21,6 +20,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerDropper extends AbstractContainerMenu {
|
||||
|
@ -53,8 +53,9 @@ public class ContainerDropper extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 9;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -83,7 +84,7 @@ public class ContainerDropper extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
|
|
@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.ArmorSlot;
|
|||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
|
@ -26,6 +25,7 @@ import net.minecraft.world.inventory.Slot;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerEnervator extends AbstractContainerMenu {
|
||||
|
@ -59,8 +59,9 @@ public class ContainerEnervator extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 2;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -100,7 +101,7 @@ public class ContainerEnervator extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -19,6 +18,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerOilGenerator extends AbstractContainerMenu {
|
||||
|
@ -43,8 +43,9 @@ public class ContainerOilGenerator extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 0;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -69,7 +70,7 @@ public class ContainerOilGenerator extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -86,7 +87,7 @@ public class ContainerOilGenerator extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.generator.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
|||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
||||
|
@ -50,8 +50,9 @@ public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player player, int slot) {
|
||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
||||
int inventoryStart = 9;
|
||||
int inventoryEnd = inventoryStart + 26;
|
||||
int hotbarStart = inventoryEnd + 1;
|
||||
|
@ -80,7 +81,7 @@ public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(newStack)) {
|
||||
if (newStack.isEmpty()) {
|
||||
theSlot.set(ItemStack.EMPTY);
|
||||
} else {
|
||||
theSlot.setChanged();
|
||||
|
@ -97,7 +98,7 @@ public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
public boolean stillValid(@Nonnull Player player) {
|
||||
return this.placer.canPlayerUse(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
|
||||
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
@ -32,7 +31,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -46,12 +45,12 @@ public class Filler extends ItemEnergy {
|
|||
Block block = state.getBlock();
|
||||
ItemStack stack = new ItemStack(block, 1);
|
||||
|
||||
if (StackUtil.isValid(stack)) {
|
||||
if (!stack.isEmpty()) {
|
||||
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||
ItemStack slot = player.getInventory().getItem(i);
|
||||
if (StackUtil.isValid(slot) && ItemStack.isSameItem(slot, stack)) {
|
||||
if (!slot.isEmpty() && ItemStack.isSameItem(slot, stack)) {
|
||||
slot.shrink(1);
|
||||
if (!StackUtil.isValid(slot)) {
|
||||
if (slot.isEmpty()) {
|
||||
player.getInventory().setItem(i, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
|
@ -74,6 +73,7 @@ public class Filler extends ItemEnergy {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
if (context.getPlayer() == null) {
|
||||
|
@ -100,7 +100,7 @@ public class Filler extends ItemEnergy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void releaseUsing(ItemStack stack, Level world, LivingEntity entity, int timeLeft) {
|
||||
public void releaseUsing(@Nonnull ItemStack stack, Level world, @Nonnull LivingEntity entity, int timeLeft) {
|
||||
if (!world.isClientSide) {
|
||||
boolean clear = true;
|
||||
if (entity instanceof Player player) {
|
||||
|
@ -123,7 +123,7 @@ public class Filler extends ItemEnergy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
public void inventoryTick(@Nonnull ItemStack stack, @Nonnull Level world, @Nonnull Entity entity, int itemSlot, boolean isSelected) {
|
||||
super.inventoryTick(stack, world, entity, itemSlot, isSelected);
|
||||
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class Filler extends ItemEnergy {
|
|||
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable TooltipContext context, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
public void appendHoverText(@Nonnull ItemStack stack, @Nonnull TooltipContext context, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag flagIn) {
|
||||
super.appendHoverText(stack, context, tooltip, flagIn);
|
||||
|
||||
MutableComponent display = loadData(stack)
|
||||
|
@ -218,7 +218,7 @@ public class Filler extends ItemEnergy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getUseDuration(ItemStack stack, LivingEntity livingEntity) {
|
||||
public int getUseDuration(@Nonnull ItemStack stack, @Nonnull LivingEntity livingEntity) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class ItemBattery extends ItemEnergy {
|
|||
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, @Nullable TooltipContext playerIn, List<Component> list, TooltipFlag advanced) {
|
||||
public void appendHoverText(@Nonnull ItemStack stack, @Nonnull TooltipContext playerIn, @Nonnull List<Component> list, @Nonnull TooltipFlag advanced) {
|
||||
super.appendHoverText(stack, playerIn, list, advanced);
|
||||
list.add(Component.translatable("tooltip.actuallyadditions.battery." + (ItemUtil.isEnabled(stack)
|
||||
? "discharge"
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items;
|
|||
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -26,6 +25,7 @@ import net.minecraft.world.item.context.UseOnContext;
|
|||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class ItemPlayerProbe extends ItemBase {
|
|||
|
||||
// TODO: [port] might be the wrong event
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
public void inventoryTick(@Nonnull ItemStack stack, Level world, @Nonnull Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (!world.isClientSide) {
|
||||
UUID uuid = stack.get(ActuallyComponents.UUID);
|
||||
if (uuid != null) {
|
||||
|
@ -57,6 +57,7 @@ public class ItemPlayerProbe extends ItemBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InteractionResult useOn(UseOnContext context) {
|
||||
Player player = context.getPlayer();
|
||||
|
@ -84,14 +85,15 @@ public class ItemPlayerProbe extends ItemBase {
|
|||
return InteractionResult.FAIL;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InteractionResult interactLivingEntity(ItemStack aStack, Player player, LivingEntity entity, InteractionHand hand) {
|
||||
public InteractionResult interactLivingEntity(@Nonnull ItemStack aStack, Player player, @Nonnull LivingEntity entity, @Nonnull InteractionHand hand) {
|
||||
if (!player.level().isClientSide) {
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (StackUtil.isValid(stack) && stack.getItem() == this) {
|
||||
if (!stack.isEmpty() && stack.getItem() == this) {
|
||||
if (entity instanceof Player playerHit) {
|
||||
|
||||
if (!playerHit.isShiftKeyDown()) {
|
||||
if (!playerHit.isShiftKeyDown()) {
|
||||
stack.set(ActuallyComponents.UUID, playerHit.getUUID());
|
||||
stack.set(ActuallyComponents.NAME, playerHit.getName().getString());
|
||||
return InteractionResult.SUCCESS;
|
||||
|
@ -104,7 +106,7 @@ public class ItemPlayerProbe extends ItemBase {
|
|||
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext pContext, List<Component> tooltip, TooltipFlag advanced) {
|
||||
public void appendHoverText(ItemStack stack, @Nonnull TooltipContext pContext, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag advanced) {
|
||||
String name = stack.get(ActuallyComponents.NAME);
|
||||
if (name != null) {
|
||||
tooltip.add(Component.translatable("tooltip.actuallyadditions.playerProbe.probing").append(": " + name));
|
||||
|
|
|
@ -39,6 +39,8 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||
import net.neoforged.neoforge.common.NeoForge;
|
||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemWaterBowl extends ItemBase {
|
||||
|
||||
public ItemWaterBowl() {
|
||||
|
@ -68,7 +70,7 @@ public class ItemWaterBowl extends ItemBase {
|
|||
ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1);
|
||||
|
||||
ItemStack bowl = new ItemStack(ActuallyItems.WATER_BOWL.get());
|
||||
if (!StackUtil.isValid(reduced)) {
|
||||
if (reduced.isEmpty()) {
|
||||
event.getEntity().setItemInHand(event.getHand(), bowl);
|
||||
} else if (!event.getEntity().getInventory().add(bowl.copy())) {
|
||||
ItemEntity entityItem = new ItemEntity(event.getLevel(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), bowl.copy());
|
||||
|
@ -82,13 +84,14 @@ public class ItemWaterBowl extends ItemBase {
|
|||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||
public InteractionResultHolder<ItemStack> use(@Nonnull Level world, Player player, @Nonnull InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
|
||||
HitResult trace = player.pick(8.0D, 1.0F, false);
|
||||
|
||||
if (trace == null) {
|
||||
if (trace.getType() == HitResult.Type.MISS) {
|
||||
return InteractionResultHolder.pass(stack);
|
||||
} else if (trace.getType() != HitResult.Type.BLOCK) {
|
||||
return InteractionResultHolder.pass(stack);
|
||||
|
@ -117,7 +120,7 @@ public class ItemWaterBowl extends ItemBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||
public void inventoryTick(@Nonnull ItemStack stack, Level world, @Nonnull Entity entity, int itemSlot, boolean isSelected) {
|
||||
if (!world.isClientSide) {
|
||||
if (CommonConfig.Other.WATER_BOWL_LOSS.get()) {
|
||||
if (world.getGameTime() % 10 == 0 && world.random.nextFloat() >= 0.5F) {
|
||||
|
@ -134,7 +137,7 @@ public class ItemWaterBowl extends ItemBase {
|
|||
if (lastX != 0 && lastX != (int) entity.getX() || lastY != 0 && lastY != (int) entity.getY()) {
|
||||
if (!entity.isShiftKeyDown()) {
|
||||
if (entity instanceof Player player) {
|
||||
if (this.tryPlaceContainedLiquid(player, world, player.blockPosition(), true)) {
|
||||
if (this.tryPlaceContainedLiquid(player, world, player.blockPosition(), true)) {
|
||||
this.checkReplace(player, stack, new ItemStack(Items.BOWL), itemSlot);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +162,7 @@ public class ItemWaterBowl extends ItemBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||
public boolean shouldCauseReequipAnimation(@Nonnull ItemStack oldStack, @Nonnull ItemStack newStack, boolean slotChanged) {
|
||||
return !ItemStack.isSameItem(oldStack, newStack);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file ("ItemWaterRemovalRing.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.items;
|
||||
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
public class ItemWaterRemovalRing extends ItemEnergy {
|
||||
|
||||
public ItemWaterRemovalRing() {
|
||||
super(800000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inventoryTick(ItemStack stack, Level world, Entity player, int itemSlot, boolean isSelected) {
|
||||
if (!(player instanceof Player) || player.level().isClientSide || player.isShiftKeyDown()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack equipped = ((Player) player).getMainHandItem();
|
||||
|
||||
int energyUse = 150;
|
||||
if (StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse) {
|
||||
|
||||
//Setting everything to air
|
||||
int range = 3;
|
||||
for (int x = -range; x < range + 1; x++) {
|
||||
for (int z = -range; z < range + 1; z++) {
|
||||
for (int y = -range; y < range + 1; y++) {
|
||||
int theX = Mth.floor(player.getX() + x);
|
||||
int theY = Mth.floor(player.getY() + y);
|
||||
int theZ = Mth.floor(player.getZ() + z);
|
||||
|
||||
//Remove Water
|
||||
BlockPos pos = new BlockPos(theX, theY, theZ);
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
// TODO: Ensure water check is correct
|
||||
if ((block == Blocks.WATER) && this.getEnergyStored(stack) >= energyUse) {
|
||||
world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
|
||||
if (!((Player) player).isCreative()) {
|
||||
this.extractEnergy(stack, energyUse, false);
|
||||
}
|
||||
}
|
||||
//Remove Lava
|
||||
// TODO: Ensure lava check is correct
|
||||
else if ((block == Blocks.LAVA) && this.getEnergyStored(stack) >= energyUse * 2) {
|
||||
world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||
|
||||
if (!((Player) player).isCreative()) {
|
||||
this.extractEnergy(stack, energyUse * 2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
|||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
@ -29,6 +28,8 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
|
||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ItemWingsOfTheBats extends ItemBase {
|
||||
|
||||
public static final String THE_BAT_BAT = "the bat bat";
|
||||
|
@ -50,7 +51,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
|||
*/
|
||||
public static ItemStack getWingItem(Player player) {
|
||||
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||
if (StackUtil.isValid(player.getInventory().getItem(i)) && player.getInventory().getItem(i).getItem() instanceof ItemWingsOfTheBats) {
|
||||
if (!player.getInventory().getItem(i).isEmpty() && player.getInventory().getItem(i).getItem() instanceof ItemWingsOfTheBats) {
|
||||
return player.getInventory().getItem(i);
|
||||
}
|
||||
}
|
||||
|
@ -58,12 +59,12 @@ public class ItemWingsOfTheBats extends ItemBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean isBarVisible(ItemStack stack) {
|
||||
public boolean isBarVisible(@Nonnull ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBarWidth(ItemStack stack) {
|
||||
public int getBarWidth(@Nonnull ItemStack stack) {
|
||||
/* PlayerEntity player = ClientProxy.getCurrentPlayer();
|
||||
if (player != null) {
|
||||
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
|
@ -74,7 +75,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getBarColor(ItemStack stack) {
|
||||
public int getBarColor(@Nonnull ItemStack stack) {
|
||||
/* PlayerEntity player = ClientProxy.getCurrentPlayer();
|
||||
if (player != null) {
|
||||
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||
|
@ -96,7 +97,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
|||
Iterable<ItemStack> equip = player.getHandSlots();
|
||||
for (ItemStack stack : equip) {
|
||||
// Todo: [port] this might not work anymore due to the way things are checked
|
||||
if (StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getHoverName().getString()) && stack.getItem() instanceof SwordItem) {
|
||||
if (!stack.isEmpty() && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getHoverName().getString()) && stack.getItem() instanceof SwordItem) {
|
||||
looting += 3;
|
||||
break;
|
||||
}
|
||||
|
@ -121,7 +122,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
|||
boolean tryDeduct = false;
|
||||
boolean shouldSend = false;
|
||||
|
||||
boolean wingsEquipped = StackUtil.isValid(ItemWingsOfTheBats.getWingItem(player));
|
||||
boolean wingsEquipped = !ItemWingsOfTheBats.getWingItem(player).isEmpty();
|
||||
if (!data.hasBatWings) {
|
||||
if (data.batWingsFlyTime <= 0) {
|
||||
if (wingsEquipped) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.neoforged.neoforge.capabilities.Capabilities;
|
|||
import net.neoforged.neoforge.energy.EnergyStorage;
|
||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -46,7 +47,7 @@ public abstract class ItemEnergy extends ItemBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltip, TooltipFlag flagIn) {
|
||||
public void appendHoverText(@Nonnull ItemStack stack, @Nonnull TooltipContext context, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag flagIn) {
|
||||
super.appendHoverText(stack, context, tooltip, flagIn);
|
||||
IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||
if(storage != null) {
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LensColor extends Lens {
|
|||
for (ItemEntity item : items) {
|
||||
if (item.isAlive() && !item.getItem().isEmpty() && tile.getEnergy() >= ENERGY_USE) {
|
||||
ItemStack newStack = this.tryConvert(item.getItem(), tile.getWorldObject().registryAccess());
|
||||
if (StackUtil.isValid(newStack)) {
|
||||
if (!newStack.isEmpty()) {
|
||||
item.discard();
|
||||
|
||||
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getX(), item.getY(), item.getZ(), newStack);
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
|
|||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
|
@ -45,7 +44,7 @@ public class LensDisenchanting extends Lens {
|
|||
for (ItemEntity item : items) {
|
||||
if (item != null && item.isAlive()) {
|
||||
ItemStack stack = item.getItem();
|
||||
if (StackUtil.isValid(stack) && stack.getCount() == 1) {
|
||||
if (!stack.isEmpty() && stack.getCount() == 1) {
|
||||
Item stackItem = stack.getItem();
|
||||
if (stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK) {
|
||||
if (book == null) {
|
||||
|
@ -55,7 +54,7 @@ public class LensDisenchanting extends Lens {
|
|||
}
|
||||
} else {
|
||||
ItemEnchantments enchants = stack.getAllEnchantments(tile.getWorldObject().registryAccess().lookupOrThrow(Registries.ENCHANTMENT));
|
||||
if (enchants != null && !enchants.isEmpty()) {
|
||||
if (!enchants.isEmpty()) {
|
||||
if (toDisenchant == null) {
|
||||
toDisenchant = item;
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,6 @@ import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
|
|||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
|
@ -228,7 +227,7 @@ public class MethodHandler implements IMethodHandler {
|
|||
List<ItemEntity> items = tile.getWorldObject().getEntitiesOfClass(ItemEntity.class, aabb);
|
||||
for (ItemEntity item : items) {
|
||||
ItemStack stack = item.getItem();
|
||||
if (item.isAlive() && StackUtil.isValid(stack) && !item.getPersistentData().getBoolean("aa_cnv")) {
|
||||
if (item.isAlive() && !stack.isEmpty() && !item.getPersistentData().getBoolean("aa_cnv")) {
|
||||
Optional<RecipeHolder<LaserRecipe>> holder = LaserRecipe.getRecipeForStack(stack);
|
||||
if (holder.isPresent()) {
|
||||
LaserRecipe recipe = holder.get().value();
|
||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer;
|
|||
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
@ -35,7 +34,7 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior {
|
|||
public FarmerResult tryPlantSeed(ItemStack seed, Level world, BlockPos pos, IFarmer farmer) {
|
||||
int use = 350;
|
||||
if (farmer.getEnergy() >= use * 2) {
|
||||
if (StackUtil.isValid(seed)) {
|
||||
if (!seed.isEmpty()) {
|
||||
Item seedItem = seed.getItem();
|
||||
boolean isPumpkin = seedItem == Items.PUMPKIN_SEEDS;
|
||||
if (isPumpkin || seedItem == Items.MELON_SEEDS) {
|
||||
|
|
|
@ -32,39 +32,14 @@ public class SpecialRenderInit {
|
|||
new ThreadSpecialFetcher();
|
||||
}
|
||||
|
||||
// TODO: [port][note] ensure that this still works with the special people stuff
|
||||
public static void parse(Properties properties) {
|
||||
for (String key : properties.stringPropertyNames()) {
|
||||
String[] values = properties.getProperty(key).split("@");
|
||||
if (values.length > 0) {
|
||||
String itemName = values[0];
|
||||
|
||||
int meta;
|
||||
try {
|
||||
meta = Integer.parseInt(values[1]);
|
||||
} catch (Exception e) {
|
||||
meta = 0;
|
||||
}
|
||||
|
||||
// TODO: remove tolowercase hack
|
||||
ResourceLocation resLoc = ResourceLocation.tryParse(itemName.toLowerCase());
|
||||
String value = properties.getProperty(key);
|
||||
if (!value.isEmpty()) {
|
||||
ResourceLocation resLoc = ResourceLocation.tryParse(value);
|
||||
ItemStack stack = findItem(resLoc);
|
||||
|
||||
//TODO Remove this block once the transition to 1.11 is done and the special people stuff file has been converted to snake_case
|
||||
if (!StackUtil.isValid(stack)) {
|
||||
String convertedItemName = "";
|
||||
for (char c : itemName.toCharArray()) {
|
||||
if (Character.isUpperCase(c)) {
|
||||
convertedItemName += "_";
|
||||
convertedItemName += Character.toLowerCase(c);
|
||||
} else {
|
||||
convertedItemName += c;
|
||||
}
|
||||
}
|
||||
stack = findItem(ResourceLocation.tryParse(convertedItemName));
|
||||
}
|
||||
|
||||
if (StackUtil.isValid(stack)) {
|
||||
if (!stack.isEmpty()) {
|
||||
SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack));
|
||||
}
|
||||
}
|
||||
|
@ -73,14 +48,14 @@ public class SpecialRenderInit {
|
|||
|
||||
private static ItemStack findItem(ResourceLocation resLoc) {
|
||||
if (BuiltInRegistries.ITEM.containsKey(resLoc)) {
|
||||
Item item = BuiltInRegistries.ITEM.get(resLoc);
|
||||
if (item != null) {
|
||||
return new ItemStack(item);
|
||||
var item = BuiltInRegistries.ITEM.getOptional(resLoc);
|
||||
if (item.isPresent()) {
|
||||
return new ItemStack(item.get());
|
||||
}
|
||||
} else if (BuiltInRegistries.BLOCK.containsKey(resLoc)) {
|
||||
Block block = BuiltInRegistries.BLOCK.get(resLoc);
|
||||
if (block != null) {
|
||||
return new ItemStack(block);
|
||||
var block = BuiltInRegistries.BLOCK.getOptional(resLoc);
|
||||
if (block.isPresent()) {
|
||||
return new ItemStack(block.get());
|
||||
}
|
||||
}
|
||||
return ItemStack.EMPTY;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
|||
if (t instanceof TileEntityDisplayStand tile) {
|
||||
tile.serverTick();
|
||||
|
||||
if (StackUtil.isValid(tile.inv.getStackInSlot(0)) && !tile.isRedstonePowered) {
|
||||
if (!tile.inv.getStackInSlot(0).isEmpty() && !tile.isRedstonePowered) {
|
||||
IDisplayStandItem item = tile.convertToDisplayStandItem(tile.inv.getStackInSlot(0).getItem());
|
||||
if (item != null) {
|
||||
int energy = item.getUsePerTick(tile.inv.getStackInSlot(0), tile, tile.ticksElapsed);
|
||||
|
|
|
@ -53,6 +53,7 @@ public class TileEntityItemInterface extends TileEntityBase {
|
|||
return TileEntityItemInterface.this.getSlotCount();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
IItemHandlerInfo handler = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
||||
|
@ -62,8 +63,9 @@ public class TileEntityItemInterface extends TileEntityBase {
|
|||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
||||
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
||||
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stack, false)) {
|
||||
ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate);
|
||||
|
@ -76,14 +78,15 @@ public class TileEntityItemInterface extends TileEntityBase {
|
|||
return stack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||
ItemStack stackIn = this.getStackInSlot(slot);
|
||||
if (StackUtil.isValid(stackIn)) {
|
||||
if (!stackIn.isEmpty()) {
|
||||
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
||||
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stackIn, true)) {
|
||||
ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate);
|
||||
if (StackUtil.isValid(extracted) && !simulate) {
|
||||
if (!extracted.isEmpty() && !simulate) {
|
||||
TileEntityItemInterface.this.setChanged();
|
||||
TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getBlockPos(), info.relayInQuestion.getBlockPos());
|
||||
}
|
||||
|
@ -285,7 +288,7 @@ public class TileEntityItemInterface extends TileEntityBase {
|
|||
}
|
||||
}
|
||||
|
||||
private static class IItemHandlerInfo extends SpecificItemHandlerInfo {
|
||||
public static class IItemHandlerInfo extends SpecificItemHandlerInfo {
|
||||
|
||||
public final IItemHandler handler;
|
||||
public final int switchedIndex;
|
||||
|
@ -297,7 +300,7 @@ public class TileEntityItemInterface extends TileEntityBase {
|
|||
}
|
||||
}
|
||||
|
||||
private static class SpecificItemHandlerInfo {
|
||||
public static class SpecificItemHandlerInfo {
|
||||
|
||||
public final TileEntityLaserRelayItem relayInQuestion;
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase {
|
|||
|
||||
public int getMaxRange() {
|
||||
ItemStack upgrade = this.inv.getStackInSlot(0);
|
||||
if (StackUtil.isValid(upgrade) && upgrade.getItem() == ActuallyItems.LASER_UPGRADE_RANGE.get()) {
|
||||
if (!upgrade.isEmpty() && upgrade.getItem() == ActuallyItems.LASER_UPGRADE_RANGE.get()) {
|
||||
return MAX_DISTANCE_RANGED;
|
||||
} else {
|
||||
return MAX_DISTANCE;
|
||||
|
|
|
@ -175,7 +175,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
|||
}
|
||||
|
||||
ItemStack stack = tile.inv.getStackInSlot(1);
|
||||
if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemSolidifiedExperience) {
|
||||
if (!stack.isEmpty() && stack.getItem() instanceof ItemSolidifiedExperience) {
|
||||
int remainingSpace = Mth.clamp(Integer.MAX_VALUE - tile.amount, 0, stack.getCount());
|
||||
if (stack.getCount() >= remainingSpace && remainingSpace != 0) {
|
||||
tile.amount += remainingSpace;
|
||||
|
|
|
@ -45,6 +45,8 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|||
import net.neoforged.neoforge.client.ClientHooks;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public final class AssetUtil {
|
||||
|
||||
public static final int MAX_LIGHT_X = 0xF000F0;
|
||||
|
@ -94,8 +96,8 @@ public final class AssetUtil {
|
|||
// }
|
||||
|
||||
|
||||
public static void renderItemWithoutScrewingWithColors(ItemStack stack, PoseStack matrices, int combinedOverlay, int combinedLight) {
|
||||
if (StackUtil.isValid(stack)) {
|
||||
public static void renderItemWithoutScrewingWithColors(@Nonnull ItemStack stack, PoseStack matrices, int combinedOverlay, int combinedLight) {
|
||||
if (!stack.isEmpty()) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
ItemRenderer renderer = mc.getItemRenderer();
|
||||
TextureManager manager = mc.getTextureManager();
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
// TODO: [port][note] no longer used
|
||||
///*
|
||||
// * This file ("AwfulUtil.java") is part of the Actually Additions mod for Minecraft.
|
||||
// * It is created and owned by Ellpeck and distributed
|
||||
// * under the Actually Additions License to be found at
|
||||
// * http://ellpeck.de/actaddlicense
|
||||
// * View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
// *
|
||||
// * © 2015-2017 Ellpeck
|
||||
// */
|
||||
//
|
||||
//package de.ellpeck.actuallyadditions.mod.util;
|
||||
//
|
||||
//import com.google.common.collect.Lists;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.loot.LootContext;
|
||||
//import net.minecraft.loot.LootTable;
|
||||
//import net.minecraft.util.math.MathHelper;
|
||||
//import net.minecraftforge.fml.loading.FMLLoader;
|
||||
//import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
//
|
||||
//import java.util.Collections;
|
||||
//import java.util.Iterator;
|
||||
//import java.util.List;
|
||||
//import java.util.Random;
|
||||
//
|
||||
////This is stuff copied from somewhere in vanilla and changed so that it works properly
|
||||
////It's unpolished and vanilla-y, so don't look at it! O_O
|
||||
//public final class AwfulUtil {
|
||||
//
|
||||
// public static void fillInventory(LootTable table, IItemHandlerModifiable inventory, Random rand, LootContext context) {
|
||||
// List<ItemStack> list = table.generateLootForPools(rand, context);
|
||||
// List<Integer> list1 = getEmptySlotsRandomized(inventory, rand);
|
||||
// shuffleItems(list, list1.size(), rand);
|
||||
//
|
||||
// for (ItemStack itemstack : list) {
|
||||
// if (itemstack.isEmpty()) {
|
||||
// inventory.setStackInSlot(list1.remove(list1.size() - 1), ItemStack.EMPTY);
|
||||
// } else {
|
||||
// inventory.setStackInSlot(list1.remove(list1.size() - 1), itemstack);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static void shuffleItems(List<ItemStack> stacks, int someInt, Random rand) {
|
||||
// List<ItemStack> list = Lists.newArrayList();
|
||||
// Iterator<ItemStack> iterator = stacks.iterator();
|
||||
//
|
||||
// while (iterator.hasNext()) {
|
||||
// ItemStack itemstack = iterator.next();
|
||||
//
|
||||
// if (itemstack.isEmpty()) {
|
||||
// iterator.remove();
|
||||
// } else if (itemstack.getCount() > 1) {
|
||||
// list.add(itemstack);
|
||||
// iterator.remove();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// someInt = someInt - stacks.size();
|
||||
//
|
||||
// while (someInt > 0 && list.size() > 0) {
|
||||
// ItemStack itemstack2 = list.remove(MathHelper.nextInt(rand, 0, list.size() - 1));
|
||||
// int i = MathHelper.nextInt(rand, 1, itemstack2.getCount() / 2);
|
||||
// ItemStack itemstack1 = itemstack2.split(i);
|
||||
//
|
||||
// if (itemstack2.getCount() > 1 && rand.nextBoolean()) {
|
||||
// list.add(itemstack2);
|
||||
// } else {
|
||||
// stacks.add(itemstack2);
|
||||
// }
|
||||
//
|
||||
// if (itemstack1.getCount() > 1 && rand.nextBoolean()) {
|
||||
// list.add(itemstack1);
|
||||
// } else {
|
||||
// stacks.add(itemstack1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// stacks.addAll(list);
|
||||
// Collections.shuffle(stacks, rand);
|
||||
// }
|
||||
//
|
||||
// private static List<Integer> getEmptySlotsRandomized(IItemHandlerModifiable inventory, Random rand) {
|
||||
// List<Integer> list = Lists.newArrayList();
|
||||
//
|
||||
// for (int i = 0; i < inventory.getSlots(); ++i) {
|
||||
// if (inventory.getStackInSlot(i).isEmpty()) {
|
||||
// list.add(i);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Collections.shuffle(list, rand);
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
// public static void callTheFuckinPolice(Object... stuff) {
|
||||
// int i = 0;
|
||||
// String error = "Actually Additions: Something is very wrong. This method was provided with ";
|
||||
// for (Object k : stuff) {
|
||||
// error += "\n" + i++ + ": " + (k == null
|
||||
// ? "null"
|
||||
// : k.getClass().getSimpleName() + " <- CLASS | INSTANCE -> " + k.toString() + ", ");
|
||||
// }
|
||||
// error += "\n" + "The current side is: " + FMLLoader.getDist().name();
|
||||
// error += "\n" + "Report this to https://github.com/Ellpeck/ActuallyAdditions/issues";
|
||||
// throw new IllegalStateException(error);
|
||||
// }
|
||||
//}
|
|
@ -16,45 +16,9 @@ import net.minecraft.core.NonNullList;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class StackUtil {
|
||||
|
||||
/**
|
||||
* Pretty much just a check for {@link ItemStack#isEmpty()} but exists in case Mojang does some more refactoring.
|
||||
*
|
||||
* @param stack The stack
|
||||
* @return If the stack is not empty, or if it's an IDisableableItem, if its enabled.
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isValid(ItemStack stack) {
|
||||
return stack != null && !stack.isEmpty();
|
||||
// if (stack == null) AwfulUtil.callTheFuckinPolice("Null ItemStack detected", stack);
|
||||
// Item i = stack.getItem();
|
||||
// if (i instanceof IDisableableItem) return !((IDisableableItem) i).isDisabled();
|
||||
// return !stack.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a collection of stacks are empty, as {@link Collection#isEmpty()} does not care about empty stacks.
|
||||
*
|
||||
* @param stacks Some ItemStacks
|
||||
* @return If all stacks in the collection return true for {@link ItemStack#isEmpty()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isEmpty(Collection<ItemStack> stacks) {
|
||||
if (stacks.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (ItemStack s : stacks) {
|
||||
if (!s.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all provided itemstacks will fit in the AA handler. Use addAll below to actually add the stacks. This is strictly a check function.
|
||||
*
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* This file ("StringUtil.java") is part of the Actually Additions mod for Minecraft.
|
||||
* It is created and owned by Ellpeck and distributed
|
||||
* under the Actually Additions License to be found at
|
||||
* http://ellpeck.de/actaddlicense
|
||||
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
||||
*
|
||||
* © 2015-2017 Ellpeck
|
||||
*/
|
||||
|
||||
package de.ellpeck.actuallyadditions.mod.util;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
|
||||
@Deprecated
|
||||
public final class StringUtil {
|
||||
|
||||
/**
|
||||
* Localizes a given formatted String with the given Replacements
|
||||
*/
|
||||
|
||||
public static String localizeFormatted(String text, Object... replace) {
|
||||
return I18n.get(text, replace);
|
||||
}
|
||||
|
||||
// TODO: Move to official
|
||||
@Deprecated
|
||||
|
||||
public static void drawSplitString(Font renderer, String strg, int x, int y, int width, int color, boolean shadow) {
|
||||
// ResourcePackList <- holds the correct way
|
||||
// List<String> list = renderer.listFormattedStringToWidth(strg, width);
|
||||
// for (int i = 0; i < list.size(); i++) {
|
||||
// String s1 = list.get(i);
|
||||
// renderer.draw(s1, x, y + i * renderer.lineHeight, color, shadow);
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
// public static void renderSplitScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale, int length) {
|
||||
// List<String> lines = font.listFormattedStringToWidth(text, (int) (length / scale));
|
||||
// for (int i = 0; i < lines.size(); i++) {
|
||||
// renderScaledAsciiString(font, lines.get(i), x, y + i * (int) (font.lineHeight * scale + 3), color, shadow, scale);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public static void renderScaledString(GuiGraphics guiGraphics, Font font, String text, float x, float y, int color, boolean shadow, float scale) {
|
||||
PoseStack matrices = guiGraphics.pose();
|
||||
matrices.pushPose();
|
||||
matrices.translate(x, y, 0);
|
||||
matrices.scale(scale, scale, 1.0F);
|
||||
if (shadow)
|
||||
guiGraphics.drawString(font, text, 0, 0, color);
|
||||
else
|
||||
guiGraphics.drawString(font, text, x, y, color, false);
|
||||
matrices.popPose();
|
||||
}
|
||||
}
|
|
@ -44,6 +44,7 @@ import net.neoforged.neoforge.fluids.FluidStack;
|
|||
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||
import net.neoforged.neoforge.items.IItemHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -59,7 +60,7 @@ public final class WorldUtil {
|
|||
|
||||
public static boolean doItemInteraction(SlotlessableItemHandlerWrapper extractWrapper, SlotlessableItemHandlerWrapper insertWrapper, int maxExtract, int extractSlotStart, int extractSlotEnd, int insertSlotStart, int insertSlotEnd, FilterSettings filter) {
|
||||
ItemStack theoreticalExtract = extractItem(extractWrapper, maxExtract, true, extractSlotStart, extractSlotEnd, filter);
|
||||
if (StackUtil.isValid(theoreticalExtract)) {
|
||||
if (!theoreticalExtract.isEmpty()) {
|
||||
ItemStack remaining = StackUtil.insertItem(insertWrapper, theoreticalExtract, false, insertSlotStart, insertSlotEnd);
|
||||
if (!ItemStack.matches(remaining, theoreticalExtract)) {
|
||||
int toExtract = theoreticalExtract.getCount() - remaining.getCount();
|
||||
|
@ -95,14 +96,14 @@ public final class WorldUtil {
|
|||
}*/
|
||||
}
|
||||
|
||||
if (!StackUtil.isValid(extracted)) {
|
||||
if (extracted.isEmpty()) {
|
||||
IItemHandler handler = extractWrapper.getNormalHandler();
|
||||
if (handler != null) {
|
||||
for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) {
|
||||
if (filter == null || !filter.needsCheck() || filter.check(handler.getStackInSlot(i))) {
|
||||
extracted = handler.extractItem(i, maxExtract, simulate);
|
||||
|
||||
if (StackUtil.isValid(extracted)) {
|
||||
if (!extracted.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +163,8 @@ public final class WorldUtil {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static ItemStack useItemAtSide(Direction side, Level level, BlockPos pos, ItemStack stack) {
|
||||
if (level instanceof ServerLevel && StackUtil.isValid(stack) && pos != null) {
|
||||
public static ItemStack useItemAtSide(Direction side, Level level, BlockPos pos, @Nonnull ItemStack stack) {
|
||||
if (level instanceof ServerLevel && !stack.isEmpty() && pos != null) {
|
||||
BlockPos offsetPos = pos.relative(side);
|
||||
BlockState state = level.getBlockState(offsetPos);
|
||||
boolean replaceable = state.canBeReplaced(new BlockPlaceContext(level, null, InteractionHand.MAIN_HAND, stack,
|
||||
|
|
Loading…
Reference in a new issue