diff --git a/build.gradle b/build.gradle index a19e2dc04..dcbcfb696 100644 --- a/build.gradle +++ b/build.gradle @@ -2,16 +2,20 @@ buildscript { repositories { maven { url = 'https://maven.minecraftforge.net' } mavenCentral() + + maven { url = 'https://maven.parchmentmc.org' } } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true + classpath 'org.parchmentmc:librarian:1.+' } } +apply plugin: 'net.minecraftforge.gradle' +apply plugin: 'org.parchmentmc.librarian.forgegradle' apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven-publish' -apply plugin: 'net.minecraftforge.gradle' version = "$mod_version" group = "de.ellpeck.actuallyadditions" @@ -24,7 +28,7 @@ if (System.getenv('BUILD_NUMBER') != null) { java.toolchain.languageVersion = JavaLanguageVersion.of(8) minecraft { - mappings channel: 'official', version: "${game_version}" + mappings channel: 'parchment', version: "${parchment_version}-${game_version}" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') diff --git a/gradle.properties b/gradle.properties index e3a564838..770e073a6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,16 @@ +org.gradle.jvmargs=-Xmx3G +org.gradle.daemon=false # Actually Additions + # TODO: check this version change is okay. mod_version=1.1.52 + # Forge game_version=1.16.5 forge_version=36.2.2 +# Parchment (Mappings) +parchment_version=2021.08.08 + # Other mods jei_version=1.16.4:7.6.1.71 diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 8d9c89e6a..0c95ff3f4 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -34,7 +34,6 @@ import de.ellpeck.actuallyadditions.mod.recipe.EmpowererHandler; import de.ellpeck.actuallyadditions.mod.recipe.HairyBallHandler; import de.ellpeck.actuallyadditions.mod.tile.ActuallyTiles; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; -import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -69,17 +68,14 @@ public class ActuallyAdditions { return new ItemStack(ActuallyItems.ITEM_BOOKLET.get()); } }; - + public static final Logger LOGGER = LogManager.getLogger(NAME); @Deprecated public static ActuallyAdditions INSTANCE; - public static final Logger LOGGER = LogManager.getLogger(NAME); - // TODO: [port] eval // static { // FluidRegistry.enableUniversalBucket(); // } - public static boolean commonCapsLoaded; public ActuallyAdditions() { @@ -104,7 +100,7 @@ public class ActuallyAdditions { ActuallyAdditionsAPI.methodHandler = new MethodHandler(); ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler(); Lenses.init(); - CompatUtil.registerCraftingTweaks(); +// CompatUtil.registerCraftingTweaks(); commonCapsLoaded = false; // Loader.isModLoaded("commoncapabilities"); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java index 67a4fe962..b5df04ed5 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/booklet/gui/GuiEntry.java @@ -20,6 +20,7 @@ import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import java.io.IOException; import java.util.List; @@ -46,8 +47,8 @@ public class GuiEntry extends GuiBooklet { if (!this.chapters.isEmpty()) { IBookletChapter lastChap = this.chapters.get(this.chapters.size() - 1); this.pageAmount = lastChap == null - ? 1 - : calcEntryPage(this.entry, lastChap, this.searchText) + 1; + ? 1 + : calcEntryPage(this.entry, lastChap, this.searchText) + 1; } else { this.pageAmount = 1; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java index 2d1dfea2f..e7b06d013 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/config/GuiConfiguration.java @@ -1,37 +1,33 @@ -/* - * This file ("GuiConfiguration.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.config; - -import java.util.ArrayList; -import java.util.List; - -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.fml.client.config.GuiConfig; -import net.minecraftforge.fml.client.config.IConfigElement; - -public class GuiConfiguration extends GuiConfig { - - public GuiConfiguration(GuiScreen parentScreen) { - super(parentScreen, getConfigElements(), ActuallyAdditions.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.config.toString())); - } - - private static List getConfigElements() { - List list = new ArrayList<>(); - for (int i = 0; i < ConfigCategories.values().length; i++) { - ConfigCategories cat = ConfigCategories.values()[i]; - ConfigurationHandler.config.setCategoryComment(cat.name, cat.comment); - list.add(new ConfigElement(ConfigurationHandler.config.getCategory(cat.name))); - } - return list; - } -} +///* +// * This file ("GuiConfiguration.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.config; +// +//import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +// +//import java.util.ArrayList; +//import java.util.List; +// +//public class GuiConfiguration extends GuiConfig { +// +// public GuiConfiguration(GuiScreen parentScreen) { +// super(parentScreen, getConfigElements(), ActuallyAdditions.MODID, false, false, GuiConfig.getAbridgedConfigPath(ConfigurationHandler.config.toString())); +// } +// +// private static List getConfigElements() { +// List list = new ArrayList<>(); +// for (int i = 0; i < ConfigCategories.values().length; i++) { +// ConfigCategories cat = ConfigCategories.values()[i]; +// ConfigurationHandler.config.setCategoryComment(cat.name, cat.comment); +// list.add(new ConfigElement(ConfigurationHandler.config.getCategory(cat.name))); +// } +// return list; +// } +//} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java index 72b08e008..3b41ed011 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemAxeAA.java @@ -14,8 +14,8 @@ import com.google.common.collect.Sets; import de.ellpeck.actuallyadditions.mod.items.base.ItemToolAA; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; import net.minecraft.item.IItemTier; import net.minecraft.item.ItemStack; @@ -35,8 +35,8 @@ public class ItemAxeAA extends ItemToolAA { public float getDestroySpeed(ItemStack stack, BlockState state) { Material material = state.getMaterial(); return material != Material.WOOD && material != Material.PLANT && material != Material.VINE - ? super.getDestroySpeed(stack, state) - : this.speed; + ? super.getDestroySpeed(stack, state) + : this.speed; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java index f7d391c84..dc4d9f195 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java @@ -14,18 +14,16 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.world.World; public class ItemCrafterOnAStick extends ItemBase { public ItemCrafterOnAStick() { - super(name); - this.setMaxStackSize(1); + super(ActuallyItems.defaultNonStacking()); } @Override @@ -33,11 +31,6 @@ public class ItemCrafterOnAStick extends ItemBase { if (!world.isClientSide) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.CRAFTER.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); } - return new ActionResult<>(EnumActionResult.SUCCESS, player.getItemInHand(hand)); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; + return new ActionResult<>(ActionResultType.SUCCESS, player.getItemInHand(hand)); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java index e00388282..860fe04c7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrill.java @@ -12,7 +12,6 @@ package de.ellpeck.actuallyadditions.mod.items; import com.google.common.collect.Multimap; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; -import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill; import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler; @@ -27,23 +26,27 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.ai.attributes.Attribute; import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.ai.attributes.Attributes; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemUseContext; import net.minecraft.nbt.CompoundNBT; -import net.minecraft.util.ActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.NonNullList; -import net.minecraft.util.ResourceLocation; +import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ForgeHooks; +import net.minecraftforge.common.ToolType; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; +import javax.annotation.Nullable; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -67,10 +70,8 @@ public class ItemDrill extends ItemEnergy { * @param stack The Drill */ public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack) { - CompoundNBT compound = stack.getTagCompound(); - if (compound != null) { - TileEntityInventoryBase.loadSlots(slots, compound); - } + CompoundNBT compound = stack.getOrCreateTag(); + TileEntityInventoryBase.loadSlots(slots, compound); } /** @@ -80,22 +81,22 @@ public class ItemDrill extends ItemEnergy { * @param stack The Drill */ public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack) { - CompoundNBT compound = stack.getTagCompound(); - if (compound == null) { - compound = new CompoundNBT(); - } + CompoundNBT compound = stack.getOrCreateTag(); + TileEntityInventoryBase.saveSlots(slots, compound); - stack.setTagCompound(compound); + stack.setTag(compound); } @Override - //Places Blocks if the Placing Upgrade is installed - public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, EnumFacing side, float hitX, float hitY, float hitZ) { + public ActionResultType useOn(ItemUseContext context) { + PlayerEntity player = context.getPlayer(); + Hand hand = context.getHand(); + ItemStack stack = player.getItemInHand(hand); ItemStack upgrade = this.getHasUpgradeAsStack(stack, ItemDrillUpgrade.UpgradeType.PLACER); if (StackUtil.isValid(upgrade)) { int slot = ItemDrillUpgrade.getSlotToPlaceFrom(upgrade); - if (slot >= 0 && slot < PlayerInventory.getHotbarSize()) { + if (slot >= 0 && slot < 9) { // TODO: validate... old = PlayerInventory.getHotbarSize(); new = 9 ItemStack equip = player.inventory.getItem(slot); if (StackUtil.isValid(equip) && equip != stack) { ItemStack toPlaceStack = equip.copy(); @@ -105,7 +106,7 @@ public class ItemDrill extends ItemEnergy { //tryPlaceItemIntoWorld could throw an Exception try { //Places the Block into the World - if (toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL) { + if (toPlaceStack.useOn(context) != ActionResultType.FAIL) { if (!player.isCreative()) { WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy()); } @@ -113,17 +114,18 @@ public class ItemDrill extends ItemEnergy { } //Notify the Player and log the Exception catch (Exception e) { - ActuallyAdditions.LOGGER.error("Player " + player.getName() + " who should place a Block using a Drill at " + player.posX + ", " + player.posY + ", " + player.posZ + " in World " + world.provider.getDimension() + " threw an Exception! Don't let that happen again!"); + ActuallyAdditions.LOGGER.error("Player " + player.getName() + " who should place a Block using a Drill at " + player.getX() + ", " + player.getY() + ", " + player.getZ() + " in World " + context.getLevel().dimension() + " threw an Exception! Don't let that happen again!"); } player.inventory.setItem(slot, player.getItemInHand(hand)); WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, stack); - return EnumActionResult.SUCCESS; + return ActionResultType.SUCCESS; } } } - return EnumActionResult.FAIL; + + return super.useOn(context); } /** @@ -131,14 +133,10 @@ public class ItemDrill extends ItemEnergy { * * @param stack The Drill * @param upgrade The Upgrade to be checked - * * @return The Upgrade, if it's installed */ public ItemStack getHasUpgradeAsStack(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { - CompoundNBT compound = stack.getTagCompound(); - if (compound == null) { - return StackUtil.getEmpty(); - } + CompoundNBT compound = stack.getOrCreateTag(); ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT); loadSlotsFromNBT(inv, stack); @@ -158,7 +156,7 @@ public class ItemDrill extends ItemEnergy { if (!world.isClientSide && player.isShiftKeyDown() && hand == Hand.MAIN_HAND) { player.openGui(ActuallyAdditions.INSTANCE, GuiHandler.GuiTypes.DRILL.ordinal(), world, (int) player.posX, (int) player.posY, (int) player.posZ); } - return new ActionResult<>(EnumActionResult.PASS, player.getItemInHand(hand)); + return new ActionResult<>(ActionResultType.PASS, player.getItemInHand(hand)); } @Override @@ -178,31 +176,27 @@ public class ItemDrill extends ItemEnergy { } @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.EPIC; - } + public Multimap getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) { + Multimap map = super.getAttributeModifiers(slot, stack); - @Override - public Multimap getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) { - Multimap map = super.getAttributeModifiers(slot, stack); - - if (slot == EntityEquipmentSlot.MAINHAND) { - map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE - ? 8.0F - : 0.1F, 0)); - map.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Tool Modifier", -2.5F, 0)); + if (slot == EquipmentSlotType.MAINHAND) { + map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier("Drill Modifier", this.getEnergyStored(stack) >= ENERGY_USE + ? 8.0F + : 0.1F, AttributeModifier.Operation.ADDITION)); + map.put(Attributes.ATTACK_SPEED, new AttributeModifier("Tool Modifier", -2.5F, AttributeModifier.Operation.ADDITION)); } return map; } + @Override public float getDestroySpeed(ItemStack stack, BlockState state) { return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) - ? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state).isEmpty() || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) - ? this.getEfficiencyFromUpgrade(stack) - : 1.0F - : 0.1F; + ? this.hasExtraWhitelist(state.getBlock()) || state.getBlock().getHarvestTool(state) == null || state.getBlock().getHarvestTool(state) || this.getToolClasses(stack).contains(state.getBlock().getHarvestTool(state)) + ? this.getEfficiencyFromUpgrade(stack) + : 1.0F + : 0.1F; } @Override @@ -216,24 +210,24 @@ public class ItemDrill extends ItemEnergy { } else { if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE)) { ItemUtil.addEnchantment(stack, Enchantments.BLOCK_FORTUNE, this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FORTUNE_II) - ? 3 - : 1); + ? 3 + : 1); } } //Block hit RayTraceResult ray = WorldUtil.getNearestBlockWithDefaultReachDistance(player.level, player); - if (ray != null) { - + if (ray != null && ray.getType() == RayTraceResult.Type.BLOCK) { + BlockRayTraceResult trace = (BlockRayTraceResult) ray; //Breaks the Blocks if (!player.isShiftKeyDown() && this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.THREE_BY_THREE)) { if (this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.FIVE_BY_FIVE)) { - toReturn = this.breakBlocks(stack, 2, player.level, pos, ray.sideHit, player); + toReturn = this.breakBlocks(stack, 2, player.level, pos, trace.getDirection(), player); } else { - toReturn = this.breakBlocks(stack, 1, player.level, pos, ray.sideHit, player); + toReturn = this.breakBlocks(stack, 1, player.level, pos, trace.getDirection(), player); } } else { - toReturn = this.breakBlocks(stack, 0, player.level, pos, ray.sideHit, player); + toReturn = this.breakBlocks(stack, 0, player.level, pos, trace.getDirection(), player); } //Removes Enchantments added above @@ -245,11 +239,10 @@ public class ItemDrill extends ItemEnergy { } @Override - public boolean canHarvestBlock(BlockState state, ItemStack stack) { - Block block = state.getBlock(); + public boolean canHarvestBlock(ItemStack stack, BlockState state) { return this.getEnergyStored(stack) >= this.getEnergyUsePerBlock(stack) && (this.hasExtraWhitelist(block) || state.getMaterial().isToolNotRequired() || block == Blocks.SNOW_LAYER || block == Blocks.SNOW || (block == Blocks.OBSIDIAN - ? HARVEST_LEVEL >= 3 - : block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE + ? HARVEST_LEVEL >= 3 + : block != Blocks.DIAMOND_BLOCK && block != Blocks.DIAMOND_ORE ? block != Blocks.EMERALD_ORE && block != Blocks.EMERALD_BLOCK ? block != Blocks.GOLD_BLOCK && block != Blocks.GOLD_ORE ? block != Blocks.IRON_BLOCK && block != Blocks.IRON_ORE @@ -273,7 +266,7 @@ public class ItemDrill extends ItemEnergy { } @Override - public int getHarvestLevel(ItemStack stack, String toolClass, PlayerEntity player, BlockState blockState) { + public int getHarvestLevel(ItemStack stack, ToolType p_getHarvestLevel_2_, @Nullable PlayerEntity p_getHarvestLevel_3_, @Nullable BlockState p_getHarvestLevel_4_) { return HARVEST_LEVEL; } @@ -281,7 +274,6 @@ public class ItemDrill extends ItemEnergy { * Gets the Energy that is used per Block broken * * @param stack The Drill - * * @return The Energy use per Block */ public int getEnergyUsePerBlock(ItemStack stack) { @@ -327,21 +319,12 @@ public class ItemDrill extends ItemEnergy { * * @param stack The Drill * @param upgrade The Upgrade to be checked - * * @return Is the Upgrade applied? */ public boolean getHasUpgrade(ItemStack stack, ItemDrillUpgrade.UpgradeType upgrade) { return StackUtil.isValid(this.getHasUpgradeAsStack(stack, upgrade)); } - @Override - protected void registerRendering() { - for (int i = 0; i < 16; i++) { - String name = this.getRegistryName() + "_" + TheColoredLampColors.values()[i].regName; - ActuallyAdditions.PROXY.addRenderRegister(new ItemStack(this, 1, i), new ResourceLocation(name), "inventory"); - } - } - @Override @OnlyIn(Dist.CLIENT) public void getSubItems(CreativeTabs tabs, NonNullList list) { @@ -366,7 +349,6 @@ public class ItemDrill extends ItemEnergy { * Gets the Mining Speed of the Drill * * @param stack The Drill - * * @return The Mining Speed depending on the Speed Upgrades */ public float getEfficiencyFromUpgrade(ItemStack stack) { @@ -400,17 +382,17 @@ public class ItemDrill extends ItemEnergy { * @param world The World * @param player The Player who breaks the Blocks */ - public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, EnumFacing side, PlayerEntity player) { + public boolean breakBlocks(ItemStack stack, int radius, World world, BlockPos aPos, Direction side, PlayerEntity player) { int xRange = radius; int yRange = radius; int zRange = 0; //Corrects Blocks to hit depending on Side of original Block hit - if (side.getAxis() == Axis.Y) { + if (side.getAxis() == Direction.Axis.Y) { zRange = radius; yRange = 0; } - if (side.getAxis() == Axis.X) { + if (side.getAxis() == Direction.Axis.X) { xRange = 0; zRange = radius; } @@ -429,7 +411,7 @@ public class ItemDrill extends ItemEnergy { return false; } - if (radius == 2 && side.getAxis() != Axis.Y) { + if (radius == 2 && side.getAxis() != Direction.Axis.Y) { aPos = aPos.above(); BlockState theState = world.getBlockState(aPos); if (theState.getDestroySpeed(world, aPos) <= mainHardness + 5.0F) { @@ -476,7 +458,7 @@ public class ItemDrill extends ItemEnergy { BlockState state = world.getBlockState(pos); Block block = state.getBlock(); float hardness = state.getDestroySpeed(world, pos); - boolean canHarvest = (ForgeHooks.canHarvestBlock(block, player, world, pos) || this.canHarvestBlock(state, stack)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F); + boolean canHarvest = (ForgeHooks.canHarvestBlock(state, player, world, pos) || this.canHarvestBlock(stack, state)) && (!isExtra || this.getDestroySpeed(stack, world.getBlockState(pos)) > 1.0F); if (hardness >= 0.0F && (!isExtra || canHarvest && !block.hasTileEntity(world.getBlockState(pos)))) { if (!player.isCreative()) { this.extractEnergyInternal(stack, use, false); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java index 86a7bb116..913aedb30 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDrillUpgrade.java @@ -15,7 +15,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Hand; import net.minecraft.world.World; @@ -41,20 +41,16 @@ public class ItemDrillUpgrade extends ItemBase { ItemStack stack = player.getItemInHand(hand); if (!world.isClientSide && this.type == UpgradeType.PLACER) { this.setSlotToPlaceFrom(stack, player.inventory.selected); - return new ActionResult<>(EnumActionResult.SUCCESS, stack); + return new ActionResult<>(ActionResultType.SUCCESS, stack); } - return new ActionResult<>(EnumActionResult.FAIL, stack); + return new ActionResult<>(ActionResultType.FAIL, stack); } public void setSlotToPlaceFrom(ItemStack stack, int slot) { - CompoundNBT compound = stack.getTagCompound(); - if (compound == null) { - compound = new CompoundNBT(); - } - + CompoundNBT compound = stack.getOrCreateTag(); compound.putInt("SlotToPlaceFrom", slot + 1); - stack.setTagCompound(compound); + stack.setTag(compound); } public enum UpgradeType { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java index 2d98a64df..05184c540 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemDust.java @@ -16,10 +16,10 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts; 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.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class ItemDust extends ItemBase implements IColorProvidingItem { @@ -39,15 +39,15 @@ public class ItemDust extends ItemBase implements IColorProvidingItem { @Override public String getDescriptionId(ItemStack stack) { return stack.getItemDamage() >= ALL_DUSTS.length - ? StringUtil.BUGGED_ITEM_NAME - : this.getDescriptionId() + "_" + ALL_DUSTS[stack.getItemDamage()].name; + ? StringUtil.BUGGED_ITEM_NAME + : this.getDescriptionId() + "_" + ALL_DUSTS[stack.getItemDamage()].name; } @Override public EnumRarity getRarity(ItemStack stack) { return stack.getItemDamage() >= ALL_DUSTS.length - ? EnumRarity.COMMON - : ALL_DUSTS[stack.getItemDamage()].rarity; + ? EnumRarity.COMMON + : ALL_DUSTS[stack.getItemDamage()].rarity; } @Override @@ -71,8 +71,8 @@ public class ItemDust extends ItemBase implements IColorProvidingItem { @Override public IItemColor getItemColor() { return (stack, pass) -> stack.getItemDamage() >= ALL_DUSTS.length - ? 0xFFFFFF - : ALL_DUSTS[stack.getItemDamage()].color; + ? 0xFFFFFF + : ALL_DUSTS[stack.getItemDamage()].color; } @Override diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java index 9b762d17f..83bf67843 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFertilizer.java @@ -13,38 +13,28 @@ package de.ellpeck.actuallyadditions.mod.items; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.misc.DispenserHandlerFertilize; import net.minecraft.block.DispenserBlock; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemDye; +import net.minecraft.item.BoneMealItem; import net.minecraft.item.ItemStack; -import net.minecraft.util.Direction; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.Hand; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; +import net.minecraft.item.ItemUseContext; +import net.minecraft.util.ActionResultType; public class ItemFertilizer extends ItemBase { public ItemFertilizer() { - super(name); + super(); DispenserBlock.registerBehavior(this, new DispenserHandlerFertilize()); } - + @Override - public EnumActionResult onItemUse(PlayerEntity player, World world, BlockPos pos, Hand hand, Direction side, float par8, float par9, float par10) { - ItemStack stack = player.getItemInHand(hand); - if (ItemDye.applyBonemeal(stack, world, pos, player, hand)) { - if (!world.isClientSide) { - world.levelEvent(2005, pos, 0); + public ActionResultType useOn(ItemUseContext context) { + ItemStack stack = context.getPlayer().getItemInHand(context.getHand()); + if (BoneMealItem.applyBonemeal(stack, context.getLevel(), context.getClickedPos(), context.getPlayer())) { + if (!context.getLevel().isClientSide) { + context.getLevel().levelEvent(2005, context.getClickedPos(), 0); } - return EnumActionResult.SUCCESS; + return ActionResultType.SUCCESS; } - return super.useOn(player, world, pos, hand, side, par8, par9, par10); - } - - @Override - public EnumRarity getRarity(ItemStack stack) { - return EnumRarity.RARE; + return super.useOn(context); } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java index 6465a0668..f5db339b1 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemFoods.java @@ -15,9 +15,7 @@ import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil; -import net.minecraft.client.renderer.block.model.ModelResourceLocation; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; +import net.minecraft.client.renderer.model.ModelResourceLocation; import net.minecraft.entity.item.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.EnumAction; @@ -25,6 +23,8 @@ import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public class ItemFoods extends ItemFoodBase { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java index f930d66c0..ccac7cf62 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/IDataHandler.java @@ -11,10 +11,10 @@ package de.ellpeck.actuallyadditions.mod.network; import net.minecraft.nbt.CompoundNBT; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.network.NetworkEvent; public interface IDataHandler { - void handleData(CompoundNBT compound, MessageContext context); + void handleData(CompoundNBT compound, NetworkEvent.Context context); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java index 7e2a00dc3..6aea61b57 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketClientToServer.java @@ -14,10 +14,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import io.netty.buffer.ByteBuf; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; -import net.minecraftforge.fml.common.FMLCommonHandler; -import net.minecraftforge.fml.common.network.simpleimpl.IMessage; -import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; -import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; +import net.minecraftforge.fml.network.NetworkEvent; public class PacketClientToServer { @@ -59,7 +56,7 @@ public class PacketClientToServer { public static class Handler implements IMessageHandler { @Override - public IMessage onMessage(PacketClientToServer message, MessageContext ctx) { + public IMessage onMessage(PacketClientToServer message, NetworkEvent.Context ctx) { FMLCommonHandler.instance().getMinecraftServerInstance().addScheduledTask(() -> { if (message.data != null && message.handler != null) { message.handler.handleData(message.data, ctx); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java index 4552cbd4c..867204a8b 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketHandlerHelper.java @@ -33,7 +33,7 @@ public final class PacketHandlerHelper { compound.putInt("X", pos.getX()); compound.putInt("Y", pos.getY()); compound.putInt("Z", pos.getZ()); - compound.putInt("WorldID", tile.getLevel().provider.getDimension()); + compound.putInt("WorldID", tile.getLevel().getDimension()); compound.putInt("PlayerID", Minecraft.getInstance().player.getId()); compound.putInt("ButtonID", buttonId); PacketHandler.THE_NETWORK.sendToServer(new PacketClientToServer(compound, PacketHandler.GUI_BUTTON_TO_TILE_HANDLER)); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java index 78b260992..c3672cbcf 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/network/PacketServerToClient.java @@ -15,12 +15,14 @@ import io.netty.buffer.ByteBuf; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.PacketBuffer; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; -public class PacketServerToClient implements IMessage { +public class PacketServerToClient implements Message { private CompoundNBT data; private IDataHandler handler; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java index 406b4c9b0..bcb69a30f 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/AssetUtil.java @@ -20,10 +20,7 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.particle.Particle; -import net.minecraft.client.renderer.BufferBuilder; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.*; import net.minecraft.client.renderer.model.IBakedModel; import net.minecraft.client.renderer.model.ItemCameraTransforms; import net.minecraft.client.renderer.texture.TextureManager; @@ -72,7 +69,7 @@ public final class AssetUtil { public static void renderItemInWorld(ItemStack stack, int combinedLight, int combinedOverlay, MatrixStack matrices, IRenderTypeBuffer buffer) { if (StackUtil.isValid(stack)) { Minecraft.getInstance().getItemRenderer().renderStatic( - stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer + stack, ItemCameraTransforms.TransformType.FIXED, combinedLight, combinedOverlay, matrices, buffer ); } } @@ -95,7 +92,7 @@ public final class AssetUtil { public static void renderItemWithoutScrewingWithColors(ItemStack stack) { if (StackUtil.isValid(stack)) { Minecraft mc = Minecraft.getInstance(); - RenderItem renderer = mc.getRenderItem(); + ItemRenderer renderer = mc.getItemRenderer(); TextureManager manager = mc.getTextureManager(); IBakedModel model = renderer.getItemModelWithOverrides(stack, null, null); @@ -105,7 +102,7 @@ public final class AssetUtil { GlStateManager._enableRescaleNormal(); GlStateManager._enableBlend(); GlStateManager._pushMatrix(); - model = ForgeHooksClient.handleCameraTransforms(model, TransformType.FIXED, false); + model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.FIXED, false); renderer.renderItem(stack, model); GlStateManager.cullFace(GlStateManager.CullFace.BACK); GlStateManager._popMatrix(); @@ -253,8 +250,8 @@ public final class AssetUtil { Vec3d combinedVec = vec2.subtract(vec1); double rot = rotationTime > 0 - ? 360D * (world.getTotalWorldTime() % rotationTime / rotationTime) - : 0; + ? 360D * (world.getTotalWorldTime() % rotationTime / rotationTime) + : 0; double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x * combinedVec.x + combinedVec.z * combinedVec.z)); double yaw = Math.atan2(-combinedVec.z, combinedVec.x); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java index 928362858..7fbf8cf10 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/FluidStateMapper.java @@ -11,11 +11,14 @@ package de.ellpeck.actuallyadditions.mod.util; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; +import net.minecraft.block.BlockState; import net.minecraft.client.renderer.ItemMeshDefinition; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.statemap.StateMapperBase; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.fluids.Fluid; diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java index 25313b750..a83e53329 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingBlock.java @@ -11,10 +11,11 @@ package de.ellpeck.actuallyadditions.mod.util; import net.minecraft.client.renderer.color.IBlockColor; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IColorProvidingBlock { - @OnlyIn(Dist.CLIENT) IBlockColor getBlockColor(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java index e3b015946..9c3d1d70e 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/IColorProvidingItem.java @@ -11,10 +11,11 @@ package de.ellpeck.actuallyadditions.mod.util; import net.minecraft.client.renderer.color.IItemColor; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; public interface IColorProvidingItem { - @OnlyIn(Dist.CLIENT) IItemColor getItemColor(); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java index a358ba7da..a1085bd76 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/NetHandlerSpaghettiServer.java @@ -1,49 +1,23 @@ package de.ellpeck.actuallyadditions.mod.util; -import java.util.Set; - -import net.minecraft.network.EnumPacketDirection; -import net.minecraft.network.NetHandlerPlayServer; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; +import net.minecraft.network.IPacket; import net.minecraft.network.NetworkManager; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.CPacketAnimation; -import net.minecraft.network.play.client.CPacketChatMessage; -import net.minecraft.network.play.client.CPacketClickWindow; -import net.minecraft.network.play.client.CPacketClientSettings; -import net.minecraft.network.play.client.CPacketClientStatus; -import net.minecraft.network.play.client.CPacketCloseWindow; -import net.minecraft.network.play.client.CPacketConfirmTeleport; -import net.minecraft.network.play.client.CPacketConfirmTransaction; -import net.minecraft.network.play.client.CPacketCreativeInventoryAction; -import net.minecraft.network.play.client.CPacketCustomPayload; -import net.minecraft.network.play.client.CPacketEnchantItem; -import net.minecraft.network.play.client.CPacketEntityAction; -import net.minecraft.network.play.client.CPacketHeldItemChange; -import net.minecraft.network.play.client.CPacketInput; -import net.minecraft.network.play.client.CPacketKeepAlive; -import net.minecraft.network.play.client.CPacketPlaceRecipe; -import net.minecraft.network.play.client.CPacketPlayer; -import net.minecraft.network.play.client.CPacketPlayerAbilities; -import net.minecraft.network.play.client.CPacketPlayerDigging; -import net.minecraft.network.play.client.CPacketPlayerTryUseItem; -import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; -import net.minecraft.network.play.client.CPacketRecipeInfo; -import net.minecraft.network.play.client.CPacketResourcePackStatus; -import net.minecraft.network.play.client.CPacketSeenAdvancements; -import net.minecraft.network.play.client.CPacketSpectate; -import net.minecraft.network.play.client.CPacketSteerBoat; -import net.minecraft.network.play.client.CPacketTabComplete; -import net.minecraft.network.play.client.CPacketUpdateSign; -import net.minecraft.network.play.client.CPacketUseEntity; -import net.minecraft.network.play.client.CPacketVehicleMove; -import net.minecraft.network.play.server.SPacketPlayerPosLook.EnumFlags; +import net.minecraft.network.PacketDirection; +import net.minecraft.network.play.ServerPlayNetHandler; +import net.minecraft.network.play.client.*; +import net.minecraft.network.play.server.SPlayerPositionLookPacket; import net.minecraft.util.text.ITextComponent; import net.minecraftforge.common.util.FakePlayer; -public class NetHandlerSpaghettiServer extends NetHandlerPlayServer { +import javax.annotation.Nullable; +import java.util.Set; + +public class NetHandlerSpaghettiServer extends ServerPlayNetHandler { public NetHandlerSpaghettiServer(FakePlayer player) { - super(null, new NetworkManager(EnumPacketDirection.CLIENTBOUND), player); + super(null, new NetworkManager(PacketDirection.CLIENTBOUND), player); } @Override @@ -51,140 +25,202 @@ public class NetHandlerSpaghettiServer extends NetHandlerPlayServer { } @Override - public void handlePlaceRecipe(CPacketPlaceRecipe p_194308_1_) { + public void handlePlayerInput(CInputPacket p_147358_1_) { } @Override - public void handleAnimation(CPacketAnimation packetIn) { + public void handleMoveVehicle(CMoveVehiclePacket p_184338_1_) { } @Override - public void handleRecipeBookUpdate(CPacketRecipeInfo p_191984_1_) { + public void handleAcceptTeleportPacket(CConfirmTeleportPacket p_184339_1_) { } @Override - public void handleResourcePackStatus(CPacketResourcePackStatus packetIn) { + public void handleRecipeBookSeenRecipePacket(CMarkRecipeSeenPacket p_191984_1_) { } @Override - public void handleSeenAdvancements(CPacketSeenAdvancements p_194027_1_) { + public void handleRecipeBookChangeSettingsPacket(CUpdateRecipeBookStatusPacket p_241831_1_) { } @Override - public void handleSpectate(CPacketSpectate packetIn) { + public void handleSeenAdvancements(CSeenAdvancementsPacket p_194027_1_) { } @Override - public void onDisconnect(ITextComponent reason) { + public void handleCustomCommandSuggestions(CTabCompletePacket p_195518_1_) { } @Override - public void processChatMessage(CPacketChatMessage packetIn) { + public void handleSetCommandBlock(CUpdateCommandBlockPacket p_210153_1_) { } @Override - public void processClickWindow(CPacketClickWindow packetIn) { + public void handleSetCommandMinecart(CUpdateMinecartCommandBlockPacket p_210158_1_) { } @Override - public void processClientSettings(CPacketClientSettings packetIn) { + public void handlePickItem(CPickItemPacket p_210152_1_) { } @Override - public void processClientStatus(CPacketClientStatus packetIn) { + public void handleRenameItem(CRenameItemPacket p_210155_1_) { } @Override - public void processCloseWindow(CPacketCloseWindow packetIn) { + public void handleSetBeaconPacket(CUpdateBeaconPacket p_210154_1_) { } @Override - public void processConfirmTeleport(CPacketConfirmTeleport packetIn) { + public void handleSetStructureBlock(CUpdateStructureBlockPacket p_210157_1_) { } @Override - public void processConfirmTransaction(CPacketConfirmTransaction packetIn) { + public void handleSetJigsawBlock(CUpdateJigsawBlockPacket p_217262_1_) { } @Override - public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn) { + public void handleJigsawGenerate(CJigsawBlockGeneratePacket p_230549_1_) { } @Override - public void processCustomPayload(CPacketCustomPayload packetIn) { + public void handleSelectTrade(CSelectTradePacket p_210159_1_) { } @Override - public void processEnchantItem(CPacketEnchantItem packetIn) { + public void handleEditBook(CEditBookPacket p_210156_1_) { } @Override - public void processEntityAction(CPacketEntityAction packetIn) { + public void handleEntityTagQuery(CQueryEntityNBTPacket p_211526_1_) { } @Override - public void processHeldItemChange(CPacketHeldItemChange packetIn) { + public void handleBlockEntityTagQuery(CQueryTileEntityNBTPacket p_211525_1_) { } @Override - public void processInput(CPacketInput packetIn) { + public void handleMovePlayer(CPlayerPacket p_147347_1_) { } @Override - public void processKeepAlive(CPacketKeepAlive packetIn) { + public void teleport(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) { } @Override - public void processPlayer(CPacketPlayer packetIn) { + public void teleport(double p_175089_1_, double p_175089_3_, double p_175089_5_, float p_175089_7_, float p_175089_8_, Set p_175089_9_) { } @Override - public void processPlayerAbilities(CPacketPlayerAbilities packetIn) { + public void handlePlayerAction(CPlayerDiggingPacket p_147345_1_) { } @Override - public void processPlayerDigging(CPacketPlayerDigging packetIn) { + public void handleUseItemOn(CPlayerTryUseItemOnBlockPacket p_184337_1_) { } @Override - public void processSteerBoat(CPacketSteerBoat packetIn) { + public void handleUseItem(CPlayerTryUseItemPacket p_147346_1_) { } @Override - public void processTabComplete(CPacketTabComplete packetIn) { + public void handleTeleportToEntityPacket(CSpectatePacket p_175088_1_) { } @Override - public void processTryUseItem(CPacketPlayerTryUseItem packetIn) { + public void handleResourcePackResponse(CResourcePackStatusPacket p_175086_1_) { } @Override - public void processTryUseItemOnBlock(CPacketPlayerTryUseItemOnBlock packetIn) { + public void handlePaddleBoat(CSteerBoatPacket p_184340_1_) { } @Override - public void processUpdateSign(CPacketUpdateSign packetIn) { + public void onDisconnect(ITextComponent p_147231_1_) { } @Override - public void processUseEntity(CPacketUseEntity packetIn) { + public void send(IPacket p_147359_1_) { } @Override - public void processVehicleMove(CPacketVehicleMove packetIn) { + public void send(IPacket p_211148_1_, @Nullable GenericFutureListener> p_211148_2_) { } @Override - public void sendPacket(Packet packetIn) { + public void handleSetCarriedItem(CHeldItemChangePacket p_147355_1_) { } @Override - public void setPlayerLocation(double x, double y, double z, float yaw, float pitch) { + public void handleChat(CChatMessagePacket p_147354_1_) { } @Override - public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set relativeSet) { - + public void handleAnimate(CAnimateHandPacket p_175087_1_) { } + @Override + public void handlePlayerCommand(CEntityActionPacket p_147357_1_) { + } + + @Override + public void handleInteract(CUseEntityPacket p_147340_1_) { + } + + @Override + public void handleClientCommand(CClientStatusPacket p_147342_1_) { + } + + @Override + public void handleContainerClose(CCloseWindowPacket p_147356_1_) { + } + + @Override + public void handleContainerClick(CClickWindowPacket p_147351_1_) { + } + + @Override + public void handlePlaceRecipe(CPlaceRecipePacket p_194308_1_) { + } + + @Override + public void handleContainerButtonClick(CEnchantItemPacket p_147338_1_) { + } + + @Override + public void handleSetCreativeModeSlot(CCreativeInventoryActionPacket p_147344_1_) { + } + + @Override + public void handleContainerAck(CConfirmTransactionPacket p_147339_1_) { + } + + @Override + public void handleSignUpdate(CUpdateSignPacket p_147343_1_) { + } + + @Override + public void handleKeepAlive(CKeepAlivePacket p_147353_1_) { + } + + @Override + public void handlePlayerAbilities(CPlayerAbilitiesPacket p_147348_1_) { + } + + @Override + public void handleClientInformation(CClientSettingsPacket p_147352_1_) { + } + + @Override + public void handleCustomPayload(CCustomPayloadPacket p_147349_1_) { + } + + @Override + public void handleChangeDifficulty(CSetDifficultyPacket p_217263_1_) { + } + + @Override + public void handleLockDifficulty(CLockDifficultyPacket p_217261_1_) { + } } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java index eea285407..5445ab728 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/StackUtil.java @@ -25,7 +25,6 @@ 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 @@ -49,7 +48,6 @@ public final class StackUtil { * 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 @@ -71,7 +69,6 @@ public final class StackUtil { * @param inv The AA Item handler * @param stacks The stacks to add * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. - * * @return If all stacks fit fully. If even one item would not fit, the method returns false. */ public static boolean canAddAll(ItemStackHandlerAA inv, List stacks, boolean fromAutomation) { @@ -118,7 +115,6 @@ public final class StackUtil { * @param slot The starting slot. * @param endSlot The ending slot, exclusive. * @param fromAutomation If these stacks are coming from a pipe or other external source, or internally, like from the TE's update() method. - * * @return If all stacks fit fully. If even one item would not fit, the method returns false. */ public static boolean canAddAll(ItemStackHandlerAA inv, List stacks, int slot, int endSlot, boolean fromAutomation) { @@ -162,7 +158,6 @@ public final class StackUtil { * Util method to find the first filled item in a handler. Searches from slot 0 to the end. * * @param inv The IItemHandler to search. - * * @return The first filled slot, or -1 if all slots are empty. */ public static int findFirstFilled(IItemHandler inv) { @@ -210,17 +205,15 @@ public final class StackUtil { * @param simulate If this is a simulation * @param slotStart Start range * @param slotEnd End range - * * @return The remainder that was not inserted. */ public static ItemStack insertItem(SlotlessableItemHandlerWrapper wrapper, ItemStack stack, boolean simulate, int slotStart, int slotEnd) { if (stack.isEmpty()) { return stack; } - ItemStack remain = stack.copy(); if (ActuallyAdditions.commonCapsLoaded) { - Object handler = wrapper.getSlotlessHandler(); +// Object handler = wrapper.getSlotlessHandler(); // if (handler instanceof ISlotlessItemHandler) { // remain = ((ISlotlessItemHandler) handler).insertItem(remain, simulate); // if (!ItemStack.areItemStacksEqual(remain, stack)) { @@ -229,14 +222,14 @@ public final class StackUtil { // } } - IItemHandler handler = wrapper.getNormalHandler(); - if (handler != null) { - for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, handler.getSlots()); i++) { - remain = handler.insertItem(i, remain, simulate); + return wrapper.getNormalHandler().map(e -> { + ItemStack remain = stack.copy(); + for (int i = Math.max(0, slotStart); i < Math.min(slotEnd, e.getSlots()); i++) { + remain = e.insertItem(i, remain, simulate); } - } - return remain; + return remain; + }).orElse(stack); } /**