Merge branch '1.8.9' of https://github.com/TechReborn/TechReborn into 1.8.9
This commit is contained in:
commit
aa41d576e3
9 changed files with 187 additions and 10 deletions
104
src/main/java/techreborn/blocks/BlockRubberLeaves.java
Normal file
104
src/main/java/techreborn/blocks/BlockRubberLeaves.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import biomesoplenty.common.enums.BOPTrees;
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockPlanks;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.RebornCore;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by mark on 20/02/2016.
|
||||
*/
|
||||
public class BlockRubberLeaves extends BlockLeaves implements ITexturedBlock {
|
||||
|
||||
public BlockRubberLeaves() {
|
||||
super();
|
||||
setUnlocalizedName("techreborn.rubberleaves");
|
||||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
RebornCore.jsonDestroyer.registerObject(this);
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPlanks.EnumType getWoodType(int meta) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
|
||||
List<ItemStack> list = new java.util.ArrayList<ItemStack>();
|
||||
list.add(new ItemStack(this, 1, 0));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumWorldBlockLayer getBlockLayer()
|
||||
{
|
||||
return Blocks.leaves.getBlockLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return Blocks.leaves.isOpaqueCube();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack createStackedBlock(IBlockState state)
|
||||
{
|
||||
IBlockState newState = state.withProperty(CHECK_DECAY, Boolean.valueOf(false)).withProperty(DECAYABLE, Boolean.valueOf(false));
|
||||
|
||||
return super.createStackedBlock(newState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState iBlockState, EnumFacing enumFacing) {
|
||||
return "techreborn:blocks/rubber_leaves";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] { CHECK_DECAY, DECAYABLE});
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBlockState getStateFromMeta(int meta)
|
||||
{
|
||||
return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta & 1) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 2) > 0));
|
||||
}
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state)
|
||||
{
|
||||
int meta = 0;
|
||||
if (!((Boolean)state.getValue(DECAYABLE)).booleanValue())
|
||||
{
|
||||
meta |= 1;
|
||||
}
|
||||
if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue())
|
||||
{
|
||||
meta |= 2;
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
}
|
63
src/main/java/techreborn/blocks/BlockRubberLog.java
Normal file
63
src/main/java/techreborn/blocks/BlockRubberLog.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.RebornCore;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
|
||||
/**
|
||||
* Created by mark on 19/02/2016.
|
||||
*/
|
||||
public class BlockRubberLog extends Block implements ITexturedBlock {
|
||||
public BlockRubberLog() {
|
||||
super(Material.wood);
|
||||
setUnlocalizedName("techreborn.rubberlog");
|
||||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
this.setHardness(2.0F);
|
||||
this.setStepSound(soundTypeWood);
|
||||
RebornCore.jsonDestroyer.registerObject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureNameFromState(IBlockState iBlockState, EnumFacing enumFacing) {
|
||||
if(enumFacing == EnumFacing.DOWN || enumFacing == EnumFacing.UP){
|
||||
return "techreborn:blocks/rubber_log_side";
|
||||
}
|
||||
return "techreborn:blocks/rubber_log";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int amountOfStates() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSustainLeaves(net.minecraft.world.IBlockAccess world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWood(net.minecraft.world.IBlockAccess world, BlockPos pos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
|
||||
int i = 4;
|
||||
int j = i + 1;
|
||||
|
||||
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))) {
|
||||
IBlockState iblockstate = worldIn.getBlockState(blockpos);
|
||||
|
||||
if (iblockstate.getBlock().isLeaves(worldIn, blockpos)) {
|
||||
iblockstate.getBlock().beginLeavesDecay(worldIn, blockpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -32,6 +32,9 @@ public abstract class BaseRecipeWrapper<T extends BaseRecipe> extends BlankRecip
|
|||
}
|
||||
|
||||
private static List<ItemStack> expandOreDict(ItemStack itemStack) {
|
||||
if(itemStack == null){
|
||||
return new ArrayList<ItemStack>();
|
||||
}
|
||||
int[] oreIds = OreDictionary.getOreIDs(itemStack);
|
||||
if (oreIds.length == 0) {
|
||||
return Collections.singletonList(itemStack);
|
||||
|
|
|
@ -72,6 +72,8 @@ public class ModBlocks {
|
|||
public static Block storage;
|
||||
public static Block storage2;
|
||||
public static Block machineframe;
|
||||
public static Block rubberLog;
|
||||
public static Block rubberLeaves;
|
||||
|
||||
public static void init() {
|
||||
thermalGenerator = new BlockThermalGenerator();
|
||||
|
@ -247,6 +249,11 @@ public class ModBlocks {
|
|||
|
||||
GameRegistry.registerTileEntity(TileMachineBase.class, "TileMachineBaseTR");
|
||||
|
||||
rubberLog = new BlockRubberLog();
|
||||
GameRegistry.registerBlock(rubberLog, "rubberLog");
|
||||
rubberLeaves = new BlockRubberLeaves();
|
||||
GameRegistry.registerBlock(rubberLeaves, "rubberLeaves");
|
||||
|
||||
registerOreDict();
|
||||
Core.logHelper.info("TechReborns Blocks Loaded");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.minecraft.world.biome.BiomeGenBase;
|
|||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -15,23 +17,21 @@ import java.util.Random;
|
|||
*/
|
||||
public class TreeGenerator implements IWorldGenerator {
|
||||
|
||||
RubberTreeGenerator treeGenerator = new RubberTreeGenerator(false, 6, Blocks.log.getDefaultState(), Blocks.leaves.getDefaultState(), false);
|
||||
|
||||
RubberTreeGenerator treeGenerator = new RubberTreeGenerator(false, 10, ModBlocks.rubberLog.getDefaultState(), ModBlocks.rubberLeaves.getDefaultState(), false);
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
|
||||
int chance = 0;
|
||||
BiomeGenBase biomeGenBase = world.getBiomeGenForCoords( new BlockPos(chunkX * 16 + 16, 72, chunkZ * 16 + 16));
|
||||
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)){
|
||||
chance += random.nextInt(10) + 5;
|
||||
}
|
||||
if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)){
|
||||
chance += random.nextInt(5) + 1;
|
||||
}
|
||||
// if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.SWAMP)){
|
||||
// chance += random.nextInt(10) + 5;
|
||||
// }
|
||||
// if(BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.FOREST) || BiomeDictionary.isBiomeOfType(biomeGenBase, BiomeDictionary.Type.JUNGLE)){
|
||||
// chance += random.nextInt(5) + 1;
|
||||
// }
|
||||
chance = 10;
|
||||
if(world.provider.isSurfaceWorld()){
|
||||
if(random.nextInt(100) + 1 <= chance * 2){
|
||||
|
||||
|
||||
treeGenerator.generate(world, random, new BlockPos(chunkX * 16 + random.nextInt(16), 72, chunkZ * 16 + random.nextInt(16)));
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
Loading…
Reference in a new issue