Added rubber processing
This commit is contained in:
parent
defde302fe
commit
891d2cce32
5 changed files with 133 additions and 7 deletions
|
@ -1,6 +1,5 @@
|
||||||
package techreborn.blocks;
|
package techreborn.blocks;
|
||||||
|
|
||||||
import biomesoplenty.common.enums.BOPTrees;
|
|
||||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||||
import net.minecraft.block.BlockLeaves;
|
import net.minecraft.block.BlockLeaves;
|
||||||
import net.minecraft.block.BlockPlanks;
|
import net.minecraft.block.BlockPlanks;
|
||||||
|
@ -101,4 +100,22 @@ public class BlockRubberLeaves extends BlockLeaves implements ITexturedBlock {
|
||||||
}
|
}
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getBlockColor()
|
||||||
|
{
|
||||||
|
return 16777215;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int getRenderColor(IBlockState state)
|
||||||
|
{
|
||||||
|
return 16777215;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
|
||||||
|
{
|
||||||
|
return 16777215;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,34 @@ package techreborn.blocks;
|
||||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.PropertyBool;
|
||||||
|
import net.minecraft.block.properties.PropertyDirection;
|
||||||
|
import net.minecraft.block.state.BlockState;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
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.BlockPos;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import reborncore.RebornCore;
|
import reborncore.RebornCore;
|
||||||
import techreborn.client.TechRebornCreativeTabMisc;
|
import techreborn.client.TechRebornCreativeTabMisc;
|
||||||
|
import techreborn.init.ModParts;
|
||||||
|
import techreborn.items.ItemParts;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mark on 19/02/2016.
|
* Created by mark on 19/02/2016.
|
||||||
*/
|
*/
|
||||||
public class BlockRubberLog extends Block implements ITexturedBlock {
|
public class BlockRubberLog extends Block implements ITexturedBlock {
|
||||||
|
|
||||||
|
public static PropertyDirection SAP_SIDE = PropertyDirection.create("sapSide", EnumFacing.Plane.HORIZONTAL);
|
||||||
|
public static PropertyBool HAS_SAP = PropertyBool.create("hasSap");
|
||||||
|
|
||||||
public BlockRubberLog() {
|
public BlockRubberLog() {
|
||||||
super(Material.wood);
|
super(Material.wood);
|
||||||
setUnlocalizedName("techreborn.rubberlog");
|
setUnlocalizedName("techreborn.rubberlog");
|
||||||
|
@ -21,6 +38,47 @@ public class BlockRubberLog extends Block implements ITexturedBlock {
|
||||||
this.setHardness(2.0F);
|
this.setHardness(2.0F);
|
||||||
this.setStepSound(soundTypeWood);
|
this.setStepSound(soundTypeWood);
|
||||||
RebornCore.jsonDestroyer.registerObject(this);
|
RebornCore.jsonDestroyer.registerObject(this);
|
||||||
|
this.setDefaultState(this.blockState.getBaseState().withProperty(SAP_SIDE, EnumFacing.NORTH).withProperty(HAS_SAP, false));
|
||||||
|
this.setTickRandomly(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected BlockState createBlockState() {
|
||||||
|
return new BlockState(this, SAP_SIDE, HAS_SAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBlockState getStateFromMeta(int meta) {
|
||||||
|
boolean hasSap = false;
|
||||||
|
int tempMeta = meta;
|
||||||
|
if(meta > 3){
|
||||||
|
hasSap = true;
|
||||||
|
tempMeta -= 3;
|
||||||
|
}
|
||||||
|
EnumFacing facing = EnumFacing.getHorizontal(tempMeta);
|
||||||
|
return this.getDefaultState().withProperty(SAP_SIDE, facing).withProperty(HAS_SAP, hasSap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetaFromState(IBlockState state) {
|
||||||
|
int tempMeta = 0;
|
||||||
|
EnumFacing facing = state.getValue(SAP_SIDE);
|
||||||
|
switch (facing){
|
||||||
|
case SOUTH:
|
||||||
|
tempMeta = 0;
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
tempMeta = 1;
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
tempMeta = 2;
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
tempMeta = 3;
|
||||||
|
}
|
||||||
|
if(state.getValue(HAS_SAP)){
|
||||||
|
tempMeta += 3;
|
||||||
|
}
|
||||||
|
return tempMeta;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,12 +86,17 @@ public class BlockRubberLog extends Block implements ITexturedBlock {
|
||||||
if(enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.UP){
|
if(enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.UP){
|
||||||
return "techreborn:blocks/rubber_log_side";
|
return "techreborn:blocks/rubber_log_side";
|
||||||
}
|
}
|
||||||
|
if(iBlockState.getValue(HAS_SAP)){
|
||||||
|
if(iBlockState.getValue(SAP_SIDE) == enumFacing){
|
||||||
|
return "techreborn:blocks/rubber_log_sap";
|
||||||
|
}
|
||||||
|
}
|
||||||
return "techreborn:blocks/rubber_log";
|
return "techreborn:blocks/rubber_log";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int amountOfStates() {
|
public int amountOfStates() {
|
||||||
return 1;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,15 +112,54 @@ public class BlockRubberLog extends Block implements ITexturedBlock {
|
||||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||||
int i = 4;
|
int i = 4;
|
||||||
int j = i + 1;
|
int j = i + 1;
|
||||||
|
|
||||||
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) {
|
if (worldIn.isAreaLoaded(pos.add(-j, -j, -j), pos.add(j, j, j))) {
|
||||||
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i))) {
|
for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-i, -i, -i), pos.add(i, i, i))) {
|
||||||
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||||
|
|
||||||
if (iblockstate.getBlock().isLeaves(worldIn, blockpos)) {
|
if (iblockstate.getBlock().isLeaves(worldIn, blockpos)) {
|
||||||
iblockstate.getBlock().beginLeavesDecay(worldIn, blockpos);
|
iblockstate.getBlock().beginLeavesDecay(worldIn, blockpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
|
||||||
|
super.updateTick(worldIn, pos, state, rand);
|
||||||
|
if(!state.getValue(HAS_SAP)){
|
||||||
|
if(rand.nextInt(100) == 0){
|
||||||
|
EnumFacing facing = EnumFacing.getHorizontal(rand.nextInt(3));
|
||||||
|
if(worldIn.getBlockState(pos.down()).getBlock() == this && worldIn.getBlockState(pos.up()).getBlock() == this && worldIn.isAirBlock(pos.offset(facing))){
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(HAS_SAP, true).withProperty(SAP_SIDE, facing));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||||
|
super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
|
||||||
|
if(state.getValue(HAS_SAP)){
|
||||||
|
if(state.getValue(SAP_SIDE) == side){
|
||||||
|
worldIn.setBlockState(pos, state.withProperty(HAS_SAP, false).withProperty(SAP_SIDE, EnumFacing.getHorizontal(0)));
|
||||||
|
if(!worldIn.isRemote){
|
||||||
|
Random rand = new Random();
|
||||||
|
BlockPos itemPos = pos.offset(side);
|
||||||
|
EntityItem item = new EntityItem(worldIn, itemPos.getX(), itemPos.getY(), itemPos.getZ(), ItemParts.getPartByName("rubberSap").copy());
|
||||||
|
float factor = 0.05F;
|
||||||
|
item.motionX = rand.nextGaussian() * factor;
|
||||||
|
item.motionY = rand.nextGaussian() * factor + 0.2F;
|
||||||
|
item.motionZ = rand.nextGaussian() * factor;
|
||||||
|
worldIn.spawnEntityInWorld(item);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) {
|
||||||
|
super.getSubBlocks(itemIn, tab, list);
|
||||||
|
list.add(new ItemStack(itemIn, 1, 5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,6 +349,7 @@ public class
|
||||||
static void addSmeltingRecipes() {
|
static void addSmeltingRecipes() {
|
||||||
GameRegistry.addSmelting(ItemDusts.getDustByName("iron", 1), new ItemStack(Items.iron_ingot), 1F);
|
GameRegistry.addSmelting(ItemDusts.getDustByName("iron", 1), new ItemStack(Items.iron_ingot), 1F);
|
||||||
GameRegistry.addSmelting(ItemDusts.getDustByName("gold", 1), new ItemStack(Items.gold_ingot), 1F);
|
GameRegistry.addSmelting(ItemDusts.getDustByName("gold", 1), new ItemStack(Items.gold_ingot), 1F);
|
||||||
|
GameRegistry.addSmelting(ItemParts.getPartByName("rubberSap"), ItemParts.getPartByName("rubber"), 1F);
|
||||||
|
|
||||||
Core.logHelper.info("Smelting Recipes Added");
|
Core.logHelper.info("Smelting Recipes Added");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,16 @@ public class TreeGenerator implements IWorldGenerator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||||
int chance = 0;
|
int chance = 1;
|
||||||
BiomeGenBase biomeGenBase = world.getBiomeGenForCoords( new BlockPos(chunkX * 16 + 16, 72, chunkZ * 16 + 16));
|
BiomeGenBase biomeGenBase = world.getBiomeGenForCoords( new BlockPos(chunkX * 16 + 16, 72, chunkZ * 16 + 16));
|
||||||
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)){
|
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)){
|
||||||
chance += random.nextInt(10) + 5;
|
chance += random.nextInt(15) + 5;
|
||||||
}
|
}
|
||||||
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)){
|
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)){
|
||||||
chance += random.nextInt(5) + 1;
|
chance += random.nextInt(5) + 1;
|
||||||
}
|
}
|
||||||
if(world.provider.isSurfaceWorld()){
|
if(world.provider.isSurfaceWorld()){
|
||||||
if(random.nextInt(100) + 1 <= chance * 2){
|
if(random.nextInt(chance) == 0){
|
||||||
treeGenerator.generate(world, random, new BlockPos(chunkX * 16 + random.nextInt(16), 72, chunkZ * 16 + random.nextInt(16)));
|
treeGenerator.generate(world, random, new BlockPos(chunkX * 16 + random.nextInt(16), 72, chunkZ * 16 + random.nextInt(16)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ tile.techreborn.electricfurnace.name=Electric Furnace
|
||||||
tile.techreborn.machineFrame.advancedMachine.name=Advanced Machine Block
|
tile.techreborn.machineFrame.advancedMachine.name=Advanced Machine Block
|
||||||
tile.techreborn.machineFrame.machine.name=Machine Block
|
tile.techreborn.machineFrame.machine.name=Machine Block
|
||||||
|
|
||||||
|
#Blocks
|
||||||
|
tile.techreborn.rubberlog.name=Rubber log
|
||||||
|
tile.techreborn.rubberleaves.name=Rubber Leaves
|
||||||
|
|
||||||
#Ores
|
#Ores
|
||||||
tile.techreborn.ore.Galena.name=Galena Ore
|
tile.techreborn.ore.Galena.name=Galena Ore
|
||||||
tile.techreborn.ore.Iridium.name=Iridium Ore
|
tile.techreborn.ore.Iridium.name=Iridium Ore
|
||||||
|
@ -564,6 +568,8 @@ item.techreborn.part.computerMonitor.name=Computer Monitor
|
||||||
item.techreborn.part.machineParts.name=Machine Parts
|
item.techreborn.part.machineParts.name=Machine Parts
|
||||||
item.techreborn.part.neutronReflector.name=Neutron Reflector
|
item.techreborn.part.neutronReflector.name=Neutron Reflector
|
||||||
item.techreborn.part.thickNeutronReflector.name=Thick Neutron Reflector
|
item.techreborn.part.thickNeutronReflector.name=Thick Neutron Reflector
|
||||||
|
item.techreborn.part.rubberSap.name=Sap
|
||||||
|
item.techreborn.part.rubber.name=Rubber
|
||||||
|
|
||||||
#Tools
|
#Tools
|
||||||
item.techreborn.rockcutter.name=Rockcutter
|
item.techreborn.rockcutter.name=Rockcutter
|
||||||
|
|
Loading…
Reference in a new issue