Last active
August 29, 2015 14:25
-
-
Save Mythra13/7f35758beb55ab3ee710 to your computer and use it in GitHub Desktop.
Myth Adventure (my first mod)
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
{ | |
"variants": { | |
"check_decay=false,decayable=false,variant=apple": { "model": "mythadventure:apple_leaves" }, | |
"check_decay=true,decayable=false,variant=apple": { "model": "mythadventure:apple_leaves" }, | |
"check_decay=true,decayable=true,variant=apple": { "model": "mythadventure:apple_leaves" }, | |
"check_decay=false,decayable=true,variant=apple": { "model": "mythadventure:apple_leaves" }, | |
"check_decay=false,decayable=false,variant=pine": { "model": "mythadventure:pine_leaves" }, | |
"check_decay=true,decayable=false,variant=pine": { "model": "mythadventure:pine_leaves" }, | |
"check_decay=true,decayable=true,variant=pine": { "model": "mythadventure:pine_leaves" }, | |
"check_decay=false,decayable=true,variant=pine": { "model": "mythadventure:pine_leaves" }, | |
"check_decay=false,decayable=false,variant=willow": { "model": "mythadventure:willow_leaves" }, | |
"check_decay=true,decayable=false,variant=willow": { "model": "mythadventure:willow_leaves" }, | |
"check_decay=true,decayable=true,variant=willow": { "model": "mythadventure:willow_leaves" }, | |
"check_decay=false,decayable=true,variant=willow": { "model": "mythadventure:willow_leaves" } | |
} | |
} |
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
{ | |
"variants": { | |
"axis=y,variant=apple": { "model": "mythadventure:apple_log" }, | |
"axis=z,variant=apple": { "model": "mythadventure:apple_log_side" }, | |
"axis=x,variant=apple": { "model": "mythadventure:apple_log_side", "y": 90 }, | |
"axis=none,variant=apple": { "model": "mythadventure:apple_bark" }, | |
"axis=y,variant=pine": { "model": "mythadventure:pine_log" }, | |
"axis=z,variant=pine": { "model": "mythadventure:pine_log_side" }, | |
"axis=x,variant=pine": { "model": "mythadventure:pine_log_side", "y": 90 }, | |
"axis=none,variant=pine": { "model": "mythadventure:pine_bark" }, | |
"axis=y,variant=willow": { "model": "mythadventure:willow_log" }, | |
"axis=z,variant=willow": { "model": "mythadventure:willow_log_side" }, | |
"axis=x,variant=willow": { "model": "mythadventure:willow_log_side", "y": 90 }, | |
"axis=none,variant=willow": { "model": "mythadventure:willow_bark" } | |
} | |
} |
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
package net.mythadventure.mod; | |
import (list of imports) | |
public class ClientProxy extends CommonProxy | |
{ | |
@Override | |
public void preInit(FMLPreInitializationEvent e) { | |
super.preInit(e); | |
ModelBakery.addVariantName(Item.getItemFromBlock(MythAdventure.Myth_Log), new String[]{MythAdventure.MODID + ":apple_log", MythAdventure.MODID + ":pine_log", MythAdventure.MODID + ":willow_log"}); | |
ModelBakery.addVariantName(Item.getItemFromBlock(MythAdventure.Myth_Leaves), new String[]{MythAdventure.MODID + ":apple_leaves", MythAdventure.MODID + ":pine_leaves", MythAdventure.MODID + ":willow_leaves"}); | |
} | |
@Override | |
public void init(FMLInitializationEvent e) { | |
super.init(e); | |
Item log = GameRegistry.findItem(MythAdventure.MODID, "log"); | |
registerItem(log, 0, MythAdventure.MODID + ":apple_log"); | |
registerItem(log, 1, MythAdventure.MODID + ":pine_log"); | |
registerItem(log, 2, MythAdventure.MODID + ":willow_log"); | |
Item leaves = GameRegistry.findItem(MythAdventure.MODID, "leaves"); | |
registerItem(leaves, 0, MythAdventure.MODID + ":apple_leaves"); | |
registerItem(leaves, 1, MythAdventure.MODID + ":pine_leaves"); | |
registerItem(leaves, 2, MythAdventure.MODID + ":willow_leaves"); | |
} | |
@Override | |
public void postInit(FMLPostInitializationEvent e) { | |
super.postInit(e); | |
} | |
} |
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
package net.mythadventure.mod; | |
import (list of imports) | |
public class CommonProxy { | |
public void preInit(FMLPreInitializationEvent e) { | |
MythAdventure.Myth_Log = (CustomLog) new CustomLog("log").setCreativeTab(MythAdventure.mythadventureTab); | |
MythAdventure.Myth_Leaves = (CustomLeaves) new CustomLeaves("leaves").setCreativeTab(MythAdventure.mythadventureTab); | |
} | |
public void init(FMLInitializationEvent e) { | |
} | |
public void postInit(FMLPostInitializationEvent e) { | |
} | |
} |
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
package net.mythadventure.mod.blocks; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
import javax.annotation.Nullable; | |
import com.google.common.base.Function; | |
import com.google.common.base.Predicate; | |
import net.minecraft.block.BlockLeaves; | |
import net.minecraft.block.properties.IProperty; | |
import net.minecraft.block.properties.PropertyEnum; | |
import net.minecraft.block.state.BlockState; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.client.resources.model.ModelResourceLocation; | |
import net.minecraft.creativetab.CreativeTabs; | |
import net.minecraft.entity.player.EntityPlayer; | |
import net.minecraft.init.Blocks; | |
import net.minecraft.init.Items; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.tileentity.TileEntity; | |
import net.minecraft.util.BlockPos; | |
import net.minecraft.util.EnumWorldBlockLayer; | |
import net.minecraft.world.ColorizerFoliage; | |
import net.minecraft.world.IBlockAccess; | |
import net.minecraft.world.World; | |
import net.minecraft.world.biome.BiomeColorHelper; | |
import net.minecraftforge.fml.common.registry.GameRegistry; | |
import net.minecraftforge.fml.relauncher.Side; | |
import net.minecraftforge.fml.relauncher.SideOnly; | |
import net.mythadventure.mod.MythAdventure; | |
import net.mythadventure.mod.items.ItemModLeaves; | |
import net.mythadventure.mod.world.LeafColors; | |
public class CustomLeaves extends BlockLeaves { | |
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", CustomPlanks.EnumType.class, new Predicate() { | |
public boolean apply(CustomPlanks.EnumType type) { | |
return type.getMetadata() < 4; | |
} | |
public boolean apply(Object p_apply_1_) { | |
return this.apply((CustomPlanks.EnumType)p_apply_1_); | |
} | |
}); | |
public CustomLeaves(String modelName) { | |
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, CustomPlanks.EnumType.APPLE).withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true))); | |
this.setUnlocalizedName(modelName); | |
; | |
System.out.println("INITIALIZING BLOCK: " +modelName); | |
GameRegistry.registerBlock(this, ItemModLeaves.class, modelName); // Register the Block using ItemModMultiTexture as the ItemBlock class | |
} | |
@SideOnly(Side.CLIENT) | |
public void RegisterRenderer(String modelName) { | |
System.out.println("REGISTERING BLOCK RENDERER: " +modelName); | |
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this), 0, new ModelResourceLocation(MythAdventure.MODID+":" + modelName, "inventory")); | |
} | |
/** | |
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) | |
*/ | |
@SideOnly(Side.CLIENT) | |
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { | |
list.add(new ItemStack(itemIn, 1, CustomPlanks.EnumType.APPLE.getMetadata())); | |
list.add(new ItemStack(itemIn, 1, CustomPlanks.EnumType.PINE.getMetadata())); | |
list.add(new ItemStack(itemIn, 1, CustomPlanks.EnumType.WILLOW.getMetadata())); | |
} | |
@SideOnly(Side.CLIENT) | |
public int getRenderColor(IBlockState state) { | |
if (state.getBlock() != this) { | |
return super.getRenderColor(state); | |
}else { | |
CustomPlanks.EnumType enumtype = (CustomPlanks.EnumType)state.getValue(VARIANT); | |
return enumtype == CustomPlanks.EnumType.APPLE ? LeafColors.apple() : (enumtype == CustomPlanks.EnumType.PINE ? LeafColors.pine() : (enumtype == CustomPlanks.EnumType.WILLOW ? LeafColors.willow() : super.getRenderColor(state))); | |
} | |
} | |
@SideOnly(Side.CLIENT) | |
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { | |
IBlockState iblockstate = worldIn.getBlockState(pos); | |
if (iblockstate.getBlock() == this) { | |
CustomPlanks.EnumType enumtype = (CustomPlanks.EnumType)iblockstate.getValue(VARIANT); | |
if (enumtype == CustomPlanks.EnumType.APPLE) { | |
return ColorizerFoliage.getFoliageColorBirch(); | |
} | |
if (enumtype == CustomPlanks.EnumType.PINE) { | |
return ColorizerFoliage.getFoliageColorPine(); | |
} | |
if (enumtype == CustomPlanks.EnumType.WILLOW) { | |
return ColorizerFoliage.getFoliageColorBirch(); | |
} | |
} | |
return super.colorMultiplier(worldIn, pos, renderPass); | |
} | |
protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) { | |
if (state.getValue(VARIANT) == CustomPlanks.EnumType.APPLE && worldIn.rand.nextInt(chance) == 0) { | |
spawnAsEntity(worldIn, pos, new ItemStack(Items.apple, 1, 0)); | |
} | |
} | |
protected int getSaplingDropChance(IBlockState state) { | |
return state.getValue(VARIANT) == CustomPlanks.EnumType.APPLE ? 40 : super.getSaplingDropChance(state); | |
} | |
protected ItemStack createStackedBlock(IBlockState state) { | |
return new ItemStack(Item.getItemFromBlock(this), 1, ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata()); | |
} | |
/** | |
* Convert the given metadata into a BlockState for this Block | |
*/ | |
public IBlockState getStateFromMeta(int meta) { | |
return this.getDefaultState().withProperty(VARIANT, CustomPlanks.EnumType.byMetadata((meta & 3) % 4)).withProperty(DECAYABLE, Boolean.valueOf((meta & 4) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 8) > 0)); | |
} | |
/** | |
* Convert the BlockState into the correct metadata value | |
*/ | |
public int getMetaFromState(IBlockState state){ | |
byte b0 = 0; | |
int i = b0 | ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
if (!((Boolean)state.getValue(DECAYABLE)).booleanValue()) { | |
i |= 4; | |
} | |
if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue()) { | |
i |= 8; | |
} | |
return i; | |
} | |
protected BlockState createBlockState() { | |
return new BlockState(this, new IProperty[] {VARIANT, CHECK_DECAY, DECAYABLE}); | |
} | |
/** | |
* Get the damage value that this Block should drop | |
*/ | |
public int damageDropped(IBlockState state) { | |
return ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
} | |
public boolean isOpaqueCube() { | |
return false; | |
} | |
@SideOnly(Side.CLIENT) | |
public EnumWorldBlockLayer getBlockLayer() { | |
return Blocks.leaves.getBlockLayer(); | |
} | |
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te) {{ | |
super.harvestBlock(worldIn, player, pos, state, te); | |
} | |
} | |
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) { | |
IBlockState state = world.getBlockState(pos); | |
return new ArrayList(Arrays.asList(new ItemStack(this, 1, ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata()))); | |
} | |
@Override | |
public net.minecraft.block.BlockPlanks.EnumType getWoodType(int meta) { | |
return null; | |
} | |
} |
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
package net.mythadventure.mod.blocks; | |
import (list of imports) | |
public class CustomLog extends BlockLog { | |
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", CustomPlanks.EnumType.class, new Predicate() { | |
public boolean apply(CustomPlanks.EnumType type) { | |
return type.getMetadata() < 4; | |
} | |
public boolean apply(Object p_apply_1_) { | |
return this.apply((CustomPlanks.EnumType)p_apply_1_); | |
} | |
}); | |
public CustomLog(String modelName) { | |
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, CustomPlanks.EnumType.APPLE).withProperty(LOG_AXIS, CustomLog.EnumAxis.Y)); | |
this.setUnlocalizedName(modelName); | |
System.out.println("INITIALIZING BLOCK: " +modelName); | |
GameRegistry.registerBlock(this, ItemModMultiTexture.class, modelName); // Register the Block using ItemModMultiTexture as the ItemBlock class | |
((ItemModMultiTexture) Item.getItemFromBlock(this)).setNameFunction(new Function<ItemStack, String>() { // Set the Item's name function | |
@Nullable | |
public String apply(ItemStack input) { | |
return CustomPlanks.EnumType.byMetadata(input.getItemDamage()).getName(); | |
} | |
}); | |
} | |
@SideOnly(Side.CLIENT) | |
public void RegisterRenderer(String modelName) { | |
System.out.println("REGISTERING BLOCK RENDERER: " +modelName); | |
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this), 0, new ModelResourceLocation(MythAdventure.MODID+":" + modelName, "inventory")); | |
} | |
/** | |
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) | |
*/ | |
@SideOnly(Side.CLIENT) | |
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { | |
list.add(new ItemStack(itemIn, 1, CustomPlanks.EnumType.APPLE.getMetadata())); | |
list.add(new ItemStack(itemIn, 1, CustomPlanks.EnumType.PINE.getMetadata())); | |
list.add(new ItemStack(itemIn, 1, CustomPlanks.EnumType.WILLOW.getMetadata())); | |
} | |
public IBlockState getStateFromMeta(int meta) { | |
IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, CustomPlanks.EnumType.byMetadata((meta & 3) % 4)); | |
switch (meta & 12) { | |
case 0: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); | |
break; | |
case 4: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); | |
break; | |
case 8: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); | |
break; | |
default: | |
iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); | |
} | |
return iblockstate; | |
} | |
public int getMetaFromState(IBlockState state){ | |
byte b0 = 0; | |
int i = b0 | ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
switch (CustomLog.SwitchEnumAxis.AXIS_LOOKUP[((BlockLog.EnumAxis)state.getValue(LOG_AXIS)).ordinal()]) { | |
case 1: | |
i |= 4; | |
break; | |
case 2: | |
i |= 8; | |
break; | |
case 3: | |
i |= 12; | |
} | |
return i; | |
} | |
protected BlockState createBlockState() { | |
return new BlockState(this, new IProperty[] {VARIANT, LOG_AXIS}); | |
} | |
protected ItemStack createStackedBlock(IBlockState state) { | |
return new ItemStack(Item.getItemFromBlock(this), 1, ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata()); | |
} | |
public int damageDropped(IBlockState state) { | |
return ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
} | |
static final class SwitchEnumAxis { | |
static final int[] AXIS_LOOKUP = new int[BlockLog.EnumAxis.values().length]; | |
static { | |
try { | |
AXIS_LOOKUP[BlockLog.EnumAxis.X.ordinal()] = 1; | |
} | |
catch (NoSuchFieldError var3) | |
{ ; } | |
try { | |
AXIS_LOOKUP[BlockLog.EnumAxis.Z.ordinal()] = 2; | |
} | |
catch (NoSuchFieldError var2) | |
{ ; } | |
try { | |
AXIS_LOOKUP[BlockLog.EnumAxis.NONE.ordinal()] = 3; | |
} | |
catch (NoSuchFieldError var1) | |
{ ; } | |
} | |
} | |
} |
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
package net.mythadventure.mod.blocks; | |
import java.util.List; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockPlanks; | |
import net.minecraft.block.material.Material; | |
import net.minecraft.block.properties.IProperty; | |
import net.minecraft.block.properties.PropertyEnum; | |
import net.minecraft.block.state.BlockState; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.creativetab.CreativeTabs; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.IStringSerializable; | |
import net.minecraftforge.fml.relauncher.Side; | |
import net.minecraftforge.fml.relauncher.SideOnly; | |
public class CustomPlanks extends Block{ | |
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", CustomPlanks.EnumType.class); | |
public CustomPlanks() | |
{ | |
super(Material.wood); | |
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, CustomPlanks.EnumType.APPLE)); | |
this.setCreativeTab(CreativeTabs.tabBlock); | |
} | |
/** | |
* Get the damage value that this Block should drop | |
*/ | |
public int damageDropped(IBlockState state) | |
{ | |
return ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
} | |
/** | |
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) | |
*/ | |
@SideOnly(Side.CLIENT) | |
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) | |
{ | |
CustomPlanks.EnumType[] aenumtype = CustomPlanks.EnumType.values(); | |
int i = aenumtype.length; | |
for (int j = 0; j < i; ++j) | |
{ | |
CustomPlanks.EnumType enumtype = aenumtype[j]; | |
list.add(new ItemStack(itemIn, 1, enumtype.getMetadata())); | |
} | |
} | |
/** | |
* Convert the given metadata into a BlockState for this Block | |
*/ | |
public IBlockState getStateFromMeta(int meta) | |
{ | |
return this.getDefaultState().withProperty(VARIANT, CustomPlanks.EnumType.byMetadata(meta)); | |
} | |
/** | |
* Convert the BlockState into the correct metadata value | |
*/ | |
public int getMetaFromState(IBlockState state) | |
{ | |
return ((CustomPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); | |
} | |
protected BlockState createBlockState() | |
{ | |
return new BlockState(this, new IProperty[] {VARIANT}); | |
} | |
public static enum EnumType implements IStringSerializable | |
{ | |
APPLE(0, "apple"), | |
PINE(1, "pine"), | |
WILLOW(2, "willow"); | |
private static final CustomPlanks.EnumType[] META_LOOKUP = new CustomPlanks.EnumType[values().length]; | |
private final int meta; | |
private final String name; | |
private final String unlocalizedName; | |
private EnumType(int meta, String name) | |
{ | |
this(meta, name, name); | |
} | |
private EnumType(int meta, String name, String unlocalizedName) | |
{ | |
this.meta = meta; | |
this.name = name; | |
this.unlocalizedName = unlocalizedName; | |
} | |
public int getMetadata() | |
{ | |
return this.meta; | |
} | |
public String toString() | |
{ | |
return this.name; | |
} | |
public static CustomPlanks.EnumType byMetadata(int meta) | |
{ | |
if (meta < 0 || meta >= META_LOOKUP.length) | |
{ | |
meta = 0; | |
} | |
return META_LOOKUP[meta]; | |
} | |
public String getName() | |
{ | |
return this.name; | |
} | |
public String getUnlocalizedName() | |
{ | |
return this.unlocalizedName; | |
} | |
static | |
{ | |
CustomPlanks.EnumType[] var0 = values(); | |
int var1 = var0.length; | |
for (int var2 = 0; var2 < var1; ++var2) | |
{ | |
CustomPlanks.EnumType var3 = var0[var2]; | |
META_LOOKUP[var3.getMetadata()] = var3; | |
} | |
} | |
} | |
} |
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
package net.mythadventure.mod.blocks; | |
import java.util.List; | |
import java.util.Random; | |
import javax.annotation.Nullable; | |
import com.google.common.base.Function; | |
import net.minecraft.block.BlockBush; | |
import net.minecraft.block.IGrowable; | |
import net.minecraft.block.properties.IProperty; | |
import net.minecraft.block.properties.PropertyEnum; | |
import net.minecraft.block.properties.PropertyInteger; | |
import net.minecraft.block.state.BlockState; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.client.Minecraft; | |
import net.minecraft.client.resources.model.ModelResourceLocation; | |
import net.minecraft.creativetab.CreativeTabs; | |
import net.minecraft.init.Blocks; | |
import net.minecraft.item.Item; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.util.BlockPos; | |
import net.minecraft.world.World; | |
import net.minecraft.world.gen.feature.WorldGenBigTree; | |
import net.minecraft.world.gen.feature.WorldGenTrees; | |
import net.minecraft.world.gen.feature.WorldGenerator; | |
import net.minecraftforge.fml.common.registry.GameRegistry; | |
import net.minecraftforge.fml.relauncher.Side; | |
import net.minecraftforge.fml.relauncher.SideOnly; | |
import net.mythadventure.mod.MythAdventure; | |
import net.mythadventure.mod.items.ItemModMultiTexture; | |
import net.mythadventure.mod.world.WorldGenAppleTree; | |
import net.mythadventure.mod.world.WorldGenPineTree; | |
import net.mythadventure.mod.world.WorldGenWillowTree; | |
public class CustomSapling extends BlockBush implements IGrowable { | |
public static final PropertyEnum TYPE = PropertyEnum.create("type", CustomPlanks.EnumType.class); | |
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1); | |
public CustomSapling(String modelName) { | |
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, CustomPlanks.EnumType.APPLE).withProperty(STAGE, Integer.valueOf(0))); | |
this.setUnlocalizedName(modelName); | |
float f = 0.4F; | |
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f); | |
System.out.println("INITIALIZING BLOCK: " +modelName); | |
GameRegistry.registerBlock(this, ItemModMultiTexture.class, modelName); // Register the Block using ItemModMultiTexture as the ItemBlock class | |
((ItemModMultiTexture) Item.getItemFromBlock(this)).setNameFunction(new Function<ItemStack, String>() { // Set the Item's name function | |
@Nullable | |
public String apply(ItemStack input) { | |
return CustomPlanks.EnumType.byMetadata(input.getItemDamage()).getName(); | |
} | |
}); | |
} | |
@SideOnly(Side.CLIENT) | |
public void RegisterRenderer(String modelName) { | |
System.out.println("REGISTERING BLOCK RENDERER: " +modelName); | |
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this), 0, new ModelResourceLocation(MythAdventure.MODID+":" + modelName, "inventory")); | |
} | |
/** | |
* returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) | |
*/ | |
@SideOnly(Side.CLIENT) | |
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { | |
CustomPlanks.EnumType[] aenumtype = CustomPlanks.EnumType.values(); | |
int i = aenumtype.length; | |
for (int j = 0; j < i; ++j) { | |
CustomPlanks.EnumType enumtype = aenumtype[j]; | |
list.add(new ItemStack(itemIn, 1, enumtype.getMetadata())); | |
} | |
} | |
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { | |
if (!worldIn.isRemote) { | |
super.updateTick(worldIn, pos, state, rand); | |
if (worldIn.getLightFromNeighbors(pos.up()) >= 9 && rand.nextInt(7) == 0) { | |
this.grow(worldIn, pos, state, rand); | |
} | |
} | |
} | |
//markOrGrowMarked | |
public void grow(World worldIn, BlockPos pos, IBlockState state, Random rand) { | |
if (((Integer)state.getValue(STAGE)).intValue() == 0) { | |
worldIn.setBlockState(pos, state.cycleProperty(STAGE), 4); | |
}else { | |
this.generateTree(worldIn, pos, state, rand); | |
} | |
} | |
public void generateTree(World worldIn, BlockPos pos, IBlockState state, Random rand) { | |
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(worldIn, rand, pos)) return; | |
Object object = rand.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true); | |
int i = 0; | |
int j = 0; | |
boolean flag = false; | |
switch (CustomSapling.SwitchEnumType.WOOD_TYPE_LOOKUP[((CustomPlanks.EnumType)state.getValue(TYPE)).ordinal()]) { | |
case 1: | |
object = new WorldGenAppleTree(MythAdventure.Myth_Log, MythAdventure.Myth_Leaves, CustomPlanks.EnumType.APPLE.getMetadata(), CustomPlanks.EnumType.APPLE.getMetadata(), false, 5, 3, false); | |
break; | |
case 2: | |
object = new WorldGenPineTree(CustomPlanks.EnumType.PINE.getMetadata()); | |
break; | |
case 3: | |
object = new WorldGenWillowTree(MythAdventure.Myth_Log, MythAdventure.Myth_Leaves, CustomPlanks.EnumType.WILLOW.getMetadata(), CustomPlanks.EnumType.WILLOW.getMetadata(), true, 9, false); | |
//I've added the leaves DECAYABLE code here | |
IBlockState leavesState = MythAdventure.Myth_Leaves.getDefaultState().withProperty(CustomLeaves.VARIANT, CustomPlanks.EnumType.WILLOW).withProperty(BlockLeaves.DECAYABLE, false); | |
int leavesMeta = MythAdventure.Myth_Leaves.getMetaFromState(leavesState); | |
WorldGenWillowTree treeGen = new WorldGenWillowTree(MythAdventure.Myth_Log, MythAdventure.Myth_Leaves, CustomPlanks.EnumType.WILLOW.getMetadata(), leavesMeta); | |
} | |
IBlockState iblockstate1 = Blocks.air.getDefaultState(); | |
if (flag) { | |
worldIn.setBlockState(pos.add(i, 0, j), iblockstate1, 4); | |
worldIn.setBlockState(pos.add(i + 1, 0, j), iblockstate1, 4); | |
worldIn.setBlockState(pos.add(i, 0, j + 1), iblockstate1, 4); | |
worldIn.setBlockState(pos.add(i + 1, 0, j + 1), iblockstate1, 4); | |
}else { | |
worldIn.setBlockState(pos, iblockstate1, 4); | |
} | |
if (!((WorldGenerator)object).generate(worldIn, rand, pos.add(i, 0, j))) { | |
if (flag) { | |
worldIn.setBlockState(pos.add(i, 0, j), state, 4); | |
worldIn.setBlockState(pos.add(i + 1, 0, j), state, 4); | |
worldIn.setBlockState(pos.add(i, 0, j + 1), state, 4); | |
worldIn.setBlockState(pos.add(i + 1, 0, j + 1), state, 4); | |
}else { | |
worldIn.setBlockState(pos, state, 4); | |
} | |
} | |
} | |
/** | |
* Check whether the given BlockPos has a Sapling of the given type | |
*/ | |
public boolean isTypeAt(World worldIn, BlockPos pos, CustomPlanks.EnumType type) { | |
IBlockState iblockstate = worldIn.getBlockState(pos); | |
return iblockstate.getBlock() == this && iblockstate.getValue(TYPE) == type; | |
} | |
/** | |
* Get the damage value that this Block should drop | |
*/ | |
public int damageDropped(IBlockState state) { | |
return ((CustomPlanks.EnumType)state.getValue(TYPE)).getMetadata(); | |
} | |
/** | |
* Whether this IGrowable can grow | |
*/ | |
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) { | |
return true; | |
} | |
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) { | |
return (double)worldIn.rand.nextFloat() < 0.45D; | |
} | |
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) { | |
this.grow(worldIn, pos, state, rand); | |
} | |
/** | |
* Convert the given metadata into a BlockState for this Block | |
*/ | |
public IBlockState getStateFromMeta(int meta) { | |
return this.getDefaultState().withProperty(TYPE, CustomPlanks.EnumType.byMetadata(meta & 7)).withProperty(STAGE, Integer.valueOf((meta & 8) >> 3)); | |
} | |
/** | |
* Convert the BlockState into the correct metadata value | |
*/ | |
public int getMetaFromState(IBlockState state) { | |
byte b0 = 0; | |
int i = b0 | ((CustomPlanks.EnumType)state.getValue(TYPE)).getMetadata(); | |
i |= ((Integer)state.getValue(STAGE)).intValue() << 3; | |
return i; | |
} | |
protected BlockState createBlockState() { | |
return new BlockState(this, new IProperty[] {TYPE, STAGE}); | |
} | |
static final class SwitchEnumType { | |
static final int[] WOOD_TYPE_LOOKUP = new int[CustomPlanks.EnumType.values().length]; | |
static { | |
try { | |
WOOD_TYPE_LOOKUP[CustomPlanks.EnumType.APPLE.ordinal()] = 1; | |
} | |
catch (NoSuchFieldError var3) { | |
; | |
} | |
try { | |
WOOD_TYPE_LOOKUP[CustomPlanks.EnumType.PINE.ordinal()] = 2; | |
} | |
catch (NoSuchFieldError var2) { | |
; | |
} | |
try { | |
WOOD_TYPE_LOOKUP[CustomPlanks.EnumType.WILLOW.ordinal()] = 3; | |
} | |
catch (NoSuchFieldError var1) { | |
; | |
} | |
} | |
} | |
} |
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
package net.mythadventure.mod.items; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockLeaves; | |
import net.minecraft.item.ItemLeaves; | |
import net.minecraft.item.ItemStack; | |
import net.mythadventure.mod.blocks.CustomPlanks; | |
/** | |
* Similar to vanilla's ItemLeaves, but has a constructor with a parameter of type Block instead of BlockLeaves so GameRegistry can instantiate it. | |
* The constructor immediately casts its argument to BlockLeaves, so extending BlockLeaves is still required. | |
* <p/> | |
* Also overrides getUnlocalizedName to use CustomPlanks.EnumType instead of BlockPlanks.EnumType. | |
*/ | |
public class ItemModLeaves extends ItemLeaves { | |
public ItemModLeaves(Block block) { | |
super((BlockLeaves) block); | |
} | |
@Override | |
public String getUnlocalizedName(ItemStack stack) { | |
return block.getUnlocalizedName() + "." + CustomPlanks.EnumType.byMetadata(stack.getItemDamage()).getUnlocalizedName(); | |
} | |
} |
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
package net.mythadventure.mod.items; | |
import com.google.common.base.Function; | |
import net.minecraft.block.Block; | |
import net.minecraft.item.ItemBlock; | |
import net.minecraft.item.ItemStack; | |
/** | |
* Similar to vanilla's ItemMultiTexture, but doesn't have the unused theBlock field and doesn't set nameFunction from the constructor. | |
* <p/> | |
* The latter is so that GameRegistry can correctly instantiate this class via reflection. Class#getConstructor doesn't recognise derived types, | |
* so GameRegistry will try (and fail) to get the constructor with the actual implementation classes instead of the base Block/Function types. | |
*/ | |
public class ItemModMultiTexture extends ItemBlock { | |
protected Function<ItemStack, String> nameFunction; | |
public ItemModMultiTexture(Block block) { | |
super(block); | |
} | |
public Function<ItemStack, String> getNameFunction() { | |
return nameFunction; | |
} | |
public void setNameFunction(Function<ItemStack, String> nameFunction) { | |
this.nameFunction = nameFunction; | |
} | |
@Override | |
public int getMetadata(int damage) { | |
return damage; | |
} | |
@Override | |
public String getUnlocalizedName(ItemStack stack) { | |
return super.getUnlocalizedName() + "." + this.nameFunction.apply(stack); | |
} | |
} |
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
package net.mythadventure.mod.world; | |
import java.awt.Color; | |
public class LeafColors { | |
public static int apple() | |
{ | |
return 10285631; | |
} | |
public static int pine() | |
{ | |
return 9568028; | |
} | |
public static int willow() | |
{ | |
return 6550149; | |
} | |
} |
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
{ | |
"parent": "block/cube_all", | |
"textures": { | |
"all": "mythadventure:blocks/log_apple" | |
} | |
} |
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
{ | |
"parent": "block/leaves", | |
"textures": { | |
"all": "mythadventure:blocks/leaves_apple" | |
} | |
} |
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
{ | |
"parent": "block/cube_column", | |
"textures": { | |
"end": "mythadventure:blocks/log_apple_top", | |
"side": "mythadventure:blocks/log_apple" | |
} | |
} |
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
{ | |
"parent": "block/column_side", | |
"textures": { | |
"end": "mythadventure:blocks/log_apple_top", | |
"side": "mythadventure:blocks/log_apple" | |
} | |
} |
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
{ | |
"parent": "block/leaves", | |
"textures": { | |
"all": "mythadventure:blocks/leaves_pine" | |
} | |
} |
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
{ | |
"parent": "block/leaves", | |
"textures": { | |
"all": "mythadventure:blocks/leaves_willow" | |
} | |
} |
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
{ | |
"parent": "mythadventure:block/apple_leaves", | |
"display": { | |
"thirdperson": { | |
"rotation": [ 10, -45, 170 ], | |
"translation": [ 0, 1.5, -2.75 ], | |
"scale": [ 0.375, 0.375, 0.375 ] | |
} | |
} | |
} |
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
{ | |
"parent": "mythadventure:block/apple_log", | |
"display": { | |
"thirdperson": { | |
"rotation": [ 10, -45, 170 ], | |
"translation": [ 0, 1.5, -2.75 ], | |
"scale": [ 0.375, 0.375, 0.375 ] | |
} | |
} | |
} |
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
{ | |
"parent": "mythadventure:block/pine_leaves", | |
"display": { | |
"thirdperson": { | |
"rotation": [ 10, -45, 170 ], | |
"translation": [ 0, 1.5, -2.75 ], | |
"scale": [ 0.375, 0.375, 0.375 ] | |
} | |
} | |
} |
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
{ | |
"parent": "mythadventure:block/willow_leaves", | |
"display": { | |
"thirdperson": { | |
"rotation": [ 10, -45, 170 ], | |
"translation": [ 0, 1.5, -2.75 ], | |
"scale": [ 0.375, 0.375, 0.375 ] | |
} | |
} | |
} |
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
package net.mythadventure.mod; | |
+import (list of imports) | |
public static CommonProxy proxy; | |
public static CustomLog Myth_Log; | |
public static CustomLeaves Myth_Leaves; | |
public static CreativeTabs mythadventureTab = new CreativeTabs ("mythadventure") { | |
@Override | |
public Item getTabIconItem() { | |
return Item.getItemFromBlock(MythAdventure.Myth_Log); | |
} | |
}; | |
@EventHandler | |
public void preInit(FMLPreInitializationEvent e) { | |
proxy.preInit(e); | |
} | |
@EventHandler | |
public void init(FMLInitializationEvent e) { | |
proxy.init(e); | |
} | |
@EventHandler | |
public void postInit(FMLPostInitializationEvent e) { | |
proxy.postInit(e); | |
} | |
} |
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
package net.mythadventure.mod.world; | |
import java.util.Random; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockLeaves; | |
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.init.Blocks; | |
import net.minecraft.item.Item; | |
import net.minecraft.util.BlockPos; | |
import net.minecraft.world.World; | |
import net.minecraft.world.gen.feature.WorldGenAbstractTree; | |
import net.mythadventure.mod.MythAdventure; | |
import net.mythadventure.mod.blocks.CustomLeaves; | |
import net.mythadventure.mod.blocks.CustomPlanks; | |
import net.mythadventure.mod.blocks.CustomSapling; | |
public class WorldGenWillowTree extends WorldGenAbstractTree { | |
private final int minTreeHeight; | |
private final boolean vinesGrow; | |
private final Block wood; | |
private final Block leaves; | |
private final int metaWood; | |
private final int metaLeaves; | |
public WorldGenWillowTree(Block wood, Block leaves, int metaWood, int metaLeaves) { | |
this(wood, leaves, metaWood, metaLeaves, false, 4, false); | |
} | |
public WorldGenWillowTree(Block wood, Block leaves, int metaWood, int metaLeaves, boolean doBlockNotify, int minTreeHeight, boolean vinesGrow) { | |
super(doBlockNotify); | |
this.wood = wood; | |
this.leaves = leaves; | |
this.minTreeHeight = minTreeHeight; | |
this.metaWood = metaWood; | |
this.metaLeaves = metaLeaves; | |
this.vinesGrow = vinesGrow; | |
} | |
public boolean generate(World world, Random random, BlockPos pos) { | |
int i = random.nextInt(3) + this.minTreeHeight; | |
boolean flag = true; | |
if (pos.getY() >= 1 && pos.getY() + i + 1 <= 256) { | |
byte b0; | |
int l; | |
for (int j = pos.getY(); j <= pos.getY() + 1 + i; ++j) { | |
b0 = 1; | |
if (j == pos.getY()) { | |
b0 = 0; | |
} | |
if (j >= pos.getY() + 1 + i - 2) { | |
b0 = 2; | |
} | |
for (int k = pos.getX() - b0; k <= pos.getX() + b0 && flag; ++k) { | |
for (l = pos.getZ() - b0; l <= pos.getZ() + b0 && flag; ++l) { | |
if (j >= 0 && j < 256) { | |
if (!this.isReplaceable(world, new BlockPos(k, j, l))) { | |
flag = false; | |
} | |
}else { | |
flag = false; | |
} | |
} | |
} | |
} | |
if (!flag) { | |
return false; | |
}else { | |
BlockPos down = pos.down(); | |
Block block1 = world.getBlockState(down).getBlock(); | |
boolean isSoil = block1.canSustainPlant(world, down, net.minecraft.util.EnumFacing.UP, (CustomSapling)MythAdventure.Myth_Sapling); | |
if (isSoil && pos.getY() < 256 - i - 1) { | |
block1.onPlantGrow(world, down, pos); | |
b0 = 3; //the higher the # the farther down and out the tree leaves will generate, default = 3 | |
byte b1 = 0; //the higher the # the farther up and out the tree leaves will generate, default = 0 | |
int i1; | |
int j1; | |
int k1; | |
int l1; | |
BlockPos blockpos1; | |
int topHeight = 11; // default is Math.min(6, nextIntBetween(random, height / 5, height / 3)) | |
generateColumn(world, random, pos, topHeight); | |
int maxLeavesRadius = 3; //default is 2 + topHeight / 4 | |
for (l = pos.getY() - b0 + i; l <= pos.getY() + i; ++l) { | |
i1 = l - (pos.getY() + i); | |
j1 = b1 + 1 - i1 / 2; // b1 + 1 - i1 / 2 removing the "/ 2" gives the tree a more pyramidal shape, the number after "b1" does same but less so | |
for (k1 = pos.getX() - j1; k1 <= pos.getX() + j1; ++k1) { | |
l1 = k1 - pos.getX(); | |
for (int i2 = pos.getZ() - j1; i2 <= pos.getZ() + j1; ++i2) { | |
int j2 = i2 - pos.getZ(); | |
if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || random.nextInt(2) != 0 && i1 != 0) { | |
blockpos1 = new BlockPos(k1, l, i2); | |
Block block = world.getBlockState(blockpos1).getBlock(); | |
if (block.isAir(world, blockpos1) || block.isLeaves(world, blockpos1) || block.getMaterial() == Material.vine) { | |
this.func_175905_a(world, blockpos1, MythAdventure.Myth_Leaves, this.metaLeaves); | |
} | |
} | |
} | |
} | |
} | |
for (int y = 0; y < i; y++) { //default is (int y = 0; y < i; y++) | |
int radius = Math.min(3, 2 + (i - y) / 4); //default = Math.min(3, 2 + (i - y) | |
for (int x = -radius; x <= radius; x++) { | |
for (int z = -radius; z <= radius; z++) { | |
int dist = Math.abs(x) + Math.abs(z); | |
if ((dist < 4) || ((dist == 4) && (random.nextInt(2) == 0))) { | |
blockpos1 = new BlockPos(x, y, z); | |
Block block = world.getBlockState(blockpos1).getBlock(); | |
if (block.isAir(world, blockpos1) || block.isLeaves(world, blockpos1) || block.getMaterial() == Material.vine) { | |
this.func_175905_a(world, blockpos1, MythAdventure.Myth_Leaves, this.metaLeaves); | |
} | |
} | |
} | |
} | |
} | |
for (l = 0; l < i; ++l) { | |
BlockPos upN = pos.up(l); | |
Block block2 = world.getBlockState(upN).getBlock(); | |
if (block2.isAir(world, upN) || block2.isLeaves(world, upN) || block2.getMaterial() == Material.vine) { | |
this.func_175905_a(world, pos.up(l), MythAdventure.Myth_Log, this.metaWood); | |
if (this.vinesGrow) { | |
for (l = pos.getY() - 3 + i; l <= pos.getY() + i; ++l) { | |
i1 = l - (pos.getY() + i); | |
j1 = 2 - i1 / 2; | |
for (k1 = pos.getX() - j1; k1 <= pos.getX() + j1; ++k1) { | |
for (l1 = pos.getZ() - j1; l1 <= pos.getZ() + j1; ++l1) { | |
BlockPos blockpos3 = new BlockPos(k1, l, l1); | |
if (world.getBlockState(blockpos3).getBlock().isLeaves(world, blockpos3)) { | |
BlockPos blockpos4 = blockpos3.west(); | |
blockpos1 = blockpos3.east(); | |
BlockPos blockpos5 = blockpos3.north(); | |
BlockPos blockpos2 = blockpos3.south(); | |
if (random.nextInt(4) == 0 && world.getBlockState(blockpos4).getBlock().isAir(world, blockpos4)) { | |
this.generateVines(world, blockpos4, 0); | |
} | |
if (random.nextInt(4) == 0 && world.getBlockState(blockpos1).getBlock().isAir(world, blockpos1)) { | |
this.generateVines(world, blockpos1, 0); | |
} | |
if (random.nextInt(4) == 0 && world.getBlockState(blockpos5).getBlock().isAir(world, blockpos5)) { | |
this.generateVines(world, blockpos5, 0); | |
} | |
if (random.nextInt(4) == 0 && world.getBlockState(blockpos2).getBlock().isAir(world, blockpos2)) { | |
this.generateVines(world, blockpos2, 0); | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
return true; | |
}else { | |
return false; | |
} | |
} | |
}else { | |
return false; | |
} | |
} | |
public void generateColumn(World worldIn, Random random, BlockPos pos, int topHeight) { | |
for (int y = 0; y < topHeight; y++) { | |
int radius = Math.min(3, 2 + (topHeight - y) / 4); //default is Math.min(3, 2 + (topHeight - y) / 4); | |
for (int x = -radius; x <= radius; x++) { | |
for (int z = -radius; z <= radius; z++) { | |
int dist = Math.abs(x) + Math.abs(z); | |
if ((dist < 4) || ((dist == 4) && (random.nextInt(1) == 0))) { //default is ((dist < 4) || ((dist == 4) && (random.nextInt(2) == 0))) | |
setLeaves(worldIn, pos.add(x, y, z)); | |
} | |
if ((dist <= 3)) { | |
setAir(worldIn, pos.add(x, y, z)); | |
} | |
} | |
} | |
} | |
} | |
private void setLeaves(World world, BlockPos pos) { | |
this.func_175905_a(world, pos, MythAdventure.Myth_Leaves, this.metaLeaves); | |
} | |
private void setWood(World world, BlockPos pos) { | |
this.func_175905_a(world, pos, MythAdventure.Myth_Log, this.metaLeaves); | |
} | |
private void setAir(World world, BlockPos pos) { | |
this.func_175905_a(world, pos, Blocks.air, 0); | |
} | |
private void generateVines(World worldIn, BlockPos pos, int meta) { | |
this.func_175905_a(worldIn, pos, MythAdventure.Myth_Leaves, 2); | |
int j = 4; | |
for (pos = pos.down(); worldIn.getBlockState(pos).getBlock().isAir(worldIn, pos) && j > 0; --j) { | |
this.func_175905_a(worldIn, pos, MythAdventure.Myth_Leaves, 2); | |
pos = pos.down(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment