From 59785c4d1c1303e857729748cbad0d86902595bf Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Sat, 18 Jun 2022 10:53:23 -0500 Subject: [PATCH] more cleaning. --- port.MD | 2 +- src/generated/resources/.cache/cache | 1 - .../actuallyadditions/models/item/knife.json | 6 --- .../mod/items/ActuallyItems.java | 6 +-- .../mod/items/ItemBattery.java | 30 ++++++----- .../mod/items/ItemCrafterOnAStick.java | 5 +- .../mod/items/ItemKnife.java | 51 ------------------- .../mod/items/ItemLeafBlower.java | 19 ++++--- .../mod/items/ItemMagnetRing.java | 6 ++- 9 files changed, 39 insertions(+), 87 deletions(-) delete mode 100644 src/generated/resources/assets/actuallyadditions/models/item/knife.json delete mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java diff --git a/port.MD b/port.MD index b72d08fdb..4f323d59d 100644 --- a/port.MD +++ b/port.MD @@ -11,7 +11,7 @@ - [ ] Fishing nets - [ ] Solar panels - [ ] Item repairers -- [ ] Knife (food can just be crafted normally) +- [x] Knife (food can just be crafted normally) - [ ] Black lotuses and black dye - [ ] Chest to storage crate upgrade (makes little sense with the way they are being changed), keep the other ones though - [x] Ring of liquid banning diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index cda7a3bb4..7ef538d53 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -355,7 +355,6 @@ aac45de00a0838a7a955e2bc56e125ef29c19a47 assets/actuallyadditions/models/item/ho 5513baa5bd2d53702880a1ab6bb23d7159ebbd89 assets/actuallyadditions/models/item/iron_aiot.json a4bc0e00bec22d8a0da612b6dfe4dba7688a2758 assets/actuallyadditions/models/item/iron_casing.json 971f45a5a05b2c399e8075597b0826965f6b6f0b assets/actuallyadditions/models/item/item_interface.json -d676c5b6ddcc920059a70e8107faa0dbf023b05c assets/actuallyadditions/models/item/knife.json 1e3d4970b8a5ed46ed72deedc5c38d8347658d2f assets/actuallyadditions/models/item/lamp_black.json 8b730988dfb2cb6caa448647d245f9a4160c4247 assets/actuallyadditions/models/item/lamp_blue.json 42df4aeb9a27d43da2c3a47cafd4f3fac1f3c0fa assets/actuallyadditions/models/item/lamp_brown.json diff --git a/src/generated/resources/assets/actuallyadditions/models/item/knife.json b/src/generated/resources/assets/actuallyadditions/models/item/knife.json deleted file mode 100644 index 0bbc031bf..000000000 --- a/src/generated/resources/assets/actuallyadditions/models/item/knife.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "minecraft:item/handheld", - "textures": { - "layer0": "actuallyadditions:item/knife" - } -} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java index 680cdf007..09b30996d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java @@ -151,7 +151,6 @@ public final class ActuallyItems { public static final RegistryObject COFFEE = ITEMS.register("coffee", ItemCoffee::new); //TODO flatten public static final RegistryObject PHANTOM_CONNECTOR = ITEMS.register("phantom_connector", ItemPhantomConnector::new); //public static final RegistryObject FOOD = ITEMS.register("food", ItemBase::new); //just... food? //TODO - public static final RegistryObject KNIFE = ITEMS.register("knife", ItemKnife::new); public static final RegistryObject CRAFTER_ON_A_STICK = ITEMS.register("crafter_on_a_stick", ItemCrafterOnAStick::new); //public static final RegistryObject DUST = ITEMS.register("dust", ItemDust::new); //TODO flatten public static final RegistryObject SOLIDIFIED_EXPERIENCE = ITEMS.register("solidified_experience", ItemSolidifiedExperience::new); @@ -195,13 +194,12 @@ public final class ActuallyItems { DRILL_UPGRADE_SPEED, DRILL_UPGRADE_SPEED_II, DRILL_UPGRADE_SPEED_III, DRILL_UPGRADE_SILK_TOUCH, DRILL_UPGRADE_FORTUNE, DRILL_UPGRADE_FORTUNE_II, DRILL_UPGRADE_THREE_BY_THREE, DRILL_UPGRADE_FIVE_BY_FIVE, DRILL_UPGRADE_BLOCK_PLACING, COFFEE_CUP, PHANTOM_CONNECTOR, RICE, - KNIFE, CRAFTER_ON_A_STICK, + CRAFTER_ON_A_STICK, /* CRUSHED_IRON, CRUSHED_GOLD, CRUSHED_DIAMOND, CRUSHED_EMERALD, CRUSHED_LAPIS, CRUSHED_QUARTZ, CRUSHED_COAL, CRUSHED_BLACK_QUARTZ, */ SOLIDIFIED_EXPERIENCE, LEAF_BLOWER, ADVANCED_LEAF_BLOWER, RING_OF_GROWTH, RING_OF_MAGNETIZING, - COFFEE_BEANS, RICE_SEEDS, CANOLA_SEEDS, FLAX_SEEDS, COFFEE_SEEDS , - WOODEN_AIOT, STONE_AIOT, IRON_AIOT, GOLD_AIOT, DIAMOND_AIOT, NETHERITE_AIOT + COFFEE_BEANS, RICE_SEEDS, CANOLA_SEEDS, FLAX_SEEDS, COFFEE_SEEDS ); private static Supplier basicItem() { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java index af29d4810..991885a40 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemBattery.java @@ -10,10 +10,8 @@ package de.ellpeck.actuallyadditions.mod.items; -import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.util.ItemUtil; -import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; @@ -25,9 +23,11 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.api.distmarker.OnlyIns; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.energy.CapabilityEnergy; +import net.minecraftforge.energy.IEnergyStorage; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.List; @@ -43,25 +43,29 @@ public class ItemBattery extends ItemEnergy { } @Override - public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { + public void inventoryTick(@Nonnull ItemStack stack, World world, @Nonnull Entity entity, int itemSlot, boolean isSelected) { if (!world.isClientSide && entity instanceof PlayerEntity && ItemUtil.isEnabled(stack) && !isSelected) { PlayerEntity player = (PlayerEntity) entity; for (int i = 0; i < player.inventory.getContainerSize(); i++) { ItemStack slot = player.inventory.getItem(i); - if (StackUtil.isValid(slot) && slot.getCount() == 1) { - int extractable = this.extractEnergy(stack, Integer.MAX_VALUE, true); - int received = slot.getCapability(CapabilityEnergy.ENERGY).map(e -> e.receiveEnergy(extractable, false)).orElse(0); + if (!slot.isEmpty() && slot.getCount() == 1) { + LazyOptional energy = slot.getCapability(CapabilityEnergy.ENERGY); + energy.ifPresent(cap -> { + int extractable = this.extractEnergy(stack, Integer.MAX_VALUE, true); + int received = cap.receiveEnergy(extractable, false); - if (received > 0) { - this.extractEnergy(stack, received, false); - } + if (received > 0) { + this.extractEnergy(stack, received, false); + } + }); } } } } + @Nonnull @Override - public ActionResult use(World worldIn, PlayerEntity player, Hand hand) { + public ActionResult use(World worldIn, @Nonnull PlayerEntity player, @Nonnull Hand hand) { if (!worldIn.isClientSide && player.isShiftKeyDown()) { ItemUtil.changeEnabled(player, hand); return ActionResult.success(player.getItemInHand(hand)); @@ -73,9 +77,9 @@ public class ItemBattery extends ItemEnergy { @Override public void appendHoverText(ItemStack stack, @Nullable World playerIn, List list, ITooltipFlag advanced) { super.appendHoverText(stack, playerIn, list, advanced); - list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".battery." + (ItemUtil.isEnabled(stack) + list.add(new TranslationTextComponent("tooltip.actuallyadditions.battery." + (ItemUtil.isEnabled(stack) ? "discharge" : "noDischarge"))); - list.add(new TranslationTextComponent("tooltip." + ActuallyAdditions.MODID + ".battery.changeMode")); + list.add(new TranslationTextComponent("tooltip.actuallyadditions.battery.changeMode")); } } 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 e64d6b04d..af73bd707 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemCrafterOnAStick.java @@ -24,6 +24,8 @@ import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import net.minecraftforge.fml.network.NetworkHooks; +import javax.annotation.Nonnull; + public class ItemCrafterOnAStick extends ItemBase { private static final ITextComponent CONTAINER_TITLE = new TranslationTextComponent("container.crafting"); @@ -31,8 +33,9 @@ public class ItemCrafterOnAStick extends ItemBase { super(ActuallyItems.defaultNonStacking()); } + @Nonnull @Override - public ActionResult use(World world, PlayerEntity player, Hand hand) { + public ActionResult use(World world, @Nonnull PlayerEntity player, @Nonnull Hand hand) { if (!world.isClientSide) { NetworkHooks.openGui((ServerPlayerEntity) player, new SimpleNamedContainerProvider((windowId, playerInventory, playerEntity) -> new WorkbenchContainer(windowId, playerInventory), CONTAINER_TITLE)); } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java deleted file mode 100644 index f6ec3eb12..000000000 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemKnife.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file ("ItemKnife.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 com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; -import net.minecraft.entity.ai.attributes.Attribute; -import net.minecraft.entity.ai.attributes.AttributeModifier; -import net.minecraft.entity.ai.attributes.Attributes; -import net.minecraft.inventory.EquipmentSlotType; -import net.minecraft.item.ItemStack; - -public class ItemKnife extends ItemBase { - - public ItemKnife() { - super(ActuallyItems.defaultNonStacking().defaultDurability(100).setNoRepair()); - } - - - // @Override - // public boolean getShareTag() { - // return true; - // } - - - @Override - public Multimap getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) { - Multimap map = ArrayListMultimap.create(); - if (slot == EquipmentSlotType.MAINHAND) { - // TODO: [port] validate - map.put(Attributes.ATTACK_DAMAGE, new AttributeModifier("Knife Modifier", 3, AttributeModifier.Operation.ADDITION)); - } - return map; - } - - @Override - public ItemStack getContainerItem(ItemStack stack) { - ItemStack theStack = stack.copy(); - theStack.setDamageValue(theStack.getDamageValue() + 1); - return theStack; - } -} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java index 1418a31a3..ab5ac0f80 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemLeafBlower.java @@ -27,6 +27,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IForgeShearable; +import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collections; @@ -39,19 +40,21 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { this.isAdvanced = isAdvanced; } + @Nonnull @Override - public ActionResult use(World world, PlayerEntity player, Hand hand) { + public ActionResult use(@Nonnull World world, PlayerEntity player, @Nonnull Hand hand) { player.startUsingItem(hand); return ActionResult.success(player.getItemInHand(hand)); } + @Nonnull @Override - public UseAction getUseAnimation(ItemStack stack) { + public UseAction getUseAnimation(@Nonnull ItemStack stack) { return UseAction.BOW; } @Override - public int getUseDuration(ItemStack stack) { + public int getUseDuration(@Nonnull ItemStack stack) { return Integer.MAX_VALUE; } @@ -107,16 +110,16 @@ public class ItemLeafBlower extends ItemBase implements IDisplayStandItem { if (!breakPositions.isEmpty()) { Collections.shuffle(breakPositions); - BlockPos theCoord = breakPositions.get(0); - BlockState theState = world.getBlockState(theCoord); + BlockPos pos = breakPositions.get(0); + BlockState theState = world.getBlockState(pos); - world.destroyBlock(theCoord, true); + world.destroyBlock(pos, true); // theState.getBlock().dropBlockAsItem(world, theCoord, theState, 0); //Plays the Breaking Sound - world.levelEvent(2001, theCoord, Block.getId(theState)); + world.levelEvent(2001, pos, Block.getId(theState)); //Deletes the Block - world.setBlockAndUpdate(theCoord, Blocks.AIR.defaultBlockState()); + world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState()); return true; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java index 1ce41f081..fe7a82789 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemMagnetRing.java @@ -21,6 +21,7 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.world.World; +import javax.annotation.Nonnull; import java.util.List; public class ItemMagnetRing extends ItemEnergy { @@ -35,7 +36,7 @@ public class ItemMagnetRing extends ItemEnergy { } @Override - public void inventoryTick(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) { + public void inventoryTick(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull Entity entity, int itemSlot, boolean isSelected) { if (entity instanceof PlayerEntity && !world.isClientSide && !ItemUtil.isEnabled(stack)) { PlayerEntity player = (PlayerEntity) entity; if (player.isCreative() || player.isSpectator()) { @@ -72,8 +73,9 @@ public class ItemMagnetRing extends ItemEnergy { } } + @Nonnull @Override - public ActionResult use(World worldIn, PlayerEntity player, Hand hand) { + public ActionResult use(World worldIn, @Nonnull PlayerEntity player, @Nonnull Hand hand) { if (!worldIn.isClientSide && player.isShiftKeyDown()) { ItemUtil.changeEnabled(player, hand); return ActionResult.success(player.getItemInHand(hand));