mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-25 08:28:34 +01:00
Compare commits
2 commits
9cfbb61739
...
268cf651d0
Author | SHA1 | Date | |
---|---|---|---|
|
268cf651d0 | ||
|
6774b08ac5 |
47 changed files with 155 additions and 1354 deletions
|
@ -1,189 +0,0 @@
|
|||
// TODO: [port][note] no longer used
|
||||
///*
|
||||
// * This file ("BlockGiantChest.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.blocks;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.block.Block;
|
||||
//import net.minecraft.block.SoundType;
|
||||
//import net.minecraft.block.material.Material;
|
||||
//import net.minecraft.client.util.ITooltipFlag;
|
||||
//import net.minecraft.entity.EntityLivingBase;
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.item.EnumRarity;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.nbt.CompoundNBT;
|
||||
//import net.minecraft.nbt.ListNBT;
|
||||
//import net.minecraft.tileentity.TileEntity;
|
||||
//import net.minecraft.util.Hand;
|
||||
//import net.minecraft.util.NonNullList;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.util.text.TextFormatting;
|
||||
//import net.minecraft.world.IBlockAccess;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraftforge.items.IItemHandlerModifiable;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class BlockGiantChest extends BlockContainerBase {
|
||||
//
|
||||
// public final int type;
|
||||
//
|
||||
// public BlockGiantChest(String name, int type) {
|
||||
// super(Material.WOOD, name);
|
||||
// this.type = type;
|
||||
//
|
||||
// this.setHarvestLevel("axe", 0);
|
||||
// this.setHardness(0.5F);
|
||||
// this.setResistance(15.0F);
|
||||
// this.setSoundType(SoundType.WOOD);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public TileEntity createNewTileEntity(IBlockReader worldIn) {
|
||||
// switch (this.type) {
|
||||
// case 1:
|
||||
// return new TileEntityGiantChestMedium();
|
||||
// case 2:
|
||||
// return new TileEntityGiantChestLarge();
|
||||
// default:
|
||||
// return new TileEntityGiantChest();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isFullCube(BlockState state) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isOpaqueCube(BlockState state) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
|
||||
// if (!world.isRemote) {
|
||||
// TileEntityGiantChest chest = (TileEntityGiantChest) world.getTileEntity(pos);
|
||||
// if (chest != null) {
|
||||
// chest.fillWithLoot(player);
|
||||
// player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.GIANT_CHEST.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public EnumRarity getRarity(ItemStack stack) {
|
||||
// return EnumRarity.EPIC;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onBlockPlacedBy(World world, BlockPos pos, BlockState state, EntityLivingBase entity, ItemStack stack) {
|
||||
// if (stack.getTagCompound() != null) {
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// if (tile instanceof TileEntityGiantChest) {
|
||||
// ListNBT list = stack.getTagCompound().getList("Items", 10);
|
||||
// IItemHandlerModifiable inv = ((TileEntityGiantChest) tile).inv;
|
||||
//
|
||||
// for (int i = 0; i < list.size(); i++) {
|
||||
// CompoundNBT compound = list.getCompound(i);
|
||||
// if (compound != null && compound.hasKey("id")) {
|
||||
// inv.setStackInSlot(i, new ItemStack(list.getCompound(i)));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// super.onBlockPlacedBy(world, pos, state, entity, stack);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void getDrops(NonNullList<ItemStack> drops, IBlockAccess world, BlockPos pos, BlockState state, int fortune) {
|
||||
// super.getDrops(drops, world, pos, state, fortune);
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// if (tile instanceof TileEntityGiantChest) {
|
||||
// ItemStackHandlerAA slots = ((TileEntityGiantChest) tile).inv;
|
||||
// int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
||||
// if (place >= 0) {
|
||||
// ListNBT list = new ListNBT();
|
||||
// for (int i = 0; i < slots.getSlots(); i++) {
|
||||
// //Destroy the keeper
|
||||
// if (i != place) {
|
||||
// CompoundNBT compound = new CompoundNBT();
|
||||
// if (StackUtil.isValid(slots.getStackInSlot(i))) {
|
||||
// slots.getStackInSlot(i).writeToNBT(compound);
|
||||
// }
|
||||
// list.appendTag(compound);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (list.size() > 0) {
|
||||
// ItemStack stackInQuestion = drops.get(0);
|
||||
// if (StackUtil.isValid(stackInQuestion)) {
|
||||
// if (stackInQuestion.getTagCompound() == null) {
|
||||
// stackInQuestion.setTagCompound(new CompoundNBT());
|
||||
// }
|
||||
// stackInQuestion.getTagCompound().setTag("Items", list);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean shouldDropInventory(World world, BlockPos pos) {
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected ItemBlockBase getItemBlock() {
|
||||
// return new TheItemBlock(this);
|
||||
// }
|
||||
//
|
||||
// public static class TheItemBlock extends ItemBlockBase {
|
||||
//
|
||||
// public TheItemBlock(Block block) {
|
||||
// super(block);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced) {
|
||||
// int type = this.block instanceof BlockGiantChest
|
||||
// ? ((BlockGiantChest) this.block).type
|
||||
// : -1;
|
||||
// if (type == 2) {
|
||||
// tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container.actuallyadditions.giantChestLarge.desc"));
|
||||
// } else if (type == 0) {
|
||||
// tooltip.add(TextFormatting.ITALIC + StringUtil.localize("container.actuallyadditions.giantChest.desc"));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CompoundNBT getNBTShareTag(ItemStack stack) {
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
// TODO: [port][note] no longer used
|
||||
///*
|
||||
// * This file ("ContainerGiantChest.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.inventory;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import invtweaks.api.container.ChestContainer;
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.entity.player.PlayerInventory;
|
||||
//import net.minecraft.inventory.container.Container;
|
||||
//import net.minecraft.inventory.container.Slot;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//@ChestContainer(rowSize = 13, isLargeChest = true)
|
||||
//public class ContainerGiantChest extends Container {
|
||||
//
|
||||
// public final TileEntityGiantChest tileChest;
|
||||
//
|
||||
// public ContainerGiantChest(PlayerInventory inventory, TileEntityBase tile, int page) {
|
||||
// this.tileChest = (TileEntityGiantChest) tile;
|
||||
//
|
||||
// for (int i = 0; i < 9; i++) {
|
||||
// for (int j = 0; j < 13; j++) {
|
||||
// this.addSlot(new SlotItemHandlerUnconditioned(this.tileChest.inv, 9 * 13 * page + j + i * 13, 5 + j * 18, 5 + i * 18));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
// for (int j = 0; j < 9; j++) {
|
||||
// this.addSlot(new Slot(inventory, j + i * 9 + 9, 33 + 8 + j * 18, 172 + 4 + i * 18));
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < 9; i++) {
|
||||
// this.addSlot(new Slot(inventory, i, 33 + 8 + i * 18, 172 + 62));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack transferStackInSlot(PlayerEntity player, int slot) {
|
||||
// int inventoryStart = 117;
|
||||
// int inventoryEnd = inventoryStart + 26;
|
||||
// int hotbarStart = inventoryEnd + 1;
|
||||
// int hotbarEnd = hotbarStart + 8;
|
||||
//
|
||||
// Slot theSlot = this.inventorySlots.get(slot);
|
||||
//
|
||||
// if (theSlot != null && theSlot.getHasStack()) {
|
||||
// ItemStack newStack = theSlot.getStack();
|
||||
// ItemStack currentStack = newStack.copy();
|
||||
//
|
||||
// //Other Slots in Inventory excluded
|
||||
// if (slot >= inventoryStart) {
|
||||
// //Shift from Inventory
|
||||
// if (!this.mergeItemStack(newStack, 0, 117, false)) {
|
||||
// //
|
||||
// if (slot >= inventoryStart && slot <= inventoryEnd) {
|
||||
// if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// }
|
||||
// } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
//
|
||||
// if (!StackUtil.isValid(newStack)) {
|
||||
// theSlot.putStack(StackUtil.getEmpty());
|
||||
// } else {
|
||||
// theSlot.onSlotChanged();
|
||||
// }
|
||||
//
|
||||
// if (newStack.getCount() == currentStack.getCount()) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// theSlot.onTake(player, newStack);
|
||||
//
|
||||
// return currentStack;
|
||||
// }
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canInteractWith(PlayerEntity player) {
|
||||
// return this.tileChest.canPlayerUse(player);
|
||||
// }
|
||||
//}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
// TODO: [port][note] no longer needed
|
||||
///*
|
||||
// * This file ("ContainerRepairer.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.inventory;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.entity.player.PlayerInventory;
|
||||
//import net.minecraft.inventory.container.Container;
|
||||
//import net.minecraft.inventory.container.Slot;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//public class ContainerRepairer extends Container {
|
||||
//
|
||||
// private final TileEntityItemRepairer tileRepairer;
|
||||
//
|
||||
// public ContainerRepairer(PlayerInventory inventory, TileEntityBase tile) {
|
||||
// this.tileRepairer = (TileEntityItemRepairer) tile;
|
||||
//
|
||||
// this.addSlot(new SlotItemHandlerUnconditioned(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_INPUT, 47, 53));
|
||||
// this.addSlot(new SlotOutput(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53));
|
||||
//
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
// for (int j = 0; j < 9; j++) {
|
||||
// this.addSlot(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
||||
// }
|
||||
// }
|
||||
// for (int i = 0; i < 9; i++) {
|
||||
// this.addSlot(new Slot(inventory, i, 8 + i * 18, 155));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack transferStackInSlot(PlayerEntity player, int slot) {
|
||||
// int inventoryStart = 2;
|
||||
// int inventoryEnd = inventoryStart + 26;
|
||||
// int hotbarStart = inventoryEnd + 1;
|
||||
// int hotbarEnd = hotbarStart + 8;
|
||||
//
|
||||
// Slot theSlot = this.inventorySlots.get(slot);
|
||||
//
|
||||
// if (theSlot != null && theSlot.getHasStack()) {
|
||||
// ItemStack newStack = theSlot.getStack();
|
||||
// ItemStack currentStack = newStack.copy();
|
||||
//
|
||||
// //Other Slots in Inventory excluded
|
||||
// if (slot >= inventoryStart) {
|
||||
// //Shift from Inventory
|
||||
// if (TileEntityItemRepairer.canBeRepaired(newStack)) {
|
||||
// if (!this.mergeItemStack(newStack, TileEntityItemRepairer.SLOT_INPUT, TileEntityItemRepairer.SLOT_INPUT + 1, false)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// }
|
||||
// //
|
||||
//
|
||||
// else if (slot >= inventoryStart && slot <= inventoryEnd) {
|
||||
// if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// } else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// } else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
//
|
||||
// if (!StackUtil.isValid(newStack)) {
|
||||
// theSlot.putStack(StackUtil.getEmpty());
|
||||
// } else {
|
||||
// theSlot.onSlotChanged();
|
||||
// }
|
||||
//
|
||||
// if (newStack.getCount() == currentStack.getCount()) {
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
// theSlot.onTake(player, newStack);
|
||||
//
|
||||
// return currentStack;
|
||||
// }
|
||||
// return StackUtil.getEmpty();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canInteractWith(PlayerEntity player) {
|
||||
// return this.tileRepairer.canPlayerUse(player);
|
||||
// }
|
||||
//}
|
|
@ -1,29 +0,0 @@
|
|||
// TODO: [port][note] no longer needed
|
||||
///*
|
||||
// * This file ("ContainerSmileyCloud.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.inventory;
|
||||
//
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.inventory.container.Container;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//
|
||||
//public class ContainerSmileyCloud extends Container {
|
||||
//
|
||||
// @Override
|
||||
// public ItemStack transferStackInSlot(PlayerEntity player, int slot) {
|
||||
// return ItemStack.EMPTY;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean canInteractWith(PlayerEntity player) {
|
||||
// return true;
|
||||
// }
|
||||
//}
|
|
@ -1,79 +0,0 @@
|
|||
// TODO: [port] no longer needed
|
||||
///*
|
||||
// * This file ("GuiGiantChest.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.inventory.gui;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.ContainerGiantChest;
|
||||
//import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import net.minecraft.client.gui.widget.button.Button;
|
||||
//import net.minecraft.entity.player.PlayerInventory;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//
|
||||
//public class GuiGiantChest extends GuiWtfMojang {
|
||||
//
|
||||
// private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_giant_chest");
|
||||
//
|
||||
// private final TileEntityGiantChest chest;
|
||||
// private final int page;
|
||||
//
|
||||
// public GuiGiantChest(PlayerInventory inventory, TileEntityBase tile, int page) {
|
||||
// super(new ContainerGiantChest(inventory, tile, page));
|
||||
// this.chest = (TileEntityGiantChest) tile;
|
||||
// this.page = page;
|
||||
//
|
||||
// this.xSize = 242;
|
||||
// this.ySize = 172 + 86;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void init() {
|
||||
// super.init();
|
||||
//
|
||||
// if (this.page > 0) {
|
||||
// this.addButton(new Button(this.page - 1, this.guiLeft + 13, this.guiTop + 172, 20, 20, "<"));
|
||||
// }
|
||||
//
|
||||
// if (this.page == 0 && this.chest instanceof TileEntityGiantChestMedium || this.page <= 1 && this.chest instanceof TileEntityGiantChestLarge) {
|
||||
// this.addButton(new Button(this.page + 1, this.guiLeft + 209, this.guiTop + 172, 20, 20, ">"));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void actionPerformed(Button button) throws IOException {
|
||||
// if (button.id >= 0 && button.id < 3) {
|
||||
// PacketHandlerHelper.sendButtonPacket(this.chest, button.id);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
// AssetUtil.displayNameString(this.font, this.xSize, -10, this.chest);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
// RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
// this.getMinecraft().getTextureManager().bindTexture(RES_LOC);
|
||||
// guiGraphics.blit(matrices, this.guiLeft, this.guiTop, 0, 0, 242, 190);
|
||||
// this.getMinecraft().getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
|
||||
// guiGraphics.blit(matrices, this.guiLeft + 33, this.guiTop + 172, 0, 0, 176, 86);
|
||||
// }
|
||||
//}
|
|
@ -1,72 +0,0 @@
|
|||
// TODO: [port][note] no longer needed
|
||||
///*
|
||||
// * This file ("GuiRepairer.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.inventory.gui;
|
||||
//
|
||||
//import com.mojang.blaze3d.platform.GlStateManager;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.ContainerRepairer;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import net.minecraft.entity.player.PlayerInventory;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
//
|
||||
//
|
||||
//
|
||||
//public class GuiRepairer extends GuiWtfMojang {
|
||||
//
|
||||
// private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_repairer");
|
||||
// private final TileEntityItemRepairer tileRepairer;
|
||||
// private EnergyDisplay energy;
|
||||
//
|
||||
// public GuiRepairer(PlayerInventory inventory, TileEntityBase tile) {
|
||||
// super(new ContainerRepairer(inventory, tile));
|
||||
// this.tileRepairer = (TileEntityItemRepairer) tile;
|
||||
// this.xSize = 176;
|
||||
// this.ySize = 93 + 86;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void init() {
|
||||
// super.init();
|
||||
// this.energy = new EnergyDisplay(this.guiLeft + 27, this.guiTop + 5, this.tileRepairer.storage);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void render(int x, int y, float f) {
|
||||
// super.render(x, y, f);
|
||||
// this.energy.drawOverlay(x, y);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
// AssetUtil.displayNameString(this.font, this.xSize, -10, this.tileRepairer);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
// RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//
|
||||
// this.getMinecraft().getTextureManager().bindTexture(AssetUtil.GUI_INVENTORY_LOCATION);
|
||||
// guiGraphics.blit(matrices, this.guiLeft, this.guiTop + 93, 0, 0, 176, 86);
|
||||
//
|
||||
// this.getMinecraft().getTextureManager().bindTexture(RES_LOC);
|
||||
// guiGraphics.blit(matrices, this.guiLeft, this.guiTop, 0, 0, 176, 93);
|
||||
//
|
||||
// if (TileEntityItemRepairer.canBeRepaired(this.tileRepairer.inv.getStackInSlot(TileEntityItemRepairer.SLOT_INPUT))) {
|
||||
// int i = this.tileRepairer.getItemDamageToScale(22);
|
||||
// guiGraphics.blit(matrices, this.guiLeft + 73, this.guiTop + 52, 176, 28, i, 16);
|
||||
// }
|
||||
//
|
||||
// this.energy.draw();
|
||||
// }
|
||||
//}
|
|
@ -1,127 +0,0 @@
|
|||
// TODO: [port][note] no longer needed
|
||||
///*
|
||||
// * This file ("GuiSmileyCloud.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.inventory.gui;
|
||||
//
|
||||
//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.inventory.ContainerSmileyCloud;
|
||||
//import de.ellpeck.actuallyadditions.mod.network.packet.PacketClientToServer;
|
||||
//import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
//import net.minecraft.nbt.CompoundNBT;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import net.minecraft.util.text.TextFormatting;
|
||||
//import net.minecraft.world.World;
|
||||
//import net.minecraftforge.api.distmarker.Dist;
|
||||
//import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
//import org.lwjgl.input.Keyboard;
|
||||
//
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//
|
||||
//public class GuiSmileyCloud extends GuiWtfMojang {
|
||||
//
|
||||
// private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("gui_smiley_cloud");
|
||||
//
|
||||
// private final int x;
|
||||
// private final int y;
|
||||
// private final int z;
|
||||
// private final World world;
|
||||
// private final TileEntitySmileyCloud cloud;
|
||||
// private TextFieldWidget nameField;
|
||||
//
|
||||
// public GuiSmileyCloud(TileEntityBase tile, int x, int y, int z, World world) {
|
||||
// super(new ContainerSmileyCloud());
|
||||
// this.cloud = (TileEntitySmileyCloud) tile;
|
||||
// this.x = x;
|
||||
// this.y = y;
|
||||
// this.z = z;
|
||||
// this.world = world;
|
||||
// this.xSize = 124;
|
||||
// this.ySize = 20;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void init() {
|
||||
// super.init();
|
||||
//
|
||||
// this.nameField = new TextFieldWidget(4000, this.font, this.guiLeft + 5, this.guiTop + 6, 114, 8);
|
||||
// this.nameField.setMaxStringLength(20);
|
||||
// this.nameField.setEnableBackgroundDrawing(false);
|
||||
// this.nameField.setFocused(true);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
// String name = this.cloud.name == null || this.cloud.name.isEmpty()
|
||||
// ? ""
|
||||
// : TextFormatting.GOLD + this.cloud.name + TextFormatting.RESET + " " + StringUtil.localize("info.actuallyadditions.gui.the") + " ";
|
||||
// String localizedName = name + StringUtil.localize("container.actuallyadditions.cloud.name");
|
||||
// this.font.drawString(localizedName, this.xSize / 2 - this.font.getStringWidth(localizedName) / 2, -10, StringUtil.DECIMAL_COLOR_WHITE);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
// RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
//
|
||||
// this.getMinecraft().getTextureManager().bindTexture(RES_LOC);
|
||||
// guiGraphics.blit(matrices, this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
|
||||
//
|
||||
// this.nameField.drawTextBox();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void mouseClicked(int par1, int par2, int par3) throws IOException {
|
||||
// this.nameField.mouseClicked(par1, par2, par3);
|
||||
// super.mouseClicked(par1, par2, par3);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void keyTyped(char theChar, int key) throws IOException {
|
||||
// if (key != 1 && this.nameField.isFocused()) {
|
||||
// if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
|
||||
// this.setVariable(this.nameField);
|
||||
// } else {
|
||||
// this.nameField.textboxKeyTyped(theChar, key);
|
||||
// }
|
||||
// } else {
|
||||
// super.keyTyped(theChar, key);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void updateScreen() {
|
||||
// super.updateScreen();
|
||||
// this.nameField.updateCursorCounter();
|
||||
// }
|
||||
//
|
||||
// public void setVariable(TextFieldWidget field) {
|
||||
// this.sendPacket(field.getText(), 0);
|
||||
// field.setText("");
|
||||
// }
|
||||
//
|
||||
// private void sendPacket(String text, int textID) {
|
||||
// CompoundNBT compound = new CompoundNBT();
|
||||
// compound.putInt("X", this.x);
|
||||
// compound.putInt("Y", this.y);
|
||||
// compound.putInt("Z", this.z);
|
||||
// compound.putInt("WorldID", this.world.provider.getDimension());
|
||||
// compound.putInt("PlayerID", Minecraft.getInstance().player.getEntityId());
|
||||
// compound.putInt("TextID", textID);
|
||||
// compound.setString("Text", text);
|
||||
// PacketDistributor.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_STRING_TO_TILE_HANDLER));
|
||||
// }
|
||||
//}
|
|
@ -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"
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
///*
|
||||
// * This file ("ItemCrystalShard.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.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.blocks.BlockCrystal;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.client.renderer.color.IItemColor;
|
||||
//import net.minecraft.creativetab.CreativeTabs;
|
||||
//import net.minecraft.item.EnumRarity;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.NonNullList;
|
||||
//import net.minecraftforge.common.IRarity;
|
||||
//
|
||||
//
|
||||
//public class ItemCrystalShard extends ItemBase implements IColorProvidingItem {
|
||||
//
|
||||
// public ItemCrystalShard() {
|
||||
// super(name);
|
||||
// this.setHasSubtypes(true);
|
||||
// this.setMaxDamage(0);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public int getMetadata(int damage) {
|
||||
// return damage;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDescriptionId(ItemStack stack) {
|
||||
// return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
|
||||
// ? StringUtil.BUGGED_ITEM_NAME
|
||||
// : this.getDescriptionId() + "_" + BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].name;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IRarity getForgeRarity(ItemStack stack) {
|
||||
// return stack.getItemDamage() >= BlockCrystal.ALL_CRYSTALS.length
|
||||
// ? EnumRarity.COMMON
|
||||
// : BlockCrystal.ALL_CRYSTALS[stack.getItemDamage()].rarity;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
//
|
||||
// public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> list) {
|
||||
// if (this.isInCreativeTab(tab)) {
|
||||
// for (int j = 0; j < BlockCrystal.ALL_CRYSTALS.length; j++) {
|
||||
// list.add(new ItemStack(this, 1, j));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void registerRendering() {
|
||||
// for (int i = 0; i < BlockCrystal.ALL_CRYSTALS.length; i++) {
|
||||
// ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), this.getRegistryName(), "inventory");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
//
|
||||
// public IItemColor getItemColor() {
|
||||
// return (stack, tintIndex) -> {
|
||||
// int damage = stack.getItemDamage();
|
||||
// if (damage >= 0 && damage < BlockCrystal.ALL_CRYSTALS.length) {
|
||||
// return BlockCrystal.ALL_CRYSTALS[damage].clusterColor;
|
||||
// } else {
|
||||
// return 0;
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//}
|
|
@ -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,11 +85,12 @@ 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()) {
|
||||
|
@ -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));
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
// TODO: [port] REMOVE THIS CLASS, NO longer needed
|
||||
///*
|
||||
// * This file ("ItemSpawnerChanger.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.ActuallyAdditions;
|
||||
//import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||
//import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||
//import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||
//import net.minecraft.block.BlockState;
|
||||
//import net.minecraft.client.util.ITooltipFlag;
|
||||
//import net.minecraft.entity.EntityList;
|
||||
//import net.minecraft.entity.EntityLivingBase;
|
||||
//import net.minecraft.entity.player.PlayerEntity;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.nbt.CompoundNBT;
|
||||
//import net.minecraft.tileentity.MobSpawnerBaseLogic;
|
||||
//import net.minecraft.tileentity.TileEntity;
|
||||
//import net.minecraft.tileentity.TileEntityMobSpawner;
|
||||
//import net.minecraft.util.Direction;
|
||||
//import net.minecraft.util.EnumActionResult;
|
||||
//import net.minecraft.util.Hand;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//import net.minecraft.util.math.BlockPos;
|
||||
//import net.minecraft.util.text.TextFormatting;
|
||||
//import net.minecraft.world.World;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class ItemSpawnerChanger extends ItemBase {
|
||||
//
|
||||
// public ItemSpawnerChanger() {
|
||||
// super();
|
||||
// this.setMaxStackSize(1);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction facing, float hitX, float hitY, float hitZ) {
|
||||
// if (!world.isRemote) {
|
||||
// ItemStack stack = player.getHeldItemMainhand();
|
||||
// if (player.canPlayerEdit(pos.offset(facing), facing, stack)) {
|
||||
// TileEntity tile = world.getTileEntity(pos);
|
||||
// if (tile instanceof TileEntityMobSpawner) {
|
||||
// String entity = this.getStoredEntity(stack);
|
||||
// if (entity != null) {
|
||||
// MobSpawnerBaseLogic logic = ((TileEntityMobSpawner) tile).getSpawnerBaseLogic();
|
||||
//
|
||||
// //This is a hacky way to remove the spawn potentials that make the spawner reset from time to time
|
||||
// //Don't judge, there isn't a method for it and it's better than Reflection hackiness
|
||||
// CompoundNBT compound = new CompoundNBT();
|
||||
// logic.writeToNBT(compound);
|
||||
// compound.removeTag("SpawnPotentials");
|
||||
// compound.removeTag("SpawnData");
|
||||
// logic.readFromNBT(compound);
|
||||
//
|
||||
// logic.setEntityId(ResourceLocation.tryParse(entity));
|
||||
//
|
||||
// tile.markDirty();
|
||||
//
|
||||
// BlockState state = world.getBlockState(pos);
|
||||
// world.notifyBlockUpdate(pos, state, state, 3);
|
||||
//
|
||||
// ItemPhantomConnector.clearStorage(stack, "Entity");
|
||||
//
|
||||
// if (!player.isCreative()) {
|
||||
// player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
||||
// }
|
||||
//
|
||||
// return EnumActionResult.SUCCESS;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return EnumActionResult.FAIL;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean itemInteractionForEntity(ItemStack aStack, PlayerEntity player, EntityLivingBase entity, Hand hand) {
|
||||
// if (!player.world.isRemote) {
|
||||
// ItemStack stack = player.getHeldItemMainhand();
|
||||
// if (this.getStoredEntity(stack) == null) {
|
||||
// if (this.storeClickedEntity(stack, entity)) {
|
||||
// entity.setDead();
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// private boolean storeClickedEntity(ItemStack stack, EntityLivingBase entity) {
|
||||
// if (!stack.hasTagCompound()) {
|
||||
// stack.setTagCompound(new CompoundNBT());
|
||||
// }
|
||||
//
|
||||
// if (!(entity instanceof PlayerEntity) && entity.isNonBoss()) {
|
||||
// ResourceLocation entityLoc = EntityList.getKey(entity.getClass());
|
||||
// if (entityLoc != null) {
|
||||
// String entityName = entityLoc.toString();
|
||||
// if (entityName != null && !entityName.isEmpty()) {
|
||||
// for (String name : ConfigStringListValues.SPAWNER_CHANGER_BLACKLIST.getValue()) {
|
||||
// if (entityName.equals(name)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// stack.getTagCompound().setString("Entity", entityName);
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// private String getStoredEntity(ItemStack stack) {
|
||||
// if (stack.hasTagCompound()) {
|
||||
// String entity = stack.getTagCompound().getString("Entity");
|
||||
// if (entity != null && !entity.isEmpty()) {
|
||||
// return entity;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addInformation(ItemStack stack, World playerIn, List<String> list, ITooltipFlag advanced) {
|
||||
// String entity = this.getStoredEntity(stack);
|
||||
// if (entity != null) {
|
||||
// list.add("Entity: " + entity);
|
||||
// list.add(TextFormatting.ITALIC + StringUtil.localize("tooltip.actuallyadditions.clearStorage.desc"));
|
||||
// }
|
||||
// }
|
||||
//}
|
|
@ -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) {
|
||||
|
@ -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