Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added crafting tables (wipes tears from face)
- Loading branch information
Alexander Behrhof
committed
Jul 12, 2015
1 parent
062f52e
commit 9921cf9
Showing
77 changed files
with
533 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/main/java/com/progwml6/natura/blocks/misc/BlockNaturaWorkbench.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
package com.progwml6.natura.blocks.misc; | ||
|
||
import java.util.List; | ||
|
||
import com.progwml6.natura.Natura; | ||
import com.progwml6.natura.NaturaCreativeTabs; | ||
import com.progwml6.natura.network.NaturaGuiHandler; | ||
|
||
import mantle.blocks.util.IBlockWithVariants; | ||
import mantle.blocks.util.blockstates.BlockVariant; | ||
import mantle.blocks.util.blockstates.PropertyVariant; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.properties.IProperty; | ||
import net.minecraft.block.state.BlockState; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.creativetab.CreativeTabs; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.BlockPos; | ||
import net.minecraft.util.EnumFacing; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
public class BlockNaturaWorkbench extends Block implements IBlockWithVariants | ||
{ | ||
public static final BlockVariant EUCALYPTUS = new BlockVariant(0, "table_eucalyptus"), | ||
SAKURA = new BlockVariant(1, "table_sakura"), | ||
GHOSTWOOD = new BlockVariant(2, "table_ghostwood"), | ||
REDWOOD = new BlockVariant(3, "table_redwood"), | ||
BLOODWOOD = new BlockVariant(4, "table_bloodwood"), | ||
HOPSEED = new BlockVariant(5, "table_hopseed"), | ||
MAPLE = new BlockVariant(6, "table_maple"), | ||
SILVERBELL = new BlockVariant(7, "table_silverbell"), | ||
PURPLEHEART = new BlockVariant(8, "table_purpleheart"), | ||
TIGER = new BlockVariant(9, "table_tiger"), | ||
WILLOW = new BlockVariant(10, "table_willow"), | ||
DARKWOOD = new BlockVariant(11, "table_darkwood"), | ||
FUSEWOOD = new BlockVariant(12, "table_fusewood"); | ||
|
||
public static final PropertyVariant WOOD_TYPE = PropertyVariant.create("variant", EUCALYPTUS, SAKURA, GHOSTWOOD, REDWOOD, BLOODWOOD, HOPSEED, MAPLE, SILVERBELL, PURPLEHEART, TIGER, WILLOW, DARKWOOD, FUSEWOOD); | ||
|
||
public BlockNaturaWorkbench() | ||
{ | ||
super(Material.wood); | ||
|
||
this.setHardness(2.5f); | ||
this.setStepSound(Block.soundTypeWood); | ||
|
||
this.setDefaultState(this.getBlockState().getBaseState().withProperty(WOOD_TYPE, EUCALYPTUS)); | ||
this.setCreativeTab(NaturaCreativeTabs.tabMisc); | ||
} | ||
|
||
@Override | ||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) | ||
{ | ||
if (!world.isRemote) | ||
{ | ||
player.openGui(Natura.INSTANCE, NaturaGuiHandler.WORKBENCH_ID, world, pos.getX(), pos.getY(), pos.getZ()); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings({ "rawtypes", "unchecked" }) | ||
@SideOnly(Side.CLIENT) | ||
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) | ||
{ | ||
for (BlockVariant variant : WOOD_TYPE.getAllowedValues()) | ||
{ | ||
list.add(new ItemStack(itemIn, 1, variant.getMeta())); | ||
} | ||
} | ||
|
||
@Override | ||
public IBlockState getStateFromMeta(int meta) | ||
{ | ||
return this.getDefaultState().withProperty(WOOD_TYPE, WOOD_TYPE.fromMeta(meta)); | ||
} | ||
|
||
@Override | ||
public int getMetaFromState(IBlockState state) | ||
{ | ||
return ((BlockVariant) state.getValue(WOOD_TYPE)).getMeta(); | ||
} | ||
|
||
@Override | ||
protected BlockState createBlockState() | ||
{ | ||
return new BlockState(this, new IProperty[] { WOOD_TYPE }); | ||
} | ||
|
||
@Override | ||
public int damageDropped(IBlockState state) | ||
{ | ||
return ((BlockVariant) state.getValue(WOOD_TYPE)).getMeta(); | ||
} | ||
|
||
@Override | ||
public String getVariantNameFromStack(ItemStack stack) | ||
{ | ||
return WOOD_TYPE.fromMeta(stack.getMetadata()).getName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/progwml6/natura/containers/ContainerNaturaWorkbench.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.progwml6.natura.containers; | ||
|
||
import com.progwml6.natura.blocks.BlocksNatura; | ||
|
||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.entity.player.InventoryPlayer; | ||
import net.minecraft.inventory.ContainerWorkbench; | ||
import net.minecraft.util.BlockPos; | ||
import net.minecraft.world.World; | ||
|
||
public class ContainerNaturaWorkbench extends ContainerWorkbench | ||
{ | ||
private World world; | ||
|
||
private BlockPos pos; | ||
|
||
public ContainerNaturaWorkbench(InventoryPlayer inventory, World world, BlockPos pos) | ||
{ | ||
super(inventory, world, pos); | ||
|
||
this.world = world; | ||
this.pos = pos; | ||
} | ||
|
||
@Override | ||
public boolean canInteractWith(EntityPlayer player) | ||
{ | ||
return this.world.getBlockState(this.pos).getBlock() == BlocksNatura.crafting_table && player.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64.0D; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/progwml6/natura/items/itemblocks/misc/ItemBlockWorkbench.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.progwml6.natura.items.itemblocks.misc; | ||
|
||
import mantle.blocks.util.ItemBlockVariants; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public class ItemBlockWorkbench extends ItemBlockVariants | ||
{ | ||
public ItemBlockWorkbench(Block block) | ||
{ | ||
super(block); | ||
} | ||
|
||
@Override | ||
public String getUnlocalizedName(ItemStack stack) | ||
{ | ||
return Blocks.crafting_table.getUnlocalizedName(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/progwml6/natura/network/NaturaGuiHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.progwml6.natura.network; | ||
|
||
import com.progwml6.natura.containers.ContainerNaturaWorkbench; | ||
|
||
import net.minecraft.client.gui.inventory.GuiCrafting; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.util.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.common.network.IGuiHandler; | ||
|
||
public class NaturaGuiHandler implements IGuiHandler | ||
{ | ||
public static final int WORKBENCH_ID = 1; | ||
|
||
@Override | ||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) | ||
{ | ||
switch (ID) | ||
{ | ||
case WORKBENCH_ID: | ||
return new ContainerNaturaWorkbench(player.inventory, world, new BlockPos(x, y, z)); | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) | ||
{ | ||
switch (ID) | ||
{ | ||
case WORKBENCH_ID: | ||
return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z)); | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/resources/assets/natura/blockstates/crafting_table.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"variants": { | ||
"variant=table_eucalyptus": { "model": "natura:table_eucalyptus" }, | ||
"variant=table_sakura": { "model": "natura:table_sakura" }, | ||
"variant=table_ghostwood": { "model": "natura:table_ghostwood" }, | ||
"variant=table_redwood": { "model": "natura:table_redwood" }, | ||
"variant=table_bloodwood": { "model": "natura:table_bloodwood" }, | ||
"variant=table_hopseed": { "model": "natura:table_hopseed" }, | ||
"variant=table_maple": { "model": "natura:table_maple" }, | ||
"variant=table_silverbell": { "model": "natura:table_silverbell" }, | ||
"variant=table_purpleheart": { "model": "natura:table_purpleheart" }, | ||
"variant=table_tiger": { "model": "natura:table_tiger" }, | ||
"variant=table_willow": { "model": "natura:table_willow" }, | ||
"variant=table_darkwood": { "model": "natura:table_darkwood" }, | ||
"variant=table_fusewood": { "model": "natura:table_fusewood" } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/resources/assets/natura/models/block/table_bloodwood.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"parent": "block/cube", | ||
"textures": { | ||
"particle": "natura:blocks/bloodwood_workbench_face", | ||
"down": "natura:blocks/bloodwood_planks", | ||
"up": "natura:blocks/bloodwood_workbench_top", | ||
"north": "natura:blocks/bloodwood_workbench_face", | ||
"east": "natura:blocks/bloodwood_workbench_side", | ||
"south": "natura:blocks/bloodwood_workbench_side", | ||
"west": "natura:blocks/bloodwood_workbench_face" | ||
} | ||
} |
Oops, something went wrong.