From 786d9d330261668292d4135b65f1e1219b99bb78 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Sat, 27 Apr 2024 09:46:57 -0500 Subject: [PATCH] starting some skeleton of the crate. --- .../mod/blocks/ActuallyBlocks.java | 51 ++----------------- .../actuallyadditions/mod/blocks/Crate.java | 48 +++++++++++++++++ .../mod/items/ActuallyItems.java | 6 +-- .../actuallyadditions/mod/tile/CrateBE.java | 18 +++++++ .../mod/util/CrateItemHandler.java | 23 +++++++++ .../assets/actuallyadditions/lang/en_us.json | 10 ++-- 6 files changed, 101 insertions(+), 55 deletions(-) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Crate.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/tile/CrateBE.java create mode 100644 src/main/java/de/ellpeck/actuallyadditions/mod/util/CrateItemHandler.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java index f5b3434dc..d6e50f38d 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/ActuallyBlocks.java @@ -14,53 +14,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.blocks.base.AACrops; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; import de.ellpeck.actuallyadditions.mod.items.metalists.Crystals; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBatteryBox; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBioReactor; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCanolaPress; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoalGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCoffeeMachine; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCrusher; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityCrusherDouble; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityDropper; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnervator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFarmer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFeeder; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFireworkBox; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityFluidPlacer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityHeatCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityItemInterfaceHopping; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergy; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyAdvanced; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayEnergyExtreme; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayFluids; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItem; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelayItemAdvanced; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLavaFactoryController; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLeafGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityLongRangeBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityOilGenerator; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomBreaker; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomEnergyface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomItemface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomLiquiface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomPlacer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPhantomRedstoneface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlacer; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityPoweredFurnace; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityRangedCollector; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityShockSuppressor; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityVerticalDigger; -import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; +import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.registration.AABlockReg; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.world.item.Item; @@ -162,6 +116,9 @@ public final class ActuallyBlocks { public static final AABlockReg POWERED_FURNACE = new AABlockReg<>("powered_furnace", BlockPoweredFurnace::new, (b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityPoweredFurnace::new); + public static final AABlockReg CRATE_SMALL = new AABlockReg<>("crate_small", () -> new Crate(Crate.Size.SMALL), + (b) -> new AABlockItem(b, defaultBlockItemProperties), (pos, state) -> new CrateBE(pos, state, Crate.Size.SMALL)); //TODO + // Crystal Blocks public static final AABlockReg ENORI_CRYSTAL = new AABlockReg<>("enori_crystal_block", () -> new BlockCrystal(false), BlockCrystal::createBlockItem); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Crate.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Crate.java new file mode 100644 index 000000000..6e3813775 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/Crate.java @@ -0,0 +1,48 @@ +package de.ellpeck.actuallyadditions.mod.blocks; + +import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase; +import de.ellpeck.actuallyadditions.mod.tile.CrateBE; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.material.PushReaction; + +import javax.annotation.Nullable; + +public class Crate extends BlockContainerBase { + private final Size size; + public Crate(Size size) { + super(ActuallyBlocks.defaultPickProps().pushReaction(PushReaction.BLOCK)); + this.size = size; + } + + public Size getSize() { + return size; + } + + public enum Size { + SMALL(9, 4), + MEDIUM(18, 8), + LARGE(27, 16); //TODO Maybe? + + Size(int slotCount, int stackBoost) { + this.slots = slotCount; + this.stackBoost = stackBoost; + } + private final int slots; + private final int stackBoost; + + public int getSlots() { + return slots; + } + public int getStackBoost() { + return stackBoost; + } + } + + @Nullable + @Override + public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) { + return new CrateBE(pPos, pState, this.size); + } +} 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 407ef490a..8cc109f52 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ActuallyItems.java @@ -41,7 +41,7 @@ public final class ActuallyItems { // MISC ITEMS public static final DeferredItem CANOLA = ITEMS.register("canola", () -> new ItemBase()); - public static final DeferredItem COFFEE_CUP = ITEMS.register("coffee_cup", () -> new ItemCoffee()); + public static final DeferredItem COFFEE_CUP = ITEMS.register("coffee_cup", ItemCoffee::new); public static final DeferredItem RING = ITEMS.register("ring", () -> new ItemBase()); public static final DeferredItem BASIC_COIL = ITEMS.register("basic_coil", () -> new ItemBase()); public static final DeferredItem ADVANCED_COIL = ITEMS.register("advanced_coil", () -> new ItemBase()); @@ -49,13 +49,13 @@ public final class ActuallyItems { public static final DeferredItem RICE_DOUGH = ITEMS.register("rice_dough", () -> new ItemBase()); public static final DeferredItem TINY_COAL = ITEMS.register("tiny_coal", () -> new ItemBase() { @Override - public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) { + public int getBurnTime(@Nonnull ItemStack itemStack, @Nullable RecipeType recipeType) { return 200; } }); public static final DeferredItem TINY_CHARCOAL = ITEMS.register("tiny_charcoal", () -> new ItemBase() { @Override - public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) { + public int getBurnTime(@Nonnull ItemStack itemStack, @Nullable RecipeType recipeType) { return 200; } }); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CrateBE.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CrateBE.java new file mode 100644 index 000000000..1e12ac6b6 --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/CrateBE.java @@ -0,0 +1,18 @@ +package de.ellpeck.actuallyadditions.mod.tile; + +import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; +import de.ellpeck.actuallyadditions.mod.blocks.Crate; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +public class CrateBE extends TileEntityBase{ + private final Crate.Size size; + public CrateBE(BlockPos pos, BlockState state, Crate.Size size) { + super(ActuallyBlocks.CRATE_SMALL.getTileEntityType(), pos, state); + this.size = size; + } + + public Crate.Size getSize() { + return size; + } +} diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/util/CrateItemHandler.java b/src/main/java/de/ellpeck/actuallyadditions/mod/util/CrateItemHandler.java new file mode 100644 index 000000000..73043b23a --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/util/CrateItemHandler.java @@ -0,0 +1,23 @@ +package de.ellpeck.actuallyadditions.mod.util; + +import de.ellpeck.actuallyadditions.mod.blocks.Crate; +import net.minecraft.world.item.ItemStack; + +public class CrateItemHandler extends ItemStackHandlerAA { + private Crate.Size size; + public CrateItemHandler(Crate.Size size) { + super(size.getSlots()); + + this.size = size; + } + + @Override + protected int getStackLimit(int slot, ItemStack stack) { + return Math.min(this.getSlotLimit(slot), stack.getMaxStackSize() * this.size.getStackBoost()); + } + + @Override + public int getSlotLimit(int slot) { + return 64 * this.size.getStackBoost(); + } +} diff --git a/src/main/resources/assets/actuallyadditions/lang/en_us.json b/src/main/resources/assets/actuallyadditions/lang/en_us.json index 79ccdf5aa..5c97272af 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_us.json +++ b/src/main/resources/assets/actuallyadditions/lang/en_us.json @@ -530,11 +530,11 @@ "container.actuallyadditions.crusher_double": "Double Crusher", "container.actuallyadditions.powered_furnace": "Powered Furnace", "container.actuallyadditions.feeder": "Feeder", - "container.actuallyadditions.giantChest": "Small Storage Crate", - "container.actuallyadditions.giantChest.desc": "'Small'", - "container.actuallyadditions.giantChestMedium": "Medium Storage Crate", - "container.actuallyadditions.giantChestLarge": "Large Storage Crate", - "container.actuallyadditions.giantChestLarge.desc": "Supersolid", + "container.actuallyadditions.crate_small": "Small Storage Crate (wip)", + "container.actuallyadditions.crate_small.desc": "'Small'", + "container.actuallyadditions.crate_medium": "Medium Storage Crate (wip)", + "container.actuallyadditions.crate_large": "Large Storage Crate (wip)", + "container.actuallyadditions.crate_large.desc": "Supersolid", "container.actuallyadditions.repairer": "Repairer", "container.actuallyadditions.placer": "Placer", "container.actuallyadditions.breaker": "Breaker",