From 6ea3fb85bd112ca21fee371c80fa9b1bab6d3cd3 Mon Sep 17 00:00:00 2001 From: TonimatasMC Date: Wed, 13 Jul 2022 20:43:07 +0200 Subject: [PATCH 1/2] Final fixes Coal Crusher --- .../block/entity/Utils/Simplify.java | 4 +- .../entity/custom/CoalCrusherBlockEntity.java | 69 +++++++------------ .../krystalcraft/screen/CoalCrusherMenu.java | 11 ++- .../screen/CoalCrusherScreen.java | 1 - 4 files changed, 30 insertions(+), 55 deletions(-) diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java index 6664d321..63c1d252 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java @@ -11,8 +11,8 @@ public static boolean hasWaterInWaterSlot(ItemStackHandler itemStackHandler) { return itemStackHandler.getStackInSlot(0).getItem() == ModItems.SET_WATER_BOTTLES.get(); } - public static boolean hasCoalSlot(ItemStackHandler itemStackHandler, int fuelProgress, int fuelMaxProgress) { - return itemStackHandler.getStackInSlot(2).getItem() == Items.COAL || fuelProgress <= fuelMaxProgress; + public static boolean hasCoalSlot(int fuel) { + return fuel != 0; } public static boolean canInsertItemIntoOutputSlot(SimpleContainer inventory, ItemStack output) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java index ae378567..61ed5425 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java @@ -23,7 +23,7 @@ import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemStackHandler; import net.tonimatasmc.krystalcraft.block.entity.ModBlockEntities; -import net.tonimatasmc.krystalcraft.item.ModItems; +import net.tonimatasmc.krystalcraft.block.entity.Utils.Simplify; import net.tonimatasmc.krystalcraft.recipe.CoalCrusherRecipe; import net.tonimatasmc.krystalcraft.screen.CoalCrusherMenu; import org.jetbrains.annotations.NotNull; @@ -46,8 +46,7 @@ protected void onContentsChanged(int slot) { protected final ContainerData data; private int progress = 0; private int maxProgress = 72; - private static int fuelProgress = 0; - private static final int fuelMaxProgress = 72*8; + private int fuel; public CoalCrusherBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(ModBlockEntities.COAL_CRUSHER_BLOCK_ENTITY.get(), pWorldPosition, pBlockState); @@ -58,6 +57,7 @@ public int get(int index) { switch (index) { case 0: return CoalCrusherBlockEntity.this.progress; case 1: return CoalCrusherBlockEntity.this.maxProgress; + case 2: return CoalCrusherBlockEntity.this.fuel; default: return 0; } } @@ -66,11 +66,12 @@ public void set(int index, int value) { switch (index) { case 0 -> CoalCrusherBlockEntity.this.progress = value; case 1 -> CoalCrusherBlockEntity.this.maxProgress = value; + case 2 -> CoalCrusherBlockEntity.this.fuel = value; } } public int getCount() { - return 2; + return 3; } }; } @@ -97,7 +98,6 @@ public LazyOptional getCapability(@Nonnull Capability cap, @javax.anno return super.getCapability(cap, side); } - @Override public void onLoad() { super.onLoad(); @@ -114,6 +114,7 @@ public void invalidateCaps() { protected void saveAdditional(@NotNull CompoundTag tag) { tag.put("inventory", itemHandler.serializeNBT()); tag.putInt("coal_crusher.progress", progress); + tag.putInt("coal_crusher.fuel", fuel); super.saveAdditional(tag); } @@ -122,6 +123,7 @@ public void load(@Nullable CompoundTag nbt) { super.load(Objects.requireNonNull(nbt)); itemHandler.deserializeNBT(nbt.getCompound("inventory")); progress = nbt.getInt("coal_crusher.progress"); + progress = nbt.getInt("coal_crusher.fuel"); } public void drops() { @@ -134,13 +136,19 @@ public void drops() { } public static void tick(Level pLevel, BlockPos pPos, BlockState pState, CoalCrusherBlockEntity pBlockEntity) { - if(hasRecipe(pBlockEntity)) { + if (hasRecipe(pBlockEntity)) { pBlockEntity.progress++; - fuelProgress++; setChanged(pLevel, pPos, pState); - if (pBlockEntity.progress > pBlockEntity.maxProgress && fuelProgress <= fuelMaxProgress) { - craftItem(pBlockEntity); + if (pBlockEntity.progress > pBlockEntity.maxProgress) { + if (pBlockEntity.fuel > 0) { + craftItem(pBlockEntity); + } else { + if (pBlockEntity.itemHandler.getStackInSlot(2).getItem() == Items.COAL || pBlockEntity.itemHandler.getStackInSlot(2).getItem() == Items.CHARCOAL) { + pBlockEntity.itemHandler.extractItem(2, 1, false); + pBlockEntity.fuel = 8; + } + } } } else { pBlockEntity.resetProgress(); @@ -149,32 +157,22 @@ public static void tick(Level pLevel, BlockPos pPos, BlockState pState, CoalCrus } private static boolean hasRecipe(CoalCrusherBlockEntity entity) { - Level level = entity.level; - SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); + Level level = entity.level; for (int i = 0; i < entity.itemHandler.getSlots(); i++) { inventory.setItem(i, entity.itemHandler.getStackInSlot(i)); } - Optional match = Objects.requireNonNull(level).getRecipeManager() - .getRecipeFor(CoalCrusherRecipe.Type.INSTANCE, inventory, level); - - return match.isPresent() && canInsertAmountIntoOutputSlot(inventory) && canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && - hasWaterInWaterSlot(entity) && hasCoalSlot(entity); - } - - private static boolean hasWaterInWaterSlot(CoalCrusherBlockEntity entity) { - return entity.itemHandler.getStackInSlot(0).getItem() == ModItems.SET_WATER_BOTTLES.get(); - } + Optional match = Objects.requireNonNull(level).getRecipeManager().getRecipeFor(CoalCrusherRecipe.Type.INSTANCE, inventory, level); - private static boolean hasCoalSlot(CoalCrusherBlockEntity entity) { - return entity.itemHandler.getStackInSlot(2).getItem() == Items.COAL || fuelProgress <= fuelMaxProgress; + return match.isPresent() && Simplify.canInsertAmountIntoOutputSlot(inventory) && Simplify.canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && + Simplify.hasWaterInWaterSlot(entity.itemHandler); } private static void craftItem(CoalCrusherBlockEntity entity) { - Level level = entity.level; SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); + Level level = entity.level; for (int i = 0; i < entity.itemHandler.getSlots(); i++) { inventory.setItem(i, entity.itemHandler.getStackInSlot(i)); @@ -183,7 +181,6 @@ private static void craftItem(CoalCrusherBlockEntity entity) { Optional match = Objects.requireNonNull(level).getRecipeManager().getRecipeFor(CoalCrusherRecipe.Type.INSTANCE, inventory, level); if(match.isPresent()) { - entity.itemHandler.getStackInSlot(0).hurt(1, RandomSource.create(), null); if ((entity.itemHandler.getStackInSlot(0).getMaxDamage() - entity.itemHandler.getStackInSlot(0).getDamageValue()) <= 0) { @@ -194,11 +191,7 @@ private static void craftItem(CoalCrusherBlockEntity entity) { entity.itemHandler.setStackInSlot(3, new ItemStack(match.get().getResultItem().getItem(), entity.itemHandler.getStackInSlot(3).getCount() + 1)); - if (fuelProgress >= fuelMaxProgress) { - entity.itemHandler.extractItem(2, 1, false); - fuelProgress = 0; - } - + entity.fuel = entity.fuel - 1; entity.resetProgress(); } } @@ -206,20 +199,4 @@ private static void craftItem(CoalCrusherBlockEntity entity) { private void resetProgress() { this.progress = 0; } - - public static int getFuelProgress() { - return fuelProgress; - } - - public static int getFuelMaxProgress() { - return fuelMaxProgress; - } - - private static boolean canInsertItemIntoOutputSlot(SimpleContainer inventory, ItemStack output) { - return inventory.getItem(3).getItem() == output.getItem() || inventory.getItem(3).isEmpty(); - } - - private static boolean canInsertAmountIntoOutputSlot(SimpleContainer inventory) { - return inventory.getItem(3).getMaxStackSize() > inventory.getItem(3).getCount(); - } } \ No newline at end of file diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java index 0479858c..be2b419d 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java @@ -49,23 +49,22 @@ public CoalCrusherMenu(int pContainerId, Inventory inv, BlockEntity entity, Cont } public boolean isCrafting() { - return data.get(0) > 0 && data.get(2) < 0; + return data.get(0) > 0; } public int getScaledProgress() { int progress = this.data.get(0); int maxProgress = this.data.get(1); - int progressArrowSize = 26; + int progressArrowSize = 14; return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0; } public int getFuelScaledProgress() { - int progress = CoalCrusherBlockEntity.getFuelProgress(); - int maxProgress = CoalCrusherBlockEntity.getFuelMaxProgress(); - int progressArrowSize = 26*8; + int progress = this.data.get(2); + int progressArrowSize = 14; - return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0; + return progress != 0 ? progress * progressArrowSize / 8 : 0; } // CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java index 756ef7a6..9a367f0d 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java @@ -33,7 +33,6 @@ protected void renderBg(@Nullable PoseStack pPoseStack, float pPartialTick, int if (menu.isCrafting()) { blit(pPoseStack, x + 102, y + 21, 190, 0, 23, menu.getScaledProgress()); } - blit(pPoseStack, x + 55, y + 35, 176, 0, 14, menu.getFuelScaledProgress()); } From c90b60133ac6f5ca141ccdcf44f88e9e2729d839 Mon Sep 17 00:00:00 2001 From: TonimatasMC Date: Sat, 16 Jul 2022 06:31:06 +0200 Subject: [PATCH 2/2] Fixed Coal Combiner and optimize all code. --- .../krystalcraft/KrystalCraft.java | 17 +------ .../krystalcraft/block/ModBlocks.java | 4 +- .../block/custom/CoalCombinerBlock.java | 4 +- .../block/custom/CoalCrusherBlock.java | 10 ++-- .../block/custom/GemCuttingStationBlock.java | 10 ++-- .../block/entity/ModBlockEntities.java | 2 - .../block/entity/Utils/Simplify.java | 5 +- .../custom/CoalCombinerBlockEntity.java | 46 +++++++++-------- .../entity/custom/CoalCrusherBlockEntity.java | 2 +- .../custom/GemCuttingStationBlockEntity.java | 32 ++++-------- .../config/KrystalCraftModCommonConfigs.java | 1 - .../datagen/ModBlockTagsProvider.java | 1 - .../datagen/ModBlocksStateProvider.java | 5 +- .../datagen/ModItemModelProvider.java | 8 +-- .../datagen/ModItemTagsProvider.java | 6 --- .../datagen/ModLootTableProvider.java | 5 +- .../enchantment/ModEnchantments.java | 1 + .../enchantment/VenomEnchantment.java | 51 ------------------- .../{ => enchants}/FreezingEnchantment.java | 13 +---- .../{ => enchants}/LifeLeechEnchantment.java | 14 +---- .../LightningStrikeEnchantment.java | 4 +- .../PlayerHeadsEnchantment.java | 7 +-- .../enchants/VenomEnchantment.java | 42 +++++++++++++++ .../{ => enchants}/XpLeechEnchantment.java | 10 +--- .../krystalcraft/event/ModEventBusEvents.java | 1 - .../krystalcraft/item/KrystalCraftTab.java | 1 + .../krystalcraft/item/ModArmorTier.java | 43 ++++------------ .../krystalcraft/item/ModItems.java | 8 ++- .../item/custom/SetWaterBottles.java | 4 -- .../recipe/CoalCombinerRecipe.java | 5 +- .../recipe/CoalCrusherRecipe.java | 9 ++-- .../recipe/GemCuttingStationRecipe.java | 6 +-- .../krystalcraft/recipe/ModRecipes.java | 1 + .../krystalcraft/screen/CoalCombinerMenu.java | 35 +++++-------- .../screen/CoalCombinerScreen.java | 6 +-- .../krystalcraft/screen/CoalCrusherMenu.java | 25 +++------ .../screen/CoalCrusherScreen.java | 5 +- .../screen/GemCuttingStationMenu.java | 20 ++------ .../krystalcraft/screen/slot/ModFuelSlot.java | 11 +--- .../krystalcraft/util/ModTags.java | 10 +--- .../world/biomemods/ModBiomeModifiers.java | 2 - .../biomemods/ModEntityBiomeModifier.java | 1 + .../world/biomemods/ModOreBiomeModifier.java | 1 + .../biomemods/ModVegetalBiomeModifier.java | 1 + .../world/feature/ModConfiguredFeatures.java | 4 +- .../world/feature/ModPlacedFeatures.java | 13 +++-- 46 files changed, 177 insertions(+), 335 deletions(-) delete mode 100644 src/main/java/net/tonimatasmc/krystalcraft/enchantment/VenomEnchantment.java rename src/main/java/net/tonimatasmc/krystalcraft/enchantment/{ => enchants}/FreezingEnchantment.java (72%) rename src/main/java/net/tonimatasmc/krystalcraft/enchantment/{ => enchants}/LifeLeechEnchantment.java (72%) rename src/main/java/net/tonimatasmc/krystalcraft/enchantment/{ => enchants}/LightningStrikeEnchantment.java (88%) rename src/main/java/net/tonimatasmc/krystalcraft/enchantment/{ => enchants}/PlayerHeadsEnchantment.java (82%) create mode 100644 src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/VenomEnchantment.java rename src/main/java/net/tonimatasmc/krystalcraft/enchantment/{ => enchants}/XpLeechEnchantment.java (73%) diff --git a/src/main/java/net/tonimatasmc/krystalcraft/KrystalCraft.java b/src/main/java/net/tonimatasmc/krystalcraft/KrystalCraft.java index 9c4d56db..47124dcb 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/KrystalCraft.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/KrystalCraft.java @@ -20,8 +20,6 @@ import net.tonimatasmc.krystalcraft.screen.CoalCrusherScreen; import net.tonimatasmc.krystalcraft.screen.GemCuttingStationScreen; import net.tonimatasmc.krystalcraft.screen.ModMenuTypes; -import net.tonimatasmc.krystalcraft.world.biomemods.ModBiomeModifiers; -import net.tonimatasmc.krystalcraft.world.feature.ModPlacedFeatures; @Mod(KrystalCraft.MOD_ID) public class KrystalCraft { @@ -41,7 +39,7 @@ public KrystalCraft() { ModEnchantments.register(eventBus); //ModBiomeModifiers.register(eventBus); - // ModPlacedFeatures.register(eventBus); + //ModPlacedFeatures.register(eventBus); eventBus.addListener(this::clientSetup); @@ -56,17 +54,4 @@ private void clientSetup(final FMLClientSetupEvent event) { MenuScreens.register(ModMenuTypes.COAL_CRUSHER_MENU.get(), CoalCrusherScreen::new); MenuScreens.register(ModMenuTypes.COAL_COMBINER_MENU.get(), CoalCombinerScreen::new); } - - @SuppressWarnings("unused") - @Mod.EventBusSubscriber(modid = KrystalCraft.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD) - public static class Client { - private Client() { - - } - - private void doClientStuff(final FMLClientSetupEvent event) { - event.enqueueWork(() -> { - }); - } - } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/ModBlocks.java b/src/main/java/net/tonimatasmc/krystalcraft/block/ModBlocks.java index d0e6fd2b..3713d48b 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/ModBlocks.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/ModBlocks.java @@ -165,8 +165,8 @@ private static RegistryObject registerBlock(String name, Su } private static RegistryObject registerBlockItem(String name, RegistryObject block, String tooltipKey) { - return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), - new Item.Properties().tab(KrystalCraftTab.KRYSTALCRAFT)) { + return ModItems.ITEMS.register(name, () -> new BlockItem(block.get(), new Item.Properties().tab(KrystalCraftTab.KRYSTALCRAFT)) { + @Override public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List pTooltip, @NotNull TooltipFlag pFlag) { pTooltip.add(Component.translatable(tooltipKey)); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCombinerBlock.java b/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCombinerBlock.java index 4de67b92..55139f98 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCombinerBlock.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCombinerBlock.java @@ -35,11 +35,9 @@ public CoalCombinerBlock(Properties properties) { super(properties); } - private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 18, 16); - @Override public @Nonnull VoxelShape getShape(@Nullable BlockState pState, @Nullable BlockGetter pLevel, @Nullable BlockPos pPos, @Nullable CollisionContext pContext) { - return SHAPE; + return Block.box(0, 0, 0, 16, 18, 16); } @Override diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCrusherBlock.java b/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCrusherBlock.java index 69f7e78e..f050dc20 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCrusherBlock.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/custom/CoalCrusherBlock.java @@ -35,12 +35,10 @@ public CoalCrusherBlock(Properties properties) { super(properties); } - private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 18, 16); - @Override @Nonnull public VoxelShape getShape(@Nullable BlockState pState, @Nullable BlockGetter pLevel, @Nullable BlockPos pPos, @Nullable CollisionContext pContext) { - return SHAPE; + return Block.box(0, 0, 0, 16, 18, 16); } @Override @@ -75,10 +73,12 @@ public RenderShape getRenderShape(@Nullable BlockState pState) { public void onRemove(BlockState pState, @Nullable Level pLevel, @Nullable BlockPos pPos, BlockState pNewState, boolean pIsMoving) { if (pState.getBlock() != pNewState.getBlock()) { BlockEntity blockEntity = Objects.requireNonNull(pLevel).getBlockEntity(Objects.requireNonNull(pPos)); + if (blockEntity instanceof CoalCrusherBlockEntity) { ((CoalCrusherBlockEntity) blockEntity).drops(); } } + super.onRemove(pState, Objects.requireNonNull(pLevel), Objects.requireNonNull(pPos), pNewState, pIsMoving); } @@ -87,6 +87,7 @@ public void onRemove(BlockState pState, @Nullable Level pLevel, @Nullable BlockP public InteractionResult use(@Nullable BlockState pState, Level pLevel, @Nullable BlockPos pPos, @Nullable Player pPlayer, @Nullable InteractionHand pHand, @Nullable BlockHitResult pHit) { if (!pLevel.isClientSide()) { BlockEntity entity = pLevel.getBlockEntity(Objects.requireNonNull(pPos)); + if(entity instanceof CoalCrusherBlockEntity) { NetworkHooks.openGui(((ServerPlayer) Objects.requireNonNull(pPlayer)), (CoalCrusherBlockEntity)entity, pPos); } else { @@ -106,7 +107,6 @@ public BlockEntity newBlockEntity(@Nullable BlockPos pPos, @Nullable BlockState @Nullable @Override public BlockEntityTicker getTicker(@Nullable Level pLevel, @Nullable BlockState pState, @Nullable BlockEntityType pBlockEntityType) { - return createTickerHelper(pBlockEntityType, ModBlockEntities.COAL_CRUSHER_BLOCK_ENTITY.get(), - CoalCrusherBlockEntity::tick); + return createTickerHelper(pBlockEntityType, ModBlockEntities.COAL_CRUSHER_BLOCK_ENTITY.get(), CoalCrusherBlockEntity::tick); } } \ No newline at end of file diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/custom/GemCuttingStationBlock.java b/src/main/java/net/tonimatasmc/krystalcraft/block/custom/GemCuttingStationBlock.java index e7064321..e12a9a84 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/custom/GemCuttingStationBlock.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/custom/GemCuttingStationBlock.java @@ -35,12 +35,10 @@ public GemCuttingStationBlock(Properties properties) { super(properties); } - private static final VoxelShape SHAPE = Block.box(0, 0, 0, 16, 8, 16); - @Override @Nonnull public VoxelShape getShape(@Nullable BlockState pState, @Nullable BlockGetter pLevel, @Nullable BlockPos pPos, @Nullable CollisionContext pContext) { - return SHAPE; + return Block.box(0, 0, 0, 16, 8, 16); } @Override @@ -75,10 +73,12 @@ public RenderShape getRenderShape(@Nullable BlockState pState) { public void onRemove(BlockState pState, @Nullable Level pLevel, @Nullable BlockPos pPos, BlockState pNewState, boolean pIsMoving) { if (pState.getBlock() != pNewState.getBlock()) { BlockEntity blockEntity = Objects.requireNonNull(pLevel).getBlockEntity(Objects.requireNonNull(pPos)); + if (blockEntity instanceof GemCuttingStationBlockEntity) { ((GemCuttingStationBlockEntity) blockEntity).drops(); } } + super.onRemove(pState, Objects.requireNonNull(pLevel), Objects.requireNonNull(pPos), pNewState, pIsMoving); } @@ -87,6 +87,7 @@ public void onRemove(BlockState pState, @Nullable Level pLevel, @Nullable BlockP public InteractionResult use(@Nullable BlockState pState, Level pLevel, @Nullable BlockPos pPos, @Nullable Player pPlayer, @Nullable InteractionHand pHand, @Nullable BlockHitResult pHit) { if (!pLevel.isClientSide()) { BlockEntity entity = pLevel.getBlockEntity(Objects.requireNonNull(pPos)); + if(entity instanceof GemCuttingStationBlockEntity) { NetworkHooks.openGui(((ServerPlayer) Objects.requireNonNull(pPlayer)), (GemCuttingStationBlockEntity)entity, pPos); } else { @@ -106,7 +107,6 @@ public BlockEntity newBlockEntity(@Nullable BlockPos pPos, @Nullable BlockState @Nullable @Override public BlockEntityTicker getTicker(@Nullable Level pLevel, @Nullable BlockState pState, @Nullable BlockEntityType pBlockEntityType) { - return createTickerHelper(pBlockEntityType, ModBlockEntities.GEM_CUTTING_STATION_BLOCK_ENTITY.get(), - GemCuttingStationBlockEntity::tick); + return createTickerHelper(pBlockEntityType, ModBlockEntities.GEM_CUTTING_STATION_BLOCK_ENTITY.get(), GemCuttingStationBlockEntity::tick); } } \ No newline at end of file diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/ModBlockEntities.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/ModBlockEntities.java index aa8037ad..00e1f6d6 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/ModBlockEntities.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/ModBlockEntities.java @@ -15,8 +15,6 @@ public class ModBlockEntities { public static final DeferredRegister> BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, KrystalCraft.MOD_ID); - - public static final RegistryObject> GEM_CUTTING_STATION_BLOCK_ENTITY = BLOCK_ENTITIES.register("gem_cutting_station_block_entity", () -> BlockEntityType.Builder.of(GemCuttingStationBlockEntity::new, diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java index 63c1d252..52e92474 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/Utils/Simplify.java @@ -2,7 +2,6 @@ import net.minecraft.world.SimpleContainer; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; import net.minecraftforge.items.ItemStackHandler; import net.tonimatasmc.krystalcraft.item.ModItems; @@ -11,8 +10,8 @@ public static boolean hasWaterInWaterSlot(ItemStackHandler itemStackHandler) { return itemStackHandler.getStackInSlot(0).getItem() == ModItems.SET_WATER_BOTTLES.get(); } - public static boolean hasCoalSlot(int fuel) { - return fuel != 0; + public static boolean hasToolsInToolSlot(ItemStackHandler itemStackHandler) { + return itemStackHandler.getStackInSlot(2).getItem() == ModItems.GEM_CUTTER_TOOL.get(); } public static boolean canInsertItemIntoOutputSlot(SimpleContainer inventory, ItemStack output) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCombinerBlockEntity.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCombinerBlockEntity.java index 5f3b1d3c..2217da01 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCombinerBlockEntity.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCombinerBlockEntity.java @@ -4,9 +4,6 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ComponentContents; -import net.minecraft.network.chat.Style; -import net.minecraft.util.FormattedCharSequence; import net.minecraft.world.Containers; import net.minecraft.world.MenuProvider; import net.minecraft.world.SimpleContainer; @@ -32,7 +29,6 @@ import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; -import java.util.List; import java.util.Objects; import java.util.Optional; @@ -45,10 +41,10 @@ protected void onContentsChanged(int slot) { }; private LazyOptional lazyItemHandler = LazyOptional.empty(); - protected final ContainerData data; private int progress = 0; private int maxProgress = 72; + private int fuel; public CoalCombinerBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(ModBlockEntities.COAL_COMBINER_BLOCK_ENTITY.get(), pWorldPosition, pBlockState); @@ -59,6 +55,7 @@ public int get(int index) { switch (index) { case 0: return CoalCombinerBlockEntity.this.progress; case 1: return CoalCombinerBlockEntity.this.maxProgress; + case 2: return CoalCombinerBlockEntity.this.fuel; default: return 0; } } @@ -67,11 +64,12 @@ public void set(int index, int value) { switch (index) { case 0 -> CoalCombinerBlockEntity.this.progress = value; case 1 -> CoalCombinerBlockEntity.this.maxProgress = value; + case 2 -> CoalCombinerBlockEntity.this.fuel = value; } } public int getCount() { - return 2; + return 3; } }; } @@ -93,20 +91,20 @@ public AbstractContainerMenu createMenu(int pContainerId, @Nullable Inventory pI public LazyOptional getCapability(@Nonnull Capability cap, @javax.annotation.Nullable Direction side) { if (cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return lazyItemHandler.cast(); - }return super.getCapability(cap, side); + } + + return super.getCapability(cap, side); } @Override public void onLoad() { super.onLoad(); - lazyItemHandler = LazyOptional.of(() -> itemHandler); } @Override public void invalidateCaps() { super.invalidateCaps(); - lazyItemHandler.invalidate(); } @@ -114,16 +112,16 @@ public void invalidateCaps() { protected void saveAdditional(@NotNull CompoundTag tag) { tag.put("inventory", itemHandler.serializeNBT()); tag.putInt("coal_combiner.progress", progress); - + tag.putInt("coal_combiner.fuel", fuel); super.saveAdditional(tag); } @Override public void load(@Nullable CompoundTag nbt) { super.load(Objects.requireNonNull(nbt)); - itemHandler.deserializeNBT(nbt.getCompound("inventory")); progress = nbt.getInt("coal_combiner.progress"); + progress = nbt.getInt("coal_combiner.fuel"); } public void drops() { @@ -137,12 +135,19 @@ public void drops() { } public static void tick(Level pLevel, BlockPos pPos, BlockState pState, CoalCombinerBlockEntity pBlockEntity) { - if(hasRecipe(pBlockEntity)) { + if (hasRecipe(pBlockEntity)) { pBlockEntity.progress++; setChanged(pLevel, pPos, pState); - if(pBlockEntity.progress > pBlockEntity.maxProgress) { - craftItem(pBlockEntity); + if (pBlockEntity.progress > pBlockEntity.maxProgress) { + if (pBlockEntity.fuel > 0) { + craftItem(pBlockEntity); + } else { + if (pBlockEntity.itemHandler.getStackInSlot(2).getItem() == Items.COAL || pBlockEntity.itemHandler.getStackInSlot(2).getItem() == Items.CHARCOAL) { + pBlockEntity.itemHandler.extractItem(2, 1, false); + pBlockEntity.fuel = 8; + } + } } } else { pBlockEntity.resetProgress(); @@ -151,8 +156,8 @@ public static void tick(Level pLevel, BlockPos pPos, BlockState pState, CoalComb } private static boolean hasRecipe(CoalCombinerBlockEntity entity) { - Level level = entity.level; SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); + Level level = entity.level; for (int i = 0; i < entity.itemHandler.getSlots(); i++) { inventory.setItem(i, entity.itemHandler.getStackInSlot(i)); @@ -160,12 +165,8 @@ private static boolean hasRecipe(CoalCombinerBlockEntity entity) { Optional match = Objects.requireNonNull(level).getRecipeManager().getRecipeFor(CoalCombinerRecipe.Type.INSTANCE, inventory, level); - return match.isPresent() && Simplify.canInsertAmountIntoOutputSlot(inventory) && Simplify.canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && hasCoalSlot(entity); - - } - - private static boolean hasCoalSlot(CoalCombinerBlockEntity entity) { - return entity.itemHandler.getStackInSlot(2).getItem() == Items.COAL; + return match.isPresent() && Simplify.canInsertAmountIntoOutputSlot(inventory) && Simplify.canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && + Simplify.hasWaterInWaterSlot(entity.itemHandler); } private static void craftItem(CoalCombinerBlockEntity entity) { @@ -181,9 +182,10 @@ private static void craftItem(CoalCombinerBlockEntity entity) { if(match.isPresent()) { entity.itemHandler.extractItem(0,1, false); entity.itemHandler.extractItem(1,1, false); - entity.itemHandler.extractItem(2,1, false); entity.itemHandler.setStackInSlot(3, new ItemStack(match.get().getResultItem().getItem(), entity.itemHandler.getStackInSlot(3).getCount() + 1)); + + entity.fuel = entity.fuel - 1; entity.resetProgress(); } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java index 61ed5425..70de72dc 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/CoalCrusherBlockEntity.java @@ -42,7 +42,6 @@ protected void onContentsChanged(int slot) { }; private LazyOptional lazyItemHandler = LazyOptional.empty(); - protected final ContainerData data; private int progress = 0; private int maxProgress = 72; @@ -128,6 +127,7 @@ public void load(@Nullable CompoundTag nbt) { public void drops() { SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots()); + for (int i = 0; i < itemHandler.getSlots(); i++) { inventory.setItem(i, itemHandler.getStackInSlot(i)); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/GemCuttingStationBlockEntity.java b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/GemCuttingStationBlockEntity.java index 77958a0a..a04f4cdc 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/GemCuttingStationBlockEntity.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/block/entity/custom/GemCuttingStationBlockEntity.java @@ -32,10 +32,10 @@ import javax.annotation.Nonnull; import java.util.Objects; import java.util.Optional; -import java.util.Random; public class GemCuttingStationBlockEntity extends BlockEntity implements MenuProvider { private final ItemStackHandler itemHandler = new ItemStackHandler(4) { + @Override protected void onContentsChanged(int slot) { setChanged(); @@ -43,13 +43,13 @@ protected void onContentsChanged(int slot) { }; private LazyOptional lazyItemHandler = LazyOptional.empty(); - protected final ContainerData data; private int progress = 0; private int maxProgress = 72; public GemCuttingStationBlockEntity(BlockPos pWorldPosition, BlockState pBlockState) { super(ModBlockEntities.GEM_CUTTING_STATION_BLOCK_ENTITY.get(), pWorldPosition, pBlockState); + this.data = new ContainerData() { @SuppressWarnings("EnhancedSwitchMigration") @@ -124,6 +124,7 @@ public void load(@Nullable CompoundTag nbt) { public void drops() { SimpleContainer inventory = new SimpleContainer(itemHandler.getSlots()); + for (int i = 0; i < itemHandler.getSlots(); i++) { inventory.setItem(i, itemHandler.getStackInSlot(i)); } @@ -132,10 +133,11 @@ public void drops() { } public static void tick(Level pLevel, BlockPos pPos, BlockState pState, GemCuttingStationBlockEntity pBlockEntity) { - if(hasRecipe(pBlockEntity)) { + if (hasRecipe(pBlockEntity)) { pBlockEntity.progress++; setChanged(pLevel, pPos, pState); - if(pBlockEntity.progress > pBlockEntity.maxProgress) { + + if (pBlockEntity.progress > pBlockEntity.maxProgress) { craftItem(pBlockEntity); } } else { @@ -145,31 +147,22 @@ public static void tick(Level pLevel, BlockPos pPos, BlockState pState, GemCutti } private static boolean hasRecipe(GemCuttingStationBlockEntity entity) { + SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); Level level = entity.level; - SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); for (int i = 0; i < entity.itemHandler.getSlots(); i++) { inventory.setItem(i, entity.itemHandler.getStackInSlot(i)); } - Optional match = Objects.requireNonNull(level).getRecipeManager() - .getRecipeFor(GemCuttingStationRecipe.Type.INSTANCE, inventory, level); + Optional match = Objects.requireNonNull(level).getRecipeManager().getRecipeFor(GemCuttingStationRecipe.Type.INSTANCE, inventory, level); return match.isPresent() && Simplify.canInsertAmountIntoOutputSlot(inventory) && Simplify.canInsertItemIntoOutputSlot(inventory, match.get().getResultItem()) && - hasWaterInWaterSlot(entity) && hasToolsInToolSlot(entity); - } - - private static boolean hasWaterInWaterSlot(GemCuttingStationBlockEntity entity) { - return entity.itemHandler.getStackInSlot(0).getItem() == ModItems.SET_WATER_BOTTLES.get(); - } - - private static boolean hasToolsInToolSlot(GemCuttingStationBlockEntity entity) { - return entity.itemHandler.getStackInSlot(2).getItem() == ModItems.GEM_CUTTER_TOOL.get(); + Simplify.hasWaterInWaterSlot(entity.itemHandler) && Simplify.hasToolsInToolSlot(entity.itemHandler); } private static void craftItem(GemCuttingStationBlockEntity entity) { - Level level = entity.level; SimpleContainer inventory = new SimpleContainer(entity.itemHandler.getSlots()); + Level level = entity.level; for (int i = 0; i < entity.itemHandler.getSlots(); i++) { inventory.setItem(i, entity.itemHandler.getStackInSlot(i)); @@ -177,8 +170,7 @@ private static void craftItem(GemCuttingStationBlockEntity entity) { Optional match = Objects.requireNonNull(level).getRecipeManager().getRecipeFor(GemCuttingStationRecipe.Type.INSTANCE, inventory, level); - if(match.isPresent()) { - + if (match.isPresent()) { entity.itemHandler.getStackInSlot(0).hurt(1, RandomSource.create(), null); if ((entity.itemHandler.getStackInSlot(0).getMaxDamage() - entity.itemHandler.getStackInSlot(0).getDamageValue()) <= 0) { @@ -186,7 +178,6 @@ private static void craftItem(GemCuttingStationBlockEntity entity) { } entity.itemHandler.extractItem(1,1, false); - entity.itemHandler.getStackInSlot(2).hurt(1, RandomSource.create(), null); if ((entity.itemHandler.getStackInSlot(2).getMaxDamage() - entity.itemHandler.getStackInSlot(2).getDamageValue()) <= 0) { @@ -194,7 +185,6 @@ private static void craftItem(GemCuttingStationBlockEntity entity) { } entity.itemHandler.setStackInSlot(3, new ItemStack(match.get().getResultItem().getItem(), entity.itemHandler.getStackInSlot(3).getCount() + 1)); - entity.resetProgress(); } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/config/KrystalCraftModCommonConfigs.java b/src/main/java/net/tonimatasmc/krystalcraft/config/KrystalCraftModCommonConfigs.java index dadcf3c2..b531f344 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/config/KrystalCraftModCommonConfigs.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/config/KrystalCraftModCommonConfigs.java @@ -58,7 +58,6 @@ public class KrystalCraftModCommonConfigs { JADE_ORE_VEIN_SIZE = BUILDER.comment("How many Jade Ore Blocks spawn in one Vein!").defineInRange("Vein Size of Jade Ore", 3, 1, 10); JADE_ORE_MINIMUN_HEIGHT = BUILDER.define("Minimum spawning height of Jade Ore", -80); JADE_ORE_MAXIMUN_HEIGHT = BUILDER.define("Maximun spawning height of Jade Ore", 80); - SILVER_ORE_VEINS_PER_CHUNK = BUILDER.comment("How many Silver Ore Veins spawn per chunk!").define("Veins of Silver Ore Per Chunk", 8); SILVER_ORE_VEIN_SIZE = BUILDER.comment("How many Silver Ore Blocks spawn in one Vein!").defineInRange("Vein Size of Silver Ore", 8, 1, 10); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlockTagsProvider.java b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlockTagsProvider.java index e85152b1..8fa7d6ed 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlockTagsProvider.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlockTagsProvider.java @@ -24,7 +24,6 @@ protected void addTags() { tag(ModTags.Blocks.TIN_ORE).add(ModBlocks.TIN_ORE.get(), ModBlocks.DEEPSLATE_TIN_ORE.get()); tag(ModTags.Blocks.TOPAZ_ORE).add(ModBlocks.TOPAZ_ORE.get(), ModBlocks.DEEPSLATE_TOPAZ_ORE.get()); tag(ModTags.Blocks.ORES).add(ModBlocks.EXPERIENCE_ORE.get(), ModBlocks.DEEPSLATE_EXPERIENCE_ORE.get(), ModBlocks.JADE_ORE.get(), ModBlocks.DEEPSLATE_JADE_ORE.get(), ModBlocks.LEAD_ORE.get(), ModBlocks.DEEPSLATE_LEAD_ORE.get(), ModBlocks.PLATINUM_ORE.get(), ModBlocks.DEEPSLATE_PLATINUM_ORE.get(), ModBlocks.RUBY_ORE.get(), ModBlocks.DEEPSLATE_RUBY_ORE.get(), ModBlocks.SAPPHIRE_ORE.get(), ModBlocks.DEEPSLATE_SAPPHIRE_ORE.get(), ModBlocks.SILVER_ORE.get(), ModBlocks.DEEPSLATE_SILVER_ORE.get(), ModBlocks.TIN_ORE.get(), ModBlocks.DEEPSLATE_TIN_ORE.get(), ModBlocks.TOPAZ_ORE.get(), ModBlocks.DEEPSLATE_TOPAZ_ORE.get()); - tag(ModTags.Blocks.BRONZE_BLOCK).add(ModBlocks.BRONZE_BLOCK.get()); tag(ModTags.Blocks.JADE_BLOCK).add(ModBlocks.JADE_BLOCK.get()); tag(ModTags.Blocks.LEAD_BLOCK).add(ModBlocks.LEAD_BLOCK.get()); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlocksStateProvider.java b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlocksStateProvider.java index 38ceff37..53f1a05e 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlocksStateProvider.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModBlocksStateProvider.java @@ -55,15 +55,12 @@ public ModelFile flowerPotCross(String name) { public void makeCrop(CropBlock block, String modelName, String textureName) { Function function = state -> states(state, block, modelName, textureName); - getVariantBuilder(block).forAllStates(function); } private ConfiguredModel[] states(BlockState state, CropBlock block, String modelName, String textureName) { ConfiguredModel[] models = new ConfiguredModel[1]; - models[0] = new ConfiguredModel(models().crop(modelName + state.getValue(block.getAgeProperty()), - new ResourceLocation(KrystalCraft.MOD_ID, "block/" + textureName + state.getValue(block.getAgeProperty())))); - + models[0] = new ConfiguredModel(models().crop(modelName + state.getValue(block.getAgeProperty()), new ResourceLocation(KrystalCraft.MOD_ID, "block/" + textureName + state.getValue(block.getAgeProperty())))); return models; } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemModelProvider.java b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemModelProvider.java index 11841eb1..a867cda9 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemModelProvider.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemModelProvider.java @@ -155,15 +155,11 @@ protected void registerModels() { } private void simpleItem(RegistryObject item) { - withExistingParent(Objects.requireNonNull(item.getId()).getPath(), - new ResourceLocation("item/generated")).texture("layer0", - new ResourceLocation(KrystalCraft.MOD_ID, "item/" + item.getId().getPath())); + withExistingParent(Objects.requireNonNull(item.getId()).getPath(), new ResourceLocation("item/generated")).texture("layer0", new ResourceLocation(KrystalCraft.MOD_ID, "item/" + item.getId().getPath())); } private void handheldItem(RegistryObject item) { - withExistingParent(Objects.requireNonNull(item.getId()).getPath(), - new ResourceLocation("item/handheld")).texture("layer0", - new ResourceLocation(KrystalCraft.MOD_ID, "item/" + item.getId().getPath())); + withExistingParent(Objects.requireNonNull(item.getId()).getPath(), new ResourceLocation("item/handheld")).texture("layer0", new ResourceLocation(KrystalCraft.MOD_ID, "item/" + item.getId().getPath())); } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemTagsProvider.java b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemTagsProvider.java index ddfd705f..6f09ee21 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemTagsProvider.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModItemTagsProvider.java @@ -30,27 +30,23 @@ protected void addTags() { tag(ModTags.Items.TOPAZ_DUST).add(ModItems.TOPAZ_DUST.get()); tag(ModTags.Items.COPPER_DUST).add(ModItems.COPPER_DUST.get()); tag(ModTags.Items.DUSTS).add(ModItems.SILVER_DUST.get(), ModItems.BRONZE_DUST.get(), ModItems.DIAMOND_DUST.get(), ModItems.EMERALD_DUST.get(), ModItems.JADE_DUST.get(), ModItems.LAPIS_DUST.get(), ModItems.LEAD_DUST.get(), ModItems.PLATINUM_DUST.get(), ModItems.RUBY_DUST.get(), ModItems.SAPPHIRE_DUST.get(), ModItems.TIN_DUST.get(), ModItems.TOPAZ_DUST.get(), ModItems.COPPER_DUST.get()); - tag(ModTags.Items.JADE_GEM).add(ModItems.JADE.get()); tag(ModTags.Items.RUBY_GEM).add(ModItems.RUBY.get()); tag(ModTags.Items.SAPPHIRE_GEM).add(ModItems.SAPPHIRE.get()); tag(ModTags.Items.TOPAZ_GEM).add(ModItems.TOPAZ.get()); tag(ModTags.Items.GEMS).add(ModItems.JADE.get(), ModItems.RUBY.get(), ModItems.SAPPHIRE.get(), ModItems.TOPAZ.get()); - tag(ModTags.Items.SILVER_INGOT).add(ModItems.SILVER_INGOT.get()); tag(ModTags.Items.PLATINUM_INGOT).add(ModItems.PLATINUM_INGOT.get()); tag(ModTags.Items.LEAD_INGOT).add(ModItems.LEAD_INGOT.get()); tag(ModTags.Items.TIN_INGOT).add(ModItems.TIN_INGOT.get()); tag(ModTags.Items.BRONZE_INGOT).add(ModItems.BRONZE_INGOT.get()); tag(ModTags.Items.INGOTS).add(ModItems.SILVER_INGOT.get(), ModItems.PLATINUM_INGOT.get(), ModItems.LEAD_INGOT.get(), ModItems.TIN_INGOT.get(), ModItems.BRONZE_INGOT.get()); - tag(ModTags.Items.BRONZE_NUGGETS).add(ModItems.BRONZE_NUGGET.get()); tag(ModTags.Items.LEAD_NUGGETS).add(ModItems.LEAD_NUGGET.get()); tag(ModTags.Items.PLATINUM_NUGGETS).add(ModItems.PLATINUM_NUGGET.get()); tag(ModTags.Items.SILVER_NUGGETS).add(ModItems.SILVER_INGOT.get()); tag(ModTags.Items.TIN_NUGGETS).add(ModItems.TIN_INGOT.get()); tag(ModTags.Items.NUGGETS).add(ModItems.BRONZE_NUGGET.get(), ModItems.LEAD_NUGGET.get(), ModItems.PLATINUM_NUGGET.get(), ModItems.COPPER_NUGGET.get(), ModItems.TIN_NUGGET.get()); - tag(ModTags.Items.JADE_RAW_MATERIAL).add(ModItems.RAW_JADE.get()); tag(ModTags.Items.LEAD_RAW_MATERIAL).add(ModItems.RAW_LEAD.get()); tag(ModTags.Items.PLATINUM_RAW_MATERIAL).add(ModItems.RAW_PLATINUM.get()); @@ -64,7 +60,6 @@ protected void addTags() { tag(ModTags.Items.LAPIS_RAW_MATERIAL).add(ModItems.RAW_LAPIS.get()); tag(ModTags.Items.REDSTONE_RAW_MATERIAL).add(ModItems.RAW_REDSTONE.get()); tag(ModTags.Items.RAW_MATERIALS).add(ModItems.RAW_REDSTONE.get(), ModItems.RAW_LAPIS.get(), ModItems.RAW_EMERALD.get(), ModItems.RAW_DIAMOND.get(), ModItems.RAW_TOPAZ.get(), ModItems.RAW_TIN.get(), ModItems.RAW_SILVER.get(), ModItems.RAW_SAPPHIRE.get(), ModItems.RAW_RUBY.get(), ModItems.RAW_PLATINUM.get(), ModItems.RAW_LEAD.get(), ModItems.RAW_JADE.get()); - copy(ModTags.Blocks.EXPERIENCE_ORE, ModTags.Items.EXPERIENCE_ORE); copy(ModTags.Blocks.JADE_ORE, ModTags.Items.JADE_ORE); copy(ModTags.Blocks.LEAD_ORE, ModTags.Items.LEAD_ORE); @@ -75,7 +70,6 @@ protected void addTags() { copy(ModTags.Blocks.TIN_ORE, ModTags.Items.TIN_ORE); copy(ModTags.Blocks.TOPAZ_ORE, ModTags.Items.TOPAZ_ORE); copy(ModTags.Blocks.ORES, ModTags.Items.ORES); - copy(ModTags.Blocks.BRONZE_BLOCK, ModTags.Items.BRONZE_BLOCK); copy(ModTags.Blocks.JADE_BLOCK, ModTags.Items.JADE_BLOCK); copy(ModTags.Blocks.LEAD_BLOCK, ModTags.Items.LEAD_BLOCK); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModLootTableProvider.java b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModLootTableProvider.java index 7eed2f4a..fb9dd886 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModLootTableProvider.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/datagen/ModLootTableProvider.java @@ -21,10 +21,7 @@ import java.util.function.Supplier; public class ModLootTableProvider extends LootTableProvider { - private final List>>, LootContextParamSet>> - loot_tables = ImmutableList.of( - Pair.of(ModBlockLootTables::new, LootContextParamSets.BLOCK), - Pair.of(ModChestLootTables::new, LootContextParamSets.CHEST)); + private final List>>, LootContextParamSet>> loot_tables = ImmutableList.of(Pair.of(ModBlockLootTables::new, LootContextParamSets.BLOCK), Pair.of(ModChestLootTables::new, LootContextParamSets.CHEST)); public ModLootTableProvider(DataGenerator pGenerator) { super(pGenerator); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/ModEnchantments.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/ModEnchantments.java index 20e4cfca..5dedcbf3 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/ModEnchantments.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/ModEnchantments.java @@ -8,6 +8,7 @@ import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import net.tonimatasmc.krystalcraft.KrystalCraft; +import net.tonimatasmc.krystalcraft.enchantment.enchants.*; @SuppressWarnings("unused") public class ModEnchantments { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/VenomEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/VenomEnchantment.java deleted file mode 100644 index a13b01f0..00000000 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/VenomEnchantment.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.tonimatasmc.krystalcraft.enchantment; - -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.effect.MobEffectInstance; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.EnchantmentCategory; - -import javax.annotation.Nullable; -import java.util.Objects; - -public class VenomEnchantment extends Enchantment { - protected VenomEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { - super(pRarity, pCategory, pApplicableSlots); - } - - @SuppressWarnings("unused") - @Override - public void doPostAttack(LivingEntity pAttacker, @Nullable Entity pTarget, int pLevel) { - if (!pAttacker.level.isClientSide()) { - ServerLevel world = (ServerLevel) pAttacker.level; - ServerPlayer player = ((ServerPlayer) pAttacker); - BlockPos position = Objects.requireNonNull(pTarget).blockPosition(); - - if (pLevel == 1) { - LivingEntity entity = (LivingEntity) pTarget; - entity.addEffect(new MobEffectInstance(MobEffects.POISON, 60, 1)); - } - - if (pLevel == 2) { - LivingEntity entity = (LivingEntity) pTarget; - entity.addEffect(new MobEffectInstance(MobEffects.POISON, 120, 2)); - } - - if (pLevel == 3) { - LivingEntity entity = (LivingEntity) pTarget; - entity.addEffect(new MobEffectInstance(MobEffects.POISON, 180, 3)); - } - } - } - - @Override - public int getMaxLevel() { - return 3; - } -} diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/FreezingEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/FreezingEnchantment.java similarity index 72% rename from src/main/java/net/tonimatasmc/krystalcraft/enchantment/FreezingEnchantment.java rename to src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/FreezingEnchantment.java index d95b4e14..2f5394df 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/FreezingEnchantment.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/FreezingEnchantment.java @@ -1,9 +1,6 @@ -package net.tonimatasmc.krystalcraft.enchantment; +package net.tonimatasmc.krystalcraft.enchantment.enchants; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; @@ -13,21 +10,15 @@ import net.minecraft.world.item.enchantment.EnchantmentCategory; import javax.annotation.Nullable; -import java.util.Objects; public class FreezingEnchantment extends Enchantment { - protected FreezingEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { + public FreezingEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, pCategory, pApplicableSlots); } - @SuppressWarnings("unused") @Override public void doPostAttack(LivingEntity pAttacker, @Nullable Entity pTarget, int pLevel) { if (!pAttacker.level.isClientSide()) { - ServerLevel world = (ServerLevel) pAttacker.level; - ServerPlayer player = ((ServerPlayer) pAttacker); - BlockPos position = Objects.requireNonNull(pTarget).blockPosition(); - if (pLevel == 1) { if (pTarget instanceof LivingEntity eTarget) { eTarget.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 0, true, true)); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/LifeLeechEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/LifeLeechEnchantment.java similarity index 72% rename from src/main/java/net/tonimatasmc/krystalcraft/enchantment/LifeLeechEnchantment.java rename to src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/LifeLeechEnchantment.java index d57cbd9a..d4b3c034 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/LifeLeechEnchantment.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/LifeLeechEnchantment.java @@ -1,9 +1,6 @@ -package net.tonimatasmc.krystalcraft.enchantment; +package net.tonimatasmc.krystalcraft.enchantment.enchants; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; @@ -11,25 +8,18 @@ import net.minecraft.world.item.enchantment.EnchantmentCategory; import javax.annotation.Nullable; -import java.util.Objects; public class LifeLeechEnchantment extends Enchantment { - protected LifeLeechEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { + public LifeLeechEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, pCategory, pApplicableSlots); } - @SuppressWarnings("unused") @Override public void doPostAttack(LivingEntity pAttacker, @Nullable Entity pTarget, int pLevel) { if (!pAttacker.level.isClientSide()) { - ServerLevel world = (ServerLevel) pAttacker.level; - ServerPlayer player = ((ServerPlayer) pAttacker); - BlockPos position = Objects.requireNonNull(pTarget).blockPosition(); - if (pLevel == 1) { float health = pAttacker.getHealth(); pAttacker.setHealth((float) (health + 0.1)); - } if (pLevel == 2) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/LightningStrikeEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/LightningStrikeEnchantment.java similarity index 88% rename from src/main/java/net/tonimatasmc/krystalcraft/enchantment/LightningStrikeEnchantment.java rename to src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/LightningStrikeEnchantment.java index 11848782..5da1a1e4 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/LightningStrikeEnchantment.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/LightningStrikeEnchantment.java @@ -1,4 +1,4 @@ -package net.tonimatasmc.krystalcraft.enchantment; +package net.tonimatasmc.krystalcraft.enchantment.enchants; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; @@ -11,7 +11,7 @@ import java.util.Objects; public class LightningStrikeEnchantment extends Enchantment { - protected LightningStrikeEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { + public LightningStrikeEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, pCategory, pApplicableSlots); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/PlayerHeadsEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/PlayerHeadsEnchantment.java similarity index 82% rename from src/main/java/net/tonimatasmc/krystalcraft/enchantment/PlayerHeadsEnchantment.java rename to src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/PlayerHeadsEnchantment.java index 723a12de..ad08cbe8 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/PlayerHeadsEnchantment.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/PlayerHeadsEnchantment.java @@ -1,4 +1,4 @@ -package net.tonimatasmc.krystalcraft.enchantment; +package net.tonimatasmc.krystalcraft.enchantment.enchants; import net.minecraft.core.BlockPos; @@ -18,16 +18,13 @@ import java.util.Objects; public class PlayerHeadsEnchantment extends Enchantment { - protected PlayerHeadsEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { + public PlayerHeadsEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, pCategory, pApplicableSlots); } - @SuppressWarnings("unused") @Override public void doPostAttack(LivingEntity pAttacker, @Nullable Entity pTarget, int pLevel) { if (!pAttacker.level.isClientSide()) { - ServerLevel world = (ServerLevel) pAttacker.level; - ServerPlayer player = ((ServerPlayer) pAttacker); BlockPos position = Objects.requireNonNull(pTarget).blockPosition(); if (pLevel == 1) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/VenomEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/VenomEnchantment.java new file mode 100644 index 00000000..ae823c65 --- /dev/null +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/VenomEnchantment.java @@ -0,0 +1,42 @@ +package net.tonimatasmc.krystalcraft.enchantment.enchants; + +import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.EnchantmentCategory; + +import javax.annotation.Nullable; +import java.util.Objects; + +public class VenomEnchantment extends Enchantment { + public VenomEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { + super(pRarity, pCategory, pApplicableSlots); + } + + @Override + public void doPostAttack(LivingEntity pAttacker, @Nullable Entity pTarget, int pLevel) { + if (!pAttacker.level.isClientSide()) { + LivingEntity entity = (LivingEntity) pTarget; + + if (pLevel == 1) { + Objects.requireNonNull(entity).addEffect(new MobEffectInstance(MobEffects.POISON, 60, 1)); + } + + if (pLevel == 2) { + Objects.requireNonNull(entity).addEffect(new MobEffectInstance(MobEffects.POISON, 120, 2)); + } + + if (pLevel == 3) { + Objects.requireNonNull(entity).addEffect(new MobEffectInstance(MobEffects.POISON, 180, 3)); + } + } + } + + @Override + public int getMaxLevel() { + return 3; + } +} diff --git a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/XpLeechEnchantment.java b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/XpLeechEnchantment.java similarity index 73% rename from src/main/java/net/tonimatasmc/krystalcraft/enchantment/XpLeechEnchantment.java rename to src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/XpLeechEnchantment.java index be8fb616..fdc784c9 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/enchantment/XpLeechEnchantment.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/enchantment/enchants/XpLeechEnchantment.java @@ -1,7 +1,5 @@ -package net.tonimatasmc.krystalcraft.enchantment; +package net.tonimatasmc.krystalcraft.enchantment.enchants; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; @@ -10,20 +8,16 @@ import net.minecraft.world.item.enchantment.EnchantmentCategory; import javax.annotation.Nullable; -import java.util.Objects; public class XpLeechEnchantment extends Enchantment { - protected XpLeechEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { + public XpLeechEnchantment(Rarity pRarity, EnchantmentCategory pCategory, EquipmentSlot... pApplicableSlots) { super(pRarity, pCategory, pApplicableSlots); } - @SuppressWarnings("unused") @Override public void doPostAttack(LivingEntity pAttacker, @Nullable Entity pTarget, int pLevel) { if (!pAttacker.level.isClientSide()) { - ServerLevel world = (ServerLevel) pAttacker.level; ServerPlayer player = ((ServerPlayer) pAttacker); - BlockPos position = Objects.requireNonNull(pTarget).blockPosition(); if (pLevel == 1) { player.giveExperiencePoints(1); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/event/ModEventBusEvents.java b/src/main/java/net/tonimatasmc/krystalcraft/event/ModEventBusEvents.java index 3aa30c26..40773c53 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/event/ModEventBusEvents.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/event/ModEventBusEvents.java @@ -14,7 +14,6 @@ public class ModEventBusEvents { @SubscribeEvent public static void registerModifierSerializers(@Nonnull final RegisterEvent event) { event.register(ForgeRegistries.Keys.LOOT_MODIFIER_SERIALIZERS, helper -> { - }); } } \ No newline at end of file diff --git a/src/main/java/net/tonimatasmc/krystalcraft/item/KrystalCraftTab.java b/src/main/java/net/tonimatasmc/krystalcraft/item/KrystalCraftTab.java index e7a5af2b..c7ba68b7 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/item/KrystalCraftTab.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/item/KrystalCraftTab.java @@ -7,6 +7,7 @@ public class KrystalCraftTab { public static final CreativeModeTab KRYSTALCRAFT = new CreativeModeTab("KrystalCraft") { + @Override @Nonnull public ItemStack makeIcon() { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/item/ModArmorTier.java b/src/main/java/net/tonimatasmc/krystalcraft/item/ModArmorTier.java index 42a9a8b0..d5ca44e5 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/item/ModArmorTier.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/item/ModArmorTier.java @@ -16,35 +16,16 @@ @SuppressWarnings({"NullableProblems", "deprecation"}) public enum ModArmorTier implements ArmorMaterial { - JADE("jade", new int[] {3, 5, 6, 2}, new int[] {275, 365, 315, 240}, 16, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, () -> - Ingredient.of(ModItems.JADE.get())), - - TOPAZ("topaz", new int[] {3, 4, 7, 1}, new int[] {285, 375, 325, 250}, 8, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.2f, 0.0f, () -> - Ingredient.of(ModItems.TOPAZ.get())), - - SILVER("silver", new int[]{2, 5, 7, 2}, new int[] {235, 295, 280, 240}, 7, SoundEvents.ARMOR_EQUIP_IRON, 0.5f, 0.0F, () -> - Ingredient.of(ModItems.SILVER_INGOT.get())), - - LEAD("lead", new int[] {3, 6, 8, 3}, new int[] {390, 460, 420, 350}, 6, SoundEvents.ARMOR_EQUIP_IRON, 1.5f, 0.0f, () -> - Ingredient.of(ModItems.LEAD_INGOT.get())), - - TIN("tin", new int[] {2, 4, 5, 1}, new int[] {190, 250, 220, 210}, 8, SoundEvents.ARMOR_EQUIP_IRON, 0.0f, 0.0f,() -> - Ingredient.of(ModItems.TIN_INGOT.get())), - - PLATINUM("platinum", new int[] {3, 5, 6, 2}, new int[] {480, 570, 510, 400}, 8, SoundEvents.ARMOR_EQUIP_IRON, 2.0f, 1.0f, () -> - Ingredient.of(ModItems.PLATINUM_INGOT.get())), - - COPPER("copper", new int[] {2, 4, 5, 1}, new int[] {190, 250, 220, 210}, 8, SoundEvents.ARMOR_EQUIP_IRON, 0.2f, 0.0f, () -> - Ingredient.of(Items.COPPER_INGOT)), - - SAPPHIRE("sapphire", new int[] {3, 4, 7, 1}, new int[] {305, 395, 345, 270}, 28, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.3f, 0.0f, () -> - Ingredient.of(ModItems.SAPPHIRE.get())), - - RUBY("ruby", new int[] {2, 3, 6, 2}, new int[] {305, 395, 345, 270}, 28, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, () -> - Ingredient.of(ModItems.RUBY.get())), - - BRONZE("bronze", new int[]{2, 4, 6, 2}, new int[] {215, 275, 240, 220}, 7, SoundEvents.ARMOR_EQUIP_IRON, 0.3f, 0.0F, () -> - Ingredient.of(ModItems.BRONZE_INGOT.get())); + JADE("jade", new int[] {3, 5, 6, 2}, new int[] {275, 365, 315, 240}, 16, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, () -> Ingredient.of(ModItems.JADE.get())), + TOPAZ("topaz", new int[] {3, 4, 7, 1}, new int[] {285, 375, 325, 250}, 8, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.2f, 0.0f, () -> Ingredient.of(ModItems.TOPAZ.get())), + SILVER("silver", new int[]{2, 5, 7, 2}, new int[] {235, 295, 280, 240}, 7, SoundEvents.ARMOR_EQUIP_IRON, 0.5f, 0.0F, () -> Ingredient.of(ModItems.SILVER_INGOT.get())), + LEAD("lead", new int[] {3, 6, 8, 3}, new int[] {390, 460, 420, 350}, 6, SoundEvents.ARMOR_EQUIP_IRON, 1.5f, 0.0f, () -> Ingredient.of(ModItems.LEAD_INGOT.get())), + TIN("tin", new int[] {2, 4, 5, 1}, new int[] {190, 250, 220, 210}, 8, SoundEvents.ARMOR_EQUIP_IRON, 0.0f, 0.0f,() -> Ingredient.of(ModItems.TIN_INGOT.get())), + PLATINUM("platinum", new int[] {3, 5, 6, 2}, new int[] {480, 570, 510, 400}, 8, SoundEvents.ARMOR_EQUIP_IRON, 2.0f, 1.0f, () -> Ingredient.of(ModItems.PLATINUM_INGOT.get())), + COPPER("copper", new int[] {2, 4, 5, 1}, new int[] {190, 250, 220, 210}, 8, SoundEvents.ARMOR_EQUIP_IRON, 0.2f, 0.0f, () -> Ingredient.of(Items.COPPER_INGOT)), + SAPPHIRE("sapphire", new int[] {3, 4, 7, 1}, new int[] {305, 395, 345, 270}, 28, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.3f, 0.0f, () -> Ingredient.of(ModItems.SAPPHIRE.get())), + RUBY("ruby", new int[] {2, 3, 6, 2}, new int[] {305, 395, 345, 270}, 28, SoundEvents.ARMOR_EQUIP_DIAMOND, 1.0f, 0.0f, () -> Ingredient.of(ModItems.RUBY.get())), + BRONZE("bronze", new int[]{2, 4, 6, 2}, new int[] {215, 275, 240, 220}, 7, SoundEvents.ARMOR_EQUIP_IRON, 0.3f, 0.0F, () -> Ingredient.of(ModItems.BRONZE_INGOT.get())); private final int[] MAX_DAMAGE_ARRAY; private final String name; @@ -55,9 +36,7 @@ public enum ModArmorTier implements ArmorMaterial { private final float knockbackResistance; private final LazyLoadedValue repairMaterial; - ModArmorTier(String name, int[] damageReductionAmountArray, int[] MAX_DAMAGE_ARRAY, int enchantability, - SoundEvent soundEvent, float toughness, float knockbackResistance, - Supplier repairMaterial) { + ModArmorTier(String name, int[] damageReductionAmountArray, int[] MAX_DAMAGE_ARRAY, int enchantability, SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier repairMaterial) { this.MAX_DAMAGE_ARRAY = MAX_DAMAGE_ARRAY; this.name = name; this.damageReductionAmountArray = damageReductionAmountArray; diff --git a/src/main/java/net/tonimatasmc/krystalcraft/item/ModItems.java b/src/main/java/net/tonimatasmc/krystalcraft/item/ModItems.java index 510a2bed..55f4202f 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/item/ModItems.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/item/ModItems.java @@ -3,10 +3,11 @@ import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.item.*; import net.minecraftforge.eventbus.api.IEventBus; -import net.minecraftforge.registries.*; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; import net.tonimatasmc.krystalcraft.KrystalCraft; -@SuppressWarnings("unused") public class ModItems { public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, KrystalCraft.MOD_ID); @@ -524,9 +525,6 @@ public class ModItems { public static final RegistryObject SET_WATER_BOTTLES = ITEMS.register("set_water_bottles",() -> new Item(new Item.Properties().tab(KrystalCraftTab.KRYSTALCRAFT).durability(64))); - - - public static void register(IEventBus iEventBus) { ITEMS.register(iEventBus); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/item/custom/SetWaterBottles.java b/src/main/java/net/tonimatasmc/krystalcraft/item/custom/SetWaterBottles.java index 34d14643..2f30cb25 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/item/custom/SetWaterBottles.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/item/custom/SetWaterBottles.java @@ -1,11 +1,7 @@ package net.tonimatasmc.krystalcraft.item.custom; -import net.minecraft.world.InteractionResult; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.context.UseOnContext; -import net.tonimatasmc.krystalcraft.item.ModItems; -import org.jetbrains.annotations.NotNull; public class SetWaterBottles extends Item { public SetWaterBottles(Properties properties) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCombinerRecipe.java b/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCombinerRecipe.java index 9d9873df..858cd217 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCombinerRecipe.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCombinerRecipe.java @@ -81,13 +81,13 @@ public RecipeType getType() { @SuppressWarnings("unused") public static class Type implements RecipeType { private Type() { - } public static final Type INSTANCE = new Type(); public static final String ID = "coal_combiner"; } + @SuppressWarnings("unused") public static class Serializer implements RecipeSerializer { public static final Serializer INSTANCE = new Serializer(); public static final ResourceLocation ID = new ResourceLocation(KrystalCraft.MOD_ID, "coal_combiner"); @@ -96,7 +96,6 @@ public static class Serializer implements RecipeSerializer { @Nonnull public CoalCombinerRecipe fromJson(@Nullable ResourceLocation id, @Nullable JsonObject json) { ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(Objects.requireNonNull(json), "output")); - JsonArray ingredients = GsonHelper.getAsJsonArray(json, "ingredients"); NonNullList inputs = NonNullList.withSize(2, Ingredient.EMPTY); @@ -110,9 +109,7 @@ public CoalCombinerRecipe fromJson(@Nullable ResourceLocation id, @Nullable Json @Override public CoalCombinerRecipe fromNetwork(@Nullable ResourceLocation id, FriendlyByteBuf buf) { NonNullList inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY); - inputs.replaceAll(ignored -> Ingredient.fromNetwork(buf)); - ItemStack output = buf.readItem(); return new CoalCombinerRecipe(id, output, inputs); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCrusherRecipe.java b/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCrusherRecipe.java index 7fd72903..05268033 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCrusherRecipe.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/recipe/CoalCrusherRecipe.java @@ -11,6 +11,7 @@ import net.minecraft.world.item.crafting.*; import net.minecraft.world.level.Level; import net.tonimatasmc.krystalcraft.KrystalCraft; +import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -28,7 +29,7 @@ public CoalCrusherRecipe(ResourceLocation id, ItemStack output, NonNullList { public static final Serializer INSTANCE = new Serializer(); public static final ResourceLocation ID = new ResourceLocation(KrystalCraft.MOD_ID, "coal_crusher"); @@ -94,7 +96,6 @@ public static class Serializer implements RecipeSerializer { @Nonnull public CoalCrusherRecipe fromJson(@Nullable ResourceLocation id, @Nullable JsonObject json) { ItemStack output = ShapedRecipe.itemStackFromJson(GsonHelper.getAsJsonObject(Objects.requireNonNull(json), "output")); - JsonArray ingredients = GsonHelper.getAsJsonArray(json, "ingredients"); NonNullList inputs = NonNullList.withSize(1, Ingredient.EMPTY); @@ -108,9 +109,7 @@ public CoalCrusherRecipe fromJson(@Nullable ResourceLocation id, @Nullable JsonO @Override public CoalCrusherRecipe fromNetwork(@Nullable ResourceLocation id, FriendlyByteBuf buf) { NonNullList inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY); - inputs.replaceAll(ignored -> Ingredient.fromNetwork(buf)); - ItemStack output = buf.readItem(); return new CoalCrusherRecipe(id, output, inputs); } @@ -118,9 +117,11 @@ public CoalCrusherRecipe fromNetwork(@Nullable ResourceLocation id, FriendlyByte @Override public void toNetwork(FriendlyByteBuf buf, CoalCrusherRecipe recipe) { buf.writeInt(recipe.getIngredients().size()); + for (Ingredient ing : recipe.getIngredients()) { ing.toNetwork(buf); } + buf.writeItemStack(recipe.getResultItem(), false); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/recipe/GemCuttingStationRecipe.java b/src/main/java/net/tonimatasmc/krystalcraft/recipe/GemCuttingStationRecipe.java index 68e14756..5e452da9 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/recipe/GemCuttingStationRecipe.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/recipe/GemCuttingStationRecipe.java @@ -87,6 +87,7 @@ private Type() { public static final String ID = "gem_cutting"; } + @SuppressWarnings("unused") public static class Serializer implements RecipeSerializer { public static final Serializer INSTANCE = new Serializer(); public static final ResourceLocation ID = new ResourceLocation(KrystalCraft.MOD_ID, "gem_cutting"); @@ -95,7 +96,6 @@ public static class Serializer implements RecipeSerializer inputs = NonNullList.withSize(1, Ingredient.EMPTY); @@ -109,9 +109,7 @@ public GemCuttingStationRecipe fromJson(@Nullable ResourceLocation id, @Nullable @Override public GemCuttingStationRecipe fromNetwork(@Nullable ResourceLocation id, FriendlyByteBuf buf) { NonNullList inputs = NonNullList.withSize(buf.readInt(), Ingredient.EMPTY); - inputs.replaceAll(ignored -> Ingredient.fromNetwork(buf)); - ItemStack output = buf.readItem(); return new GemCuttingStationRecipe(id, output, inputs); } @@ -119,9 +117,11 @@ public GemCuttingStationRecipe fromNetwork(@Nullable ResourceLocation id, Friend @Override public void toNetwork(FriendlyByteBuf buf, GemCuttingStationRecipe recipe) { buf.writeInt(recipe.getIngredients().size()); + for (Ingredient ing : recipe.getIngredients()) { ing.toNetwork(buf); } + buf.writeItemStack(recipe.getResultItem(), false); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/recipe/ModRecipes.java b/src/main/java/net/tonimatasmc/krystalcraft/recipe/ModRecipes.java index df1b1cf9..57b10013 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/recipe/ModRecipes.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/recipe/ModRecipes.java @@ -7,6 +7,7 @@ import net.minecraftforge.registries.RegistryObject; import net.tonimatasmc.krystalcraft.KrystalCraft; +@SuppressWarnings("unused") public class ModRecipes { public static final DeferredRegister> SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, KrystalCraft.MOD_ID); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerMenu.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerMenu.java index f328535e..91a37204 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerMenu.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerMenu.java @@ -61,13 +61,13 @@ public int getScaledProgress() { return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0; } - // CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons - // must assign a slot number to each of the slots used by the GUI. - // For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar. - // Each time we add a Slot to the container, it automatically increases the slotIndex, which means - // 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8) - // 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35) - // 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8) + public int getFuelScaledProgress() { + int progress = this.data.get(2); + int progressArrowSize = 14; + + return progress != 0 ? progress * progressArrowSize / 8 : 0; + } + private static final int HOTBAR_SLOT_COUNT = 9; private static final int PLAYER_INVENTORY_ROW_COUNT = 3; private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9; @@ -75,27 +75,20 @@ public int getScaledProgress() { private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT; private static final int VANILLA_FIRST_SLOT_INDEX = 0; private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT; - - // THIS YOU HAVE TO DEFINE! - private static final int TE_INVENTORY_SLOT_COUNT = 4; // must be the number of slots you have! + private static final int TE_INVENTORY_SLOT_COUNT = 4; // Number of slots in the screen @Override public @NotNull ItemStack quickMoveStack(@NotNull Player playerIn, int index) { Slot sourceSlot = slots.get(index); - if (!sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM - + if (!sourceSlot.hasItem()) return ItemStack.EMPTY; ItemStack sourceStack = sourceSlot.getItem(); ItemStack copyOfSourceStack = sourceStack.copy(); - // Check if the slot clicked is one of the vanilla container slots if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) { - // This is a vanilla container slot so merge the stack into the tile inventory - if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX - + TE_INVENTORY_SLOT_COUNT, false)) { - return ItemStack.EMPTY; // EMPTY_ITEM + if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)) { + return ItemStack.EMPTY; } } else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) { - // This is a TE slot so merge the stack into the players inventory if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) { return ItemStack.EMPTY; } @@ -103,20 +96,20 @@ public int getScaledProgress() { System.out.println("Invalid slotIndex:" + index); return ItemStack.EMPTY; } - // If stack size == 0 (the entire stack was moved) set slot contents to null + if (sourceStack.getCount() == 0) { sourceSlot.set(ItemStack.EMPTY); } else { sourceSlot.setChanged(); } + sourceSlot.onTake(playerIn, sourceStack); return copyOfSourceStack; } @Override public boolean stillValid(@Nullable Player pPlayer) { - return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), - Objects.requireNonNull(pPlayer), ModBlocks.COAL_COMBINER.get()); + return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), Objects.requireNonNull(pPlayer), ModBlocks.COAL_COMBINER.get()); } private void addPlayerInventory(Inventory playerInventory) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerScreen.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerScreen.java index 5d22d446..4eab12c7 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerScreen.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCombinerScreen.java @@ -31,16 +31,16 @@ protected void renderBg(@Nullable PoseStack pPoseStack, float pPartialTick, int this.blit(Objects.requireNonNull(pPoseStack), x, y, 0, -8, imageWidth, imageHeight + 16); if (menu.isCrafting()) { - blit(pPoseStack, x + 81, y + 41, 176, 0, 14, menu.getScaledProgress()); + //Future crafting animation with menu.getScaledProgress() } + + blit(pPoseStack, x + 81, y + 41, 176, 0, 14, menu.getFuelScaledProgress()); } @Override public void render(@Nullable PoseStack pPoseStack, int mouseX, int mouseY, float delta) { renderBackground(Objects.requireNonNull(pPoseStack)); - super.render(pPoseStack, mouseX, mouseY, delta); - renderTooltip(pPoseStack, mouseX, mouseY); } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java index be2b419d..c26f1892 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherMenu.java @@ -67,13 +67,6 @@ public int getFuelScaledProgress() { return progress != 0 ? progress * progressArrowSize / 8 : 0; } - // CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons - // must assign a slot number to each of the slots used by the GUI. - // For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar. - // Each time we add a Slot to the container, it automatically increases the slotIndex, which means - // 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8) - // 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35) - // 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8) private static final int HOTBAR_SLOT_COUNT = 9; private static final int PLAYER_INVENTORY_ROW_COUNT = 3; private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9; @@ -81,28 +74,22 @@ public int getFuelScaledProgress() { private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT; private static final int VANILLA_FIRST_SLOT_INDEX = 0; private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT; - - // THIS YOU HAVE TO DEFINE! - private static final int TE_INVENTORY_SLOT_COUNT = 4; // must be the number of slots you have! + private static final int TE_INVENTORY_SLOT_COUNT = 4; // Number of slots in the screen @SuppressWarnings("ConstantConditions") @Override @Nonnull public ItemStack quickMoveStack(@Nullable Player playerIn, int index) { Slot sourceSlot = slots.get(index); - if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM + if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; ItemStack sourceStack = sourceSlot.getItem(); ItemStack copyOfSourceStack = sourceStack.copy(); - // Check if the slot clicked is one of the vanilla container slots if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) { - // This is a vanilla container slot so merge the stack into the tile inventory - if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX - + TE_INVENTORY_SLOT_COUNT, false)) { + if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)) { return ItemStack.EMPTY; // EMPTY_ITEM } } else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) { - // This is a TE slot so merge the stack into the players inventory if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) { return ItemStack.EMPTY; } @@ -110,20 +97,20 @@ public ItemStack quickMoveStack(@Nullable Player playerIn, int index) { System.out.println("Invalid slotIndex:" + index); return ItemStack.EMPTY; } - // If stack size == 0 (the entire stack was moved) set slot contents to null + if (sourceStack.getCount() == 0) { sourceSlot.set(ItemStack.EMPTY); } else { sourceSlot.setChanged(); } + sourceSlot.onTake(playerIn, sourceStack); return copyOfSourceStack; } @Override public boolean stillValid(@Nullable Player pPlayer) { - return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), - Objects.requireNonNull(pPlayer), ModBlocks.COAL_CRUSHER.get()); + return stillValid(ContainerLevelAccess.create(level, blockEntity.getBlockPos()), Objects.requireNonNull(pPlayer), ModBlocks.COAL_CRUSHER.get()); } private void addPlayerInventory(Inventory playerInventory) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java index 9a367f0d..af1f8570 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/CoalCrusherScreen.java @@ -13,8 +13,7 @@ import java.util.Objects; public class CoalCrusherScreen extends AbstractContainerScreen { - private static final ResourceLocation TEXTURE = - new ResourceLocation(KrystalCraft.MOD_ID, "textures/gui/coal_crusher_gui.png"); + private static final ResourceLocation TEXTURE = new ResourceLocation(KrystalCraft.MOD_ID, "textures/gui/coal_crusher_gui.png"); public CoalCrusherScreen(CoalCrusherMenu pMenu, Inventory pPlayerInventory, Component pTitle) { super(pMenu, pPlayerInventory, pTitle); @@ -25,6 +24,7 @@ protected void renderBg(@Nullable PoseStack pPoseStack, float pPartialTick, int RenderSystem.setShader(GameRenderer::getPositionTexShader); RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); RenderSystem.setShaderTexture(0, TEXTURE); + int x = (width - imageWidth) / 2; int y = (height - imageHeight) / 2; @@ -33,6 +33,7 @@ protected void renderBg(@Nullable PoseStack pPoseStack, float pPartialTick, int if (menu.isCrafting()) { blit(pPoseStack, x + 102, y + 21, 190, 0, 23, menu.getScaledProgress()); } + blit(pPoseStack, x + 55, y + 35, 176, 0, 14, menu.getFuelScaledProgress()); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/GemCuttingStationMenu.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/GemCuttingStationMenu.java index 0dc8055e..b88ed8da 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/GemCuttingStationMenu.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/GemCuttingStationMenu.java @@ -46,12 +46,10 @@ public GemCuttingStationMenu(int pContainerId, Inventory inv, BlockEntity entity addDataSlots(data); } - @SuppressWarnings("unused") public boolean isCrafting() { return data.get(0) > 0; } - @SuppressWarnings("unused") public int getScaledProgress() { int progress = this.data.get(0); int maxProgress = this.data.get(1); @@ -60,13 +58,6 @@ public int getScaledProgress() { return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0; } - // CREDIT GOES TO: diesieben07 | https://github.com/diesieben07/SevenCommons - // must assign a slot number to each of the slots used by the GUI. - // For this container, we can see both the tile inventory's slots as well as the player inventory slots and the hotbar. - // Each time we add a Slot to the container, it automatically increases the slotIndex, which means - // 0 - 8 = hotbar slots (which will map to the InventoryPlayer slot numbers 0 - 8) - // 9 - 35 = player inventory slots (which map to the InventoryPlayer slot numbers 9 - 35) - // 36 - 44 = TileInventory slots, which map to our TileEntity slot numbers 0 - 8) private static final int HOTBAR_SLOT_COUNT = 9; private static final int PLAYER_INVENTORY_ROW_COUNT = 3; private static final int PLAYER_INVENTORY_COLUMN_COUNT = 9; @@ -74,28 +65,23 @@ public int getScaledProgress() { private static final int VANILLA_SLOT_COUNT = HOTBAR_SLOT_COUNT + PLAYER_INVENTORY_SLOT_COUNT; private static final int VANILLA_FIRST_SLOT_INDEX = 0; private static final int TE_INVENTORY_FIRST_SLOT_INDEX = VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT; - - // THIS YOU HAVE TO DEFINE! - private static final int TE_INVENTORY_SLOT_COUNT = 4; // must be the number of slots you have! + private static final int TE_INVENTORY_SLOT_COUNT = 4; // Number of slots in the screen @SuppressWarnings("ConstantConditions") @Override @Nonnull public ItemStack quickMoveStack(@Nullable Player playerIn, int index) { Slot sourceSlot = slots.get(index); - if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; //EMPTY_ITEM + if (sourceSlot == null || !sourceSlot.hasItem()) return ItemStack.EMPTY; ItemStack sourceStack = sourceSlot.getItem(); ItemStack copyOfSourceStack = sourceStack.copy(); - // Check if the slot clicked is one of the vanilla container slots if (index < VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT) { - // This is a vanilla container slot so merge the stack into the tile inventory if (!moveItemStackTo(sourceStack, TE_INVENTORY_FIRST_SLOT_INDEX, TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT, false)) { return ItemStack.EMPTY; // EMPTY_ITEM } } else if (index < TE_INVENTORY_FIRST_SLOT_INDEX + TE_INVENTORY_SLOT_COUNT) { - // This is a TE slot so merge the stack into the players inventory if (!moveItemStackTo(sourceStack, VANILLA_FIRST_SLOT_INDEX, VANILLA_FIRST_SLOT_INDEX + VANILLA_SLOT_COUNT, false)) { return ItemStack.EMPTY; } @@ -103,7 +89,7 @@ public ItemStack quickMoveStack(@Nullable Player playerIn, int index) { System.out.println("Invalid slotIndex:" + index); return ItemStack.EMPTY; } - // If stack size == 0 (the entire stack was moved) set slot contents to null + if (sourceStack.getCount() == 0) { sourceSlot.set(ItemStack.EMPTY); } else { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/screen/slot/ModFuelSlot.java b/src/main/java/net/tonimatasmc/krystalcraft/screen/slot/ModFuelSlot.java index 118b511c..dbd1c8ff 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/screen/slot/ModFuelSlot.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/screen/slot/ModFuelSlot.java @@ -14,15 +14,6 @@ public ModFuelSlot(IItemHandler itemHandler, int index, int xPosition, int yPosi @Override public boolean mayPlace(@NotNull ItemStack stack) { - return AbstractFurnaceBlockEntity.isFuel(stack) || ModFuelSlot.isBucket(stack); - } - - @Override - public int getMaxStackSize(@NotNull ItemStack pStack) { - return ModFuelSlot.isBucket(pStack) ? 1 : super.getMaxStackSize(pStack); - } - - public static boolean isBucket(ItemStack stack) { - return stack.is(Items.BUCKET); + return stack.getItem() == Items.COAL || stack.getItem() == Items.CHARCOAL; } } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/util/ModTags.java b/src/main/java/net/tonimatasmc/krystalcraft/util/ModTags.java index 4eb4ea71..a65d2e95 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/util/ModTags.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/util/ModTags.java @@ -9,6 +9,7 @@ import net.tonimatasmc.krystalcraft.KrystalCraft; public class ModTags { + @SuppressWarnings("unused") public static class Blocks { public static final TagKey ORES = forgeTag("ores"); public static final TagKey STORAGE_BLOCKS = forgeTag("storage_blocks"); @@ -22,7 +23,6 @@ public static class Blocks { public static final TagKey SILVER_ORE = forgeTag("ores/silver"); public static final TagKey TIN_ORE = forgeTag("ores/tin"); public static final TagKey TOPAZ_ORE = forgeTag("ores/topaz"); - public static final TagKey BRONZE_BLOCK = forgeTag("storage_blocks/bronze"); public static final TagKey JADE_BLOCK = forgeTag("storage_blocks/jade"); public static final TagKey LEAD_BLOCK = forgeTag("storage_blocks/lead"); @@ -42,6 +42,7 @@ private static TagKey forgeTag(String name) { } } + @SuppressWarnings("unused") public static class Items { public static final TagKey DUSTS = forgeTag("dusts"); public static final TagKey GEMS = forgeTag("gems"); @@ -50,7 +51,6 @@ public static class Items { public static final TagKey RAW_MATERIALS = forgeTag("raw_materials"); public static final TagKey ORES = forgeTag("ores"); public static final TagKey STORAGE_BLOCKS = forgeTag("storage_blocks"); - public static final TagKey BRONZE_DUST = forgeTag("dusts/bronze"); public static final TagKey COPPER_DUST = forgeTag("dusts/copper"); public static final TagKey JADE_DUST = forgeTag("dusts/jade"); @@ -64,24 +64,20 @@ public static class Items { public static final TagKey DIAMOND_DUST = forgeTag("dusts/diamond"); public static final TagKey EMERALD_DUST = forgeTag("dusts/emerald"); public static final TagKey LAPIS_DUST = forgeTag("dusts/lapis"); - public static final TagKey JADE_GEM = forgeTag("gems/jade"); public static final TagKey RUBY_GEM = forgeTag("gems/ruby"); public static final TagKey SAPPHIRE_GEM = forgeTag("gems/sapphire"); public static final TagKey TOPAZ_GEM = forgeTag("gems/topaz"); - public static final TagKey BRONZE_INGOT = forgeTag("ingots/bronze"); public static final TagKey LEAD_INGOT = forgeTag("ingots/lead"); public static final TagKey PLATINUM_INGOT = forgeTag("ingots/platinum"); public static final TagKey SILVER_INGOT = forgeTag("ingots/silver"); public static final TagKey TIN_INGOT = forgeTag("ingots/tin"); - public static final TagKey BRONZE_NUGGETS = forgeTag("nuggets/bronze"); public static final TagKey LEAD_NUGGETS = forgeTag("nuggets/lead"); public static final TagKey PLATINUM_NUGGETS = forgeTag("nuggets/platinum"); public static final TagKey SILVER_NUGGETS = forgeTag("nuggets/silver"); public static final TagKey TIN_NUGGETS = forgeTag("nuggets/tin"); - public static final TagKey EXPERIENCE_ORE = forgeTag("ores/experience"); public static final TagKey JADE_ORE = forgeTag("ores/jade"); public static final TagKey LEAD_ORE = forgeTag("ores/lead"); @@ -91,7 +87,6 @@ public static class Items { public static final TagKey SILVER_ORE = forgeTag("ores/silver"); public static final TagKey TIN_ORE = forgeTag("ores/tin"); public static final TagKey TOPAZ_ORE = forgeTag("ores/topaz"); - public static final TagKey BRONZE_BLOCK = forgeTag("storage_blocks/bronze"); public static final TagKey JADE_BLOCK = forgeTag("storage_blocks/jade"); public static final TagKey LEAD_BLOCK = forgeTag("storage_blocks/lead"); @@ -101,7 +96,6 @@ public static class Items { public static final TagKey SILVER_BLOCK = forgeTag("storage_blocks/silver"); public static final TagKey TIN_BLOCK = forgeTag("storage_blocks/tin"); public static final TagKey TOPAZ_BLOCK = forgeTag("storage_blocks/topaz"); - public static final TagKey JADE_RAW_MATERIAL = forgeTag("raw_materials/jade"); public static final TagKey LEAD_RAW_MATERIAL = forgeTag("raw_materials/lead"); public static final TagKey PLATINUM_RAW_MATERIAL = forgeTag("raw_materials/platinum"); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModBiomeModifiers.java b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModBiomeModifiers.java index bb6aaca1..38066073 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModBiomeModifiers.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModBiomeModifiers.java @@ -16,7 +16,6 @@ public class ModBiomeModifiers { public static final DeferredRegister> BIOME_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.BIOME_MODIFIER_SERIALIZERS, KrystalCraft.MOD_ID); - public static RegistryObject> VEGETAL_MODIFIER = BIOME_MODIFIERS.register("vegetal", () -> RecordCodecBuilder.create(builder -> builder.group( Biome.LIST_CODEC.fieldOf("biomes").forGetter(ModVegetalBiomeModifier::biomes), @@ -35,7 +34,6 @@ public class ModBiomeModifiers { MobSpawnSettings.SpawnerData.CODEC.fieldOf("entity").forGetter(ModEntityBiomeModifier::spawnerData) ).apply(builder, ModEntityBiomeModifier::new))); - public static void register(IEventBus eventBus) { BIOME_MODIFIERS.register(eventBus); } diff --git a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModEntityBiomeModifier.java b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModEntityBiomeModifier.java index 56970656..447b3424 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModEntityBiomeModifier.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModEntityBiomeModifier.java @@ -9,6 +9,7 @@ import net.minecraftforge.common.world.ModifiableBiomeInfo; public record ModEntityBiomeModifier(HolderSet biomes, MobSpawnSettings.SpawnerData spawnerData) implements BiomeModifier { + @Override public void modify(Holder biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) { if (phase == Phase.ADD && biomes.contains(biome)) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModOreBiomeModifier.java b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModOreBiomeModifier.java index 2d047e4f..755d10ee 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModOreBiomeModifier.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModOreBiomeModifier.java @@ -10,6 +10,7 @@ import net.minecraftforge.common.world.ModifiableBiomeInfo; public record ModOreBiomeModifier(HolderSet biomes, Holder feature) implements BiomeModifier { + @Override public void modify(Holder biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) { if (phase == Phase.ADD && biomes.contains(biome)) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModVegetalBiomeModifier.java b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModVegetalBiomeModifier.java index 2e740ace..2dfbf0d9 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModVegetalBiomeModifier.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/world/biomemods/ModVegetalBiomeModifier.java @@ -10,6 +10,7 @@ import net.minecraftforge.common.world.ModifiableBiomeInfo; public record ModVegetalBiomeModifier(HolderSet biomes, Holder feature) implements BiomeModifier { + @Override public void modify(Holder biome, Phase phase, ModifiableBiomeInfo.BiomeInfo.Builder builder) { if (phase == Phase.ADD && biomes.contains(biome)) { diff --git a/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModConfiguredFeatures.java b/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModConfiguredFeatures.java index 99c92eeb..5e3579cf 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModConfiguredFeatures.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModConfiguredFeatures.java @@ -50,8 +50,8 @@ public class ModConfiguredFeatures { //---------------------------------------------------------------------------------------------------------------------- - //public static final Holder> JADE_ORE = FeatureUtils.register("jade_ore", - // Feature.ORE, new OreConfiguration(OVERWORLD_JADE_ORES, KrystalCraftModCommonConfigs.JADE_ORE_VEIN_SIZE.get())); + public static final Holder> JADE_ORE = FeatureUtils.register("jade_ore", + Feature.ORE, new OreConfiguration(OVERWORLD_JADE_ORES, KrystalCraftModCommonConfigs.JADE_ORE_VEIN_SIZE.get())); public static final Holder> SILVER_ORE = FeatureUtils.register("silver_ore", Feature.ORE, new OreConfiguration(OVERWORLD_SILVER_ORES, KrystalCraftModCommonConfigs.SILVER_ORE_VEIN_SIZE.get())); diff --git a/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModPlacedFeatures.java b/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModPlacedFeatures.java index 422ebc70..15ba609d 100644 --- a/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModPlacedFeatures.java +++ b/src/main/java/net/tonimatasmc/krystalcraft/world/feature/ModPlacedFeatures.java @@ -12,17 +12,16 @@ import net.tonimatasmc.krystalcraft.KrystalCraft; import net.tonimatasmc.krystalcraft.config.KrystalCraftModCommonConfigs; -@SuppressWarnings({"unchecked"}) +@SuppressWarnings({"unchecked", "unused"}) public class ModPlacedFeatures { public static final DeferredRegister PLACED_FEATURES = DeferredRegister.create(Registry.PLACED_FEATURE_REGISTRY, KrystalCraft.MOD_ID); - //public static final RegistryObject JADE_ORE_PLACED = PLACED_FEATURES.register("jade_ore_placed", - // () -> new PlacedFeature((Holder>)(Holder>) - // ModConfiguredFeatures.JADE_ORE, ModOrePlacement.commonOrePlacement( - // KrystalCraftModCommonConfigs.JADE_ORE_VEINS_PER_CHUNK.get(), // VeinsPerChunk - // HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(KrystalCraftModCommonConfigs.JADE_ORE_MINIMUN_HEIGHT.get()), VerticalAnchor.aboveBottom(KrystalCraftModCommonConfigs.JADE_ORE_MAXIMUN_HEIGHT.get()))))); - + public static final RegistryObject JADE_ORE_PLACED = PLACED_FEATURES.register("jade_ore_placed", + () -> new PlacedFeature((Holder>)(Holder>) + ModConfiguredFeatures.JADE_ORE, ModOrePlacement.commonOrePlacement( + KrystalCraftModCommonConfigs.JADE_ORE_VEINS_PER_CHUNK.get(), // VeinsPerChunk + HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(KrystalCraftModCommonConfigs.JADE_ORE_MINIMUN_HEIGHT.get()), VerticalAnchor.aboveBottom(KrystalCraftModCommonConfigs.JADE_ORE_MAXIMUN_HEIGHT.get()))))); public static final RegistryObject SILVER_ORE_PLACED = PLACED_FEATURES.register("silver_ore_placed", () -> new PlacedFeature((Holder>)(Holder>)