Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some quick sanity improvements #15

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ forge*changelog.txt
/src/recipes.txt
/src/stamp_holder_hires.png
/resources/

# Java datagen cache
/src/generated/resources/.cache

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@

package com.redstoneguy10ls.lithiccoins;

import com.mojang.datafixers.util.Either;
import com.redstoneguy10ls.lithiccoins.client.render.mintBlockEntityRenderer;
import com.redstoneguy10ls.lithiccoins.client.render.MintBlockEntityRenderer;
import com.redstoneguy10ls.lithiccoins.client.screen.WaxKanppingScreen;
import com.redstoneguy10ls.lithiccoins.common.Capability.IPurse;
import com.redstoneguy10ls.lithiccoins.common.Capability.LocationCapability;
import com.redstoneguy10ls.lithiccoins.common.Capability.PurseCapability;
import com.redstoneguy10ls.lithiccoins.common.capability.IPurse;
import com.redstoneguy10ls.lithiccoins.common.capability.LocationCapability;
import com.redstoneguy10ls.lithiccoins.common.capability.PurseCapability;
import com.redstoneguy10ls.lithiccoins.common.blockentities.LCBlockEntities;
import com.redstoneguy10ls.lithiccoins.common.container.LCContainerTypes;
import com.redstoneguy10ls.lithiccoins.common.items.LCItems;
import com.redstoneguy10ls.lithiccoins.common.items.stampTypes;
import com.redstoneguy10ls.lithiccoins.util.LCHelpers;
import com.redstoneguy10ls.lithiccoins.util.coinTooltip;
import com.redstoneguy10ls.lithiccoins.util.tooltips;
import com.redstoneguy10ls.lithiccoins.util.CoinTooltip;
import com.redstoneguy10ls.lithiccoins.util.Tooltips;
import net.dries007.tfc.client.model.ContainedFluidModel;
import net.dries007.tfc.util.Metal;

import net.minecraft.client.gui.screens.MenuScreens;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.inventory.tooltip.TooltipComponent;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.RegisterClientTooltipComponentFactoriesEvent;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.eventbus.api.IEventBus;
Expand Down Expand Up @@ -56,12 +50,12 @@ public static void init()

public static void regusterEntityRenderers(EntityRenderersEvent.RegisterRenderers event)
{
event.registerBlockEntityRenderer(LCBlockEntities.MINT.get(), ctx -> new mintBlockEntityRenderer());
event.registerBlockEntityRenderer(LCBlockEntities.MINT.get(), ctx -> new MintBlockEntityRenderer());
}

public static void onTooltipFactoryRegistry(RegisterClientTooltipComponentFactoriesEvent event)
{
event.register(tooltips.CoinImageTooltip.class, coinTooltip::new);
event.register(Tooltips.CoinImageTooltip.class, CoinTooltip::new);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.redstoneguy10ls.lithiccoins;


import com.redstoneguy10ls.lithiccoins.common.Capability.LocationCapability;
import com.redstoneguy10ls.lithiccoins.common.Capability.LocationHandler;
import com.redstoneguy10ls.lithiccoins.common.capability.LocationCapability;
import com.redstoneguy10ls.lithiccoins.common.capability.LocationHandler;
import com.redstoneguy10ls.lithiccoins.util.LCTags;
import net.dries007.tfc.util.Helpers;
import net.minecraft.core.BlockPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;

import com.redstoneguy10ls.lithiccoins.util.LithicCoinsInteractionManager;
import org.slf4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
Expand Down Expand Up @@ -65,6 +67,7 @@ public LithicCoins()

private void commonSetup(final FMLCommonSetupEvent event)
{
event.enqueueWork(LithicCoinsInteractionManager::init);
}

private void addCreative(BuildCreativeModeTabContentsEvent event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,25 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import com.redstoneguy10ls.lithiccoins.common.blockentities.mintBlockEntity;
import com.redstoneguy10ls.lithiccoins.common.blockentities.MintBlockEntity;
import com.redstoneguy10ls.lithiccoins.common.blocks.LCStateProperties;
import com.redstoneguy10ls.lithiccoins.common.blocks.mintBlock;
import net.dries007.tfc.common.capabilities.Capabilities;
import net.dries007.tfc.util.Helpers;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraftforge.items.IItemHandler;

import static com.redstoneguy10ls.lithiccoins.common.blocks.mintBlock.FACING;
import static net.minecraft.core.Direction.NORTH;
import static net.minecraft.core.Direction.SOUTH;
import net.minecraftforge.items.IItemHandler;

public class mintBlockEntityRenderer implements BlockEntityRenderer<mintBlockEntity> {
public class MintBlockEntityRenderer implements BlockEntityRenderer<MintBlockEntity> {

@Override
public void render(mintBlockEntity mint, float partialTicks, PoseStack stack, MultiBufferSource bufferSource, int packedLight, int packedOverlay)
public void render(MintBlockEntity mint, float partialTicks, PoseStack stack, MultiBufferSource bufferSource, int packedLight, int packedOverlay)
{
final Level level = mint.getLevel();
final IItemHandler inventory = Helpers.getCapability(mint, Capabilities.ITEM);
Expand All @@ -37,10 +30,10 @@ public void render(mintBlockEntity mint, float partialTicks, PoseStack stack, Mu
return;
}

final ItemStack topdie = inventory.getStackInSlot(mintBlockEntity.SLOT_TOPDIE);
final ItemStack coin = inventory.getStackInSlot(mintBlockEntity.SLOT_COIN);
final ItemStack bottom = inventory.getStackInSlot(mintBlockEntity.SLOT_BOTTOMDIE);
final ItemStack output = inventory.getStackInSlot(mintBlockEntity.SLOT_OUTPUT);
final ItemStack topdie = inventory.getStackInSlot(MintBlockEntity.SLOT_TOPDIE);
final ItemStack coin = inventory.getStackInSlot(MintBlockEntity.SLOT_COIN);
final ItemStack bottom = inventory.getStackInSlot(MintBlockEntity.SLOT_BOTTOMDIE);
final ItemStack output = inventory.getStackInSlot(MintBlockEntity.SLOT_OUTPUT);

final BlockState blockState = mint.getLevel().getBlockState(mint.getBlockPos());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
public class LCBlockEntities {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(Registries.BLOCK_ENTITY_TYPE, MOD_ID);

public static final RegistryObject<BlockEntityType<mintBlockEntity>> MINT =
register("mint", mintBlockEntity::new, LCBlocks.MINT);
public static final RegistryObject<BlockEntityType<MintBlockEntity>> MINT =
register("mint", MintBlockEntity::new, LCBlocks.MINT);

private static <T extends BlockEntity> RegistryObject<BlockEntityType<T>> register(String name, BlockEntityType.BlockEntitySupplier<T> factory, Supplier<? extends Block> block)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.redstoneguy10ls.lithiccoins.common.blockentities;

import com.redstoneguy10ls.lithiccoins.common.Capability.LocationCapability;
import com.redstoneguy10ls.lithiccoins.common.blocks.mintBlock;
import com.redstoneguy10ls.lithiccoins.common.items.TopDies;
import com.redstoneguy10ls.lithiccoins.common.recipes.LCRecipeTypes;
import com.redstoneguy10ls.lithiccoins.common.blockentities.MintBlockEntity.MintInventory;
import com.redstoneguy10ls.lithiccoins.common.capability.LocationCapability;
import com.redstoneguy10ls.lithiccoins.common.blocks.MintBlock;
import com.redstoneguy10ls.lithiccoins.common.recipes.MintingRecipe;
import com.redstoneguy10ls.lithiccoins.util.LCHelpers;
import com.redstoneguy10ls.lithiccoins.util.LCTags;
Expand All @@ -27,7 +26,7 @@

import static com.redstoneguy10ls.lithiccoins.LithicCoins.MOD_ID;

public class mintBlockEntity extends InventoryBlockEntity<mintBlockEntity.mintInventory> implements ISlotCallback {
public class MintBlockEntity extends InventoryBlockEntity<MintInventory> implements ISlotCallback {

public static final int SLOT_TOPDIE = 0;
public static final int SLOT_BOTTOMDIE = 1;
Expand All @@ -43,18 +42,18 @@ public class mintBlockEntity extends InventoryBlockEntity<mintBlockEntity.mintIn

private static final Component NAME = Component.translatable(MOD_ID + ".block_entity.mint");

public mintBlockEntity(BlockPos pos, BlockState state)
public MintBlockEntity(BlockPos pos, BlockState state)
{
super(LCBlockEntities.MINT.get(), pos, state, mintInventory::new, NAME);
super(LCBlockEntities.MINT.get(), pos, state, MintInventory::new, NAME);

}
public mintBlockEntity(BlockEntityType<? extends mintBlockEntity> type, BlockPos pos, BlockState state, InventoryFactory<mintInventory> inventoryFactory, Component defaultName)
public MintBlockEntity(BlockEntityType<? extends MintBlockEntity> type, BlockPos pos, BlockState state, InventoryFactory<MintInventory> inventoryFactory, Component defaultName)
{
super(type,pos,state,inventoryFactory, defaultName);

}

public static void serverTick(Level level, BlockPos pos, BlockState state, mintBlockEntity mint)
public static void serverTick(Level level, BlockPos pos, BlockState state, MintBlockEntity mint)
{
final ServerLevel serverLevel = (ServerLevel) level;

Expand All @@ -71,7 +70,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, mintB
clientTick(level, pos, state, mint);

}
public static void clientTick(Level level, BlockPos pos, BlockState state, mintBlockEntity mint)
public static void clientTick(Level level, BlockPos pos, BlockState state, MintBlockEntity mint)
{
if(mint.hittimer > 0)
{
Expand Down Expand Up @@ -127,8 +126,8 @@ public void updateHit()
{
assert level != null;
BlockState state = level.getBlockState(worldPosition);
BlockState newState = Helpers.setProperty(state, mintBlock.HIT, hasHit());
if(hasHit() != state.getValue(mintBlock.HIT))
BlockState newState = Helpers.setProperty(state, MintBlock.HIT, hasHit());
if(hasHit() != state.getValue(MintBlock.HIT))
{
level.setBlockAndUpdate(worldPosition, newState);
}
Expand Down Expand Up @@ -286,13 +285,13 @@ else if(getBottomDieTier() < recipe.getTier())
return InteractionResult.PASS;
}

public static class mintInventory extends InventoryItemHandler implements MintingRecipe.Inventory{
public static class MintInventory extends InventoryItemHandler implements MintingRecipe.Inventory{

private final mintBlockEntity mint;
private final MintBlockEntity mint;

public mintInventory(InventoryBlockEntity<mintInventory> mint) {
public MintInventory(InventoryBlockEntity<MintInventory> mint) {
super(mint, 4);
this.mint = (mintBlockEntity) mint;
this.mint = (MintBlockEntity) mint;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.redstoneguy10ls.lithiccoins.common.blocks;

import com.redstoneguy10ls.lithiccoins.common.blockentities.LCBlockEntities;
import com.redstoneguy10ls.lithiccoins.common.blockentities.mintBlockEntity;
import com.redstoneguy10ls.lithiccoins.common.blockentities.MintBlockEntity;
import com.redstoneguy10ls.lithiccoins.common.items.LCItems;
import net.dries007.tfc.common.blocks.ExtendedProperties;
import net.dries007.tfc.util.registry.RegistrationHelpers;
Expand All @@ -26,13 +26,13 @@ public class LCBlocks {


public static final RegistryObject<Block> MINT = register("mint",
() -> new mintBlock(ExtendedProperties.of()
() -> new MintBlock(ExtendedProperties.of()
.mapColor(MapColor.STONE)
.strength(2.0F, 2.0F)
.sound(SoundType.BASALT)
.noOcclusion()
.blockEntity(LCBlockEntities.MINT)
.serverTicks(mintBlockEntity::serverTick)));
.serverTicks(MintBlockEntity::serverTick)));

private static <T extends Block> RegistryObject<T> register(String name, Supplier<T> blockSupplier)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.redstoneguy10ls.lithiccoins.common.blockentities.LCBlockEntities;
import com.redstoneguy10ls.lithiccoins.common.blockentities.mintBlockEntity;
import com.redstoneguy10ls.lithiccoins.common.blockentities.MintBlockEntity;
import com.redstoneguy10ls.lithiccoins.common.misc.LCSounds;
import com.redstoneguy10ls.lithiccoins.util.LCHelpers;
import com.redstoneguy10ls.lithiccoins.util.LCTags;
import net.dries007.tfc.client.IHighlightHandler;
import net.dries007.tfc.client.particle.TFCParticles;
Expand Down Expand Up @@ -32,7 +31,6 @@
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
Expand All @@ -43,10 +41,10 @@
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.ItemHandlerHelper;

import static com.redstoneguy10ls.lithiccoins.common.blockentities.mintBlockEntity.*;
import static com.redstoneguy10ls.lithiccoins.common.blockentities.MintBlockEntity.*;


public class mintBlock extends DeviceBlock implements IHighlightHandler {
public class MintBlock extends DeviceBlock implements IHighlightHandler {

public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
//public static final IntegerProperty HAS_TOP_DIE = LCStateProperties.HAS_TOP_DIE;
Expand Down Expand Up @@ -84,7 +82,7 @@ public class mintBlock extends DeviceBlock implements IHighlightHandler {



public mintBlock(ExtendedProperties properties) {
public MintBlock(ExtendedProperties properties) {
super(properties, InventoryRemoveBehavior.DROP);
//registerDefaultState(getStateDefinition().any().setValue(HAS_BOTTOM_DIE, 0));
//registerDefaultState(getStateDefinition().any().setValue(HAS_TOP_DIE, 0));
Expand Down Expand Up @@ -152,7 +150,7 @@ else if (BOTTOM_DIE_W_AABB.move(pos).contains(hit)) {

@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if(level.getBlockEntity(pos) instanceof final mintBlockEntity mint)
if(level.getBlockEntity(pos) instanceof final MintBlockEntity mint)
{
final ItemStack heldStack = player.getItemInHand(hand);
final SelectionPlace selection = getPlayerSelection(level,pos,player,hit);
Expand Down Expand Up @@ -182,7 +180,7 @@ public InteractionResult use(BlockState state, Level level, BlockPos pos, Player
return InteractionResult.PASS;
}

private static InteractionResult attemptMint(Level level, mintBlockEntity mint, Player player,BlockPos pos)
private static InteractionResult attemptMint(Level level, MintBlockEntity mint, Player player,BlockPos pos)
{
final InteractionResult mintResult = mint.minting(player);
if(mintResult == InteractionResult.SUCCESS)
Expand All @@ -203,7 +201,7 @@ private static InteractionResult attemptMint(Level level, mintBlockEntity mint,
return InteractionResult.FAIL;
}

private static InteractionResult coinstuff(BlockState state, Level level, mintBlockEntity mint, IItemHandler inventory, Player player, ItemStack stack, int slot)
private static InteractionResult coinstuff(BlockState state, Level level, MintBlockEntity mint, IItemHandler inventory, Player player, ItemStack stack, int slot)
{
if ((player.isShiftKeyDown() || Helpers.isItem(stack, LCTags.Items.BLANK_COIN))) {
if(mint.hasBottomDie() > 0)
Expand All @@ -221,7 +219,7 @@ private static InteractionResult coinstuff(BlockState state, Level level, mintBl
return InteractionResult.PASS;
}

private static InteractionResult lookTest(BlockState state,Level level, mintBlockEntity mint, IItemHandler inventory, Player player, ItemStack stack, int slot){
private static InteractionResult lookTest(BlockState state,Level level, MintBlockEntity mint, IItemHandler inventory, Player player, ItemStack stack, int slot){
if(slot == SLOT_BOTTOMDIE)
{
if ((player.isShiftKeyDown() || Helpers.isItem(stack, LCTags.Items.BOTTOM_DIE))) {
Expand All @@ -240,7 +238,7 @@ private static InteractionResult lookTest(BlockState state,Level level, mintBloc
return InteractionResult.PASS;
}

private static InteractionResult insertOrExtract(Level level, mintBlockEntity mint, IItemHandler inventory, Player player, ItemStack stack, int slot)
private static InteractionResult insertOrExtract(Level level, MintBlockEntity mint, IItemHandler inventory, Player player, ItemStack stack, int slot)
{
if(!stack.isEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;
/*
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;

import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;

import net.minecraft.nbt.CompoundTag;
import net.minecraftforge.common.util.INBTSerializable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;

public interface IPurse {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.FriendlyByteBuf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;


import com.redstoneguy10ls.lithiccoins.util.LCHelpers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;

import net.minecraft.ChatFormatting;
import net.minecraft.core.Direction;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.redstoneguy10ls.lithiccoins.common.Capability;
package com.redstoneguy10ls.lithiccoins.common.capability;


import net.minecraft.resources.ResourceLocation;
Expand Down
Loading