mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 23:28:35 +01:00
Compare commits
No commits in common. "268cf651d0c6c56278e73b5f7af73096f2927b4b" and "9cfbb6173927efd15e8f317af085ff324e24877c" have entirely different histories.
268cf651d0
...
9cfbb61739
47 changed files with 1354 additions and 155 deletions
|
@ -0,0 +1,189 @@
|
||||||
|
// 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) {
|
protected boolean tryUseItemOnTank(Player player, InteractionHand hand, FluidTank tank) {
|
||||||
ItemStack heldItem = player.getItemInHand(hand);
|
ItemStack heldItem = player.getItemInHand(hand);
|
||||||
return !heldItem.isEmpty() && FluidUtil.interactWithFluidHandler(player, hand, tank);
|
return StackUtil.isValid(heldItem) && FluidUtil.interactWithFluidHandler(player, hand, tank);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
package de.ellpeck.actuallyadditions.mod.blocks.base;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@ -28,7 +29,6 @@ import net.minecraft.world.level.material.PushReaction;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
import net.neoforged.neoforge.items.ItemHandlerHelper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
@ -63,9 +63,8 @@ public class BlockPlant extends CropBlock {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemInteractionResult useItemOn(@Nonnull ItemStack pStack, @Nonnull BlockState state, @Nonnull Level world, @Nonnull BlockPos pos, @Nonnull Player player, @Nonnull InteractionHand hand, @Nonnull BlockHitResult pHitResult) {
|
protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) {
|
||||||
if (this.getAge(state) < 7) {
|
if (this.getAge(state) < 7) {
|
||||||
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
return ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION;
|
||||||
}
|
}
|
||||||
|
@ -74,12 +73,12 @@ public class BlockPlant extends CropBlock {
|
||||||
List<ItemStack> drops = Block.getDrops(state, (ServerLevel) world, pos, null);
|
List<ItemStack> drops = Block.getDrops(state, (ServerLevel) world, pos, null);
|
||||||
boolean deductedSeedSize = false;
|
boolean deductedSeedSize = false;
|
||||||
for (ItemStack drop : drops) {
|
for (ItemStack drop : drops) {
|
||||||
if (!drop.isEmpty()) {
|
if (StackUtil.isValid(drop)) {
|
||||||
if (drop.getItem() == this.seedItem.get() && !deductedSeedSize) {
|
if (drop.getItem() == this.seedItem.get() && !deductedSeedSize) {
|
||||||
drop.shrink(1);
|
drop.shrink(1);
|
||||||
deductedSeedSize = true;
|
deductedSeedSize = true;
|
||||||
}
|
}
|
||||||
if (!drop.isEmpty()) {
|
if (StackUtil.isValid(drop)) {
|
||||||
ItemHandlerHelper.giveItemToPlayer(player, drop);
|
ItemHandlerHelper.giveItemToPlayer(player, drop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +90,6 @@ public class BlockPlant extends CropBlock {
|
||||||
return super.useItemOn(pStack, state, world, pos, player, hand, pHitResult);
|
return super.useItemOn(pStack, state, world, pos, player, hand, pHitResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemLike getBaseSeedId() {
|
protected ItemLike getBaseSeedId() {
|
||||||
return this.seedItem.get();
|
return this.seedItem.get();
|
||||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
import de.ellpeck.actuallyadditions.mod.crafting.EmpowererRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
|
@ -28,16 +29,14 @@ import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class RenderEmpowerer implements BlockEntityRenderer<TileEntityEmpowerer> {
|
public class RenderEmpowerer implements BlockEntityRenderer<TileEntityEmpowerer> {
|
||||||
public RenderEmpowerer(BlockEntityRendererProvider.Context context) {
|
public RenderEmpowerer(BlockEntityRendererProvider.Context context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(TileEntityEmpowerer tile, float partialTicks, @Nonnull PoseStack matrices, @Nonnull MultiBufferSource buffer, int combinedLight, int combinedOverlay) {
|
public void render(TileEntityEmpowerer tile, float partialTicks, PoseStack matrices, MultiBufferSource buffer, int combinedLight, int combinedOverlay) {
|
||||||
ItemStack stack = tile.inv.getStackInSlot(0);
|
ItemStack stack = tile.inv.getStackInSlot(0);
|
||||||
if (!stack.isEmpty()) {
|
if (StackUtil.isValid(stack)) {
|
||||||
// TODO: [port][refactor] migrate this logic into a single method, most renders use it
|
// TODO: [port][refactor] migrate this logic into a single method, most renders use it
|
||||||
matrices.pushPose();
|
matrices.pushPose();
|
||||||
matrices.translate(0.5F, 1F, 0.5F);
|
matrices.translate(0.5F, 1F, 0.5F);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemEngineerGoggles;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import io.netty.util.internal.ConcurrentSet;
|
import io.netty.util.internal.ConcurrentSet;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -57,13 +58,13 @@ public class RenderLaserRelay implements BlockEntityRenderer<TileEntityLaserRela
|
||||||
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
||||||
|
|
||||||
ItemStack upgrade = relay.inv.getStackInSlot(0);
|
ItemStack upgrade = relay.inv.getStackInSlot(0);
|
||||||
if (!upgrade.isEmpty()) {
|
if (StackUtil.isValid(upgrade)) {
|
||||||
if (upgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get()) {
|
if (upgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get()) {
|
||||||
hasInvis = true;
|
hasInvis = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack hand = player.getMainHandItem();
|
ItemStack hand = player.getMainHandItem();
|
||||||
if (hasGoggles || !hand.isEmpty() && (hand.getItem() == CommonConfig.Other.relayConfigureItem || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName().getString())) {
|
if (hasGoggles || StackUtil.isValid(hand) && (hand.getItem() == CommonConfig.Other.relayConfigureItem || hand.getItem() instanceof ItemLaserWrench) || "themattabase".equals(player.getName().getString())) {
|
||||||
matrices.pushPose();
|
matrices.pushPose();
|
||||||
Direction direction = state.hasProperty(BlockStateProperties.FACING) ?
|
Direction direction = state.hasProperty(BlockStateProperties.FACING) ?
|
||||||
state.getValue(BlockStateProperties.FACING) : Direction.UP;
|
state.getValue(BlockStateProperties.FACING) : Direction.UP;
|
||||||
|
@ -91,7 +92,7 @@ public class RenderLaserRelay implements BlockEntityRenderer<TileEntityLaserRela
|
||||||
BlockEntity secondTile = tile.getLevel().getBlockEntity(second);
|
BlockEntity secondTile = tile.getLevel().getBlockEntity(second);
|
||||||
if (secondTile instanceof TileEntityLaserRelay) {
|
if (secondTile instanceof TileEntityLaserRelay) {
|
||||||
ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0);
|
ItemStack secondUpgrade = ((TileEntityLaserRelay) secondTile).inv.getStackInSlot(0);
|
||||||
boolean otherInvis = !secondUpgrade.isEmpty() && secondUpgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get();
|
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == ActuallyItems.LASER_UPGRADE_INVISIBILITY.get();
|
||||||
|
|
||||||
if (hasGoggles || !hasInvis || !otherInvis) {
|
if (hasGoggles || !hasInvis || !otherInvis) {
|
||||||
int color = hasInvis && otherInvis
|
int color = hasInvis && otherInvis
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class ClientEvents {
|
||||||
Font font = minecraft.font;
|
Font font = minecraft.font;
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (StackUtil.isValid(stack)) {
|
||||||
if (stack.getItem() instanceof IHudDisplay) {
|
if (stack.getItem() instanceof IHudDisplay) {
|
||||||
((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
((IHudDisplay) stack.getItem()).displayHud(guiGraphics, minecraft, player, stack, posHit, minecraft.getWindow());
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,12 +85,12 @@ public class CommonEvents {
|
||||||
ItemEntity item = event.getItemEntity();
|
ItemEntity item = event.getItemEntity();
|
||||||
if (item != null && item.isAlive()) {
|
if (item != null && item.isAlive()) {
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (!stack.isEmpty()) {
|
if (StackUtil.isValid(stack)) {
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||||
if (i != player.getInventory().selected) {
|
if (i != player.getInventory().selected) {
|
||||||
|
|
||||||
ItemStack invStack = player.getInventory().getItem(i);
|
ItemStack invStack = player.getInventory().getItem(i);
|
||||||
if (!invStack.isEmpty() && (invStack.getItem() instanceof Sack)) {
|
if (StackUtil.isValid(invStack) && (invStack.getItem() instanceof Sack)) {
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
boolean isVoid = ((Sack) invStack.getItem()).isVoid;
|
boolean isVoid = ((Sack) invStack.getItem()).isVoid;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public class CommonEvents {
|
||||||
if (filter.check(stack)) {
|
if (filter.check(stack)) {
|
||||||
for (int j = 0; j < inv.getSlots(); j++) {
|
for (int j = 0; j < inv.getSlots(); j++) {
|
||||||
ItemStack bagStack = inv.getStackInSlot(j);
|
ItemStack bagStack = inv.getStackInSlot(j);
|
||||||
if (!bagStack.isEmpty()) {
|
if (StackUtil.isValid(bagStack)) {
|
||||||
if (ItemUtil.canBeStacked(bagStack, stack)) {
|
if (ItemUtil.canBeStacked(bagStack, stack)) {
|
||||||
int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize() - bagStack.getCount());
|
int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize() - bagStack.getCount());
|
||||||
if (maxTransfer > 0) {
|
if (maxTransfer > 0) {
|
||||||
|
@ -145,7 +145,7 @@ public class CommonEvents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.isEmpty()) {
|
if (!StackUtil.isValid(stack)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class CommonEvents {
|
||||||
//checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
|
//checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
|
||||||
|
|
||||||
if (CommonConfig.Other.GIVE_BOOKLET_ON_FIRST_CRAFT.get()) {
|
if (CommonConfig.Other.GIVE_BOOKLET_ON_FIRST_CRAFT.get()) {
|
||||||
if (!event.getEntity().level().isClientSide && !event.getCrafting().isEmpty() && event.getCrafting().getItem() != ActuallyItems.ITEM_BOOKLET.get()) {
|
if (!event.getEntity().level().isClientSide && StackUtil.isValid(event.getCrafting()) && event.getCrafting().getItem() != ActuallyItems.ITEM_BOOKLET.get()) {
|
||||||
|
|
||||||
String name = BuiltInRegistries.ITEM.getKey(event.getCrafting().getItem()).toString();
|
String name = BuiltInRegistries.ITEM.getKey(event.getCrafting().getItem()).toString();
|
||||||
if (name != null && name.toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)) {
|
if (name != null && name.toLowerCase(Locale.ROOT).contains(ActuallyAdditions.MODID)) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -19,7 +20,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerBioReactor extends AbstractContainerMenu {
|
public class ContainerBioReactor extends AbstractContainerMenu {
|
||||||
|
@ -50,9 +50,8 @@ public class ContainerBioReactor extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 8;
|
int inventoryStart = 8;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -85,7 +84,7 @@ public class ContainerBioReactor extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -102,7 +101,7 @@ public class ContainerBioReactor extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.tile.canPlayerUse(player);
|
return this.tile.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -19,7 +20,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerBreaker extends AbstractContainerMenu {
|
public class ContainerBreaker extends AbstractContainerMenu {
|
||||||
|
@ -51,9 +51,8 @@ public class ContainerBreaker extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 9;
|
int inventoryStart = 9;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -82,7 +81,7 @@ public class ContainerBreaker extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -99,7 +98,7 @@ public class ContainerBreaker extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.breaker.canPlayerUse(player);
|
return this.breaker.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
|
import de.ellpeck.actuallyadditions.mod.crafting.PressingRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -21,7 +22,6 @@ import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.crafting.RecipeHolder;
|
import net.minecraft.world.item.crafting.RecipeHolder;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -49,9 +49,8 @@ public class ContainerCanolaPress extends AbstractContainerMenu {
|
||||||
return new ContainerCanolaPress(windowId, inv, (TileEntityCanolaPress) Objects.requireNonNull(inv.player.level().getBlockEntity(data.readBlockPos())));
|
return new ContainerCanolaPress(windowId, inv, (TileEntityCanolaPress) Objects.requireNonNull(inv.player.level().getBlockEntity(data.readBlockPos())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 1;
|
int inventoryStart = 1;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -85,7 +84,7 @@ public class ContainerCanolaPress extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -102,7 +101,7 @@ public class ContainerCanolaPress extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.press.canPlayerUse(player);
|
return this.press.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -19,7 +20,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerCoalGenerator extends AbstractContainerMenu {
|
public class ContainerCoalGenerator extends AbstractContainerMenu {
|
||||||
|
@ -46,9 +46,8 @@ public class ContainerCoalGenerator extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 1;
|
int inventoryStart = 1;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -81,7 +80,7 @@ public class ContainerCoalGenerator extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -98,7 +97,7 @@ public class ContainerCoalGenerator extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.generator.canPlayerUse(player);
|
return this.generator.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
import de.ellpeck.actuallyadditions.mod.items.ItemCoffee;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -23,7 +24,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
||||||
|
@ -58,9 +58,8 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 11;
|
int inventoryStart = 11;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -108,7 +107,7 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -125,7 +124,7 @@ public class ContainerCoffeeMachine extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.machine.canPlayerUse(player);
|
return this.machine.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLongRangeBreaker;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLongRangeBreaker;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -19,7 +20,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
||||||
|
@ -50,9 +50,8 @@ public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
||||||
return new ContainerDirectionalBreaker(windowId, inv, (TileEntityLongRangeBreaker) Objects.requireNonNull(inv.player.level().getBlockEntity(data.readBlockPos())));
|
return new ContainerDirectionalBreaker(windowId, inv, (TileEntityLongRangeBreaker) Objects.requireNonNull(inv.player.level().getBlockEntity(data.readBlockPos())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 9;
|
int inventoryStart = 9;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -81,7 +80,7 @@ public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -98,7 +97,7 @@ public class ContainerDirectionalBreaker extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.breaker.canPlayerUse(player);
|
return this.breaker.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditio
|
||||||
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
import de.ellpeck.actuallyadditions.mod.items.DrillItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
|
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -23,8 +24,6 @@ import net.minecraft.world.inventory.ClickType;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class ContainerDrill extends AbstractContainerMenu {
|
public class ContainerDrill extends AbstractContainerMenu {
|
||||||
|
|
||||||
public static final int SLOT_AMOUNT = 5;
|
public static final int SLOT_AMOUNT = 5;
|
||||||
|
@ -63,14 +62,13 @@ public class ContainerDrill extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = inventory.getSelected();
|
ItemStack stack = inventory.getSelected();
|
||||||
if (!stack.isEmpty() && stack.getItem() instanceof DrillItem) {
|
if (StackUtil.isValid(stack) && stack.getItem() instanceof DrillItem) {
|
||||||
DrillItem.loadSlotsFromNBT(this.drillInventory, inventory.getSelected());
|
DrillItem.loadSlotsFromNBT(this.drillInventory, inventory.getSelected());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 5;
|
int inventoryStart = 5;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -103,7 +101,7 @@ public class ContainerDrill extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -120,7 +118,7 @@ public class ContainerDrill extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clicked(int slotId, int dragType, @Nonnull ClickType clickTypeIn, @Nonnull Player player) {
|
public void clicked(int slotId, int dragType, ClickType clickTypeIn, Player player) {
|
||||||
if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.selected) {
|
if (clickTypeIn == ClickType.SWAP && dragType == this.inventory.selected) {
|
||||||
return; //TODO: Check if this is correct, used to return ItemStack.EMPTY
|
return; //TODO: Check if this is correct, used to return ItemStack.EMPTY
|
||||||
} else {
|
} else {
|
||||||
|
@ -129,16 +127,16 @@ public class ContainerDrill extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removed(@Nonnull Player player) {
|
public void removed(Player player) {
|
||||||
ItemStack stack = this.inventory.getSelected();
|
ItemStack stack = this.inventory.getSelected();
|
||||||
if (!stack.isEmpty() && stack.getItem() instanceof DrillItem) {
|
if (StackUtil.isValid(stack) && stack.getItem() instanceof DrillItem) {
|
||||||
DrillItem.writeSlotsToNBT(this.drillInventory, this.inventory.getSelected());
|
DrillItem.writeSlotsToNBT(this.drillInventory, this.inventory.getSelected());
|
||||||
}
|
}
|
||||||
super.removed(player);
|
super.removed(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -20,7 +21,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerDropper extends AbstractContainerMenu {
|
public class ContainerDropper extends AbstractContainerMenu {
|
||||||
|
@ -53,9 +53,8 @@ public class ContainerDropper extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 9;
|
int inventoryStart = 9;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -84,7 +83,7 @@ public class ContainerDropper extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
|
|
@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.ArmorSlot;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.world.entity.EquipmentSlot;
|
import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
@ -25,7 +26,6 @@ import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerEnervator extends AbstractContainerMenu {
|
public class ContainerEnervator extends AbstractContainerMenu {
|
||||||
|
@ -59,9 +59,8 @@ public class ContainerEnervator extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 2;
|
int inventoryStart = 2;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -101,7 +100,7 @@ public class ContainerEnervator extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
// 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,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -18,7 +19,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerOilGenerator extends AbstractContainerMenu {
|
public class ContainerOilGenerator extends AbstractContainerMenu {
|
||||||
|
@ -43,9 +43,8 @@ public class ContainerOilGenerator extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 0;
|
int inventoryStart = 0;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -70,7 +69,7 @@ public class ContainerOilGenerator extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -87,7 +86,7 @@ public class ContainerOilGenerator extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.generator.canPlayerUse(player);
|
return this.generator.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -19,7 +20,6 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
||||||
|
@ -50,9 +50,8 @@ public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack quickMoveStack(@Nonnull Player player, int slot) {
|
public ItemStack quickMoveStack(Player player, int slot) {
|
||||||
int inventoryStart = 9;
|
int inventoryStart = 9;
|
||||||
int inventoryEnd = inventoryStart + 26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd + 1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
|
@ -81,7 +80,7 @@ public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStack.isEmpty()) {
|
if (!StackUtil.isValid(newStack)) {
|
||||||
theSlot.set(ItemStack.EMPTY);
|
theSlot.set(ItemStack.EMPTY);
|
||||||
} else {
|
} else {
|
||||||
theSlot.setChanged();
|
theSlot.setChanged();
|
||||||
|
@ -98,7 +97,7 @@ public class ContainerPhantomPlacer extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stillValid(@Nonnull Player player) {
|
public boolean stillValid(Player player) {
|
||||||
return this.placer.canPlayerUse(player);
|
return this.placer.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,29 @@
|
||||||
|
// 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;
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,79 @@
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,72 @@
|
||||||
|
// 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();
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -0,0 +1,127 @@
|
||||||
|
// 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,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Util;
|
import de.ellpeck.actuallyadditions.mod.util.Util;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -31,7 +32,7 @@ import net.minecraft.world.level.block.state.BlockState;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
import net.minecraft.world.phys.HitResult;
|
import net.minecraft.world.phys.HitResult;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@ -45,12 +46,12 @@ public class Filler extends ItemEnergy {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
ItemStack stack = new ItemStack(block, 1);
|
ItemStack stack = new ItemStack(block, 1);
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (StackUtil.isValid(stack)) {
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||||
ItemStack slot = player.getInventory().getItem(i);
|
ItemStack slot = player.getInventory().getItem(i);
|
||||||
if (!slot.isEmpty() && ItemStack.isSameItem(slot, stack)) {
|
if (StackUtil.isValid(slot) && ItemStack.isSameItem(slot, stack)) {
|
||||||
slot.shrink(1);
|
slot.shrink(1);
|
||||||
if (slot.isEmpty()) {
|
if (!StackUtil.isValid(slot)) {
|
||||||
player.getInventory().setItem(i, ItemStack.EMPTY);
|
player.getInventory().setItem(i, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +74,6 @@ public class Filler extends ItemEnergy {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult useOn(UseOnContext context) {
|
public InteractionResult useOn(UseOnContext context) {
|
||||||
if (context.getPlayer() == null) {
|
if (context.getPlayer() == null) {
|
||||||
|
@ -100,7 +100,7 @@ public class Filler extends ItemEnergy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseUsing(@Nonnull ItemStack stack, Level world, @Nonnull LivingEntity entity, int timeLeft) {
|
public void releaseUsing(ItemStack stack, Level world, LivingEntity entity, int timeLeft) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
boolean clear = true;
|
boolean clear = true;
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
|
@ -123,7 +123,7 @@ public class Filler extends ItemEnergy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(@Nonnull ItemStack stack, @Nonnull Level world, @Nonnull Entity entity, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
super.inventoryTick(stack, world, entity, itemSlot, isSelected);
|
super.inventoryTick(stack, world, entity, itemSlot, isSelected);
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public class Filler extends ItemEnergy {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(@Nonnull ItemStack stack, @Nonnull TooltipContext context, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag flagIn) {
|
public void appendHoverText(ItemStack stack, @Nullable TooltipContext context, List<Component> tooltip, TooltipFlag flagIn) {
|
||||||
super.appendHoverText(stack, context, tooltip, flagIn);
|
super.appendHoverText(stack, context, tooltip, flagIn);
|
||||||
|
|
||||||
MutableComponent display = loadData(stack)
|
MutableComponent display = loadData(stack)
|
||||||
|
@ -218,7 +218,7 @@ public class Filler extends ItemEnergy {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUseDuration(@Nonnull ItemStack stack, @Nonnull LivingEntity livingEntity) {
|
public int getUseDuration(ItemStack stack, LivingEntity livingEntity) {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ItemBattery extends ItemEnergy {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(@Nonnull ItemStack stack, @Nonnull TooltipContext playerIn, @Nonnull List<Component> list, @Nonnull TooltipFlag advanced) {
|
public void appendHoverText(ItemStack stack, @Nullable TooltipContext playerIn, List<Component> list, TooltipFlag advanced) {
|
||||||
super.appendHoverText(stack, playerIn, list, advanced);
|
super.appendHoverText(stack, playerIn, list, advanced);
|
||||||
list.add(Component.translatable("tooltip.actuallyadditions.battery." + (ItemUtil.isEnabled(stack)
|
list.add(Component.translatable("tooltip.actuallyadditions.battery." + (ItemUtil.isEnabled(stack)
|
||||||
? "discharge"
|
? "discharge"
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
///*
|
||||||
|
// * 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,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
import de.ellpeck.actuallyadditions.mod.components.ActuallyComponents;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
@ -25,7 +26,6 @@ import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
|
|
||||||
// TODO: [port] might be the wrong event
|
// TODO: [port] might be the wrong event
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(@Nonnull ItemStack stack, Level world, @Nonnull Entity entity, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
UUID uuid = stack.get(ActuallyComponents.UUID);
|
UUID uuid = stack.get(ActuallyComponents.UUID);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
@ -57,7 +57,6 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult useOn(UseOnContext context) {
|
public InteractionResult useOn(UseOnContext context) {
|
||||||
Player player = context.getPlayer();
|
Player player = context.getPlayer();
|
||||||
|
@ -85,12 +84,11 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult interactLivingEntity(@Nonnull ItemStack aStack, Player player, @Nonnull LivingEntity entity, @Nonnull InteractionHand hand) {
|
public InteractionResult interactLivingEntity(ItemStack aStack, Player player, LivingEntity entity, InteractionHand hand) {
|
||||||
if (!player.level().isClientSide) {
|
if (!player.level().isClientSide) {
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
if (!stack.isEmpty() && stack.getItem() == this) {
|
if (StackUtil.isValid(stack) && stack.getItem() == this) {
|
||||||
if (entity instanceof Player playerHit) {
|
if (entity instanceof Player playerHit) {
|
||||||
|
|
||||||
if (!playerHit.isShiftKeyDown()) {
|
if (!playerHit.isShiftKeyDown()) {
|
||||||
|
@ -106,7 +104,7 @@ public class ItemPlayerProbe extends ItemBase {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(ItemStack stack, @Nonnull TooltipContext pContext, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag advanced) {
|
public void appendHoverText(ItemStack stack, TooltipContext pContext, List<Component> tooltip, TooltipFlag advanced) {
|
||||||
String name = stack.get(ActuallyComponents.NAME);
|
String name = stack.get(ActuallyComponents.NAME);
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
tooltip.add(Component.translatable("tooltip.actuallyadditions.playerProbe.probing").append(": " + name));
|
tooltip.add(Component.translatable("tooltip.actuallyadditions.playerProbe.probing").append(": " + name));
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
// 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,8 +39,6 @@ import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
import net.neoforged.neoforge.event.entity.player.PlayerInteractEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class ItemWaterBowl extends ItemBase {
|
public class ItemWaterBowl extends ItemBase {
|
||||||
|
|
||||||
public ItemWaterBowl() {
|
public ItemWaterBowl() {
|
||||||
|
@ -70,7 +68,7 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1);
|
ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1);
|
||||||
|
|
||||||
ItemStack bowl = new ItemStack(ActuallyItems.WATER_BOWL.get());
|
ItemStack bowl = new ItemStack(ActuallyItems.WATER_BOWL.get());
|
||||||
if (reduced.isEmpty()) {
|
if (!StackUtil.isValid(reduced)) {
|
||||||
event.getEntity().setItemInHand(event.getHand(), bowl);
|
event.getEntity().setItemInHand(event.getHand(), bowl);
|
||||||
} else if (!event.getEntity().getInventory().add(bowl.copy())) {
|
} 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());
|
ItemEntity entityItem = new ItemEntity(event.getLevel(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), bowl.copy());
|
||||||
|
@ -84,14 +82,13 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResultHolder<ItemStack> use(@Nonnull Level world, Player player, @Nonnull InteractionHand hand) {
|
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
|
||||||
ItemStack stack = player.getItemInHand(hand);
|
ItemStack stack = player.getItemInHand(hand);
|
||||||
|
|
||||||
HitResult trace = player.pick(8.0D, 1.0F, false);
|
HitResult trace = player.pick(8.0D, 1.0F, false);
|
||||||
|
|
||||||
if (trace.getType() == HitResult.Type.MISS) {
|
if (trace == null) {
|
||||||
return InteractionResultHolder.pass(stack);
|
return InteractionResultHolder.pass(stack);
|
||||||
} else if (trace.getType() != HitResult.Type.BLOCK) {
|
} else if (trace.getType() != HitResult.Type.BLOCK) {
|
||||||
return InteractionResultHolder.pass(stack);
|
return InteractionResultHolder.pass(stack);
|
||||||
|
@ -120,7 +117,7 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void inventoryTick(@Nonnull ItemStack stack, Level world, @Nonnull Entity entity, int itemSlot, boolean isSelected) {
|
public void inventoryTick(ItemStack stack, Level world, Entity entity, int itemSlot, boolean isSelected) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
if (CommonConfig.Other.WATER_BOWL_LOSS.get()) {
|
if (CommonConfig.Other.WATER_BOWL_LOSS.get()) {
|
||||||
if (world.getGameTime() % 10 == 0 && world.random.nextFloat() >= 0.5F) {
|
if (world.getGameTime() % 10 == 0 && world.random.nextFloat() >= 0.5F) {
|
||||||
|
@ -162,7 +159,7 @@ public class ItemWaterBowl extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldCauseReequipAnimation(@Nonnull ItemStack oldStack, @Nonnull ItemStack newStack, boolean slotChanged) {
|
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
|
||||||
return !ItemStack.isSameItem(oldStack, newStack);
|
return !ItemStack.isSameItem(oldStack, newStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* 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,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHelperServer;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
|
@ -28,8 +29,6 @@ import net.neoforged.bus.api.SubscribeEvent;
|
||||||
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
|
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
|
||||||
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public class ItemWingsOfTheBats extends ItemBase {
|
public class ItemWingsOfTheBats extends ItemBase {
|
||||||
|
|
||||||
public static final String THE_BAT_BAT = "the bat bat";
|
public static final String THE_BAT_BAT = "the bat bat";
|
||||||
|
@ -51,7 +50,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
*/
|
*/
|
||||||
public static ItemStack getWingItem(Player player) {
|
public static ItemStack getWingItem(Player player) {
|
||||||
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
for (int i = 0; i < player.getInventory().getContainerSize(); i++) {
|
||||||
if (!player.getInventory().getItem(i).isEmpty() && player.getInventory().getItem(i).getItem() instanceof ItemWingsOfTheBats) {
|
if (StackUtil.isValid(player.getInventory().getItem(i)) && player.getInventory().getItem(i).getItem() instanceof ItemWingsOfTheBats) {
|
||||||
return player.getInventory().getItem(i);
|
return player.getInventory().getItem(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,12 +58,12 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBarVisible(@Nonnull ItemStack stack) {
|
public boolean isBarVisible(ItemStack stack) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarWidth(@Nonnull ItemStack stack) {
|
public int getBarWidth(ItemStack stack) {
|
||||||
/* PlayerEntity player = ClientProxy.getCurrentPlayer();
|
/* PlayerEntity player = ClientProxy.getCurrentPlayer();
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
|
@ -75,7 +74,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBarColor(@Nonnull ItemStack stack) {
|
public int getBarColor(ItemStack stack) {
|
||||||
/* PlayerEntity player = ClientProxy.getCurrentPlayer();
|
/* PlayerEntity player = ClientProxy.getCurrentPlayer();
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
// PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
|
||||||
|
@ -97,7 +96,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
Iterable<ItemStack> equip = player.getHandSlots();
|
Iterable<ItemStack> equip = player.getHandSlots();
|
||||||
for (ItemStack stack : equip) {
|
for (ItemStack stack : equip) {
|
||||||
// Todo: [port] this might not work anymore due to the way things are checked
|
// Todo: [port] this might not work anymore due to the way things are checked
|
||||||
if (!stack.isEmpty() && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getHoverName().getString()) && stack.getItem() instanceof SwordItem) {
|
if (StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getHoverName().getString()) && stack.getItem() instanceof SwordItem) {
|
||||||
looting += 3;
|
looting += 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +121,7 @@ public class ItemWingsOfTheBats extends ItemBase {
|
||||||
boolean tryDeduct = false;
|
boolean tryDeduct = false;
|
||||||
boolean shouldSend = false;
|
boolean shouldSend = false;
|
||||||
|
|
||||||
boolean wingsEquipped = !ItemWingsOfTheBats.getWingItem(player).isEmpty();
|
boolean wingsEquipped = StackUtil.isValid(ItemWingsOfTheBats.getWingItem(player));
|
||||||
if (!data.hasBatWings) {
|
if (!data.hasBatWings) {
|
||||||
if (data.batWingsFlyTime <= 0) {
|
if (data.batWingsFlyTime <= 0) {
|
||||||
if (wingsEquipped) {
|
if (wingsEquipped) {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import net.neoforged.neoforge.capabilities.Capabilities;
|
||||||
import net.neoforged.neoforge.energy.EnergyStorage;
|
import net.neoforged.neoforge.energy.EnergyStorage;
|
||||||
import net.neoforged.neoforge.energy.IEnergyStorage;
|
import net.neoforged.neoforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -47,7 +46,7 @@ public abstract class ItemEnergy extends ItemBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendHoverText(@Nonnull ItemStack stack, @Nonnull TooltipContext context, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag flagIn) {
|
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltip, TooltipFlag flagIn) {
|
||||||
super.appendHoverText(stack, context, tooltip, flagIn);
|
super.appendHoverText(stack, context, tooltip, flagIn);
|
||||||
IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
IEnergyStorage storage = stack.getCapability(Capabilities.EnergyStorage.ITEM);
|
||||||
if(storage != null) {
|
if(storage != null) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class LensColor extends Lens {
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item.isAlive() && !item.getItem().isEmpty() && tile.getEnergy() >= ENERGY_USE) {
|
if (item.isAlive() && !item.getItem().isEmpty() && tile.getEnergy() >= ENERGY_USE) {
|
||||||
ItemStack newStack = this.tryConvert(item.getItem(), tile.getWorldObject().registryAccess());
|
ItemStack newStack = this.tryConvert(item.getItem(), tile.getWorldObject().registryAccess());
|
||||||
if (!newStack.isEmpty()) {
|
if (StackUtil.isValid(newStack)) {
|
||||||
item.discard();
|
item.discard();
|
||||||
|
|
||||||
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getX(), item.getY(), item.getZ(), newStack);
|
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getX(), item.getY(), item.getZ(), newStack);
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -44,7 +45,7 @@ public class LensDisenchanting extends Lens {
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
if (item != null && item.isAlive()) {
|
if (item != null && item.isAlive()) {
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (!stack.isEmpty() && stack.getCount() == 1) {
|
if (StackUtil.isValid(stack) && stack.getCount() == 1) {
|
||||||
Item stackItem = stack.getItem();
|
Item stackItem = stack.getItem();
|
||||||
if (stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK) {
|
if (stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK) {
|
||||||
if (book == null) {
|
if (book == null) {
|
||||||
|
@ -54,7 +55,7 @@ public class LensDisenchanting extends Lens {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemEnchantments enchants = stack.getAllEnchantments(tile.getWorldObject().registryAccess().lookupOrThrow(Registries.ENCHANTMENT));
|
ItemEnchantments enchants = stack.getAllEnchantments(tile.getWorldObject().registryAccess().lookupOrThrow(Registries.ENCHANTMENT));
|
||||||
if (!enchants.isEmpty()) {
|
if (enchants != null && !enchants.isEmpty()) {
|
||||||
if (toDisenchant == null) {
|
if (toDisenchant == null) {
|
||||||
toDisenchant = item;
|
toDisenchant = item;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
import de.ellpeck.actuallyadditions.mod.crafting.CoffeeIngredientRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
@ -227,7 +228,7 @@ public class MethodHandler implements IMethodHandler {
|
||||||
List<ItemEntity> items = tile.getWorldObject().getEntitiesOfClass(ItemEntity.class, aabb);
|
List<ItemEntity> items = tile.getWorldObject().getEntitiesOfClass(ItemEntity.class, aabb);
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (item.isAlive() && !stack.isEmpty() && !item.getPersistentData().getBoolean("aa_cnv")) {
|
if (item.isAlive() && StackUtil.isValid(stack) && !item.getPersistentData().getBoolean("aa_cnv")) {
|
||||||
Optional<RecipeHolder<LaserRecipe>> holder = LaserRecipe.getRecipeForStack(stack);
|
Optional<RecipeHolder<LaserRecipe>> holder = LaserRecipe.getRecipeForStack(stack);
|
||||||
if (holder.isPresent()) {
|
if (holder.isPresent()) {
|
||||||
LaserRecipe recipe = holder.get().value();
|
LaserRecipe recipe = holder.get().value();
|
||||||
|
|
|
@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
import de.ellpeck.actuallyadditions.api.farmer.FarmerResult;
|
||||||
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
import de.ellpeck.actuallyadditions.api.farmer.IFarmerBehavior;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
import de.ellpeck.actuallyadditions.api.internal.IFarmer;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
|
@ -34,7 +35,7 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior {
|
||||||
public FarmerResult tryPlantSeed(ItemStack seed, Level world, BlockPos pos, IFarmer farmer) {
|
public FarmerResult tryPlantSeed(ItemStack seed, Level world, BlockPos pos, IFarmer farmer) {
|
||||||
int use = 350;
|
int use = 350;
|
||||||
if (farmer.getEnergy() >= use * 2) {
|
if (farmer.getEnergy() >= use * 2) {
|
||||||
if (!seed.isEmpty()) {
|
if (StackUtil.isValid(seed)) {
|
||||||
Item seedItem = seed.getItem();
|
Item seedItem = seed.getItem();
|
||||||
boolean isPumpkin = seedItem == Items.PUMPKIN_SEEDS;
|
boolean isPumpkin = seedItem == Items.PUMPKIN_SEEDS;
|
||||||
if (isPumpkin || seedItem == Items.MELON_SEEDS) {
|
if (isPumpkin || seedItem == Items.MELON_SEEDS) {
|
||||||
|
|
|
@ -32,14 +32,39 @@ public class SpecialRenderInit {
|
||||||
new ThreadSpecialFetcher();
|
new ThreadSpecialFetcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: [port][note] ensure that this still works with the special people stuff
|
||||||
public static void parse(Properties properties) {
|
public static void parse(Properties properties) {
|
||||||
for (String key : properties.stringPropertyNames()) {
|
for (String key : properties.stringPropertyNames()) {
|
||||||
String value = properties.getProperty(key);
|
String[] values = properties.getProperty(key).split("@");
|
||||||
if (!value.isEmpty()) {
|
if (values.length > 0) {
|
||||||
ResourceLocation resLoc = ResourceLocation.tryParse(value);
|
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());
|
||||||
ItemStack stack = findItem(resLoc);
|
ItemStack stack = findItem(resLoc);
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
//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)) {
|
||||||
SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack));
|
SPECIAL_LIST.put(key.toLowerCase(Locale.ROOT), new RenderSpecial(stack));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,14 +73,14 @@ public class SpecialRenderInit {
|
||||||
|
|
||||||
private static ItemStack findItem(ResourceLocation resLoc) {
|
private static ItemStack findItem(ResourceLocation resLoc) {
|
||||||
if (BuiltInRegistries.ITEM.containsKey(resLoc)) {
|
if (BuiltInRegistries.ITEM.containsKey(resLoc)) {
|
||||||
var item = BuiltInRegistries.ITEM.getOptional(resLoc);
|
Item item = BuiltInRegistries.ITEM.get(resLoc);
|
||||||
if (item.isPresent()) {
|
if (item != null) {
|
||||||
return new ItemStack(item.get());
|
return new ItemStack(item);
|
||||||
}
|
}
|
||||||
} else if (BuiltInRegistries.BLOCK.containsKey(resLoc)) {
|
} else if (BuiltInRegistries.BLOCK.containsKey(resLoc)) {
|
||||||
var block = BuiltInRegistries.BLOCK.getOptional(resLoc);
|
Block block = BuiltInRegistries.BLOCK.get(resLoc);
|
||||||
if (block.isPresent()) {
|
if (block != null) {
|
||||||
return new ItemStack(block.get());
|
return new ItemStack(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
||||||
if (t instanceof TileEntityDisplayStand tile) {
|
if (t instanceof TileEntityDisplayStand tile) {
|
||||||
tile.serverTick();
|
tile.serverTick();
|
||||||
|
|
||||||
if (!tile.inv.getStackInSlot(0).isEmpty() && !tile.isRedstonePowered) {
|
if (StackUtil.isValid(tile.inv.getStackInSlot(0)) && !tile.isRedstonePowered) {
|
||||||
IDisplayStandItem item = tile.convertToDisplayStandItem(tile.inv.getStackInSlot(0).getItem());
|
IDisplayStandItem item = tile.convertToDisplayStandItem(tile.inv.getStackInSlot(0).getItem());
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
int energy = item.getUsePerTick(tile.inv.getStackInSlot(0), tile, tile.ticksElapsed);
|
int energy = item.getUsePerTick(tile.inv.getStackInSlot(0), tile, tile.ticksElapsed);
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class TileEntityItemInterface extends TileEntityBase {
|
||||||
return TileEntityItemInterface.this.getSlotCount();
|
return TileEntityItemInterface.this.getSlotCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot) {
|
public ItemStack getStackInSlot(int slot) {
|
||||||
IItemHandlerInfo handler = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
IItemHandlerInfo handler = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
||||||
|
@ -63,9 +62,8 @@ public class TileEntityItemInterface extends TileEntityBase {
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) {
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||||
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
||||||
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stack, false)) {
|
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stack, false)) {
|
||||||
ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate);
|
ItemStack remain = info.handler.insertItem(info.switchedIndex, stack, simulate);
|
||||||
|
@ -78,15 +76,14 @@ public class TileEntityItemInterface extends TileEntityBase {
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
public ItemStack extractItem(int slot, int amount, boolean simulate) {
|
||||||
ItemStack stackIn = this.getStackInSlot(slot);
|
ItemStack stackIn = this.getStackInSlot(slot);
|
||||||
if (!stackIn.isEmpty()) {
|
if (StackUtil.isValid(stackIn)) {
|
||||||
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
IItemHandlerInfo info = TileEntityItemInterface.this.getSwitchedIndexHandler(slot);
|
||||||
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stackIn, true)) {
|
if (info != null && info.isLoaded() && TileEntityItemInterface.this.isWhitelisted(info, stackIn, true)) {
|
||||||
ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate);
|
ItemStack extracted = info.handler.extractItem(info.switchedIndex, amount, simulate);
|
||||||
if (!extracted.isEmpty() && !simulate) {
|
if (StackUtil.isValid(extracted) && !simulate) {
|
||||||
TileEntityItemInterface.this.setChanged();
|
TileEntityItemInterface.this.setChanged();
|
||||||
TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getBlockPos(), info.relayInQuestion.getBlockPos());
|
TileEntityItemInterface.this.doItemParticle(extracted, TileEntityItemInterface.this.connectedRelay.getBlockPos(), info.relayInQuestion.getBlockPos());
|
||||||
}
|
}
|
||||||
|
@ -288,7 +285,7 @@ public class TileEntityItemInterface extends TileEntityBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IItemHandlerInfo extends SpecificItemHandlerInfo {
|
private static class IItemHandlerInfo extends SpecificItemHandlerInfo {
|
||||||
|
|
||||||
public final IItemHandler handler;
|
public final IItemHandler handler;
|
||||||
public final int switchedIndex;
|
public final int switchedIndex;
|
||||||
|
@ -300,7 +297,7 @@ public class TileEntityItemInterface extends TileEntityBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SpecificItemHandlerInfo {
|
private static class SpecificItemHandlerInfo {
|
||||||
|
|
||||||
public final TileEntityLaserRelayItem relayInQuestion;
|
public final TileEntityLaserRelayItem relayInQuestion;
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ public abstract class TileEntityLaserRelay extends TileEntityInventoryBase {
|
||||||
|
|
||||||
public int getMaxRange() {
|
public int getMaxRange() {
|
||||||
ItemStack upgrade = this.inv.getStackInSlot(0);
|
ItemStack upgrade = this.inv.getStackInSlot(0);
|
||||||
if (!upgrade.isEmpty() && upgrade.getItem() == ActuallyItems.LASER_UPGRADE_RANGE.get()) {
|
if (StackUtil.isValid(upgrade) && upgrade.getItem() == ActuallyItems.LASER_UPGRADE_RANGE.get()) {
|
||||||
return MAX_DISTANCE_RANGED;
|
return MAX_DISTANCE_RANGED;
|
||||||
} else {
|
} else {
|
||||||
return MAX_DISTANCE;
|
return MAX_DISTANCE;
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = tile.inv.getStackInSlot(1);
|
ItemStack stack = tile.inv.getStackInSlot(1);
|
||||||
if (!stack.isEmpty() && stack.getItem() instanceof ItemSolidifiedExperience) {
|
if (StackUtil.isValid(stack) && stack.getItem() instanceof ItemSolidifiedExperience) {
|
||||||
int remainingSpace = Mth.clamp(Integer.MAX_VALUE - tile.amount, 0, stack.getCount());
|
int remainingSpace = Mth.clamp(Integer.MAX_VALUE - tile.amount, 0, stack.getCount());
|
||||||
if (stack.getCount() >= remainingSpace && remainingSpace != 0) {
|
if (stack.getCount() >= remainingSpace && remainingSpace != 0) {
|
||||||
tile.amount += remainingSpace;
|
tile.amount += remainingSpace;
|
||||||
|
|
|
@ -45,8 +45,6 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.neoforged.neoforge.client.ClientHooks;
|
import net.neoforged.neoforge.client.ClientHooks;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
public final class AssetUtil {
|
public final class AssetUtil {
|
||||||
|
|
||||||
public static final int MAX_LIGHT_X = 0xF000F0;
|
public static final int MAX_LIGHT_X = 0xF000F0;
|
||||||
|
@ -96,8 +94,8 @@ public final class AssetUtil {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
public static void renderItemWithoutScrewingWithColors(@Nonnull ItemStack stack, PoseStack matrices, int combinedOverlay, int combinedLight) {
|
public static void renderItemWithoutScrewingWithColors(ItemStack stack, PoseStack matrices, int combinedOverlay, int combinedLight) {
|
||||||
if (!stack.isEmpty()) {
|
if (StackUtil.isValid(stack)) {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
ItemRenderer renderer = mc.getItemRenderer();
|
ItemRenderer renderer = mc.getItemRenderer();
|
||||||
TextureManager manager = mc.getTextureManager();
|
TextureManager manager = mc.getTextureManager();
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
// 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,9 +16,45 @@ import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class StackUtil {
|
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.
|
* 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.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* 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,7 +44,6 @@ import net.neoforged.neoforge.fluids.FluidStack;
|
||||||
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
|
||||||
import net.neoforged.neoforge.items.IItemHandler;
|
import net.neoforged.neoforge.items.IItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -60,7 +59,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) {
|
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);
|
ItemStack theoreticalExtract = extractItem(extractWrapper, maxExtract, true, extractSlotStart, extractSlotEnd, filter);
|
||||||
if (!theoreticalExtract.isEmpty()) {
|
if (StackUtil.isValid(theoreticalExtract)) {
|
||||||
ItemStack remaining = StackUtil.insertItem(insertWrapper, theoreticalExtract, false, insertSlotStart, insertSlotEnd);
|
ItemStack remaining = StackUtil.insertItem(insertWrapper, theoreticalExtract, false, insertSlotStart, insertSlotEnd);
|
||||||
if (!ItemStack.matches(remaining, theoreticalExtract)) {
|
if (!ItemStack.matches(remaining, theoreticalExtract)) {
|
||||||
int toExtract = theoreticalExtract.getCount() - remaining.getCount();
|
int toExtract = theoreticalExtract.getCount() - remaining.getCount();
|
||||||
|
@ -96,14 +95,14 @@ public final class WorldUtil {
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extracted.isEmpty()) {
|
if (!StackUtil.isValid(extracted)) {
|
||||||
IItemHandler handler = extractWrapper.getNormalHandler();
|
IItemHandler handler = extractWrapper.getNormalHandler();
|
||||||
if (handler != null) {
|
if (handler != null) {
|
||||||
for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) {
|
for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) {
|
||||||
if (filter == null || !filter.needsCheck() || filter.check(handler.getStackInSlot(i))) {
|
if (filter == null || !filter.needsCheck() || filter.check(handler.getStackInSlot(i))) {
|
||||||
extracted = handler.extractItem(i, maxExtract, simulate);
|
extracted = handler.extractItem(i, maxExtract, simulate);
|
||||||
|
|
||||||
if (!extracted.isEmpty()) {
|
if (StackUtil.isValid(extracted)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,8 +162,8 @@ public final class WorldUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack useItemAtSide(Direction side, Level level, BlockPos pos, @Nonnull ItemStack stack) {
|
public static ItemStack useItemAtSide(Direction side, Level level, BlockPos pos, ItemStack stack) {
|
||||||
if (level instanceof ServerLevel && !stack.isEmpty() && pos != null) {
|
if (level instanceof ServerLevel && StackUtil.isValid(stack) && pos != null) {
|
||||||
BlockPos offsetPos = pos.relative(side);
|
BlockPos offsetPos = pos.relative(side);
|
||||||
BlockState state = level.getBlockState(offsetPos);
|
BlockState state = level.getBlockState(offsetPos);
|
||||||
boolean replaceable = state.canBeReplaced(new BlockPlaceContext(level, null, InteractionHand.MAIN_HAND, stack,
|
boolean replaceable = state.canBeReplaced(new BlockPlaceContext(level, null, InteractionHand.MAIN_HAND, stack,
|
||||||
|
|
Loading…
Reference in a new issue