Added treated wood crafting table. Added treated wood stool.
This commit is contained in:
parent
839a56f4cc
commit
5614310fb6
22 changed files with 615 additions and 27 deletions
|
@ -8,6 +8,14 @@
|
|||
*/
|
||||
package wile.engineersdecor;
|
||||
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.network.IGuiHandler;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import wile.engineersdecor.blocks.BlockDecorCraftingTable;
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
import wile.engineersdecor.blocks.ModBlocks;
|
||||
import net.minecraftforge.client.event.ModelRegistryEvent;
|
||||
|
@ -75,7 +83,10 @@ public class ModEngineersDecor
|
|||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event)
|
||||
{ proxy.init(event); }
|
||||
{
|
||||
proxy.init(event);
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(this, new ModEngineersDecor.GuiHandler());
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
|
@ -105,4 +116,35 @@ public class ModEngineersDecor
|
|||
{ return new ItemStack(ModBlocks.TREATED_WOOD_LADDER); }
|
||||
});
|
||||
|
||||
public static final class GuiHandler implements IGuiHandler
|
||||
{
|
||||
public static final int GUIID_CRAFTING_TABLE = 213101;
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(final int guiid, final EntityPlayer player, final World world, int x, int y, int z)
|
||||
{
|
||||
final BlockPos pos = new BlockPos(x,y,z);
|
||||
final TileEntity te = world.getTileEntity(pos);
|
||||
switch(guiid) {
|
||||
case GUIID_CRAFTING_TABLE:
|
||||
return (te instanceof BlockDecorCraftingTable.BEntity) ? (new BlockDecorCraftingTable.BContainer(player.inventory, world, pos)) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public Object getClientGuiElement(final int guiid, final EntityPlayer player, final World world, int x, int y, int z)
|
||||
{
|
||||
final BlockPos pos = new BlockPos(x,y,z);
|
||||
final TileEntity te = (world instanceof WorldClient) ? world.getTileEntity(pos) : null;
|
||||
switch(guiid) {
|
||||
case GUIID_CRAFTING_TABLE:
|
||||
return (te instanceof BlockDecorCraftingTable.BEntity) ? (new BlockDecorCraftingTable.BGuiCrafting(player.inventory, world, pos)) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* @file BlockDecorFull.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Full block characteristics class.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class BlockDecorChair extends BlockDecorDirected
|
||||
{
|
||||
public BlockDecorChair(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound, @Nonnull AxisAlignedBB unrotatedAABB)
|
||||
{
|
||||
super(registryName, config, material, hardness, resistance, sound, unrotatedAABB);
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* @file BlockDecorFull.java
|
||||
* @author Stefan Wilhelm (wile)
|
||||
* @copyright (C) 2019 Stefan Wilhelm
|
||||
* @license MIT (see https://opensource.org/licenses/MIT)
|
||||
*
|
||||
* Full block characteristics class.
|
||||
*/
|
||||
package wile.engineersdecor.blocks;
|
||||
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class BlockDecorCraftingTable extends BlockDecorDirected
|
||||
{
|
||||
public BlockDecorCraftingTable(@Nonnull String registryName, long config, @Nullable Material material, float hardness, float resistance, @Nullable SoundType sound, @Nonnull AxisAlignedBB unrotatedAABB)
|
||||
{
|
||||
super(registryName, config, material, hardness, resistance, sound, unrotatedAABB);
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
|
||||
{ return getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); }
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state)
|
||||
{ return true; }
|
||||
|
||||
@Nullable
|
||||
public TileEntity createTileEntity(World world, IBlockState state)
|
||||
{ return new BlockDecorCraftingTable.BEntity(); }
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
if(world.isRemote) return true;
|
||||
player.openGui(ModEngineersDecor.instance, ModEngineersDecor.GuiHandler.GUIID_CRAFTING_TABLE, world, pos.getX(), pos.getY(), pos.getZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
// TE
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
public static class BEntity extends TileEntity
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
// Container
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
public static class BContainer extends ContainerWorkbench
|
||||
{
|
||||
private World world;
|
||||
private BlockPos pos;
|
||||
private EntityPlayer player;
|
||||
|
||||
public BContainer(InventoryPlayer inv, World world, BlockPos pos)
|
||||
{
|
||||
super(inv, world, pos);
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
this.player = inv.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn)
|
||||
{ return (world.getBlockState(this.pos).getBlock() instanceof BlockDecorCraftingTable) && (playerIn.getDistanceSq(this.pos) <= 8*8); }
|
||||
|
||||
@Override
|
||||
public void onCraftMatrixChanged(IInventory inv)
|
||||
{
|
||||
try {
|
||||
slotChangedCraftingGrid(this.world, player, this.craftMatrix, this.craftResult);
|
||||
} catch(Throwable exc) {
|
||||
ModEngineersDecor.logger.error("Recipe failed:", exc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
// GUI
|
||||
//--------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static class BGuiCrafting extends GuiContainer
|
||||
{
|
||||
public BGuiCrafting(InventoryPlayer playerInventory, World world, BlockPos pos)
|
||||
{ super(new BContainer(playerInventory, world, pos)); }
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
||||
{ super.drawScreen(mouseX, mouseY, partialTicks); renderHoveredToolTip(mouseX, mouseY); }
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
||||
{}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
|
||||
{
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.mc.getTextureManager().bindTexture(new ResourceLocation(ModEngineersDecor.MODID, "textures/gui/treated_wood_crafting_table.png"));
|
||||
drawTexturedModalRect(((this.width - this.xSize)/2), ((this.height - this.ySize)/2), 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -105,7 +105,7 @@ public class BlockDecorWall extends BlockDecor
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
|
||||
public boolean isPassable(IBlockAccess world, BlockPos pos)
|
||||
{ return false; }
|
||||
|
||||
@Override
|
||||
|
@ -118,13 +118,15 @@ public class BlockDecorWall extends BlockDecor
|
|||
public boolean isNormalCube(IBlockState state)
|
||||
{ return false; }
|
||||
|
||||
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos, EnumFacing p_176253_3_)
|
||||
private boolean canConnectTo(IBlockAccess world, BlockPos pos, BlockPos other, EnumFacing facing)
|
||||
{
|
||||
IBlockState iblockstate = worldIn.getBlockState(pos);
|
||||
Block block = iblockstate.getBlock();
|
||||
BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos, p_176253_3_);
|
||||
boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE_THICK || blockfaceshape == BlockFaceShape.MIDDLE_POLE && block instanceof BlockFenceGate;
|
||||
return !isExcepBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
|
||||
final IBlockState state = world.getBlockState(other);
|
||||
final Block block = state.getBlock();
|
||||
if((block instanceof BlockDecorWall) || (block instanceof BlockFenceGate)) return true;
|
||||
if(world.getBlockState(pos.offset(facing)).getBlock()!=this) return false;
|
||||
if(block instanceof BlockFence) return true;
|
||||
final BlockFaceShape shp = state.getBlockFaceShape(world, other, facing);
|
||||
return (shp == BlockFaceShape.SOLID) && (!isExcepBlockForAttachWithPiston(block));
|
||||
}
|
||||
|
||||
protected static boolean isExcepBlockForAttachWithPiston(Block b)
|
||||
|
@ -148,12 +150,12 @@ public class BlockDecorWall extends BlockDecor
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos)
|
||||
{
|
||||
boolean n = canWallConnectTo(worldIn, pos, EnumFacing.NORTH);
|
||||
boolean e = canWallConnectTo(worldIn, pos, EnumFacing.EAST);
|
||||
boolean s = canWallConnectTo(worldIn, pos, EnumFacing.SOUTH);
|
||||
boolean w = canWallConnectTo(worldIn, pos, EnumFacing.WEST);
|
||||
boolean n = canWallConnectTo(world, pos, EnumFacing.NORTH);
|
||||
boolean e = canWallConnectTo(world, pos, EnumFacing.EAST);
|
||||
boolean s = canWallConnectTo(world, pos, EnumFacing.SOUTH);
|
||||
boolean w = canWallConnectTo(world, pos, EnumFacing.WEST);
|
||||
boolean nopole = (n && s && !e && !w) || (!n && !s && e && w);
|
||||
return state.withProperty(UP,!nopole).withProperty(NORTH, n).withProperty(EAST, e).withProperty(SOUTH, s).withProperty(WEST, w);
|
||||
}
|
||||
|
@ -164,17 +166,13 @@ public class BlockDecorWall extends BlockDecor
|
|||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
{ return ((face!=EnumFacing.UP) && (face!=EnumFacing.DOWN)) ? (BlockFaceShape.MIDDLE_POLE_THICK) : (BlockFaceShape.CENTER_BIG); }
|
||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face)
|
||||
{ return (face==EnumFacing.UP) ? (BlockFaceShape.SOLID) : ((face!=EnumFacing.DOWN) ? (BlockFaceShape.MIDDLE_POLE_THICK) : (BlockFaceShape.CENTER_BIG)); }
|
||||
|
||||
@Override
|
||||
public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
|
||||
{ return canConnectTo(world, pos.offset(facing), facing.getOpposite()); }
|
||||
{ return canConnectTo(world, pos, pos.offset(facing), facing.getOpposite()); }
|
||||
|
||||
private boolean canWallConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing)
|
||||
{
|
||||
BlockPos other = pos.offset(facing);
|
||||
Block block = world.getBlockState(other).getBlock();
|
||||
return block.canBeConnectedTo(world, other, facing.getOpposite()) || canConnectTo(world, other, facing.getOpposite());
|
||||
}
|
||||
{ return canConnectTo(world, pos, pos.offset(facing), facing.getOpposite()); }
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import wile.engineersdecor.ModEngineersDecor;
|
||||
import wile.engineersdecor.detail.ModAuxiliaries;
|
||||
import wile.engineersdecor.detail.ModConfig;
|
||||
|
@ -66,6 +67,21 @@ public class ModBlocks
|
|||
BlockDecor.CFG_CUTOUT,
|
||||
Material.WOOD, 1.0f, 15f, SoundType.WOOD
|
||||
);
|
||||
public static final BlockDecorChair TREATED_WOOD_STOOL = new BlockDecorChair(
|
||||
"treated_wood_stool",
|
||||
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL_PLACEMENT|BlockDecor.CFG_HORIZIONTAL,
|
||||
Material.WOOD, 1.0f, 15f, SoundType.WOOD,
|
||||
ModAuxiliaries.getPixeledAABB(4.1,0,4.1, 11.8,8.8,11.8)
|
||||
);
|
||||
|
||||
public static final BlockDecorCraftingTable TREATED_WOOD_CRAFTING_TABLE = new BlockDecorCraftingTable(
|
||||
"treated_wood_crafting_table",
|
||||
BlockDecor.CFG_CUTOUT|BlockDecor.CFG_HORIZIONTAL_PLACEMENT|BlockDecor.CFG_HORIZIONTAL,
|
||||
Material.WOOD, 1.0f, 15f, SoundType.WOOD,
|
||||
ModAuxiliaries.getPixeledAABB(0.5,0,3, 15.5,15.125,15.5)
|
||||
);
|
||||
|
||||
|
||||
|
||||
public static final BlockDecorStairs IRON_SHEET_ROOF = new BlockDecorStairs("iron_sheet_roof", IRON_SHEET_ROOF_FULLBLOCK.getDefaultState());
|
||||
|
||||
|
@ -83,6 +99,8 @@ public class ModBlocks
|
|||
REBAR_CONCRETE_STAIRS,
|
||||
REBAR_CONCRETE_WALL,
|
||||
CLINKER_BRICK_WALL,
|
||||
TREATED_WOOD_STOOL,
|
||||
TREATED_WOOD_CRAFTING_TABLE,
|
||||
};
|
||||
|
||||
private static final Block ieDependentBlocks[] = {
|
||||
|
@ -113,6 +131,8 @@ public class ModBlocks
|
|||
for(Block e:allBlocks) registeredBlocks.add(e);
|
||||
for(Block e:registeredBlocks) event.getRegistry().register(e);
|
||||
ModEngineersDecor.logger.info("Registered " + Integer.toString(registeredBlocks.size()) + " blocks.");
|
||||
// TEs
|
||||
GameRegistry.registerTileEntity(BlockDecorCraftingTable.BEntity.class, new ResourceLocation(ModEngineersDecor.MODID, "te_crafting_table"));
|
||||
}
|
||||
|
||||
// Invoked from ClientProxy.registerModels()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue