Beginning work on updating to 1.8. Well here we are again.

This commit is contained in:
Adubbz 2014-09-28 10:29:06 +10:00
commit fad08ead79
17 changed files with 493 additions and 0 deletions

View File

@ -0,0 +1,14 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.api;
public interface IConfigurable
{
boolean isEnabled(Object... args);
}

View File

@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.api.block;
import biomesoplenty.api.IConfigurable;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
public abstract class BOPBlock extends Block implements IConfigurable
{
protected BOPBlock(Material material)
{
super(material);
}
@Override
//TODO: Account for configurations (which are provided by Forge and thus, cannot be done at this time)
public boolean isEnabled(Object... args)
{
if (args[0] instanceof IBlockState)
{
IBlockState blockState = (IBlockState)args[0];
return true;
}
return false;
}
}

View File

@ -0,0 +1,16 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.api.block;
import net.minecraft.block.Block;
public class BOPBlocks
{
public static Block ash_block;
}

View File

@ -0,0 +1,46 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.client.util;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemModelMesher;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelHelper
{
public static void registerItem(Item item, int metadata, String itemName)
{
getItemModelMesher().register(item, metadata, new ModelResourceLocation(itemName, "inventory"));
}
public static void registerBlock(Block block, int metadata, String blockName)
{
registerItem(Item.getItemFromBlock(block), metadata, blockName);
}
public static void registerBlock(Block block, String blockName)
{
registerBlock(block, 0, blockName);
}
public static void registerItem(Item item, String itemName)
{
registerItem(item, 0, itemName);
}
public static ItemModelMesher getItemModelMesher()
{
return Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
}
}

View File

@ -0,0 +1,102 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.block;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import biomesoplenty.api.block.BOPBlock;
import biomesoplenty.common.util.inventory.CreativeTabBOP;
//TODO: Commented methods and calls
public class BlockAsh extends BOPBlock
{
public BlockAsh()
{
super(Material.sand);
this.setHardness(0.4F);
//this.setHarvestLevel("shovel", 0);
this.setStepSound(Block.soundTypeSand);
this.setCreativeTab(CreativeTabBOP.instance);
}
@Override
public AxisAlignedBB getCollisionBoundingBox(World world, BlockPos pos, IBlockState state)
{
float heightOffset = 0.125F;
return new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)((float)(pos.getY() + 1) - heightOffset), (double)(pos.getZ() + 1));
}
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity)
{
/*if (entity instanceof EntityPlayer)
{
InventoryPlayer inventory = ((EntityPlayer)entity).inventory;
if (inventory.armorInventory[0] != null && inventory.armorInventory[0].getItem() == BOPCItems.wadingBoots)
{
return;
}
}*/
entity.motionX *= 0.4D;
entity.motionZ *= 0.4D;
}
/*@Override
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side)
{
if (side == ForgeDirection.UP)
{
return true;
}
return false;
}*/
/*@Override
public Item getItemDropped(int metadata, Random random, int fortune)
{
return BOPCItems.misc;
}
@Override
public int damageDropped(int meta)
{
return 1;
}*/
@Override
public int quantityDropped(Random random)
{
return 4;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, BlockPos pos, IBlockState state, Random random)
{
if (random.nextInt(2) == 0)
{
world.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, pos.getX() + random.nextFloat(), pos.getY() + 1.1F, pos.getZ() + random.nextFloat(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
}

View File

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.init;
import static biomesoplenty.api.block.BOPBlocks.ash_block;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import biomesoplenty.common.block.BlockAsh;
import biomesoplenty.common.util.RegistryUtil;
import biomesoplenty.core.BiomesOPlenty;
import com.google.common.collect.ImmutableList;
public class ModBlocks
{
public static void init()
{
ash_block = registerBlock(new BlockAsh(), "ash_block");
}
private static Block registerBlock(Block block, String name)
{
block.setUnlocalizedName(name);
block = RegistryUtil.registerBlock(block, name);
for (IBlockState state : (ImmutableList<IBlockState>)block.getBlockState().getValidStates())
{
BiomesOPlenty.proxy.registerBlockForMeshing(block, block.getMetaFromState(state), name);
}
return block;
}
}

View File

@ -0,0 +1,17 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.init;
public class ModItems
{
public static void init()
{
}
}

View File

@ -0,0 +1,52 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.util;
import java.util.Iterator;
import java.util.Map;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class RegistryUtil
{
public static Block registerBlock(Block block, String name)
{
return registerBlock(block, ItemBlock.class, name);
}
public static Block registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name)
{
return registerBlock(block, itemclass, name, new Object[]{});
}
public static Block registerBlock(Block block, Class<? extends ItemBlock> itemclass, String name, Object... itemCtorArgs)
{
block = GameRegistry.registerBlock(block, itemclass, name, itemCtorArgs);
Item associatedItem = GameRegistry.findItem(BiomesOPlenty.MOD_ID, name);
Item.field_179220_a.put(block, associatedItem);
Iterator iterator = block.getBlockState().getValidStates().iterator();
while (iterator.hasNext())
{
IBlockState iblockstate = (IBlockState)iterator.next();
int id = Block.blockRegistry.getIDForObject(block) << 4 | block.getMetaFromState(iblockstate);
Block.field_176229_d.func_148746_a(iblockstate, id);
}
return block;
}
}

View File

@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.common.util.inventory;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
//TODO: Do this properly once Forge is updated
public class CreativeTabBOP
{
public static final CreativeTabs instance = CreativeTabs.tabMisc;
}

View File

@ -0,0 +1,63 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.core;
import java.io.File;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import biomesoplenty.common.init.ModBlocks;
import biomesoplenty.common.init.ModItems;
@Mod(modid = BiomesOPlenty.MOD_ID, name = BiomesOPlenty.MOD_NAME)
public class BiomesOPlenty
{
public static final String MOD_NAME = "Biomes O' Plenty";
public static final String MOD_ID = "BiomesOPlenty";
@Instance(MOD_ID)
public static BiomesOPlenty instance;
@SidedProxy(clientSide = "biomesoplenty.core.ClientProxy", serverSide = "biomesoplenty.core.CommonProxy")
public static CommonProxy proxy;
private File configDirectory;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
configDirectory = new File(event.getModConfigurationDirectory(), "biomesoplenty");
//TODO: ModConfiguration.load();
ModItems.init();
ModBlocks.init();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
proxy.registerRenderers();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event)
{
}
public File getConfigDirectory()
{
return configDirectory;
}
}

View File

@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.core;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import biomesoplenty.client.util.ModelHelper;
public class ClientProxy extends CommonProxy
{
private static ArrayList<ModelEntry> blocksToRegister = new ArrayList();
@Override
public void registerRenderers()
{
for (ModelEntry modelEntry : blocksToRegister)
{
ModelHelper.registerItem(modelEntry.item, modelEntry.metadata, BiomesOPlenty.MOD_ID + ":" + modelEntry.name);
}
}
@Override
public void registerBlockForMeshing(Block block, int metadata, String name)
{
blocksToRegister.add(new ModelEntry(Item.getItemFromBlock(block), metadata, name));
}
private static class ModelEntry
{
public Item item;
public int metadata;
public String name;
public ModelEntry(Item item, int metadata, String name)
{
this.item = item;
this.metadata = metadata;
this.name = name;
}
}
}

View File

@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright 2014, the Biomes O' Plenty Team
*
* This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International Public License.
*
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/.
******************************************************************************/
package biomesoplenty.core;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
public class CommonProxy
{
public void registerRenderers() {}
public void registerBlockForMeshing(Block block, int metadata, String name) {}
}

View File

@ -0,0 +1,5 @@
{
"variants": {
"normal": { "model": "biomesoplenty:ash_block" }
}
}

View File

@ -0,0 +1 @@
tile.ash_block.name=Ash Block

View File

@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "biomesoplenty:blocks/ash_block"
}
}

View File

@ -0,0 +1,10 @@
{
"parent": "biomesoplenty:block/ash_block",
"display": {
"thirdperson": {
"rotation": [ 10, -45, 170 ],
"translation": [ 0, 1.5, -2.75 ],
"scale": [ 0.375, 0.375, 0.375 ]
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B