Update uncrafter block model
This commit is contained in:
parent
8f02c19d55
commit
cee3028d3b
7 changed files with 143 additions and 102 deletions
|
@ -1,11 +1,28 @@
|
|||
package dev.zontreck.otemod.blocks;
|
||||
|
||||
import dev.zontreck.otemod.blocks.entity.CompressionChamberBlockEntity;
|
||||
import dev.zontreck.otemod.blocks.entity.ModEntities;
|
||||
import dev.zontreck.otemod.blocks.entity.UncrafterBlockEntity;
|
||||
import dev.zontreck.otemod.networking.ModMessages;
|
||||
import dev.zontreck.otemod.networking.packets.EnergySyncS2CPacket;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class UncrafterBlock extends HorizontalDirectionalBlock implements EntityBlock
|
||||
|
@ -17,6 +34,69 @@ public class UncrafterBlock extends HorizontalDirectionalBlock implements Entity
|
|||
@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
|
||||
return null;
|
||||
return new UncrafterBlockEntity(blockPos, blockState);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> p_49915_) {
|
||||
super.createBlockStateDefinition(p_49915_);
|
||||
p_49915_.add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState p_60550_) {
|
||||
return RenderShape.MODEL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState state, Level lvl, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit)
|
||||
{
|
||||
if(!lvl.isClientSide())
|
||||
{
|
||||
BlockEntity be = lvl.getBlockEntity(pos);
|
||||
if(be instanceof UncrafterBlockEntity entity)
|
||||
{
|
||||
NetworkHooks.openScreen(((ServerPlayer)player), entity, pos);
|
||||
|
||||
ModMessages.sendToPlayer(new EnergySyncS2CPacket(entity.getEnergyStorage().getEnergyStored(), entity.getBlockPos()), (ServerPlayer)player);
|
||||
|
||||
}else{
|
||||
throw new IllegalStateException("Our container is missing!");
|
||||
}
|
||||
}
|
||||
|
||||
return InteractionResult.sidedSuccess(lvl.isClientSide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pMovedByPiston) {
|
||||
if(pState.getBlock() != pNewState.getBlock())
|
||||
{
|
||||
BlockEntity be = pLevel.getBlockEntity(pPos);
|
||||
if(be instanceof UncrafterBlockEntity)
|
||||
{
|
||||
((UncrafterBlockEntity)be).doDrop();
|
||||
}
|
||||
}
|
||||
|
||||
super.onRemove(pState, pLevel, pPos, pNewState, pMovedByPiston);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level pLevel, BlockState pState, BlockEntityType<T> pBlockEntityType) {
|
||||
|
||||
return createTickerHelper(pBlockEntityType, ModEntities.UNCRAFTER.get(), UncrafterBlockEntity::tick);
|
||||
}
|
||||
|
||||
|
||||
protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> createTickerHelper(BlockEntityType<A> pServerType, BlockEntityType<E> pClientType, BlockEntityTicker<? super E> pTicker) {
|
||||
return pClientType == pServerType ? (BlockEntityTicker<A>) pTicker : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
|
||||
return defaultBlockState().setValue(FACING, pContext.getHorizontalDirection());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,73 +75,6 @@ public class ModBlockStatesProvider extends BlockStateProvider {
|
|||
stairBlock(ModBlocks.DIRTY_GREEN_POOL_TILE_STAIRS, ModBlocks.DIRTY_GREEN_POOL_TILE);
|
||||
slabBlock(ModBlocks.DIRTY_GREEN_POOL_TILE_SLAB, ModBlocks.DIRTY_GREEN_POOL_TILE);
|
||||
|
||||
ResourceLocation[] clinkerBlock = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_texture7")
|
||||
};
|
||||
ResourceLocation[] clinkerStainedBlock = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/clinker_brick/clinker_brick_stained_texture7")
|
||||
};
|
||||
|
||||
ResourceLocation[] slagBricks = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/slag_brick/slag_brick_texture7")
|
||||
};
|
||||
|
||||
ResourceLocation[] rebarConcrete = new ResourceLocation[] {
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_texture7")
|
||||
};
|
||||
|
||||
ResourceLocation[] rebarConcreteTile = new ResourceLocation[] {
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture3"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture4"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture5"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture6"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/concrete/rebar_concrete_tile_texture7")
|
||||
};
|
||||
|
||||
ResourceLocation[] panzerglass = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/glass/panzerglass_block_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/glass/panzerglass_block_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/glass/panzerglass_block_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/glass/panzerglass_block_texture3")
|
||||
};
|
||||
|
||||
ResourceLocation[] oldIndustrialWood = new ResourceLocation[]{
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/material/industrial_planks_texture0"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/material/industrial_planks_texture1"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/material/industrial_planks_texture2"),
|
||||
new ResourceLocation(OTEMod.MOD_ID, "engineersdecor/material/industrial_planks_texture3"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,8 @@ public class ModItems {
|
|||
|
||||
public static final RegistryObject<Item> GREEN_BRICK = CreativeModeTabs.addToOTEModTab(ITEMS.register("green_brick", ()->new Item(new Item.Properties())));
|
||||
|
||||
public static final RegistryObject<Item> PARTIAL_ITEM = CreativeModeTabs.addToOTEModTab(ITEMS.register("partial_item", PartialItem::new));
|
||||
|
||||
|
||||
//public static final RegistryObject<Item> POSSUM_SPAWN_EGG = ITEMS.register("possum_spawn_egg", () -> new ForgeSpawnEggItem(ModEntityTypes.POSSUM, 0x938686, 0xc68787, new Item.Properties())));
|
||||
|
||||
|
|
26
src/main/java/dev/zontreck/otemod/items/PartialItem.java
Normal file
26
src/main/java/dev/zontreck/otemod/items/PartialItem.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package dev.zontreck.otemod.items;
|
||||
|
||||
import dev.zontreck.libzontreck.util.ChatHelpers;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PartialItem extends Item
|
||||
{
|
||||
int uncraftSteps = 0;
|
||||
|
||||
public PartialItem() {
|
||||
super (new Properties().fireResistant());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendHoverText(ItemStack p_41421_, @Nullable Level p_41422_, List<Component> tooltip, TooltipFlag p_41424_) {
|
||||
tooltip.add(ChatHelpers.macro("!Yellow!This is a partially deconstructed item."));
|
||||
tooltip.add(ChatHelpers.macro("!Dark_Red!Steps remaining to uncraft: [0]", "!Yellow!" + uncraftSteps));
|
||||
}
|
||||
}
|
Reference in a new issue