more cleaning.

This commit is contained in:
Flanks255 2022-06-18 10:53:23 -05:00
parent 87b1e12892
commit 59785c4d1c
9 changed files with 39 additions and 87 deletions

View file

@ -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

View file

@ -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

View file

@ -1,6 +0,0 @@
{
"parent": "minecraft:item/handheld",
"textures": {
"layer0": "actuallyadditions:item/knife"
}
}

View file

@ -151,7 +151,6 @@ public final class ActuallyItems {
public static final RegistryObject<Item> COFFEE = ITEMS.register("coffee", ItemCoffee::new); //TODO flatten
public static final RegistryObject<Item> PHANTOM_CONNECTOR = ITEMS.register("phantom_connector", ItemPhantomConnector::new);
//public static final RegistryObject<Item> FOOD = ITEMS.register("food", ItemBase::new); //just... food? //TODO
public static final RegistryObject<Item> KNIFE = ITEMS.register("knife", ItemKnife::new);
public static final RegistryObject<Item> CRAFTER_ON_A_STICK = ITEMS.register("crafter_on_a_stick", ItemCrafterOnAStick::new);
//public static final RegistryObject<Item> DUST = ITEMS.register("dust", ItemDust::new); //TODO flatten
public static final RegistryObject<Item> 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<Item> basicItem() {

View file

@ -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<IEnergyStorage> 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<ItemStack> use(World worldIn, PlayerEntity player, Hand hand) {
public ActionResult<ItemStack> 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<ITextComponent> 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"));
}
}

View file

@ -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<ItemStack> use(World world, PlayerEntity player, Hand hand) {
public ActionResult<ItemStack> 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));
}

View file

@ -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<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlotType slot, ItemStack stack) {
Multimap<Attribute, AttributeModifier> 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;
}
}

View file

@ -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<ItemStack> use(World world, PlayerEntity player, Hand hand) {
public ActionResult<ItemStack> 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;
}

View file

@ -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<ItemStack> use(World worldIn, PlayerEntity player, Hand hand) {
public ActionResult<ItemStack> use(World worldIn, @Nonnull PlayerEntity player, @Nonnull Hand hand) {
if (!worldIn.isClientSide && player.isShiftKeyDown()) {
ItemUtil.changeEnabled(player, hand);
return ActionResult.success(player.getItemInHand(hand));