REFACTOR ALL THE THINGS!

This commit is contained in:
Emmanuel BENOîT 2016-07-12 14:49:11 +02:00
parent fc0eb1f427
commit 75abf8b9d3
144 changed files with 2223 additions and 1859 deletions

View file

@ -1,7 +1,7 @@
package mmm; package mmm;
import mmm.proxy.PCommon; import mmm.core.CProxyCommon;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
@ -15,14 +15,14 @@ public class Mmm
public static final String ID = "mmm"; public static final String ID = "mmm";
public static final String NAME = "MMM!"; public static final String NAME = "MMM!";
public static final String VERSION = "0.1-1.9.4"; public static final String VERSION = "1.9-1.10.2";
public static final String PREFIX = Mmm.ID + "."; public static final String PREFIX = Mmm.ID + ".";
@Mod.Instance( Mmm.ID ) @Mod.Instance( Mmm.ID )
private static Mmm instance; private static Mmm instance;
@SidedProxy( clientSide = "mmm.proxy.PClient" , serverSide = "mmm.proxy.PServer" ) @SidedProxy( clientSide = "mmm.core.CProxyClient" , serverSide = "mmm.core.CProxyCommon" )
private static PCommon proxy = null; private static CProxyCommon proxy = null;
public static Mmm get( ) public static Mmm get( )

45
src/java/mmm/MmmDeco.java Normal file
View file

@ -0,0 +1,45 @@
package mmm;
import mmm.deco.DChairs;
import mmm.deco.DSeatEntity;
import mmm.deco.DStairs;
import mmm.deco.DTables;
import mmm.deco.fences.DFences;
import mmm.deco.slabs.DSlabs;
import mmm.deco.thrones.DThrones;
import net.minecraftforge.fml.common.registry.EntityRegistry;
public class MmmDeco
{
public static final DStairs STAIRS;
public static final DSlabs SLAB;
public static final DFences FENCE;
public static final DTables TABLE;
public static final DChairs CHAIR;
public static final DThrones THRONE;
static {
STAIRS = new DStairs( );
SLAB = new DSlabs( );
FENCE = new DFences( );
TABLE = new DTables( );
CHAIR = new DChairs( );
THRONE = new DThrones( );
}
public static void preInit( )
{
// EMPTY
}
public static void init( )
{
EntityRegistry.registerModEntity( DSeatEntity.class , "Seat" , 0 , Mmm.get( ) , 80 , 1 , false );
}
}

22
src/java/mmm/MmmFood.java Normal file
View file

@ -0,0 +1,22 @@
package mmm;
import mmm.food.FMilks;
public class MmmFood
{
public static final FMilks MILK;
static {
MILK = new FMilks( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -1,7 +1,17 @@
package mmm.materials; package mmm;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import mmm.materials.I_MRock;
import mmm.materials.MAlloys;
import mmm.materials.MItems;
import mmm.materials.MMetals;
import mmm.materials.MOres;
import mmm.materials.MRocks;
import mmm.materials.MTraps;
import mmm.materials.MTrees;
import mmm.materials.MWoodAchievementHandler;
import mmm.materials.MWoods;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStone; import net.minecraft.block.BlockStone;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -12,12 +22,13 @@ import net.minecraftforge.common.MinecraftForge;
public class Materials public class MmmMaterials
{ {
public static final MRocks ROCK; public static final MRocks ROCK;
public static final MMetals METAL; public static final MMetals METAL;
public static final MAlloys ALLOY; public static final MAlloys ALLOY;
public static final MTrees TREE; public static final MTrees TREE;
public static final MWoods WOOD;
public static final MItems ITEM; public static final MItems ITEM;
public static final MOres ORE; public static final MOres ORE;
public static final MTraps TRAP; public static final MTraps TRAP;
@ -27,6 +38,7 @@ public class Materials
METAL = new MMetals( ); METAL = new MMetals( );
ALLOY = new MAlloys( ); ALLOY = new MAlloys( );
TREE = new MTrees( ); TREE = new MTrees( );
WOOD = new MWoods( );
ITEM = new MItems( ); ITEM = new MItems( );
ORE = new MOres( ); ORE = new MOres( );
TRAP = new MTraps( ); TRAP = new MTraps( );
@ -37,8 +49,8 @@ public class Materials
public static Item makeFuel( final String name , final int burnTime ) public static Item makeFuel( final String name , final int burnTime )
{ {
final Item fuel = Materials.makeItem( name ); final Item fuel = MmmMaterials.makeItem( name );
URegistry.setFuel( fuel , burnTime ); CRegistry.setFuel( fuel , burnTime );
return fuel; return fuel;
} }
@ -46,19 +58,13 @@ public class Materials
public static Item makeItem( final String name ) public static Item makeItem( final String name )
{ {
final Item stone = new Item( ); final Item stone = new Item( );
URegistry.setIdentifiers( stone , "materials" , "stone" , name ); CRegistry.setIdentifiers( stone , "materials" , "stone" , name );
stone.setCreativeTab( CreativeTabs.MATERIALS ); stone.setCreativeTab( CreativeTabs.MATERIALS );
URegistry.addItem( stone ); CRegistry.addItem( stone );
return stone; return stone;
} }
public static void preInit( )
{
// EMPTY
}
public static boolean isRock( final IBlockState bs ) public static boolean isRock( final IBlockState bs )
{ {
final Block block = bs.getBlock( ); final Block block = bs.getBlock( );
@ -74,7 +80,7 @@ public class Materials
} }
private Materials( ) public static void preInit( )
{ {
// EMPTY // EMPTY
} }

31
src/java/mmm/MmmTech.java Normal file
View file

@ -0,0 +1,31 @@
package mmm;
import mmm.core.CNetwork;
import mmm.tech.TActivationModeMessage;
import mmm.tech.base.TBMachines;
import mmm.tech.tools.TTArmors;
import mmm.tech.tools.TTTools;
public class MmmTech
{
public static final TBMachines MACHINES;
public static final TTTools TOOL;
public static final TTArmors ARMOR;
static {
CNetwork.addServerMessage( TActivationModeMessage.class );
MACHINES = new TBMachines( );
TOOL = new TTTools( );
ARMOR = new TTArmors( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -0,0 +1,45 @@
package mmm;
import java.util.ArrayList;
import mmm.core.CRegistry;
import mmm.core.api.I_OreGenerationRegistrar;
import mmm.world.WDefaultGenWatcher;
import mmm.world.biome.WBiomes;
import mmm.world.gen.WGOre;
import mmm.world.gen.WGOreCondition;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class MmmWorld
{
public static final WBiomes BIOME;
static {
final WDefaultGenWatcher dgw = new WDefaultGenWatcher( );
MinecraftForge.TERRAIN_GEN_BUS.register( dgw );
MinecraftForge.EVENT_BUS.register( dgw );
BIOME = new WBiomes( );
}
public static void preInit( )
{
// EMPTY
}
public static void init( )
{
final ArrayList< WGOreCondition > conditions = new ArrayList<>( );
for ( final I_OreGenerationRegistrar registrar : CRegistry.getOreGenerationRegistrars( ) ) {
registrar.addConditions( conditions );
}
GameRegistry.registerWorldGenerator( new WGOre( conditions ) , 0 );
}
}

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core;
import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandle;
@ -11,14 +11,14 @@ import net.minecraft.launchwrapper.Launch;
/** Accessors for various Minecraft fields */ /** Accessors for various Minecraft fields */
public class UAccessors public class CAccessors
{ {
private static final boolean isDeobfuscated; private static final boolean isDeobfuscated;
private static MethodHandle createGetter( final Class< ? > cls , final String fnForge , final String fnSearge ) private static MethodHandle createGetter( final Class< ? > cls , final String fnForge , final String fnSearge )
{ {
final String fn = UAccessors.isDeobfuscated ? fnForge : fnSearge; final String fn = CAccessors.isDeobfuscated ? fnForge : fnSearge;
Field f; Field f;
try { try {
f = cls.getDeclaredField( fn ); f = cls.getDeclaredField( fn );
@ -40,8 +40,8 @@ public class UAccessors
static { static {
isDeobfuscated = (Boolean) Launch.blackboard.get( "fml.deobfuscatedEnvironment" ); isDeobfuscated = (Boolean) Launch.blackboard.get( "fml.deobfuscatedEnvironment" );
fg_Block_blockHardness = UAccessors.createGetter( Block.class , "blockHardness" , "field_149782_v" ); fg_Block_blockHardness = CAccessors.createGetter( Block.class , "blockHardness" , "field_149782_v" );
fg_Block_blockResistance = UAccessors.createGetter( Block.class , "blockResistance" , "field_149781_w" ); fg_Block_blockResistance = CAccessors.createGetter( Block.class , "blockResistance" , "field_149781_w" );
} }
@ -54,13 +54,13 @@ public class UAccessors
public static float getBlockHardness( final Block block ) public static float getBlockHardness( final Block block )
throws Throwable throws Throwable
{ {
return (float) UAccessors.fg_Block_blockHardness.invokeExact( block ); return (float) CAccessors.fg_Block_blockHardness.invokeExact( block );
} }
public static float getBlockResistance( final Block block ) public static float getBlockResistance( final Block block )
throws Throwable throws Throwable
{ {
return (float) UAccessors.fg_Block_blockResistance.invokeExact( block ); return (float) CAccessors.fg_Block_blockResistance.invokeExact( block );
} }
} }

View file

@ -1,13 +1,10 @@
package mmm.utils.gui; package mmm.core;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import mmm.Mmm; import mmm.Mmm;
@ -15,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
@ -27,44 +23,27 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public enum GUIUtils public class CGui
implements IGuiHandler { implements IGuiHandler
INSTANCE; {
public static final int TAB_TEXTURE_X = 0;
public static final int TAB_TEXTURE_Y = 0;
public static final int TAB_WIDTH = 26;
public static final int TAB_HEIGHT = 26;
public static final int ABT_TEXTURE_X = 26;
public static final int ABT_TEXTURE_Y = 0;
public static final int ABT_WIDTH = 10;
public static final int ABT_HEIGHT = 15;
public static final int TAB_BORDER = 4;
public static final int TAB_ICON_X = 5;
public static final int TAB_ICON_Y = 5;
public static final int TAB_ICON_WIDTH = 16;
public static final int TAB_ICON_HEIGHT = 16;
private static final HashMap< Class< ? extends TileEntity > , Constructor< ? > > SERVER_SIDE // private static final HashMap< Class< ? extends TileEntity > , Constructor< ? > > SERVER_SIDE //
= Maps.newHashMap( ); = Maps.newHashMap( );
private static final HashMap< Class< ? extends TileEntity > , Constructor< ? > > CLIENT_SIDE // private static final HashMap< Class< ? extends TileEntity > , Constructor< ? > > CLIENT_SIDE //
= Maps.newHashMap( ); = Maps.newHashMap( );
static final Logger LOGGER = LogManager.getLogger( ); static {
new CGui( );
public static final ResourceLocation GUI_TEXTURE = new ResourceLocation( "mmm" , "textures/gui/gui-common.png" ); }
public static void registerTileEntityGUI( final Class< ? extends TileEntity > teClass , public static void registerTileEntityGUI( final Class< ? extends TileEntity > teClass ,
final String containerClassName , final String guiClassName ) final String containerClassName , final String guiClassName )
{ {
if ( GUIUtils.SERVER_SIDE.containsKey( teClass ) ) { if ( CGui.SERVER_SIDE.containsKey( teClass ) ) {
throw new IllegalArgumentException( "duplicate GUI registration for tile entity class " + teClass ); throw new IllegalArgumentException( "duplicate GUI registration for tile entity class " + teClass );
} }
GUIUtils.addTileEntityConstructor( GUIUtils.SERVER_SIDE , teClass , Container.class , containerClassName , CGui.addTileEntityConstructor( CGui.SERVER_SIDE , teClass , Container.class , containerClassName ,
"container" ); "container" );
if ( FMLLaunchHandler.side( ) == Side.CLIENT ) { if ( FMLLaunchHandler.side( ) == Side.CLIENT ) {
String clsName = "net.minecraft.client.gui.inventory.GuiContainer"; String clsName = "net.minecraft.client.gui.inventory.GuiContainer";
@ -77,7 +56,7 @@ public enum GUIUtils
} catch ( final ClassNotFoundException e ) { } catch ( final ClassNotFoundException e ) {
throw new IllegalArgumentException( "couldn't find GUI class" , e ); throw new IllegalArgumentException( "couldn't find GUI class" , e );
} }
GUIUtils.addTileEntityConstructor( GUIUtils.CLIENT_SIDE , teClass , guiClass , guiClassName , "GUI" ); CGui.addTileEntityConstructor( CGui.CLIENT_SIDE , teClass , guiClass , guiClassName , "GUI" );
} }
} }
@ -102,7 +81,7 @@ public enum GUIUtils
if ( !parent.isAssignableFrom( klass ) ) { if ( !parent.isAssignableFrom( klass ) ) {
throw new IllegalArgumentException( "class " + className + " is not a " + designation + " sub-class" ); throw new IllegalArgumentException( "class " + className + " is not a " + designation + " sub-class" );
} }
output.put( teClass , GUIUtils.findConstructor( teClass , klass ) ); output.put( teClass , CGui.findConstructor( teClass , klass ) );
} }
@ -121,7 +100,7 @@ public enum GUIUtils
} }
private GUIUtils( ) private CGui( )
{ {
NetworkRegistry.INSTANCE.registerGuiHandler( Mmm.get( ) , this ); NetworkRegistry.INSTANCE.registerGuiHandler( Mmm.get( ) , this );
} }
@ -132,7 +111,7 @@ public enum GUIUtils
final int y , final int z ) final int y , final int z )
{ {
if ( ID == 0 ) { if ( ID == 0 ) {
return this.getObjectForTE( player , world , x , y , z , GUIUtils.SERVER_SIDE , "container" ); return this.getObjectForTE( player , world , x , y , z , CGui.SERVER_SIDE , "container" );
} }
return null; return null;
} }
@ -144,7 +123,7 @@ public enum GUIUtils
final int y , final int z ) final int y , final int z )
{ {
if ( ID == 0 ) { if ( ID == 0 ) {
return this.getObjectForTE( player , world , x , y , z , GUIUtils.CLIENT_SIDE , "GUI" ); return this.getObjectForTE( player , world , x , y , z , CGui.CLIENT_SIDE , "GUI" );
} }
return null; return null;
} }

View file

@ -1,7 +1,8 @@
package mmm.utils; package mmm.core;
import mmm.Mmm; import mmm.Mmm;
import mmm.core.api.I_Message;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.IThreadListener; import net.minecraft.util.IThreadListener;
@ -12,50 +13,50 @@ import net.minecraftforge.fml.relauncher.Side;
public class UNetwork public class CNetwork
{ {
private static final SimpleNetworkWrapper NET = new SimpleNetworkWrapper( Mmm.ID ); private static final SimpleNetworkWrapper NET = new SimpleNetworkWrapper( Mmm.ID );
private static int nextPacketDiscriminator = 0; private static int nextPacketDiscriminator = 0;
public static void addClientMessage( final Class< ? extends I_UMessage > message ) public static void addClientMessage( final Class< ? extends I_Message > message )
{ {
UNetwork.NET.registerMessage( // CNetwork.NET.registerMessage( //
( final I_UMessage m , final MessageContext ctx ) -> { ( final I_Message m , final MessageContext ctx ) -> {
final IThreadListener main = Minecraft.getMinecraft( ); final IThreadListener main = Minecraft.getMinecraft( );
main.addScheduledTask( ( ) -> m.handleOnClient( Minecraft.getMinecraft( ).thePlayer ) ); main.addScheduledTask( ( ) -> m.handleOnClient( Minecraft.getMinecraft( ).thePlayer ) );
return null; return null;
} , // } , //
message , UNetwork.nextPacketDiscriminator++ , Side.CLIENT ); message , CNetwork.nextPacketDiscriminator++ , Side.CLIENT );
} }
public static void addServerMessage( final Class< ? extends I_UMessage > message ) public static void addServerMessage( final Class< ? extends I_Message > message )
{ {
UNetwork.NET.registerMessage( // CNetwork.NET.registerMessage( //
( final I_UMessage m , final MessageContext ctx ) -> { ( final I_Message m , final MessageContext ctx ) -> {
final IThreadListener main = (WorldServer) ctx.getServerHandler( ).playerEntity.worldObj; final IThreadListener main = (WorldServer) ctx.getServerHandler( ).playerEntity.worldObj;
main.addScheduledTask( ( ) -> m.handleOnServer( ctx.getServerHandler( ).playerEntity ) ); main.addScheduledTask( ( ) -> m.handleOnServer( ctx.getServerHandler( ).playerEntity ) );
return null; return null;
} , // } , //
message , UNetwork.nextPacketDiscriminator++ , Side.SERVER ); message , CNetwork.nextPacketDiscriminator++ , Side.SERVER );
} }
public static void sendToServer( final I_UMessage msg ) public static void sendToServer( final I_Message msg )
{ {
UNetwork.NET.sendToServer( msg ); CNetwork.NET.sendToServer( msg );
} }
public static void sendTo( final I_UMessage msg , final EntityPlayerMP player ) public static void sendTo( final I_Message msg , final EntityPlayerMP player )
{ {
UNetwork.NET.sendTo( msg , player ); CNetwork.NET.sendTo( msg , player );
} }
public static void sendToAll( final I_UMessage msg ) public static void sendToAll( final I_Message msg )
{ {
UNetwork.NET.sendToAll( msg ); CNetwork.NET.sendToAll( msg );
} }
} }

View file

@ -1,29 +1,28 @@
package mmm.proxy; package mmm.core;
import mmm.utils.URegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class PClient public class CProxyClient
extends PCommon extends CProxyCommon
{ {
@Override @Override
public void preInit( final FMLPreInitializationEvent event ) public void preInit( final FMLPreInitializationEvent event )
{ {
super.preInit( event ); super.preInit( event );
URegistry.preInitClient( ); CRegistry.preInitClient( );
} }
@Override @Override
public void init( FMLInitializationEvent event ) public void init( final FMLInitializationEvent event )
{ {
super.init( event ); super.init( event );
URegistry.initClient( ); CRegistry.initClient( );
} }
} }

View file

@ -0,0 +1,37 @@
package mmm.core;
import mmm.MmmDeco;
import mmm.MmmFood;
import mmm.MmmMaterials;
import mmm.MmmTech;
import mmm.MmmWorld;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public class CProxyCommon
{
public void preInit( final FMLPreInitializationEvent event )
{
CAccessors.preInit( );
MmmMaterials.preInit( );
MmmWorld.preInit( );
MmmTech.preInit( );
MmmFood.preInit( );
MmmDeco.preInit( );
CRegistry.registerRecipes( );
}
public void init( final FMLInitializationEvent event )
{
MmmWorld.init( );
MmmDeco.init( );
}
}

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core;
import java.util.ArrayList; import java.util.ArrayList;
@ -8,6 +8,19 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import mmm.Mmm; import mmm.Mmm;
import mmm.core.api.I_OreGenerationRegistrar;
import mmm.core.api.I_RecipeRegistrar;
import mmm.core.api.I_RequiresClientInit;
import mmm.core.api.I_RequiresClientPreInit;
import mmm.core.api.blocks.I_ColoredBlock;
import mmm.core.api.blocks.I_StateMapperProvider;
import mmm.core.api.blocks.I_TintedBlock;
import mmm.core.api.blocks.I_TrapBlock;
import mmm.core.api.items.I_ItemModelProvider;
import mmm.core.api.items.I_ItemModelProviderBasic;
import mmm.core.api.items.I_ItemWithVariants;
import mmm.core.api.items.I_TintedItem;
import mmm.materials.MTrapBlocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@ -28,7 +41,7 @@ import scala.actors.threadpool.Arrays;
public class URegistry public class CRegistry
{ {
private static class FuelHandler private static class FuelHandler
@ -39,7 +52,7 @@ public class URegistry
public int getBurnTime( final ItemStack fuel ) public int getBurnTime( final ItemStack fuel )
{ {
final Item item = fuel.getItem( ); final Item item = fuel.getItem( );
final Object fuelInfo = URegistry.FUELS.get( item ); final Object fuelInfo = CRegistry.FUELS.get( item );
if ( fuelInfo != null ) { if ( fuelInfo != null ) {
if ( item.getHasSubtypes( ) ) { if ( item.getHasSubtypes( ) ) {
return ( (int[]) fuelInfo )[ fuel.getItemDamage( ) ]; return ( (int[]) fuelInfo )[ fuel.getItemDamage( ) ];
@ -51,8 +64,8 @@ public class URegistry
} }
private static final HashSet< I_URecipeRegistrar > RECIPE_REGISTRARS = new HashSet<>( ); private static final HashSet< I_RecipeRegistrar > RECIPE_REGISTRARS = new HashSet<>( );
private static final HashSet< I_UOreGenerationRegistrar > ORE_GEN_REGISTRARS = new HashSet<>( ); private static final HashSet< I_OreGenerationRegistrar > ORE_GEN_REGISTRARS = new HashSet<>( );
private static final HashSet< Item > ITEMS = new HashSet< Item >( ); private static final HashSet< Item > ITEMS = new HashSet< Item >( );
private static final HashSet< Block > BLOCKS = new HashSet< Block >( ); private static final HashSet< Block > BLOCKS = new HashSet< Block >( );
@ -64,7 +77,7 @@ public class URegistry
private static final FuelHandler FUEL_HANDLER = new FuelHandler( ); private static final FuelHandler FUEL_HANDLER = new FuelHandler( );
static { static {
GameRegistry.registerFuelHandler( URegistry.FUEL_HANDLER ); GameRegistry.registerFuelHandler( CRegistry.FUEL_HANDLER );
} }
@ -101,11 +114,11 @@ public class URegistry
public static void addItem( final Item item ) public static void addItem( final Item item )
{ {
if ( URegistry.ITEMS.add( item ) ) { if ( CRegistry.ITEMS.add( item ) ) {
GameRegistry.register( item ); GameRegistry.register( item );
URegistry.addRecipeRegistrar( item ); CRegistry.addRecipeRegistrar( item );
if ( item instanceof I_URequiresClientInit ) { if ( item instanceof I_RequiresClientInit ) {
URegistry.ITEMS_CLIENT_INIT.add( item ); CRegistry.ITEMS_CLIENT_INIT.add( item );
} }
} }
} }
@ -114,34 +127,34 @@ public class URegistry
public static Item addBlock( final Block block ) public static Item addBlock( final Block block )
{ {
Item item; Item item;
if ( block instanceof I_UColoredBlock ) { if ( block instanceof I_ColoredBlock ) {
item = new ItemCloth( block ); item = new ItemCloth( block );
} else { } else {
item = new ItemBlock( block ); item = new ItemBlock( block );
} }
item.setRegistryName( block.getRegistryName( ) ); item.setRegistryName( block.getRegistryName( ) );
return URegistry.addBlock( block , item ); return CRegistry.addBlock( block , item );
} }
public static Item addBlock( final Block block , final Item blockItem ) public static Item addBlock( final Block block , final Item blockItem )
{ {
if ( URegistry.BLOCKS.add( block ) ) { if ( CRegistry.BLOCKS.add( block ) ) {
GameRegistry.register( block ); GameRegistry.register( block );
URegistry.addRecipeRegistrar( block ); CRegistry.addRecipeRegistrar( block );
URegistry.addOreGenerationRegistrar( block ); CRegistry.addOreGenerationRegistrar( block );
if ( block instanceof I_UTrapBlock ) { if ( block instanceof I_TrapBlock ) {
UTrapBlocks.INSTANCE.register( (I_UTrapBlock) block ); MTrapBlocks.INSTANCE.register( (I_TrapBlock) block );
} }
if ( block instanceof I_URequiresClientPreInit ) { if ( block instanceof I_RequiresClientPreInit ) {
URegistry.BLOCKS_CLIENT_PREINIT.add( block ); CRegistry.BLOCKS_CLIENT_PREINIT.add( block );
} }
if ( block instanceof I_URequiresClientInit ) { if ( block instanceof I_RequiresClientInit ) {
URegistry.BLOCKS_CLIENT_INIT.add( block ); CRegistry.BLOCKS_CLIENT_INIT.add( block );
} }
if ( blockItem != null ) { if ( blockItem != null ) {
URegistry.addItem( blockItem ); CRegistry.addItem( blockItem );
} }
} }
return blockItem; return blockItem;
@ -158,7 +171,7 @@ public class URegistry
} else { } else {
obj = Integer.valueOf( value ); obj = Integer.valueOf( value );
} }
URegistry.FUELS.put( item , obj ); CRegistry.FUELS.put( item , obj );
} }
@ -168,10 +181,10 @@ public class URegistry
throw new IllegalArgumentException( "item " + item + " has no subtypes" ); throw new IllegalArgumentException( "item " + item + " has no subtypes" );
} }
Object obj = URegistry.FUELS.get( item ); Object obj = CRegistry.FUELS.get( item );
if ( obj == null ) { if ( obj == null ) {
obj = new int[ 16 ]; obj = new int[ 16 ];
URegistry.FUELS.put( item , obj ); CRegistry.FUELS.put( item , obj );
} }
( (int[]) obj )[ meta ] = value; ( (int[]) obj )[ meta ] = value;
@ -180,29 +193,29 @@ public class URegistry
public static void addRecipeRegistrar( final Object object ) public static void addRecipeRegistrar( final Object object )
{ {
if ( object instanceof I_URecipeRegistrar ) { if ( object instanceof I_RecipeRegistrar ) {
URegistry.RECIPE_REGISTRARS.add( (I_URecipeRegistrar) object ); CRegistry.RECIPE_REGISTRARS.add( (I_RecipeRegistrar) object );
} }
} }
public static void addOreGenerationRegistrar( final Object object ) public static void addOreGenerationRegistrar( final Object object )
{ {
if ( object instanceof I_UOreGenerationRegistrar ) { if ( object instanceof I_OreGenerationRegistrar ) {
URegistry.ORE_GEN_REGISTRARS.add( (I_UOreGenerationRegistrar) object ); CRegistry.ORE_GEN_REGISTRARS.add( (I_OreGenerationRegistrar) object );
} }
} }
public static Collection< I_UOreGenerationRegistrar > getOreGenerationRegistrars( ) public static Collection< I_OreGenerationRegistrar > getOreGenerationRegistrars( )
{ {
return Collections.unmodifiableCollection( URegistry.ORE_GEN_REGISTRARS ); return Collections.unmodifiableCollection( CRegistry.ORE_GEN_REGISTRARS );
} }
public static void registerRecipes( ) public static void registerRecipes( )
{ {
for ( final I_URecipeRegistrar registrar : URegistry.RECIPE_REGISTRARS ) { for ( final I_RecipeRegistrar registrar : CRegistry.RECIPE_REGISTRARS ) {
registrar.registerRecipes( ); registrar.registerRecipes( );
} }
} }
@ -211,33 +224,33 @@ public class URegistry
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )
public static void preInitClient( ) public static void preInitClient( )
{ {
for ( final Item item : URegistry.ITEMS ) { for ( final Item item : CRegistry.ITEMS ) {
// Automatic model location unless there's a provider // Automatic model location unless there's a provider
if ( ! ( item instanceof I_UItemModelProvider ) ) { if ( ! ( item instanceof I_ItemModelProvider ) ) {
final ModelResourceLocation location = new ModelResourceLocation( item.getRegistryName( ) , final ModelResourceLocation location = new ModelResourceLocation( item.getRegistryName( ) ,
"inventory" ); "inventory" );
ModelLoader.setCustomModelResourceLocation( item , 0 , location ); ModelLoader.setCustomModelResourceLocation( item , 0 , location );
} }
if ( ! ( item instanceof I_URequiresClientPreInit ) ) { if ( ! ( item instanceof I_RequiresClientPreInit ) ) {
continue; continue;
} }
// Item models // Item models
if ( item instanceof I_UItemModelProviderBasic ) { if ( item instanceof I_ItemModelProviderBasic ) {
ModelLoader.setCustomModelResourceLocation( item , 0 , ModelLoader.setCustomModelResourceLocation( item , 0 ,
( (I_UItemModelProviderBasic) item ).getModelResourceLocation( ) ); ( (I_ItemModelProviderBasic) item ).getModelResourceLocation( ) );
} else if ( item instanceof I_UItemWithVariants ) { } else if ( item instanceof I_ItemWithVariants ) {
final I_UItemWithVariants iwv = (I_UItemWithVariants) item; final I_ItemWithVariants iwv = (I_ItemWithVariants) item;
for ( int i = 0 ; i < iwv.getVariantsCount( ) ; i++ ) { for ( int i = 0 ; i < iwv.getVariantsCount( ) ; i++ ) {
ModelLoader.setCustomModelResourceLocation( item , i , iwv.getModelResourceLocation( i ) ); ModelLoader.setCustomModelResourceLocation( item , i , iwv.getModelResourceLocation( i ) );
} }
} }
} }
for ( final Block block : URegistry.BLOCKS_CLIENT_PREINIT ) { for ( final Block block : CRegistry.BLOCKS_CLIENT_PREINIT ) {
if ( block instanceof I_UStateMapperProvider ) { if ( block instanceof I_StateMapperProvider ) {
ModelLoader.setCustomStateMapper( block , ( (I_UStateMapperProvider) block ).getStateMapper( ) ); ModelLoader.setCustomStateMapper( block , ( (I_StateMapperProvider) block ).getStateMapper( ) );
} }
} }
} }
@ -249,22 +262,22 @@ public class URegistry
final BlockColors blockColors = Minecraft.getMinecraft( ).getBlockColors( ); final BlockColors blockColors = Minecraft.getMinecraft( ).getBlockColors( );
final ItemColors itemColors = Minecraft.getMinecraft( ).getItemColors( ); final ItemColors itemColors = Minecraft.getMinecraft( ).getItemColors( );
for ( final Block block : URegistry.BLOCKS_CLIENT_INIT ) { for ( final Block block : CRegistry.BLOCKS_CLIENT_INIT ) {
// Register tinted blocks // Register tinted blocks
if ( block instanceof I_UTintedBlock ) { if ( block instanceof I_TintedBlock ) {
blockColors.registerBlockColorHandler( ( (I_UTintedBlock) block ).getBlockTint( ) , block ); blockColors.registerBlockColorHandler( ( (I_TintedBlock) block ).getBlockTint( ) , block );
} }
// Register tinted block items // Register tinted block items
if ( block instanceof I_UTintedItem ) { if ( block instanceof I_TintedItem ) {
itemColors.registerItemColorHandler( ( (I_UTintedItem) block ).getItemTint( ) , block ); itemColors.registerItemColorHandler( ( (I_TintedItem) block ).getItemTint( ) , block );
} }
} }
for ( final Item item : URegistry.ITEMS_CLIENT_INIT ) { for ( final Item item : CRegistry.ITEMS_CLIENT_INIT ) {
// Register tinted items // Register tinted items
if ( item instanceof I_UTintedItem ) { if ( item instanceof I_TintedItem ) {
itemColors.registerItemColorHandler( ( (I_UTintedItem) item ).getItemTint( ) , item ); itemColors.registerItemColorHandler( ( (I_TintedItem) item ).getItemTint( ) , item );
} }
} }
} }

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core.api;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
@ -9,7 +9,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public interface I_UMessage public interface I_Message
extends IMessage extends IMessage
{ {

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core.api;
import java.util.List; import java.util.List;
@ -7,7 +7,7 @@ import mmm.world.gen.WGOreCondition;
public interface I_UOreGenerationRegistrar public interface I_OreGenerationRegistrar
{ {
public void addConditions( List< WGOreCondition > conditions ); public void addConditions( List< WGOreCondition > conditions );

View file

@ -0,0 +1,9 @@
package mmm.core.api;
public interface I_RecipeRegistrar
{
public void registerRecipes( );
}

View file

@ -0,0 +1,7 @@
package mmm.core.api;
public interface I_RequiresClientInit
{
// EMPTY
}

View file

@ -0,0 +1,7 @@
package mmm.core.api;
public interface I_RequiresClientPreInit
{
// EMPTY
}

View file

@ -0,0 +1,7 @@
package mmm.core.api.blocks;
public interface I_ColoredBlock
{
// EMPTY
}

View file

@ -0,0 +1,7 @@
package mmm.core.api.blocks;
public interface I_SeatBlock
{
// EMPTY
}

View file

@ -1,14 +1,15 @@
package mmm.utils; package mmm.core.api.blocks;
import mmm.core.api.I_RequiresClientPreInit;
import net.minecraft.client.renderer.block.statemap.IStateMapper; import net.minecraft.client.renderer.block.statemap.IStateMapper;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public interface I_UStateMapperProvider public interface I_StateMapperProvider
extends I_URequiresClientPreInit extends I_RequiresClientPreInit
{ {
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core.api.blocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -11,7 +11,7 @@ import net.minecraft.world.World;
public interface I_USupportBlock public interface I_SupportBlock
{ {
public static boolean check( final IBlockAccess worldIn , final BlockPos pos ) public static boolean check( final IBlockAccess worldIn , final BlockPos pos )
@ -23,14 +23,14 @@ public interface I_USupportBlock
} }
final Block downBlock = downState.getBlock( ); final Block downBlock = downState.getBlock( );
return downBlock == Blocks.GLASS || downBlock == Blocks.STAINED_GLASS || downBlock instanceof I_USupportBlock; return downBlock == Blocks.GLASS || downBlock == Blocks.STAINED_GLASS || downBlock instanceof I_SupportBlock;
} }
public static boolean dropIfUnsupported( final IBlockState state , final World worldIn , final BlockPos pos , public static boolean dropIfUnsupported( final IBlockState state , final World worldIn , final BlockPos pos ,
final Block block ) final Block block )
{ {
final boolean rv = !I_USupportBlock.check( worldIn , pos ); final boolean rv = !I_SupportBlock.check( worldIn , pos );
if ( rv ) { if ( rv ) {
block.dropBlockAsItem( worldIn , pos , state , 0 ); block.dropBlockAsItem( worldIn , pos , state , 0 );
worldIn.setBlockToAir( pos ); worldIn.setBlockToAir( pos );

View file

@ -1,6 +1,7 @@
package mmm.utils; package mmm.core.api.blocks;
import mmm.core.api.I_RequiresClientInit;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -8,8 +9,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
/** For blocks that need to register a tint */ /** For blocks that need to register a tint */
public interface I_UTintedBlock public interface I_TintedBlock
extends I_URequiresClientInit extends I_RequiresClientInit
{ {
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )

View file

@ -1,11 +1,11 @@
package mmm.utils; package mmm.core.api.blocks;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
public interface I_UTrapBlock public interface I_TrapBlock
{ {
public String getTrapType( ); public String getTrapType( );

View file

@ -0,0 +1,14 @@
package mmm.core.api.items;
import mmm.core.api.I_RequiresClientPreInit;
public interface I_ItemModelProvider
extends I_RequiresClientPreInit
{
// EMPTY
}

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core.api.items;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@ -7,8 +7,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public interface I_UItemModelProviderBasic public interface I_ItemModelProviderBasic
extends I_UItemModelProvider extends I_ItemModelProvider
{ {
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.core.api.items;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@ -7,8 +7,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public interface I_UItemWithVariants public interface I_ItemWithVariants
extends I_UItemModelProvider extends I_ItemModelProvider
{ {
public int getVariantsCount( ); public int getVariantsCount( );

View file

@ -1,6 +1,7 @@
package mmm.utils; package mmm.core.api.items;
import mmm.core.api.I_RequiresClientInit;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -11,8 +12,8 @@ import net.minecraftforge.fml.relauncher.SideOnly;
* For items that need to register a tint, or blocks with automatically registered items that need * For items that need to register a tint, or blocks with automatically registered items that need
* to be tinted. * to be tinted.
*/ */
public interface I_UTintedItem public interface I_TintedItem
extends I_URequiresClientInit extends I_RequiresClientInit
{ {
@SideOnly( Side.CLIENT ) @SideOnly( Side.CLIENT )

View file

@ -0,0 +1,24 @@
package mmm.core.api.tech;
public enum E_ActivationMode {
ALWAYS_ACTIVE ,
POWERED ,
UNPOWERED ,
DISABLED;
private static final E_ActivationMode[] VALUES = E_ActivationMode.values( );
public String getDisplayName( )
{
return "gui.mmm.tech.base.am." + this.toString( ).toLowerCase( );
}
public E_ActivationMode next( )
{
return E_ActivationMode.VALUES[ ( this.ordinal( ) + 1 ) % E_ActivationMode.VALUES.length ];
}
}

View file

@ -0,0 +1,12 @@
package mmm.core.api.tech;
public interface I_ConfigurableActivation
{
public E_ActivationMode getActivationMode( );
public void setActivationMode( E_ActivationMode mode );
}

View file

@ -1,4 +1,4 @@
package mmm.world; package mmm.core.api.world;
import mmm.world.gen.WGOreParameters; import mmm.world.gen.WGOreParameters;
@ -6,7 +6,7 @@ import net.minecraft.world.World;
public interface I_WBiomeWithOres public interface I_BiomeWithOres
{ {
public WGOreParameters[] getBiomeOres( final World world ); public WGOreParameters[] getBiomeOres( final World world );

View file

@ -1,8 +1,11 @@
package mmm.world; package mmm.core.api.world;
import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent;
public interface I_WDefaultPopulateHandler
public interface I_DefaultPopulateHandler
{ {
public boolean onDefaultPopulate( PopulateChunkEvent.Populate event ); public boolean onDefaultPopulate( PopulateChunkEvent.Populate event );

View file

@ -1,4 +1,4 @@
package mmm.world; package mmm.core.api.world;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -6,16 +6,16 @@ import net.minecraft.world.chunk.IChunkProvider;
public interface I_WLocationCheck public interface I_LocationCheck
{ {
public boolean checkLocation( World world , int chunkX , int chunkZ , IChunkProvider provider ); public boolean checkLocation( World world , int chunkX , int chunkZ , IChunkProvider provider );
default I_WLocationCheck and( final I_WLocationCheck other ) default I_LocationCheck and( final I_LocationCheck other )
{ {
final I_WLocationCheck self = this; final I_LocationCheck self = this;
return new I_WLocationCheck( ) { return new I_LocationCheck( ) {
@Override @Override
public boolean checkLocation( final World world , final int chunkX , final int chunkZ , public boolean checkLocation( final World world , final int chunkX , final int chunkZ ,
final IChunkProvider provider ) final IChunkProvider provider )
@ -27,10 +27,10 @@ public interface I_WLocationCheck
} }
default I_WLocationCheck or( final I_WLocationCheck other ) default I_LocationCheck or( final I_LocationCheck other )
{ {
final I_WLocationCheck self = this; final I_LocationCheck self = this;
return new I_WLocationCheck( ) { return new I_LocationCheck( ) {
@Override @Override
public boolean checkLocation( final World world , final int chunkX , final int chunkZ , public boolean checkLocation( final World world , final int chunkX , final int chunkZ ,
final IChunkProvider provider ) final IChunkProvider provider )
@ -42,10 +42,10 @@ public interface I_WLocationCheck
} }
default I_WLocationCheck invert( ) default I_LocationCheck invert( )
{ {
final I_WLocationCheck self = this; final I_LocationCheck self = this;
return new I_WLocationCheck( ) { return new I_LocationCheck( ) {
@Override @Override
public boolean checkLocation( final World world , final int chunkX , final int chunkZ , public boolean checkLocation( final World world , final int chunkX , final int chunkZ ,
final IChunkProvider provider ) final IChunkProvider provider )

View file

@ -0,0 +1,7 @@
package mmm.core.api.world;
public interface I_TrappedBiome
{
public float getTrapBlockChance( );
}

View file

@ -1,230 +0,0 @@
package mmm.deco;
import java.util.List;
import mmm.utils.I_UBlockSeat;
import mmm.utils.I_URecipeRegistrar;
import mmm.utils.I_USupportBlock;
import mmm.utils.UMaths;
import mmm.utils.URegistry;
import mmm.utils.USeat;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class DChair
extends Block
implements I_URecipeRegistrar , I_UBlockSeat
{
public static final PropertyDirection FACING = BlockHorizontal.FACING;
private static final AxisAlignedBB BOUNDING_BOX = UMaths.makeBlockAABB( 1 , 0 , 1 , 15 , 16 , 15 );
private static final AxisAlignedBB COLLISION_BOTTOM = UMaths.makeBlockAABB( 1 , 0 , 1 , 15 , 8 , 15 );
private static final AxisAlignedBB COLLISION_TOP_NORTH = UMaths.makeBlockAABB( 2 , 8 , 2 , 14 , 16 , 4 );
private static final AxisAlignedBB COLLISION_TOP_EAST = UMaths.makeBlockAABB( 12 , 8 , 2 , 14 , 16 , 14 );
private static final AxisAlignedBB COLLISION_TOP_SOUTH = UMaths.makeBlockAABB( 2 , 8 , 12 , 14 , 16 , 14 );
private static final AxisAlignedBB COLLISION_TOP_WEST = UMaths.makeBlockAABB( 2 , 8 , 2 , 4 , 16 , 14 );
public final DWoodType type;
public DChair( final DWoodType type )
{
super( Material.WOOD , type.getMapColor() );
this.type = type;
this.setDefaultState( this.blockState.getBaseState( ).withProperty( DChair.FACING , EnumFacing.NORTH ) );
this.setCreativeTab( CreativeTabs.DECORATIONS );
URegistry.setIdentifiers( this , "deco" , "chair" , type.getSuffix() );
this.lightOpacity = 0;
this.translucent = false;
this.fullBlock = false;
this.blockHardness = 2.5f;
this.blockResistance = 12.5f;
this.blockSoundType = SoundType.LADDER;
this.enableStats = false;
this.setHarvestLevel( "axe" , 0 );
}
@Override
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
{
return DChair.BOUNDING_BOX;
}
@Override
public void addCollisionBoxToList( final IBlockState state , final World worldIn , final BlockPos pos ,
final AxisAlignedBB container , final List< AxisAlignedBB > output , final Entity entity )
{
Block.addCollisionBoxToList( pos , container , output , DChair.COLLISION_BOTTOM );
AxisAlignedBB back;
switch ( state.getValue( DChair.FACING ) ) {
case EAST:
back = DChair.COLLISION_TOP_EAST;
break;
case NORTH:
back = DChair.COLLISION_TOP_NORTH;
break;
case SOUTH:
back = DChair.COLLISION_TOP_SOUTH;
break;
case WEST:
back = DChair.COLLISION_TOP_WEST;
break;
default:
// TODO log problem
return;
}
Block.addCollisionBoxToList( pos , container , output , back );
}
@Override
public EnumPushReaction getMobilityFlag( final IBlockState state )
{
return EnumPushReaction.DESTROY;
}
@Override
public void registerRecipes( )
{
GameRegistry.addShapedRecipe( new ItemStack( this ) , //
"B " , //
"BB" , //
"SS" , //
'B' , new ItemStack( this.type.getSlabBlock() , 1 , this.type.getMetaData() ) , //
'S' , Items.STICK //
);
}
@Override
public boolean isOpaqueCube( final IBlockState state )
{
return false;
}
@Override
public boolean isFullCube( final IBlockState state )
{
return false;
}
@Override
@SideOnly( Side.CLIENT )
public BlockRenderLayer getBlockLayer( )
{
return BlockRenderLayer.CUTOUT;
}
@Override
protected BlockStateContainer createBlockState( )
{
return new BlockStateContainer( this , new IProperty[] {
DChair.FACING
} );
}
@Override
public IBlockState withRotation( final IBlockState state , final Rotation rot )
{
return state.withProperty( DChair.FACING , rot.rotate( state.getValue( DChair.FACING ) ) );
}
@Override
public IBlockState withMirror( final IBlockState state , final Mirror mirrorIn )
{
return state.withRotation( mirrorIn.toRotation( state.getValue( DChair.FACING ) ) );
}
@Override
public IBlockState getStateFromMeta( final int meta )
{
EnumFacing enumfacing = EnumFacing.getFront( meta );
if ( enumfacing.getAxis( ) == EnumFacing.Axis.Y ) {
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState( ).withProperty( DChair.FACING , enumfacing );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return state.getValue( DChair.FACING ).getIndex( );
}
@Override
public IBlockState onBlockPlaced( final World worldIn , final BlockPos pos , final EnumFacing facing ,
final float hitX , final float hitY , final float hitZ , final int meta , final EntityLivingBase placer )
{
return this.getDefaultState( ).withProperty( DChair.FACING , placer.getHorizontalFacing( ) );
}
@Override
public boolean onBlockActivated( final World worldIn , final BlockPos pos , final IBlockState state ,
final EntityPlayer playerIn , final EnumHand hand , final ItemStack heldItem , final EnumFacing side ,
final float hitX , final float hitY , final float hitZ )
{
return USeat.sit( worldIn , pos , playerIn , 0.25 );
}
@Override
public void neighborChanged( final IBlockState state , final World worldIn , final BlockPos pos ,
final Block blockIn )
{
I_USupportBlock.dropIfUnsupported( state , worldIn , pos , this );
}
@Override
public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos )
{
return super.canPlaceBlockAt( worldIn , pos ) && I_USupportBlock.check( worldIn , pos );
}
}

View file

@ -0,0 +1,259 @@
package mmm.deco;
import java.util.List;
import mmm.MmmMaterials;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.core.api.blocks.I_SeatBlock;
import mmm.core.api.blocks.I_SupportBlock;
import mmm.materials.MWood;
import mmm.utils.UMaths;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.EnumPushReaction;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class DChairs
{
public static class ChairBlock
extends Block
implements I_RecipeRegistrar , I_SeatBlock
{
public static final PropertyDirection FACING = BlockHorizontal.FACING;
private static final AxisAlignedBB BOUNDING_BOX = UMaths.makeBlockAABB( 1 , 0 , 1 , 15 , 16 , 15 );
private static final AxisAlignedBB COLLISION_BOTTOM = UMaths.makeBlockAABB( 1 , 0 , 1 , 15 , 8 , 15 );
private static final AxisAlignedBB COLLISION_TOP_NORTH = UMaths.makeBlockAABB( 2 , 8 , 2 , 14 , 16 , 4 );
private static final AxisAlignedBB COLLISION_TOP_EAST = UMaths.makeBlockAABB( 12 , 8 , 2 , 14 , 16 , 14 );
private static final AxisAlignedBB COLLISION_TOP_SOUTH = UMaths.makeBlockAABB( 2 , 8 , 12 , 14 , 16 , 14 );
private static final AxisAlignedBB COLLISION_TOP_WEST = UMaths.makeBlockAABB( 2 , 8 , 2 , 4 , 16 , 14 );
public final MWood type;
public ChairBlock( final MWood type )
{
super( Material.WOOD , type.getMapColor( ) );
this.type = type;
this.setDefaultState(
this.blockState.getBaseState( ).withProperty( ChairBlock.FACING , EnumFacing.NORTH ) );
this.setCreativeTab( CreativeTabs.DECORATIONS );
CRegistry.setIdentifiers( this , "deco" , "chair" , type.getSuffix( ) );
this.lightOpacity = 0;
this.translucent = false;
this.fullBlock = false;
this.blockHardness = 2.5f;
this.blockResistance = 12.5f;
this.blockSoundType = SoundType.LADDER;
this.enableStats = false;
this.setHarvestLevel( "axe" , 0 );
}
@Override
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
{
return ChairBlock.BOUNDING_BOX;
}
@Override
public void addCollisionBoxToList( final IBlockState state , final World worldIn , final BlockPos pos ,
final AxisAlignedBB container , final List< AxisAlignedBB > output , final Entity entity )
{
Block.addCollisionBoxToList( pos , container , output , ChairBlock.COLLISION_BOTTOM );
AxisAlignedBB back;
switch ( state.getValue( ChairBlock.FACING ) ) {
case EAST:
back = ChairBlock.COLLISION_TOP_EAST;
break;
case NORTH:
back = ChairBlock.COLLISION_TOP_NORTH;
break;
case SOUTH:
back = ChairBlock.COLLISION_TOP_SOUTH;
break;
case WEST:
back = ChairBlock.COLLISION_TOP_WEST;
break;
default:
// TODO log problem
return;
}
Block.addCollisionBoxToList( pos , container , output , back );
}
@Override
public EnumPushReaction getMobilityFlag( final IBlockState state )
{
return EnumPushReaction.DESTROY;
}
@Override
public void registerRecipes( )
{
GameRegistry.addShapedRecipe( new ItemStack( this ) , //
"B " , //
"BB" , //
"SS" , //
'B' , new ItemStack( this.type.getSlabBlock( ) , 1 , this.type.getMetaData( ) ) , //
'S' , Items.STICK //
);
}
@Override
public boolean isOpaqueCube( final IBlockState state )
{
return false;
}
@Override
public boolean isFullCube( final IBlockState state )
{
return false;
}
@Override
@SideOnly( Side.CLIENT )
public BlockRenderLayer getBlockLayer( )
{
return BlockRenderLayer.CUTOUT;
}
@Override
protected BlockStateContainer createBlockState( )
{
return new BlockStateContainer( this , new IProperty[] {
ChairBlock.FACING
} );
}
@Override
public IBlockState withRotation( final IBlockState state , final Rotation rot )
{
return state.withProperty( ChairBlock.FACING , rot.rotate( state.getValue( ChairBlock.FACING ) ) );
}
@Override
public IBlockState withMirror( final IBlockState state , final Mirror mirrorIn )
{
return state.withRotation( mirrorIn.toRotation( state.getValue( ChairBlock.FACING ) ) );
}
@Override
public IBlockState getStateFromMeta( final int meta )
{
EnumFacing enumfacing = EnumFacing.getFront( meta );
if ( enumfacing.getAxis( ) == EnumFacing.Axis.Y ) {
enumfacing = EnumFacing.NORTH;
}
return this.getDefaultState( ).withProperty( ChairBlock.FACING , enumfacing );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return state.getValue( ChairBlock.FACING ).getIndex( );
}
@Override
public IBlockState onBlockPlaced( final World worldIn , final BlockPos pos , final EnumFacing facing ,
final float hitX , final float hitY , final float hitZ , final int meta ,
final EntityLivingBase placer )
{
return this.getDefaultState( ).withProperty( ChairBlock.FACING , placer.getHorizontalFacing( ) );
}
@Override
public boolean onBlockActivated( final World worldIn , final BlockPos pos , final IBlockState state ,
final EntityPlayer playerIn , final EnumHand hand , final ItemStack heldItem , final EnumFacing side ,
final float hitX , final float hitY , final float hitZ )
{
return DSeatEntity.sit( worldIn , pos , playerIn , 0.25 );
}
@Override
public void neighborChanged( final IBlockState state , final World worldIn , final BlockPos pos ,
final Block blockIn )
{
I_SupportBlock.dropIfUnsupported( state , worldIn , pos , this );
}
@Override
public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos )
{
return super.canPlaceBlockAt( worldIn , pos ) && I_SupportBlock.check( worldIn , pos );
}
}
public final ChairBlock OAK;
public final ChairBlock BIRCH;
public final ChairBlock SPRUCE;
public final ChairBlock JUNGLE;
public final ChairBlock DARK_OAK;
public final ChairBlock ACACIA;
public final ChairBlock HEVEA;
public final ChairBlock BAMBOO;
public DChairs( )
{
CRegistry.addBlock( this.OAK = new ChairBlock( MmmMaterials.WOOD.OAK ) );
CRegistry.addBlock( this.BIRCH = new ChairBlock( MmmMaterials.WOOD.BIRCH ) );
CRegistry.addBlock( this.SPRUCE = new ChairBlock( MmmMaterials.WOOD.SPRUCE ) );
CRegistry.addBlock( this.JUNGLE = new ChairBlock( MmmMaterials.WOOD.JUNGLE ) );
CRegistry.addBlock( this.DARK_OAK = new ChairBlock( MmmMaterials.WOOD.DARK_OAK ) );
CRegistry.addBlock( this.ACACIA = new ChairBlock( MmmMaterials.WOOD.ACACIA ) );
CRegistry.addBlock( this.HEVEA = new ChairBlock( MmmMaterials.WOOD.HEVEA ) );
CRegistry.addBlock( this.BAMBOO = new ChairBlock( MmmMaterials.WOOD.BAMBOO ) );
}
}

View file

@ -1,20 +0,0 @@
package mmm.deco;
import mmm.utils.URegistry;
public class DFence
{
public final DFenceBlock BLOCK;
public final DFenceGate GATE;
public DFence( DWoodType woodType )
{
URegistry.addBlock( this.BLOCK = new DFenceBlock( woodType ) );
URegistry.addBlock( this.GATE = new DFenceGate( woodType ) );
}
}

View file

@ -1,16 +0,0 @@
package mmm.deco;
public class DFences
{
public final DFence BAMBOO;
public final DFence HEVEA;
DFences( )
{
this.BAMBOO = new DFence( DWoodType.BAMBOO );
this.HEVEA = new DFence( DWoodType.HEVEA );
}
}

View file

@ -1,9 +1,10 @@
package mmm.utils; package mmm.deco;
import java.util.List; import java.util.List;
import mmm.Mmm; import mmm.Mmm;
import mmm.core.api.blocks.I_SeatBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -15,13 +16,13 @@ import net.minecraftforge.fml.common.registry.EntityRegistry;
public class USeat public class DSeatEntity
extends Entity extends Entity
{ {
public static void register( final Mmm mmm ) public static void register( final Mmm mmm )
{ {
EntityRegistry.registerModEntity( USeat.class , "Seat" , 0 , mmm , 80 , 1 , false ); EntityRegistry.registerModEntity( DSeatEntity.class , "Seat" , 0 , mmm , 80 , 1 , false );
} }
@ -32,10 +33,10 @@ public class USeat
return true; return true;
} }
final List< USeat > seats = world.getEntitiesWithinAABB( USeat.class , final List< DSeatEntity > seats = world.getEntitiesWithinAABB( DSeatEntity.class ,
new AxisAlignedBB( pos ).expand( 1 , 1 , 1 ) ); new AxisAlignedBB( pos ).expand( 1 , 1 , 1 ) );
USeat seat = null; DSeatEntity seat = null;
for ( final USeat existingSeat : seats ) { for ( final DSeatEntity existingSeat : seats ) {
if ( !existingSeat.pos.equals( pos ) ) { if ( !existingSeat.pos.equals( pos ) ) {
continue; continue;
} }
@ -47,7 +48,7 @@ public class USeat
} }
if ( seat == null ) { if ( seat == null ) {
seat = new USeat( world , pos , yOffset ); seat = new DSeatEntity( world , pos , yOffset );
world.spawnEntityInWorld( seat ); world.spawnEntityInWorld( seat );
} }
player.startRiding( seat ); player.startRiding( seat );
@ -61,7 +62,7 @@ public class USeat
public double yOffset; public double yOffset;
public USeat( final World world ) public DSeatEntity( final World world )
{ {
super( world ); super( world );
@ -73,7 +74,7 @@ public class USeat
} }
public USeat( final World world , final BlockPos pos , final double yOffset ) public DSeatEntity( final World world , final BlockPos pos , final double yOffset )
{ {
this( world ); this( world );
@ -149,7 +150,7 @@ public class USeat
} }
final Block block = this.worldObj.getBlockState( this.pos ).getBlock( ); final Block block = this.worldObj.getBlockState( this.pos ).getBlock( );
if ( ! ( block instanceof I_UBlockSeat ) ) { if ( ! ( block instanceof I_SeatBlock ) ) {
this.setDead( ); this.setDead( );
return; return;
} }

View file

@ -1,9 +1,10 @@
package mmm.deco; package mmm.deco;
import mmm.MmmMaterials;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.materials.MTree; import mmm.materials.MTree;
import mmm.utils.I_URecipeRegistrar;
import mmm.utils.URegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs; import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockStone; import net.minecraft.block.BlockStone;
@ -15,22 +16,25 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class DStairs public class DStairs
extends BlockStairs
implements I_URecipeRegistrar
{ {
public static DStairs fromVanillaSmoothStone( final BlockStone.EnumType type )
public static class StairsBlock
extends BlockStairs
implements I_RecipeRegistrar
{
public static StairsBlock fromVanillaSmoothStone( final BlockStone.EnumType type )
{ {
final IBlockState bs = Blocks.STONE.getDefaultState( ).withProperty( BlockStone.VARIANT , type ); final IBlockState bs = Blocks.STONE.getDefaultState( ).withProperty( BlockStone.VARIANT , type );
final DStairs stairs = new DStairs( bs , type.getName( ).replace( "smooth_" , "" ) ); final StairsBlock stairs = new StairsBlock( bs , type.getName( ).replace( "smooth_" , "" ) );
URegistry.addBlock( stairs ); CRegistry.addBlock( stairs );
return stairs; return stairs;
} }
public static DStairs fromWood( final MTree materials ) public static StairsBlock fromWood( final MTree materials )
{ {
final DStairs stairs = new DStairs( materials.PLANKS.getDefaultState( ) , materials.NAME ); final StairsBlock stairs = new StairsBlock( materials.PLANKS.getDefaultState( ) , materials.NAME );
URegistry.addBlock( stairs ); CRegistry.addBlock( stairs );
if ( materials.getBaseFlammability( ) != 0 ) { if ( materials.getBaseFlammability( ) != 0 ) {
Blocks.FIRE.setFireInfo( stairs , materials.getBaseFireEncouragement( ) , Blocks.FIRE.setFireInfo( stairs , materials.getBaseFireEncouragement( ) ,
materials.getBaseFlammability( ) * 4 ); materials.getBaseFlammability( ) * 4 );
@ -42,18 +46,18 @@ public class DStairs
public final Block modelBlock; public final Block modelBlock;
public DStairs( final Block modelBlock , final String name ) public StairsBlock( final Block modelBlock , final String name )
{ {
this( modelBlock.getDefaultState( ) , name ); this( modelBlock.getDefaultState( ) , name );
} }
public DStairs( final IBlockState modelState , final String name ) public StairsBlock( final IBlockState modelState , final String name )
{ {
super( modelState ); super( modelState );
this.modelState = modelState; this.modelState = modelState;
this.modelBlock = modelState.getBlock( ); this.modelBlock = modelState.getBlock( );
URegistry.setIdentifiers( this , "deco" , "stairs" , name ); CRegistry.setIdentifiers( this , "deco" , "stairs" , name );
} }
@ -67,4 +71,21 @@ public class DStairs
'B' , new ItemStack( this.modelBlock , 4 , this.modelBlock.getMetaFromState( this.modelState ) ) ); 'B' , new ItemStack( this.modelBlock , 4 , this.modelBlock.getMetaFromState( this.modelState ) ) );
} }
}
public final StairsBlock GRANITE;
public final StairsBlock DIORITE;
public final StairsBlock ANDESITE;
public final StairsBlock HEVEA;
public final StairsBlock BAMBOO;
public DStairs( )
{
this.GRANITE = StairsBlock.fromVanillaSmoothStone( BlockStone.EnumType.GRANITE_SMOOTH );
this.DIORITE = StairsBlock.fromVanillaSmoothStone( BlockStone.EnumType.DIORITE_SMOOTH );
this.ANDESITE = StairsBlock.fromVanillaSmoothStone( BlockStone.EnumType.ANDESITE_SMOOTH );
this.HEVEA = StairsBlock.fromWood( MmmMaterials.TREE.HEVEA );
this.BAMBOO = StairsBlock.fromWood( MmmMaterials.TREE.BAMBOO );
}
} }

View file

@ -1,291 +0,0 @@
package mmm.deco;
import java.util.List;
import mmm.utils.I_URecipeRegistrar;
import mmm.utils.I_USupportBlock;
import mmm.utils.UMaths;
import mmm.utils.URegistry;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class DTable
extends Block
implements I_URecipeRegistrar
{
protected static final AxisAlignedBB COLLISION_TOP = UMaths.makeBlockAABB( 0 , 12 , 0 , 16 , 16 , 16 );
protected static final AxisAlignedBB COLLISION_LEGS[] = { //
UMaths.makeBlockAABB( 1 , 0 , 1 , 3 , 12 , 3 ) , //
UMaths.makeBlockAABB( 13 , 0 , 1 , 15 , 12 , 3 ) , //
UMaths.makeBlockAABB( 13 , 0 , 13 , 15 , 12 , 15 ) , //
UMaths.makeBlockAABB( 1 , 0 , 13 , 3 , 12 , 15 ), //
};
public static final PropertyBool NORTH = PropertyBool.create( "north" );
public static final PropertyBool EAST = PropertyBool.create( "east" );
public static final PropertyBool SOUTH = PropertyBool.create( "south" );
public static final PropertyBool WEST = PropertyBool.create( "west" );
public static final PropertyBool NW = PropertyBool.create( "nw" );
public static final PropertyBool NE = PropertyBool.create( "ne" );
public static final PropertyBool SW = PropertyBool.create( "sw" );
public static final PropertyBool SE = PropertyBool.create( "se" );
private static final PropertyBool[] DIRECTIONS = { //
DTable.NORTH , DTable.NE , DTable.EAST , DTable.SE , DTable.SOUTH ,
DTable.SW , DTable.WEST , DTable.NW//
};
public final DWoodType type;
public DTable( final DWoodType type )
{
super( Material.WOOD , type.getMapColor() );
this.type = type;
this.setDefaultState( this.blockState.getBaseState( )//
.withProperty( DTable.NORTH , Boolean.valueOf( false ) )//
.withProperty( DTable.EAST , Boolean.valueOf( false ) )//
.withProperty( DTable.SOUTH , Boolean.valueOf( false ) )//
.withProperty( DTable.WEST , Boolean.valueOf( false ) )//
.withProperty( DTable.NW , Boolean.valueOf( false ) )//
.withProperty( DTable.NE , Boolean.valueOf( false ) )//
.withProperty( DTable.SW , Boolean.valueOf( false ) )//
.withProperty( DTable.SE , Boolean.valueOf( false ) ) );
this.setCreativeTab( CreativeTabs.DECORATIONS );
URegistry.setIdentifiers( this , "deco" , "table" , type.getSuffix() );
this.lightOpacity = 0;
this.translucent = false;
this.fullBlock = false;
this.blockHardness = 2.5f;
this.blockResistance = 12.5f;
this.blockSoundType = SoundType.LADDER;
this.enableStats = false;
this.setHarvestLevel( "axe" , 0 );
}
@Override
public void registerRecipes( )
{
GameRegistry.addShapedRecipe( new ItemStack( this ) , //
"BBB" , //
"S S" , //
'B' , new ItemStack( this.type.getPlanksBlock() , 1 , this.type.getMetaData() ) , //
'S' , Items.STICK //
);
}
@Override
public boolean isOpaqueCube( final IBlockState state )
{
return false;
}
@Override
public boolean isFullCube( final IBlockState state )
{
return false;
}
public boolean canConnectTo( final IBlockAccess worldIn , final BlockPos pos )
{
return worldIn.getBlockState( pos ).getBlock( ) == this;
}
@Override
protected BlockStateContainer createBlockState( )
{
return new BlockStateContainer( this , new IProperty[] {
DTable.NORTH , DTable.EAST , DTable.WEST , DTable.SOUTH , DTable.NE ,
DTable.NW , DTable.SE , DTable.SW
} );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return 0;
}
@Override
public IBlockState getActualState( final IBlockState state , final IBlockAccess worldIn , final BlockPos pos )
{
final BlockPos n = pos.north( );
final BlockPos s = pos.south( );
final BlockPos w = pos.west( );
final BlockPos e = pos.east( );
return state.withProperty( DTable.NORTH , Boolean.valueOf( this.canConnectTo( worldIn , n ) ) )//
.withProperty( DTable.EAST , Boolean.valueOf( this.canConnectTo( worldIn , e ) ) )//
.withProperty( DTable.SOUTH , Boolean.valueOf( this.canConnectTo( worldIn , s ) ) )//
.withProperty( DTable.WEST , Boolean.valueOf( this.canConnectTo( worldIn , w ) ) )//
.withProperty( DTable.NW , Boolean.valueOf( this.canConnectTo( worldIn , n.west( ) ) ) )//
.withProperty( DTable.NE , Boolean.valueOf( this.canConnectTo( worldIn , n.east( ) ) ) )//
.withProperty( DTable.SW , Boolean.valueOf( this.canConnectTo( worldIn , s.west( ) ) ) )//
.withProperty( DTable.SE , Boolean.valueOf( this.canConnectTo( worldIn , s.east( ) ) ) )//
;
}
@Override
public IBlockState withRotation( final IBlockState state , final Rotation rot )
{
switch ( rot ) {
case CLOCKWISE_180:
return state.withProperty( DTable.NORTH , state.getValue( DTable.SOUTH ) )//
.withProperty( DTable.EAST , state.getValue( DTable.WEST ) )//
.withProperty( DTable.SOUTH , state.getValue( DTable.NORTH ) )//
.withProperty( DTable.WEST , state.getValue( DTable.EAST ) )//
.withProperty( DTable.NW , state.getValue( DTable.SE ) )//
.withProperty( DTable.NE , state.getValue( DTable.SW ) )//
.withProperty( DTable.SE , state.getValue( DTable.NW ) )//
.withProperty( DTable.SW , state.getValue( DTable.NE ) )//
;
case COUNTERCLOCKWISE_90:
return state.withProperty( DTable.NORTH , state.getValue( DTable.EAST ) )//
.withProperty( DTable.EAST , state.getValue( DTable.SOUTH ) )//
.withProperty( DTable.SOUTH , state.getValue( DTable.WEST ) )//
.withProperty( DTable.WEST , state.getValue( DTable.NORTH ) )//
.withProperty( DTable.NW , state.getValue( DTable.NE ) )//
.withProperty( DTable.NE , state.getValue( DTable.SE ) )//
.withProperty( DTable.SE , state.getValue( DTable.SW ) )//
.withProperty( DTable.SW , state.getValue( DTable.NW ) )//
;
case CLOCKWISE_90:
return state.withProperty( DTable.NORTH , state.getValue( DTable.WEST ) )//
.withProperty( DTable.EAST , state.getValue( DTable.NORTH ) )//
.withProperty( DTable.SOUTH , state.getValue( DTable.EAST ) )//
.withProperty( DTable.WEST , state.getValue( DTable.SOUTH ) )//
.withProperty( DTable.NW , state.getValue( DTable.SW ) )//
.withProperty( DTable.NE , state.getValue( DTable.NW ) )//
.withProperty( DTable.SE , state.getValue( DTable.NE ) )//
.withProperty( DTable.SW , state.getValue( DTable.SE ) )//
;
default:
return state;
}
}
@Override
public IBlockState withMirror( final IBlockState state , final Mirror mirrorIn )
{
switch ( mirrorIn ) {
case LEFT_RIGHT:
return state.withProperty( DTable.NORTH , state.getValue( DTable.SOUTH ) )//
.withProperty( DTable.SOUTH , state.getValue( DTable.NORTH ) )//
.withProperty( DTable.NW , state.getValue( DTable.SW ) )//
.withProperty( DTable.NE , state.getValue( DTable.SE ) )//
.withProperty( DTable.SW , state.getValue( DTable.NW ) )//
.withProperty( DTable.SE , state.getValue( DTable.NE ) )//
;
case FRONT_BACK:
return state.withProperty( DTable.EAST , state.getValue( DTable.WEST ) )//
.withProperty( DTable.WEST , state.getValue( DTable.EAST ) )//
.withProperty( DTable.NW , state.getValue( DTable.NE ) )//
.withProperty( DTable.NE , state.getValue( DTable.NW ) )//
.withProperty( DTable.SW , state.getValue( DTable.SE ) )//
.withProperty( DTable.SE , state.getValue( DTable.SW ) )//
;
default:
return state;
}
}
@Override
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
{
final IBlockState actual = this.getActualState( state , source , pos );
for ( int i = 0 , dir = 0 ; i < 4 ; i++ , dir += 2 ) {
final boolean c0 = actual.getValue( DTable.DIRECTIONS[ dir ] );
final boolean c1 = actual.getValue( DTable.DIRECTIONS[ ( dir + 6 ) % 8 ] );
final boolean c10 = actual.getValue( DTable.DIRECTIONS[ ( dir + 7 ) % 8 ] );
if ( ! ( c0 || c1 ) || c0 && c1 && !c10 ) {
return Block.FULL_BLOCK_AABB;
}
}
return DTable.COLLISION_TOP;
}
@Override
public void addCollisionBoxToList( final IBlockState state , final World worldIn , final BlockPos pos ,
final AxisAlignedBB container , final List< AxisAlignedBB > output , final Entity entity )
{
final IBlockState actual = this.getActualState( state , worldIn , pos );
Block.addCollisionBoxToList( pos , container , output , DTable.COLLISION_TOP );
for ( int i = 0 , dir = 0 ; i < 4 ; i++ , dir += 2 ) {
final boolean c0 = actual.getValue( DTable.DIRECTIONS[ dir ] );
final boolean c1 = actual.getValue( DTable.DIRECTIONS[ ( dir + 6 ) % 8 ] );
final boolean c10 = actual.getValue( DTable.DIRECTIONS[ ( dir + 7 ) % 8 ] );
if ( ! ( c0 || c1 ) || c0 && c1 && !c10 ) {
Block.addCollisionBoxToList( pos , container , output , DTable.COLLISION_LEGS[ i ] );
}
}
}
@Override
@SideOnly( Side.CLIENT )
public BlockRenderLayer getBlockLayer( )
{
return BlockRenderLayer.CUTOUT;
}
@Override
public boolean isSideSolid( final IBlockState base_state , final IBlockAccess world , final BlockPos pos ,
final EnumFacing side )
{
return side == EnumFacing.UP;
}
@Override
public void neighborChanged( final IBlockState state , final World worldIn , final BlockPos pos ,
final Block blockIn )
{
I_USupportBlock.dropIfUnsupported( state , worldIn , pos , this );
}
@Override
public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos )
{
return super.canPlaceBlockAt( worldIn , pos ) && I_USupportBlock.check( worldIn , pos );
}
}

View file

@ -0,0 +1,321 @@
package mmm.deco;
import java.util.List;
import mmm.MmmMaterials;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.core.api.blocks.I_SupportBlock;
import mmm.materials.MWood;
import mmm.utils.UMaths;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class DTables
{
public static class TableBlock
extends Block
implements I_RecipeRegistrar
{
protected static final AxisAlignedBB COLLISION_TOP = UMaths.makeBlockAABB( 0 , 12 , 0 , 16 , 16 , 16 );
protected static final AxisAlignedBB COLLISION_LEGS[] = { //
UMaths.makeBlockAABB( 1 , 0 , 1 , 3 , 12 , 3 ) , //
UMaths.makeBlockAABB( 13 , 0 , 1 , 15 , 12 , 3 ) , //
UMaths.makeBlockAABB( 13 , 0 , 13 , 15 , 12 , 15 ) , //
UMaths.makeBlockAABB( 1 , 0 , 13 , 3 , 12 , 15 ), //
};
public static final PropertyBool NORTH = PropertyBool.create( "north" );
public static final PropertyBool EAST = PropertyBool.create( "east" );
public static final PropertyBool SOUTH = PropertyBool.create( "south" );
public static final PropertyBool WEST = PropertyBool.create( "west" );
public static final PropertyBool NW = PropertyBool.create( "nw" );
public static final PropertyBool NE = PropertyBool.create( "ne" );
public static final PropertyBool SW = PropertyBool.create( "sw" );
public static final PropertyBool SE = PropertyBool.create( "se" );
private static final PropertyBool[] DIRECTIONS = { //
TableBlock.NORTH , TableBlock.NE , //
TableBlock.EAST , TableBlock.SE , //
TableBlock.SOUTH , TableBlock.SW , //
TableBlock.WEST , TableBlock.NW//
};
public final MWood type;
public TableBlock( final MWood type )
{
super( Material.WOOD , type.getMapColor( ) );
this.type = type;
this.setDefaultState( this.blockState.getBaseState( )//
.withProperty( TableBlock.NORTH , Boolean.valueOf( false ) )//
.withProperty( TableBlock.EAST , Boolean.valueOf( false ) )//
.withProperty( TableBlock.SOUTH , Boolean.valueOf( false ) )//
.withProperty( TableBlock.WEST , Boolean.valueOf( false ) )//
.withProperty( TableBlock.NW , Boolean.valueOf( false ) )//
.withProperty( TableBlock.NE , Boolean.valueOf( false ) )//
.withProperty( TableBlock.SW , Boolean.valueOf( false ) )//
.withProperty( TableBlock.SE , Boolean.valueOf( false ) ) );
this.setCreativeTab( CreativeTabs.DECORATIONS );
CRegistry.setIdentifiers( this , "deco" , "table" , type.getSuffix( ) );
this.lightOpacity = 0;
this.translucent = false;
this.fullBlock = false;
this.blockHardness = 2.5f;
this.blockResistance = 12.5f;
this.blockSoundType = SoundType.LADDER;
this.enableStats = false;
this.setHarvestLevel( "axe" , 0 );
}
@Override
public void registerRecipes( )
{
GameRegistry.addShapedRecipe( new ItemStack( this ) , //
"BBB" , //
"S S" , //
'B' , new ItemStack( this.type.getPlanksBlock( ) , 1 , this.type.getMetaData( ) ) , //
'S' , Items.STICK //
);
}
@Override
public boolean isOpaqueCube( final IBlockState state )
{
return false;
}
@Override
public boolean isFullCube( final IBlockState state )
{
return false;
}
public boolean canConnectTo( final IBlockAccess worldIn , final BlockPos pos )
{
return worldIn.getBlockState( pos ).getBlock( ) == this;
}
@Override
protected BlockStateContainer createBlockState( )
{
return new BlockStateContainer( this , new IProperty[] {
TableBlock.NORTH , TableBlock.EAST , TableBlock.WEST , TableBlock.SOUTH , TableBlock.NE ,
TableBlock.NW , TableBlock.SE , TableBlock.SW
} );
}
@Override
public int getMetaFromState( final IBlockState state )
{
return 0;
}
@Override
public IBlockState getActualState( final IBlockState state , final IBlockAccess worldIn , final BlockPos pos )
{
final BlockPos n = pos.north( );
final BlockPos s = pos.south( );
final BlockPos w = pos.west( );
final BlockPos e = pos.east( );
return state.withProperty( TableBlock.NORTH , Boolean.valueOf( this.canConnectTo( worldIn , n ) ) )//
.withProperty( TableBlock.EAST , Boolean.valueOf( this.canConnectTo( worldIn , e ) ) )//
.withProperty( TableBlock.SOUTH , Boolean.valueOf( this.canConnectTo( worldIn , s ) ) )//
.withProperty( TableBlock.WEST , Boolean.valueOf( this.canConnectTo( worldIn , w ) ) )//
.withProperty( TableBlock.NW , Boolean.valueOf( this.canConnectTo( worldIn , n.west( ) ) ) )//
.withProperty( TableBlock.NE , Boolean.valueOf( this.canConnectTo( worldIn , n.east( ) ) ) )//
.withProperty( TableBlock.SW , Boolean.valueOf( this.canConnectTo( worldIn , s.west( ) ) ) )//
.withProperty( TableBlock.SE , Boolean.valueOf( this.canConnectTo( worldIn , s.east( ) ) ) )//
;
}
@Override
public IBlockState withRotation( final IBlockState state , final Rotation rot )
{
switch ( rot ) {
case CLOCKWISE_180:
return state.withProperty( TableBlock.NORTH , state.getValue( TableBlock.SOUTH ) )//
.withProperty( TableBlock.EAST , state.getValue( TableBlock.WEST ) )//
.withProperty( TableBlock.SOUTH , state.getValue( TableBlock.NORTH ) )//
.withProperty( TableBlock.WEST , state.getValue( TableBlock.EAST ) )//
.withProperty( TableBlock.NW , state.getValue( TableBlock.SE ) )//
.withProperty( TableBlock.NE , state.getValue( TableBlock.SW ) )//
.withProperty( TableBlock.SE , state.getValue( TableBlock.NW ) )//
.withProperty( TableBlock.SW , state.getValue( TableBlock.NE ) )//
;
case COUNTERCLOCKWISE_90:
return state.withProperty( TableBlock.NORTH , state.getValue( TableBlock.EAST ) )//
.withProperty( TableBlock.EAST , state.getValue( TableBlock.SOUTH ) )//
.withProperty( TableBlock.SOUTH , state.getValue( TableBlock.WEST ) )//
.withProperty( TableBlock.WEST , state.getValue( TableBlock.NORTH ) )//
.withProperty( TableBlock.NW , state.getValue( TableBlock.NE ) )//
.withProperty( TableBlock.NE , state.getValue( TableBlock.SE ) )//
.withProperty( TableBlock.SE , state.getValue( TableBlock.SW ) )//
.withProperty( TableBlock.SW , state.getValue( TableBlock.NW ) )//
;
case CLOCKWISE_90:
return state.withProperty( TableBlock.NORTH , state.getValue( TableBlock.WEST ) )//
.withProperty( TableBlock.EAST , state.getValue( TableBlock.NORTH ) )//
.withProperty( TableBlock.SOUTH , state.getValue( TableBlock.EAST ) )//
.withProperty( TableBlock.WEST , state.getValue( TableBlock.SOUTH ) )//
.withProperty( TableBlock.NW , state.getValue( TableBlock.SW ) )//
.withProperty( TableBlock.NE , state.getValue( TableBlock.NW ) )//
.withProperty( TableBlock.SE , state.getValue( TableBlock.NE ) )//
.withProperty( TableBlock.SW , state.getValue( TableBlock.SE ) )//
;
default:
return state;
}
}
@Override
public IBlockState withMirror( final IBlockState state , final Mirror mirrorIn )
{
switch ( mirrorIn ) {
case LEFT_RIGHT:
return state.withProperty( TableBlock.NORTH , state.getValue( TableBlock.SOUTH ) )//
.withProperty( TableBlock.SOUTH , state.getValue( TableBlock.NORTH ) )//
.withProperty( TableBlock.NW , state.getValue( TableBlock.SW ) )//
.withProperty( TableBlock.NE , state.getValue( TableBlock.SE ) )//
.withProperty( TableBlock.SW , state.getValue( TableBlock.NW ) )//
.withProperty( TableBlock.SE , state.getValue( TableBlock.NE ) )//
;
case FRONT_BACK:
return state.withProperty( TableBlock.EAST , state.getValue( TableBlock.WEST ) )//
.withProperty( TableBlock.WEST , state.getValue( TableBlock.EAST ) )//
.withProperty( TableBlock.NW , state.getValue( TableBlock.NE ) )//
.withProperty( TableBlock.NE , state.getValue( TableBlock.NW ) )//
.withProperty( TableBlock.SW , state.getValue( TableBlock.SE ) )//
.withProperty( TableBlock.SE , state.getValue( TableBlock.SW ) )//
;
default:
return state;
}
}
@Override
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
{
final IBlockState actual = this.getActualState( state , source , pos );
for ( int i = 0 , dir = 0 ; i < 4 ; i++ , dir += 2 ) {
final boolean c0 = actual.getValue( TableBlock.DIRECTIONS[ dir ] );
final boolean c1 = actual.getValue( TableBlock.DIRECTIONS[ ( dir + 6 ) % 8 ] );
final boolean c10 = actual.getValue( TableBlock.DIRECTIONS[ ( dir + 7 ) % 8 ] );
if ( ! ( c0 || c1 ) || c0 && c1 && !c10 ) {
return Block.FULL_BLOCK_AABB;
}
}
return TableBlock.COLLISION_TOP;
}
@Override
public void addCollisionBoxToList( final IBlockState state , final World worldIn , final BlockPos pos ,
final AxisAlignedBB container , final List< AxisAlignedBB > output , final Entity entity )
{
final IBlockState actual = this.getActualState( state , worldIn , pos );
Block.addCollisionBoxToList( pos , container , output , TableBlock.COLLISION_TOP );
for ( int i = 0 , dir = 0 ; i < 4 ; i++ , dir += 2 ) {
final boolean c0 = actual.getValue( TableBlock.DIRECTIONS[ dir ] );
final boolean c1 = actual.getValue( TableBlock.DIRECTIONS[ ( dir + 6 ) % 8 ] );
final boolean c10 = actual.getValue( TableBlock.DIRECTIONS[ ( dir + 7 ) % 8 ] );
if ( ! ( c0 || c1 ) || c0 && c1 && !c10 ) {
Block.addCollisionBoxToList( pos , container , output , TableBlock.COLLISION_LEGS[ i ] );
}
}
}
@Override
@SideOnly( Side.CLIENT )
public BlockRenderLayer getBlockLayer( )
{
return BlockRenderLayer.CUTOUT;
}
@Override
public boolean isSideSolid( final IBlockState base_state , final IBlockAccess world , final BlockPos pos ,
final EnumFacing side )
{
return side == EnumFacing.UP;
}
@Override
public void neighborChanged( final IBlockState state , final World worldIn , final BlockPos pos ,
final Block blockIn )
{
I_SupportBlock.dropIfUnsupported( state , worldIn , pos , this );
}
@Override
public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos )
{
return super.canPlaceBlockAt( worldIn , pos ) && I_SupportBlock.check( worldIn , pos );
}
}
public final TableBlock OAK;
public final TableBlock BIRCH;
public final TableBlock SPRUCE;
public final TableBlock JUNGLE;
public final TableBlock DARK_OAK;
public final TableBlock ACACIA;
public final TableBlock HEVEA;
public final TableBlock BAMBOO;
public DTables( )
{
CRegistry.addBlock( this.OAK = new TableBlock( MmmMaterials.WOOD.OAK ) );
CRegistry.addBlock( this.BIRCH = new TableBlock( MmmMaterials.WOOD.BIRCH ) );
CRegistry.addBlock( this.SPRUCE = new TableBlock( MmmMaterials.WOOD.SPRUCE ) );
CRegistry.addBlock( this.JUNGLE = new TableBlock( MmmMaterials.WOOD.JUNGLE ) );
CRegistry.addBlock( this.DARK_OAK = new TableBlock( MmmMaterials.WOOD.DARK_OAK ) );
CRegistry.addBlock( this.ACACIA = new TableBlock( MmmMaterials.WOOD.ACACIA ) );
CRegistry.addBlock( this.HEVEA = new TableBlock( MmmMaterials.WOOD.HEVEA ) );
CRegistry.addBlock( this.BAMBOO = new TableBlock( MmmMaterials.WOOD.BAMBOO ) );
}
}

View file

@ -1,111 +0,0 @@
package mmm.deco;
import mmm.materials.Materials;
import mmm.utils.URegistry;
import net.minecraft.block.BlockStone;
public class DecorativeBlocks
{
public static final DStairs STAIRS_GRANITE;
public static final DStairs STAIRS_DIORITE;
public static final DStairs STAIRS_ANDESITE;
public static final DStairs STAIRS_HEVEA;
public static final DStairs STAIRS_BAMBOO;
public static final DSlab SLAB_GRANITE;
public static final DSlab SLAB_DIORITE;
public static final DSlab SLAB_ANDESITE;
public static final DSlab SLAB_HEVEA;
public static final DSlab SLAB_BAMBOO;
public static final DTable TABLE_OAK;
public static final DTable TABLE_BIRCH;
public static final DTable TABLE_SPRUCE;
public static final DTable TABLE_JUNGLE;
public static final DTable TABLE_DARK_OAK;
public static final DTable TABLE_ACACIA;
public static final DTable TABLE_HEVEA;
public static final DTable TABLE_BAMBOO;
public static final DChair CHAIR_OAK;
public static final DChair CHAIR_BIRCH;
public static final DChair CHAIR_SPRUCE;
public static final DChair CHAIR_JUNGLE;
public static final DChair CHAIR_DARK_OAK;
public static final DChair CHAIR_ACACIA;
public static final DChair CHAIR_HEVEA;
public static final DChair CHAIR_BAMBOO;
public static final DThrone THRONE_OAK;
public static final DThrone THRONE_BIRCH;
public static final DThrone THRONE_SPRUCE;
public static final DThrone THRONE_JUNGLE;
public static final DThrone THRONE_DARK_OAK;
public static final DThrone THRONE_ACACIA;
public static final DThrone THRONE_HEVEA;
public static final DThrone THRONE_BAMBOO;
public static final DFences FENCE;
static {
final BlockStone.EnumType granite = BlockStone.EnumType.GRANITE_SMOOTH;
final BlockStone.EnumType diorite = BlockStone.EnumType.DIORITE_SMOOTH;
final BlockStone.EnumType andesite = BlockStone.EnumType.ANDESITE_SMOOTH;
// Stairs
STAIRS_GRANITE = DStairs.fromVanillaSmoothStone( granite );
STAIRS_DIORITE = DStairs.fromVanillaSmoothStone( diorite );
STAIRS_ANDESITE = DStairs.fromVanillaSmoothStone( andesite );
STAIRS_HEVEA = DStairs.fromWood( Materials.TREE.HEVEA );
STAIRS_BAMBOO = DStairs.fromWood( Materials.TREE.BAMBOO );
// Slabs
SLAB_GRANITE = DSlab.fromVanillaSmoothStone( granite );
SLAB_DIORITE = DSlab.fromVanillaSmoothStone( diorite );
SLAB_ANDESITE = DSlab.fromVanillaSmoothStone( andesite );
SLAB_HEVEA = DSlab.fromWood( Materials.TREE.HEVEA );
SLAB_BAMBOO = DSlab.fromWood( Materials.TREE.BAMBOO );
// Tables
URegistry.addBlock( TABLE_OAK = new DTable( DWoodType.OAK ) );
URegistry.addBlock( TABLE_BIRCH = new DTable( DWoodType.BIRCH ) );
URegistry.addBlock( TABLE_SPRUCE = new DTable( DWoodType.SPRUCE ) );
URegistry.addBlock( TABLE_JUNGLE = new DTable( DWoodType.JUNGLE ) );
URegistry.addBlock( TABLE_DARK_OAK = new DTable( DWoodType.DARK_OAK ) );
URegistry.addBlock( TABLE_ACACIA = new DTable( DWoodType.ACACIA ) );
URegistry.addBlock( TABLE_HEVEA = new DTable( DWoodType.HEVEA ) );
URegistry.addBlock( TABLE_BAMBOO = new DTable( DWoodType.BAMBOO ) );
// Chairs
URegistry.addBlock( CHAIR_OAK = new DChair( DWoodType.OAK ) );
URegistry.addBlock( CHAIR_BIRCH = new DChair( DWoodType.BIRCH ) );
URegistry.addBlock( CHAIR_SPRUCE = new DChair( DWoodType.SPRUCE ) );
URegistry.addBlock( CHAIR_JUNGLE = new DChair( DWoodType.JUNGLE ) );
URegistry.addBlock( CHAIR_DARK_OAK = new DChair( DWoodType.DARK_OAK ) );
URegistry.addBlock( CHAIR_ACACIA = new DChair( DWoodType.ACACIA ) );
URegistry.addBlock( CHAIR_HEVEA = new DChair( DWoodType.HEVEA ) );
URegistry.addBlock( CHAIR_BAMBOO = new DChair( DWoodType.BAMBOO ) );
// Thrones
THRONE_OAK = new DThrone( DWoodType.OAK );
THRONE_BIRCH = new DThrone( DWoodType.BIRCH );
THRONE_SPRUCE = new DThrone( DWoodType.SPRUCE );
THRONE_JUNGLE = new DThrone( DWoodType.JUNGLE );
THRONE_DARK_OAK = new DThrone( DWoodType.DARK_OAK );
THRONE_ACACIA = new DThrone( DWoodType.ACACIA );
THRONE_HEVEA = new DThrone( DWoodType.HEVEA);
THRONE_BAMBOO = new DThrone( DWoodType.BAMBOO );
FENCE = new DFences( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -0,0 +1,21 @@
package mmm.deco.fences;
import mmm.core.CRegistry;
import mmm.materials.MWood;
public class DFence
{
public final DFenceBlock BLOCK;
public final DFenceGate GATE;
public DFence( final MWood woodType )
{
CRegistry.addBlock( this.BLOCK = new DFenceBlock( woodType ) );
CRegistry.addBlock( this.GATE = new DFenceGate( woodType ) );
}
}

View file

@ -1,8 +1,9 @@
package mmm.deco; package mmm.deco.fences;
import mmm.utils.I_URecipeRegistrar; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.I_RecipeRegistrar;
import mmm.materials.MWood;
import net.minecraft.block.BlockFence; import net.minecraft.block.BlockFence;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -14,13 +15,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class DFenceBlock public class DFenceBlock
extends BlockFence extends BlockFence
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
private DWoodType woodType; private final MWood woodType;
public DFenceBlock( DWoodType woodType ) public DFenceBlock( final MWood woodType )
{ {
super( Material.WOOD , woodType.getMapColor( ) ); super( Material.WOOD , woodType.getMapColor( ) );
this.woodType = woodType; this.woodType = woodType;
@ -28,7 +29,7 @@ public class DFenceBlock
this.setResistance( 5.f ); this.setResistance( 5.f );
this.setSoundType( SoundType.WOOD ); this.setSoundType( SoundType.WOOD );
this.setHarvestLevel( "axe" , 0 ); this.setHarvestLevel( "axe" , 0 );
URegistry.setIdentifiers( this , "deco" , "fence" , woodType.getSuffix( ) ); CRegistry.setIdentifiers( this , "deco" , "fence" , woodType.getSuffix( ) );
} }

View file

@ -1,9 +1,10 @@
package mmm.deco; package mmm.deco.fences;
import mmm.utils.I_URecipeRegistrar; import mmm.core.CRegistry;
import mmm.utils.I_UStateMapperProvider; import mmm.core.api.I_RecipeRegistrar;
import mmm.utils.URegistry; import mmm.core.api.blocks.I_StateMapperProvider;
import mmm.materials.MWood;
import mmm.utils.UStateMapper; import mmm.utils.UStateMapper;
import net.minecraft.block.BlockFenceGate; import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks;
@ -19,13 +20,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class DFenceGate public class DFenceGate
extends BlockFenceGate extends BlockFenceGate
implements I_URecipeRegistrar , I_UStateMapperProvider implements I_RecipeRegistrar , I_StateMapperProvider
{ {
private final DWoodType woodType; private final MWood woodType;
public DFenceGate( DWoodType woodType ) public DFenceGate( final MWood woodType )
{ {
super( BlockPlanks.EnumType.OAK ); super( BlockPlanks.EnumType.OAK );
this.woodType = woodType; this.woodType = woodType;
@ -33,12 +34,12 @@ public class DFenceGate
this.setResistance( 5.f ); this.setResistance( 5.f );
this.setSoundType( SoundType.WOOD ); this.setSoundType( SoundType.WOOD );
this.setHarvestLevel( "axe" , 0 ); this.setHarvestLevel( "axe" , 0 );
URegistry.setIdentifiers( this , "deco" , "fence" , "gate" , woodType.getSuffix( ) ); CRegistry.setIdentifiers( this , "deco" , "fence" , "gate" , woodType.getSuffix( ) );
} }
@Override @Override
public MapColor getMapColor( IBlockState state ) public MapColor getMapColor( final IBlockState state )
{ {
return this.woodType.getMapColor( ); return this.woodType.getMapColor( );
} }

View file

@ -0,0 +1,20 @@
package mmm.deco.fences;
import mmm.MmmMaterials;
public class DFences
{
public final DFence BAMBOO;
public final DFence HEVEA;
public DFences( )
{
this.BAMBOO = new DFence( MmmMaterials.WOOD.BAMBOO );
this.HEVEA = new DFence( MmmMaterials.WOOD.HEVEA );
}
}

View file

@ -1,8 +1,8 @@
package mmm.deco; package mmm.deco.slabs;
import mmm.utils.UAccessors; import mmm.core.CAccessors;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockSlab; import net.minecraft.block.BlockSlab;
import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.IProperty;
@ -45,8 +45,8 @@ public abstract class A_DSlabBlock
this.setSoundType( this.modelBlock.getSoundType( ) ); this.setSoundType( this.modelBlock.getSoundType( ) );
try { try {
this.setHardness( UAccessors.getBlockHardness( this.modelBlock ) ); this.setHardness( CAccessors.getBlockHardness( this.modelBlock ) );
this.setResistance( UAccessors.getBlockResistance( this.modelBlock ) + 0.5f ); this.setResistance( CAccessors.getBlockResistance( this.modelBlock ) + 0.5f );
} catch ( final Throwable e ) { } catch ( final Throwable e ) {
if ( e instanceof RuntimeException ) { if ( e instanceof RuntimeException ) {
throw (RuntimeException) e; throw (RuntimeException) e;
@ -61,7 +61,7 @@ public abstract class A_DSlabBlock
} }
this.setDefaultState( state.withProperty( A_DSlabBlock.VARIANT , E_Variant.DEFAULT ) ); this.setDefaultState( state.withProperty( A_DSlabBlock.VARIANT , E_Variant.DEFAULT ) );
URegistry.setIdentifiers( this , "deco" , "slabs" , name ); CRegistry.setIdentifiers( this , "deco" , "slabs" , name );
} }

View file

@ -1,4 +1,4 @@
package mmm.deco; package mmm.deco.slabs;
import java.util.Random; import java.util.Random;

View file

@ -1,4 +1,4 @@
package mmm.deco; package mmm.deco.slabs;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;

View file

@ -1,9 +1,9 @@
package mmm.deco; package mmm.deco.slabs;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.materials.MTree; import mmm.materials.MTree;
import mmm.utils.I_URecipeRegistrar;
import mmm.utils.URegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockStone; import net.minecraft.block.BlockStone;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -14,20 +14,20 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class DSlab public class DSlabParts
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
public static DSlab fromVanillaSmoothStone( final BlockStone.EnumType type ) public static DSlabParts fromVanillaSmoothStone( final BlockStone.EnumType type )
{ {
final IBlockState bs = Blocks.STONE.getDefaultState( ).withProperty( BlockStone.VARIANT , type ); final IBlockState bs = Blocks.STONE.getDefaultState( ).withProperty( BlockStone.VARIANT , type );
final String name = type.getName( ).replace( "smooth_" , "" ); final String name = type.getName( ).replace( "smooth_" , "" );
return new DSlab( bs , name ); return new DSlabParts( bs , name );
} }
public static DSlab fromWood( final MTree materials ) public static DSlabParts fromWood( final MTree materials )
{ {
final DSlab slab = new DSlab( materials.PLANKS.getDefaultState( ) , materials.NAME ); final DSlabParts slab = new DSlabParts( materials.PLANKS.getDefaultState( ) , materials.NAME );
if ( materials.getBaseFlammability( ) != 0 ) { if ( materials.getBaseFlammability( ) != 0 ) {
Blocks.FIRE.setFireInfo( slab.HALF , materials.getBaseFireEncouragement( ) , Blocks.FIRE.setFireInfo( slab.HALF , materials.getBaseFireEncouragement( ) ,
materials.getBaseFlammability( ) * 4 ); materials.getBaseFlammability( ) * 4 );
@ -42,22 +42,22 @@ public class DSlab
public final ItemSlab ITEM; public final ItemSlab ITEM;
public DSlab( final Block modelBlock , final String name ) public DSlabParts( final Block modelBlock , final String name )
{ {
this( modelBlock.getDefaultState( ) , name ); this( modelBlock.getDefaultState( ) , name );
} }
public DSlab( final IBlockState modelState , final String name ) public DSlabParts( final IBlockState modelState , final String name )
{ {
this.HALF = new DSlabHalf( modelState , name ); this.HALF = new DSlabHalf( modelState , name );
this.DOUBLE = new DSlabDouble( this.HALF , name ); this.DOUBLE = new DSlabDouble( this.HALF , name );
this.ITEM = new ItemSlab( this.HALF , this.HALF , this.DOUBLE ); this.ITEM = new ItemSlab( this.HALF , this.HALF , this.DOUBLE );
URegistry.setIdentifiers( this.ITEM , "deco" , "slabs" , name ); CRegistry.setIdentifiers( this.ITEM , "deco" , "slabs" , name );
URegistry.addBlock( this.HALF , this.ITEM ); CRegistry.addBlock( this.HALF , this.ITEM );
URegistry.addBlock( this.DOUBLE , null ); CRegistry.addBlock( this.DOUBLE , null );
URegistry.addRecipeRegistrar( this ); CRegistry.addRecipeRegistrar( this );
} }

View file

@ -0,0 +1,26 @@
package mmm.deco.slabs;
import mmm.MmmMaterials;
import net.minecraft.block.BlockStone;
public class DSlabs
{
public final DSlabParts GRANITE;
public final DSlabParts DIORITE;
public final DSlabParts ANDESITE;
public final DSlabParts HEVEA;
public final DSlabParts BAMBOO;
public DSlabs( )
{
this.GRANITE = DSlabParts.fromVanillaSmoothStone( BlockStone.EnumType.GRANITE_SMOOTH );
this.DIORITE = DSlabParts.fromVanillaSmoothStone( BlockStone.EnumType.DIORITE_SMOOTH );
this.ANDESITE = DSlabParts.fromVanillaSmoothStone( BlockStone.EnumType.ANDESITE_SMOOTH );
this.HEVEA = DSlabParts.fromWood( MmmMaterials.TREE.HEVEA );
this.BAMBOO = DSlabParts.fromWood( MmmMaterials.TREE.BAMBOO );
}
}

View file

@ -1,8 +1,9 @@
package mmm.deco; package mmm.deco.thrones;
import mmm.core.CRegistry;
import mmm.materials.MWood;
import mmm.utils.UBlockItemWithVariants; import mmm.utils.UBlockItemWithVariants;
import mmm.utils.URegistry;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -15,11 +16,11 @@ public class DThrone
public final Item ITEM; public final Item ITEM;
public DThrone( final DWoodType woodType ) public DThrone( final MWood woodType )
{ {
URegistry.addBlock( this.BOTTOM = new DThroneBlock( this , woodType , false ) , null ); CRegistry.addBlock( this.BOTTOM = new DThroneBlock( this , woodType , false ) , null );
URegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null ); CRegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null );
this.ITEM = new UBlockItemWithVariants( this.BOTTOM , "deco" , "throne" , woodType.getSuffix() ) // this.ITEM = new UBlockItemWithVariants( this.BOTTOM , "deco" , "throne" , woodType.getSuffix( ) ) //
.useColorVariants( ) // .useColorVariants( ) //
.register( ); .register( );
} }

View file

@ -1,15 +1,16 @@
package mmm.deco; package mmm.deco.thrones;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mmm.utils.I_UBlockSeat; import mmm.core.api.I_RecipeRegistrar;
import mmm.utils.I_UColoredBlock; import mmm.core.api.blocks.I_ColoredBlock;
import mmm.utils.I_URecipeRegistrar; import mmm.core.api.blocks.I_SeatBlock;
import mmm.utils.I_USupportBlock; import mmm.core.api.blocks.I_SupportBlock;
import mmm.deco.DSeatEntity;
import mmm.materials.MWood;
import mmm.utils.UMaths; import mmm.utils.UMaths;
import mmm.utils.USeat;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockHorizontal; import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -47,7 +48,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class DThroneBlock public class DThroneBlock
extends Block extends Block
implements I_UColoredBlock , I_UBlockSeat , I_URecipeRegistrar implements I_ColoredBlock , I_SeatBlock , I_RecipeRegistrar
{ {
public static final PropertyDirection FACING; public static final PropertyDirection FACING;
@ -65,12 +66,12 @@ public class DThroneBlock
COLOR = PropertyEnum.< EnumDyeColor > create( "color" , EnumDyeColor.class ); COLOR = PropertyEnum.< EnumDyeColor > create( "color" , EnumDyeColor.class );
} }
public final DWoodType woodType; public final MWood woodType;
public final DThrone parts; public final DThrone parts;
public final boolean isTop; public final boolean isTop;
public DThroneBlock( final DThrone throne , final DWoodType woodType , final boolean isTop ) public DThroneBlock( final DThrone throne , final MWood woodType , final boolean isTop )
{ {
super( Material.WOOD ); super( Material.WOOD );
this.woodType = woodType; this.woodType = woodType;
@ -78,8 +79,8 @@ public class DThroneBlock
this.isTop = isTop; this.isTop = isTop;
this.setCreativeTab( CreativeTabs.DECORATIONS ); this.setCreativeTab( CreativeTabs.DECORATIONS );
this.setRegistryName( "mmm:deco/throne/" + woodType.getSuffix() + "/" + ( isTop ? "top" : "bottom" ) ); this.setRegistryName( "mmm:deco/throne/" + woodType.getSuffix( ) + "/" + ( isTop ? "top" : "bottom" ) );
this.setUnlocalizedName( "mmm.deco.throne." + woodType.getSuffix() ); this.setUnlocalizedName( "mmm.deco.throne." + woodType.getSuffix( ) );
if ( this.isTop ) { if ( this.isTop ) {
this.setDefaultState( this.blockState.getBaseState( ) // this.setDefaultState( this.blockState.getBaseState( ) //
@ -131,7 +132,7 @@ public class DThroneBlock
public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos ) public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos )
{ {
if ( this.isTop ) { if ( this.isTop ) {
switch ( state.getValue( DChair.FACING ) ) { switch ( state.getValue( DThroneBlock.FACING ) ) {
case EAST: case EAST:
return DThroneBlock.COLLISION_TOP_EAST; return DThroneBlock.COLLISION_TOP_EAST;
case NORTH: case NORTH:
@ -226,7 +227,7 @@ public class DThroneBlock
public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos ) public boolean canPlaceBlockAt( final World worldIn , final BlockPos pos )
{ {
return pos.getY( ) < worldIn.getHeight( ) - 1 && super.canPlaceBlockAt( worldIn , pos ) return pos.getY( ) < worldIn.getHeight( ) - 1 && super.canPlaceBlockAt( worldIn , pos )
&& super.canPlaceBlockAt( worldIn , pos.up( ) ) && I_USupportBlock.check( worldIn , pos ); && super.canPlaceBlockAt( worldIn , pos.up( ) ) && I_SupportBlock.check( worldIn , pos );
} }
@ -252,7 +253,8 @@ public class DThroneBlock
// BLOCK REMOVAL AND PICKING // BLOCK REMOVAL AND PICKING
// ************************************************************************************************* // *************************************************************************************************
public Item getItemDropped( IBlockState state , Random rand , int fortune ) @Override
public Item getItemDropped( final IBlockState state , final Random rand , final int fortune )
{ {
return this.parts.ITEM; return this.parts.ITEM;
} }
@ -303,7 +305,7 @@ public class DThroneBlock
{ {
DThroneBlock.dropping = true; DThroneBlock.dropping = true;
final BlockPos otherPos = this.isTop ? pos.down( ) : pos.up( ); final BlockPos otherPos = this.isTop ? pos.down( ) : pos.up( );
Block otherBlock = world.getBlockState( otherPos ).getBlock( ); final Block otherBlock = world.getBlockState( otherPos ).getBlock( );
if ( otherBlock instanceof DThroneBlock && ( (DThroneBlock) otherBlock ).isTop == !this.isTop ) { if ( otherBlock instanceof DThroneBlock && ( (DThroneBlock) otherBlock ).isTop == !this.isTop ) {
world.setBlockToAir( otherPos ); world.setBlockToAir( otherPos );
} }
@ -335,7 +337,7 @@ public class DThroneBlock
final Block blockIn ) final Block blockIn )
{ {
if ( ! ( this.isTop || DThroneBlock.dropping ) ) { if ( ! ( this.isTop || DThroneBlock.dropping ) ) {
I_USupportBlock.dropIfUnsupported( state , worldIn , pos , this ); I_SupportBlock.dropIfUnsupported( state , worldIn , pos , this );
} }
} }
@ -362,7 +364,7 @@ public class DThroneBlock
} else { } else {
p = pos; p = pos;
} }
return USeat.sit( worldIn , p , playerIn , 0.25 ); return DSeatEntity.sit( worldIn , p , playerIn , 0.25 );
} }
@ -392,7 +394,7 @@ public class DThroneBlock
"GWG" , // "GWG" , //
"BBB" , // "BBB" , //
'W' , new ItemStack( Blocks.WOOL , 1 , dyeColor.getMetadata( ) ) , // 'W' , new ItemStack( Blocks.WOOL , 1 , dyeColor.getMetadata( ) ) , //
'B' , new ItemStack( this.woodType.getPlanksBlock() , 1 , this.woodType.getMetaData() ) , // 'B' , new ItemStack( this.woodType.getPlanksBlock( ) , 1 , this.woodType.getMetaData( ) ) , //
'G' , Items.GOLD_INGOT , // 'G' , Items.GOLD_INGOT , //
'E' , Items.EMERALD // 'E' , Items.EMERALD //
); );

View file

@ -0,0 +1,31 @@
package mmm.deco.thrones;
import mmm.MmmMaterials;
public class DThrones
{
public final DThrone OAK;
public final DThrone BIRCH;
public final DThrone SPRUCE;
public final DThrone JUNGLE;
public final DThrone DARK_OAK;
public final DThrone ACACIA;
public final DThrone HEVEA;
public final DThrone BAMBOO;
public DThrones( )
{
this.OAK = new DThrone( MmmMaterials.WOOD.OAK );
this.BIRCH = new DThrone( MmmMaterials.WOOD.BIRCH );
this.SPRUCE = new DThrone( MmmMaterials.WOOD.SPRUCE );
this.JUNGLE = new DThrone( MmmMaterials.WOOD.JUNGLE );
this.DARK_OAK = new DThrone( MmmMaterials.WOOD.DARK_OAK );
this.ACACIA = new DThrone( MmmMaterials.WOOD.ACACIA );
this.HEVEA = new DThrone( MmmMaterials.WOOD.HEVEA );
this.BAMBOO = new DThrone( MmmMaterials.WOOD.BAMBOO );
}
}

View file

@ -1,8 +1,8 @@
package mmm.food; package mmm.food;
import mmm.utils.I_UItemModelProviderBasic; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.items.I_ItemModelProviderBasic;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@ -12,7 +12,7 @@ import net.minecraft.item.Item;
public class FMilkBucket public class FMilkBucket
extends Item extends Item
implements I_UItemModelProviderBasic implements I_ItemModelProviderBasic
{ {
public final FMilkType milkType; public final FMilkType milkType;
@ -22,7 +22,7 @@ public class FMilkBucket
{ {
super( ); super( );
this.milkType = milkType; this.milkType = milkType;
URegistry.setIdentifiers( this , "food" , "milk" , milkType.name ); CRegistry.setIdentifiers( this , "food" , "milk" , milkType.name );
this.setMaxStackSize( 1 ); this.setMaxStackSize( 1 );
this.setCreativeTab( CreativeTabs.MISC ); this.setCreativeTab( CreativeTabs.MISC );
} }

View file

@ -3,15 +3,9 @@ package mmm.food;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.google.common.collect.HashMultimap; import mmm.core.CRegistry;
import mmm.utils.URegistry;
import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityCow; import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.HorseType;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -19,35 +13,6 @@ import net.minecraft.item.Item;
public class FMilkType public class FMilkType
{ {
public static final HashMultimap< Class< ? extends EntityAnimal > , FMilkType > MILK_TYPES;
public static final FMilkType COW;
public static final FMilkType SHEEP;
public static final FMilkType PIG;
public static final FMilkType HORSE;
public static final FMilkType DONKEY;
static {
MILK_TYPES = HashMultimap.create( );
COW = new FMilkType( );
SHEEP = new FMilkType( "sheep" , EntitySheep.class );
PIG = new FMilkType( "pig" , EntityPig.class ) //
.setPeriod( 48000 );
HORSE = new FMilkType( "horse" , EntityHorse.class ) //
.setExtraCheck( a -> ( (EntityHorse) a ).getType( ) == HorseType.HORSE ) //
.setPeriod( 24000 );
DONKEY = new FMilkType( "donkey" , EntityHorse.class )
.setExtraCheck( a -> ( (EntityHorse) a ).getType( ) == HorseType.DONKEY ) //
.setPeriod( 36000 );
}
public static void preInit( )
{
// EMPTY
}
public final String name; public final String name;
public final boolean isVanilla; public final boolean isVanilla;
public final Class< ? extends EntityAnimal > animal; public final Class< ? extends EntityAnimal > animal;
@ -56,7 +21,7 @@ public class FMilkType
private Predicate< EntityAnimal > extraCheck; private Predicate< EntityAnimal > extraCheck;
private FMilkType( ) public FMilkType( )
{ {
this( "cow" , true , EntityCow.class , Items.MILK_BUCKET ); this( "cow" , true , EntityCow.class , Items.MILK_BUCKET );
} }
@ -76,10 +41,10 @@ public class FMilkType
this.animal = animal; this.animal = animal;
if ( bucket == null ) { if ( bucket == null ) {
bucket = new FMilkBucket( this ); bucket = new FMilkBucket( this );
URegistry.addItem( bucket ); CRegistry.addItem( bucket );
} }
this.bucket = bucket; this.bucket = bucket;
FMilkType.MILK_TYPES.put( animal , this );
} }
@ -92,11 +57,11 @@ public class FMilkType
public int getPeriod( ) public int getPeriod( )
{ {
return period; return this.period;
} }
public FMilkType setPeriod( int period ) public FMilkType setPeriod( final int period )
{ {
this.period = period; this.period = period;
return this; return this;

View file

@ -5,8 +5,9 @@ import java.util.Set;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import mmm.Mmm; import mmm.Mmm;
import mmm.utils.I_UMessage; import mmm.MmmFood;
import mmm.utils.UNetwork; import mmm.core.CNetwork;
import mmm.core.api.I_Message;
import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityAnimal;
@ -19,10 +20,8 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.NBTTagLong;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject; import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.event.entity.player.PlayerEvent;
@ -105,7 +104,7 @@ public class FMilkable
// ************************************************************************************************************* // *************************************************************************************************************
public static class Message public static class Message
implements I_UMessage implements I_Message
{ {
private int entityId; private int entityId;
private long lastMilking; private long lastMilking;
@ -160,7 +159,7 @@ public class FMilkable
@SubscribeEvent @SubscribeEvent
public void attachCapability( final AttachCapabilitiesEvent.Entity event ) public void attachCapability( final AttachCapabilitiesEvent.Entity event )
{ {
if ( FMilkType.MILK_TYPES.containsKey( event.getEntity( ).getClass( ) ) ) { if ( MmmFood.MILK.TYPES.containsKey( event.getEntity( ).getClass( ) ) ) {
event.addCapability( FMilkable.ID , new Provider( ) ); event.addCapability( FMilkable.ID , new Provider( ) );
} }
} }
@ -175,7 +174,7 @@ public class FMilkable
} }
final Entity entity = event.getTarget( ); final Entity entity = event.getTarget( );
if ( entity.hasCapability( FMilkable.CAPABILITY , null ) ) { if ( entity.hasCapability( FMilkable.CAPABILITY , null ) ) {
UNetwork.sendTo( new Message( entity ) , (EntityPlayerMP) player ); CNetwork.sendTo( new Message( entity ) , (EntityPlayerMP) player );
} }
} }
@ -202,7 +201,7 @@ public class FMilkable
} }
// Find actual milk type // Find actual milk type
final Set< FMilkType > milkTypes = FMilkType.MILK_TYPES.get( animal.getClass( ) ); final Set< FMilkType > milkTypes = MmmFood.MILK.TYPES.get( animal.getClass( ) );
FMilkType milkType = null; FMilkType milkType = null;
for ( final FMilkType type : milkTypes ) { for ( final FMilkType type : milkTypes ) {
if ( type.check( animal ) ) { if ( type.check( animal ) ) {
@ -229,7 +228,7 @@ public class FMilkable
// Send updates to players // Send updates to players
if ( !player.worldObj.isRemote ) { if ( !player.worldObj.isRemote ) {
UNetwork.sendToAll( new Message( animal ) ); CNetwork.sendToAll( new Message( animal ) );
} }
// Actually milk the animal // Actually milk the animal
@ -245,16 +244,6 @@ public class FMilkable
} }
} }
// *************************************************************************************************************
public static void register( )
{
CapabilityManager.INSTANCE.register( FMilkable.class , new Storage( ) , FMilkable::new );
MinecraftForge.EVENT_BUS.register( new EventHandler( ) );
UNetwork.addClientMessage( Message.class );
}
// ************************************************************************************************************* // *************************************************************************************************************
private long lastMilking = -500000; private long lastMilking = -500000;

View file

@ -0,0 +1,57 @@
package mmm.food;
import com.google.common.collect.HashMultimap;
import mmm.core.CNetwork;
import mmm.food.FMilkable.EventHandler;
import mmm.food.FMilkable.Message;
import mmm.food.FMilkable.Storage;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.HorseType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.CapabilityManager;
public class FMilks
{
public final HashMultimap< Class< ? extends EntityAnimal > , FMilkType > TYPES;
public final FMilkType COW;
public final FMilkType SHEEP;
public final FMilkType PIG;
public final FMilkType HORSE;
public final FMilkType DONKEY;
public FMilks( )
{
this.TYPES = HashMultimap.create( );
this.COW = this.addMilk( new FMilkType( ) );
this.SHEEP = this.addMilk( new FMilkType( "sheep" , EntitySheep.class ) );
this.PIG = this.addMilk( new FMilkType( "pig" , EntityPig.class ) //
.setPeriod( 48000 ) );
this.HORSE = this.addMilk( new FMilkType( "horse" , EntityHorse.class ) //
.setExtraCheck( a -> ( (EntityHorse) a ).getType( ) == HorseType.HORSE ) //
.setPeriod( 24000 ) );
this.DONKEY = this.addMilk( new FMilkType( "donkey" , EntityHorse.class )
.setExtraCheck( a -> ( (EntityHorse) a ).getType( ) == HorseType.DONKEY ) //
.setPeriod( 36000 ) );
CapabilityManager.INSTANCE.register( FMilkable.class , new Storage( ) , FMilkable::new );
MinecraftForge.EVENT_BUS.register( new EventHandler( ) );
CNetwork.addClientMessage( Message.class );
}
private FMilkType addMilk( final FMilkType type )
{
this.TYPES.put( type.animal , type );
return type;
}
}

View file

@ -1,17 +0,0 @@
package mmm.food;
public class Food
{
static {
FMilkType.preInit( );
FMilkable.register( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -281,7 +281,7 @@ public class MAlloyRecipe
} }
public boolean hasInput( ItemStack stack ) public boolean hasInput( final ItemStack stack )
{ {
for ( int i = 0 ; i < this.inputs.length ; i++ ) { for ( int i = 0 ; i < this.inputs.length ; i++ ) {
if ( this.inputs[ i ].isItemEqual( stack ) ) { if ( this.inputs[ i ].isItemEqual( stack ) ) {

View file

@ -1,8 +1,9 @@
package mmm.materials; package mmm.materials;
import mmm.utils.I_URecipeRegistrar; import mmm.MmmMaterials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.init.Items; import net.minecraft.init.Items;
@ -10,19 +11,19 @@ import net.minecraft.init.Items;
public class MAlloys public class MAlloys
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
public final MMetal BRONZE; public final MMetal BRONZE;
public final MMetal STEEL; public final MMetal STEEL;
// public static final MMetal RED_COPPER; // public static final MMetal RED_COPPER;
MAlloys( ) public MAlloys( )
{ {
URegistry.addRecipeRegistrar( this ); CRegistry.addRecipeRegistrar( this );
BRONZE = new MMetal( "bronze" , 0f , 5f , 1 , MapColor.BROWN ); this.BRONZE = new MMetal( "bronze" , 0f , 5f , 1 , MapColor.BROWN );
STEEL = new MMetal( "steel" , 0f , 7f , 2 , MapColor.LIGHT_BLUE ) // this.STEEL = new MMetal( "steel" , 0f , 7f , 2 , MapColor.LIGHT_BLUE ) //
.setBlockResistance( 12f ); .setBlockResistance( 12f );
// RED_COPPER = new MMetal( "red_copper" , 0f , 2f , 1 , MapColor.RED ); // RED_COPPER = new MMetal( "red_copper" , 0f , 2f , 1 , MapColor.RED );
} }
@ -33,36 +34,36 @@ public class MAlloys
{ {
// Bronze // Bronze
MAlloyRecipe.build( ).setName( "materials/bronze" ).setBurnTime( 400 ) // MAlloyRecipe.build( ).setName( "materials/bronze" ).setBurnTime( 400 ) //
.addInput( Materials.METAL.COPPER.INGOT ) // .addInput( MmmMaterials.METAL.COPPER.INGOT ) //
.addInput( Materials.METAL.TIN.NUGGET ) // .addInput( MmmMaterials.METAL.TIN.NUGGET ) //
.setOutput( this.BRONZE.INGOT ).setSlag( 1 ) // .setOutput( this.BRONZE.INGOT ).setSlag( 1 ) //
.register( ); .register( );
// Pig iron // Pig iron
MAlloyRecipe.build( ).setName( "materials/pig_iron/from_ingot" ).setBurnTime( 1600 ) // MAlloyRecipe.build( ).setName( "materials/pig_iron/from_ingot" ).setBurnTime( 1600 ) //
.addInput( Materials.METAL.IRON.INGOT ) // .addInput( MmmMaterials.METAL.IRON.INGOT ) //
.addInput( Materials.ROCK.LIMESTONE ) // .addInput( MmmMaterials.ROCK.LIMESTONE ) //
.addInput( Materials.ITEM.COKE ) // .addInput( MmmMaterials.ITEM.COKE ) //
.setOutput( Materials.ITEM.PIG_IRON_INGOT , 2 ).setSlag( 3 ) // .setOutput( MmmMaterials.ITEM.PIG_IRON_INGOT , 2 ).setSlag( 3 ) //
.register( ); .register( );
MAlloyRecipe.build( ).setName( "materials/pig_iron/from_ore" ).setBurnTime( 1600 ) // MAlloyRecipe.build( ).setName( "materials/pig_iron/from_ore" ).setBurnTime( 1600 ) //
.addInput( Blocks.IRON_ORE ) // .addInput( Blocks.IRON_ORE ) //
.addInput( Materials.ROCK.LIMESTONE ) // .addInput( MmmMaterials.ROCK.LIMESTONE ) //
.addInput( Materials.ITEM.COKE ) // .addInput( MmmMaterials.ITEM.COKE ) //
.setOutput( Materials.ITEM.PIG_IRON_INGOT ).setSlag( 5 ) // .setOutput( MmmMaterials.ITEM.PIG_IRON_INGOT ).setSlag( 5 ) //
.register( ); .register( );
// Steel // Steel
MAlloyRecipe.build( ).setName( "materials/steel/from_ingot" ).setBurnTime( 3200 ) // MAlloyRecipe.build( ).setName( "materials/steel/from_ingot" ).setBurnTime( 3200 ) //
.addInput( Materials.METAL.IRON.INGOT ) // .addInput( MmmMaterials.METAL.IRON.INGOT ) //
.addInput( Materials.ROCK.LIMESTONE ) // .addInput( MmmMaterials.ROCK.LIMESTONE ) //
.addInput( Materials.ITEM.PIG_IRON_INGOT ) // .addInput( MmmMaterials.ITEM.PIG_IRON_INGOT ) //
.setOutput( this.STEEL.INGOT , 2 ).setSlag( 3 ) // .setOutput( this.STEEL.INGOT , 2 ).setSlag( 3 ) //
.register( ); .register( );
MAlloyRecipe.build( ).setName( "materials/steel/from_ore" ).setBurnTime( 3200 ) // MAlloyRecipe.build( ).setName( "materials/steel/from_ore" ).setBurnTime( 3200 ) //
.addInput( Blocks.IRON_ORE ) // .addInput( Blocks.IRON_ORE ) //
.addInput( Materials.ROCK.LIMESTONE ) // .addInput( MmmMaterials.ROCK.LIMESTONE ) //
.addInput( Materials.ITEM.PIG_IRON_INGOT ) // .addInput( MmmMaterials.ITEM.PIG_IRON_INGOT ) //
.setOutput( this.STEEL.INGOT ).setSlag( 5 ) // .setOutput( this.STEEL.INGOT ).setSlag( 5 ) //
.register( ); .register( );
@ -72,6 +73,6 @@ public class MAlloys
// XXX coke is not an alloy // XXX coke is not an alloy
MAlloyRecipe.build( ).setName( "materials/coke" ).setBurnTime( 3200 ).addInput( Items.COAL , 2 ) MAlloyRecipe.build( ).setName( "materials/coke" ).setBurnTime( 3200 ).addInput( Items.COAL , 2 )
.setOutput( Materials.ITEM.COKE ).setSlag( 1 ).register( ); .setOutput( MmmMaterials.ITEM.COKE ).setSlag( 1 ).register( );
} }
} }

View file

@ -1,8 +1,9 @@
package mmm.materials; package mmm.materials;
import mmm.utils.I_URecipeRegistrar; import mmm.MmmMaterials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -11,7 +12,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class MItems public class MItems
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
public final Item SLAG; public final Item SLAG;
public final Item COKE; public final Item COKE;
@ -25,24 +26,24 @@ public class MItems
public final Item SALTPETER; public final Item SALTPETER;
MItems( ) public MItems( )
{ {
URegistry.addRecipeRegistrar( this ); CRegistry.addRecipeRegistrar( this );
// Items that do not correspond to metals or ores // Items that do not correspond to metals or ores
SLAG = Materials.makeItem( "slag" ); this.SLAG = MmmMaterials.makeItem( "slag" );
COKE = Materials.makeFuel( "coke" , 9600 ); this.COKE = MmmMaterials.makeFuel( "coke" , 9600 );
PIG_IRON_INGOT = new MMetalItem( E_MMetalItemType.INGOT , "pig_iron" ); this.PIG_IRON_INGOT = new MMetalItem( E_MMetalItemType.INGOT , "pig_iron" );
URegistry.addItem( PIG_IRON_INGOT ); CRegistry.addItem( this.PIG_IRON_INGOT );
// Ore drops // Ore drops
MALACHITE = Materials.makeItem( "malachite" ); this.MALACHITE = MmmMaterials.makeItem( "malachite" );
CUPRITE = Materials.makeItem( "cuprite" ); this.CUPRITE = MmmMaterials.makeItem( "cuprite" );
CASSITERITE = Materials.makeItem( "cassiterite" ); this.CASSITERITE = MmmMaterials.makeItem( "cassiterite" );
SPHALERITE = Materials.makeItem( "sphalerite" ); this.SPHALERITE = MmmMaterials.makeItem( "sphalerite" );
ROCK_SALT = Materials.makeItem( "rock_salt" ); this.ROCK_SALT = MmmMaterials.makeItem( "rock_salt" );
SULPHUR_POWDER = Materials.makeItem( "sulphur_powder" ); this.SULPHUR_POWDER = MmmMaterials.makeItem( "sulphur_powder" );
SALTPETER = Materials.makeItem( "saltpeter_powder" ); this.SALTPETER = MmmMaterials.makeItem( "saltpeter_powder" );
} }
@ -51,12 +52,12 @@ public class MItems
{ {
// Green dye from malachite // Green dye from malachite
GameRegistry.addShapelessRecipe( new ItemStack( Items.DYE , 1 , 2 ) , GameRegistry.addShapelessRecipe( new ItemStack( Items.DYE , 1 , 2 ) ,
new ItemStack( Materials.ITEM.MALACHITE ) ); new ItemStack( MmmMaterials.ITEM.MALACHITE ) );
// Gunpowder from saltpeter, sulphur and charcoal // Gunpowder from saltpeter, sulphur and charcoal
GameRegistry.addShapelessRecipe( new ItemStack( Items.GUNPOWDER ) , // GameRegistry.addShapelessRecipe( new ItemStack( Items.GUNPOWDER ) , //
new ItemStack( Materials.ITEM.SALTPETER ) , // new ItemStack( MmmMaterials.ITEM.SALTPETER ) , //
new ItemStack( Materials.ITEM.SULPHUR_POWDER ) , // new ItemStack( MmmMaterials.ITEM.SULPHUR_POWDER ) , //
new ItemStack( Items.COAL , 1 , 1 ) ); new ItemStack( Items.COAL , 1 , 1 ) );
} }

View file

@ -5,9 +5,9 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import mmm.utils.I_UTintedBlock; import mmm.core.CRegistry;
import mmm.utils.I_UTintedItem; import mmm.core.api.blocks.I_TintedBlock;
import mmm.utils.URegistry; import mmm.core.api.items.I_TintedItem;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks;
@ -34,7 +34,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class MLeaves public class MLeaves
extends BlockLeaves extends BlockLeaves
implements I_UTintedBlock , I_UTintedItem implements I_TintedBlock , I_TintedItem
{ {
private final MTree wood; private final MTree wood;
@ -48,7 +48,7 @@ public class MLeaves
.withProperty( BlockLeaves.CHECK_DECAY , true )// .withProperty( BlockLeaves.CHECK_DECAY , true )//
.withProperty( BlockLeaves.DECAYABLE , true ) ); .withProperty( BlockLeaves.DECAYABLE , true ) );
URegistry.setIdentifiers( this , "materials" , "leaves" , wood.NAME ); CRegistry.setIdentifiers( this , "materials" , "leaves" , wood.NAME );
} }

View file

@ -1,7 +1,7 @@
package mmm.materials; package mmm.materials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLog; import net.minecraft.block.BlockLog;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -34,7 +34,7 @@ public class MLog
this.setDefaultState( this.blockState.getBaseState( )// this.setDefaultState( this.blockState.getBaseState( )//
.withProperty( BlockLog.LOG_AXIS , BlockLog.EnumAxis.Y ) ); .withProperty( BlockLog.LOG_AXIS , BlockLog.EnumAxis.Y ) );
URegistry.setIdentifiers( this , "materials" , "log" , wood.NAME ); CRegistry.setIdentifiers( this , "materials" , "log" , wood.NAME );
} }

View file

@ -1,8 +1,8 @@
package mmm.materials; package mmm.materials;
import mmm.utils.I_URecipeRegistrar; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.I_RecipeRegistrar;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class MMetal public class MMetal
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
public final float SMELTING_XP; public final float SMELTING_XP;
@ -36,7 +36,7 @@ public class MMetal
} }
public MMetal setBlockResistance( float resistance ) public MMetal setBlockResistance( final float resistance )
{ {
this.BLOCK.setResistance( resistance ); this.BLOCK.setResistance( resistance );
return this; return this;
@ -57,19 +57,19 @@ public class MMetal
{ {
boolean custom = false; boolean custom = false;
if ( this.BLOCK instanceof MMetalBlock ) { if ( this.BLOCK instanceof MMetalBlock ) {
URegistry.addBlock( this.BLOCK ); CRegistry.addBlock( this.BLOCK );
custom = true; custom = true;
} }
if ( this.INGOT instanceof MMetalItem ) { if ( this.INGOT instanceof MMetalItem ) {
URegistry.addItem( this.INGOT ); CRegistry.addItem( this.INGOT );
custom = true; custom = true;
} }
if ( this.NUGGET instanceof MMetalItem ) { if ( this.NUGGET instanceof MMetalItem ) {
URegistry.addItem( this.NUGGET ); CRegistry.addItem( this.NUGGET );
custom = true; custom = true;
} }
if ( custom ) { if ( custom ) {
URegistry.addRecipeRegistrar( this ); CRegistry.addRecipeRegistrar( this );
} }
return this; return this;
} }

View file

@ -1,7 +1,7 @@
package mmm.materials; package mmm.materials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -22,7 +22,7 @@ public class MMetalBlock
this.setSoundType( SoundType.METAL ); this.setSoundType( SoundType.METAL );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHarvestLevel( "pickaxe" , harvestLevel ); this.setHarvestLevel( "pickaxe" , harvestLevel );
URegistry.setIdentifiers( this , "materials" , "block" , name ); CRegistry.setIdentifiers( this , "materials" , "block" , name );
} }
} }

View file

@ -1,7 +1,7 @@
package mmm.materials; package mmm.materials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
@ -14,7 +14,7 @@ public class MMetalItem
{ {
super( ); super( );
this.setCreativeTab( CreativeTabs.MATERIALS ); this.setCreativeTab( CreativeTabs.MATERIALS );
URegistry.setIdentifiers( this , "materials" , type.name , name ); CRegistry.setIdentifiers( this , "materials" , type.name , name );
} }
} }

View file

@ -16,15 +16,15 @@ public class MMetals
public final MMetal ZINC; public final MMetal ZINC;
MMetals( ) public MMetals( )
{ {
GOLD = new MMetal( Blocks.GOLD_BLOCK , Items.GOLD_INGOT , Items.GOLD_NUGGET ); this.GOLD = new MMetal( Blocks.GOLD_BLOCK , Items.GOLD_INGOT , Items.GOLD_NUGGET );
IRON = new MMetal( Blocks.IRON_BLOCK , Items.IRON_INGOT , // this.IRON = new MMetal( Blocks.IRON_BLOCK , Items.IRON_INGOT , //
new MMetalItem( E_MMetalItemType.NUGGET , "iron" ) ); new MMetalItem( E_MMetalItemType.NUGGET , "iron" ) );
COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT ); this.COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT );
TIN = new MMetal( "tin" , 0.6f , 1f , 0 , MapColor.GRAY ); this.TIN = new MMetal( "tin" , 0.6f , 1f , 0 , MapColor.GRAY );
ZINC = new MMetal( "zinc" , 0.4f , 4f , 1 , MapColor.GRAY ); this.ZINC = new MMetal( "zinc" , 0.4f , 4f , 1 , MapColor.GRAY );
} }
} }

View file

@ -1,9 +1,9 @@
package mmm.materials; package mmm.materials;
import mmm.utils.I_UTrapBlock; import mmm.core.CRegistry;
import mmm.core.api.blocks.I_TrapBlock;
import mmm.utils.UMaths; import mmm.utils.UMaths;
import mmm.utils.URegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -19,7 +19,7 @@ import net.minecraft.world.World;
public class MMud public class MMud
extends Block extends Block
implements I_UTrapBlock implements I_TrapBlock
{ {
private static final AxisAlignedBB MUD_AABB = UMaths.makeBlockAABB( 0 , 0 , 0 , 16 , 15 , 16 ); private static final AxisAlignedBB MUD_AABB = UMaths.makeBlockAABB( 0 , 0 , 0 , 16 , 15 , 16 );
@ -31,7 +31,7 @@ public class MMud
this.setHarvestLevel( "shovel" , 0 ); this.setHarvestLevel( "shovel" , 0 );
this.setSoundType( SoundType.GROUND ); this.setSoundType( SoundType.GROUND );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
URegistry.setIdentifiers( this , "materials" , "trap" , "mud" ); CRegistry.setIdentifiers( this , "materials" , "trap" , "mud" );
} }

View file

@ -5,8 +5,8 @@ import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import mmm.utils.I_URecipeRegistrar; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.I_RecipeRegistrar;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class MOre public class MOre
extends Block extends Block
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
private int dropMin , dropMax; private int dropMin , dropMax;
private Item dropItems; private Item dropItems;
@ -52,12 +52,12 @@ public class MOre
this.setHardness( 3.0f ); this.setHardness( 3.0f );
this.setResistance( 5.0f ); this.setResistance( 5.0f );
this.setHarvestLevel( "pickaxe" , harvestLevel ); this.setHarvestLevel( "pickaxe" , harvestLevel );
URegistry.setIdentifiers( this , "materials" , "ore" , name ); CRegistry.setIdentifiers( this , "materials" , "ore" , name );
this.dropMin = this.dropMax = 1; this.dropMin = this.dropMax = 1;
this.expMin = this.expMax = 0; this.expMin = this.expMax = 0;
this.metal = null; this.metal = null;
this.genQuantity = 0; this.genQuantity = 0;
URegistry.addBlock( this ); CRegistry.addBlock( this );
} }

View file

@ -3,8 +3,9 @@ package mmm.materials;
import java.util.List; import java.util.List;
import mmm.utils.I_UOreGenerationRegistrar; import mmm.MmmMaterials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import mmm.core.api.I_OreGenerationRegistrar;
import mmm.world.WLocation; import mmm.world.WLocation;
import mmm.world.gen.WGOreCondition; import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters; import mmm.world.gen.WGOreParameters;
@ -14,7 +15,7 @@ import net.minecraft.init.Blocks;
public class MOres public class MOres
implements I_UOreGenerationRegistrar implements I_OreGenerationRegistrar
{ {
public final MOre COPPER; public final MOre COPPER;
public final MOre MALACHITE; public final MOre MALACHITE;
@ -30,42 +31,42 @@ public class MOres
public final MOre SALTPETER; public final MOre SALTPETER;
MOres( ) public MOres( )
{ {
URegistry.addOreGenerationRegistrar( this ); CRegistry.addOreGenerationRegistrar( this );
COPPER = new MOre( "copper" , 1 ) // this.COPPER = new MOre( "copper" , 1 ) //
.setMetal( Materials.METAL.COPPER ); .setMetal( MmmMaterials.METAL.COPPER );
MALACHITE = new MOre( "malachite" , 1 )// this.MALACHITE = new MOre( "malachite" , 1 )//
.setMetal( Materials.METAL.COPPER ) // .setMetal( MmmMaterials.METAL.COPPER ) //
.setDrops( Materials.ITEM.MALACHITE ) // .setDrops( MmmMaterials.ITEM.MALACHITE ) //
.setExperience( 1 , 3 ); .setExperience( 1 , 3 );
CUPRITE = new MOre( "cuprite" , 1 ) // this.CUPRITE = new MOre( "cuprite" , 1 ) //
.setMetal( Materials.METAL.COPPER , 2 ) // .setMetal( MmmMaterials.METAL.COPPER , 2 ) //
.setDrops( Materials.ITEM.CUPRITE ) // .setDrops( MmmMaterials.ITEM.CUPRITE ) //
.setExperience( 2 , 5 ); .setExperience( 2 , 5 );
CASSITERITE = new MOre( "cassiterite" , 0 )// this.CASSITERITE = new MOre( "cassiterite" , 0 )//
.setMetal( Materials.METAL.TIN , 1 , E_MMetalItemType.NUGGET ) // .setMetal( MmmMaterials.METAL.TIN , 1 , E_MMetalItemType.NUGGET ) //
.setDrops( Materials.ITEM.CASSITERITE , 2 , 5 ) // .setDrops( MmmMaterials.ITEM.CASSITERITE , 2 , 5 ) //
.setExperience( 2 , 5 ); .setExperience( 2 , 5 );
SPHALERITE = new MOre( "sphalerite" , 1 ) // this.SPHALERITE = new MOre( "sphalerite" , 1 ) //
.setMetal( Materials.METAL.ZINC ) // .setMetal( MmmMaterials.METAL.ZINC ) //
.setDrops( Materials.ITEM.SPHALERITE ) // .setDrops( MmmMaterials.ITEM.SPHALERITE ) //
.setExperience( 1 , 3 ); .setExperience( 1 , 3 );
ROCK_SALT = new MOre( "rock_salt" , 0 ) // this.ROCK_SALT = new MOre( "rock_salt" , 0 ) //
.setDrops( Materials.ITEM.ROCK_SALT , 2 , 5 ) // .setDrops( MmmMaterials.ITEM.ROCK_SALT , 2 , 5 ) //
.setExperience( 0 , 1 ); .setExperience( 0 , 1 );
BAUXITE = new MOre( "bauxite" , 1 ); this.BAUXITE = new MOre( "bauxite" , 1 );
GALENA = new MOre( "galena" , 1 ); this.GALENA = new MOre( "galena" , 1 );
CINNABAR = new MOre( "cinnabar" , 1 ); this.CINNABAR = new MOre( "cinnabar" , 1 );
SULPHUR = new MOre( "sulphur" , 0 ) // this.SULPHUR = new MOre( "sulphur" , 0 ) //
.setResistance( 2.0f ) // .setResistance( 2.0f ) //
.setHardness( 1.0f ) // .setHardness( 1.0f ) //
.setDrops( Materials.ITEM.SULPHUR_POWDER , 3 , 6 ) // .setDrops( MmmMaterials.ITEM.SULPHUR_POWDER , 3 , 6 ) //
.setExperience( 1 , 2 ); .setExperience( 1 , 2 );
SILVER = new MOre( "silver" , 2 ); this.SILVER = new MOre( "silver" , 2 );
SALTPETER = new MOre( "saltpeter" , 0 ) // this.SALTPETER = new MOre( "saltpeter" , 0 ) //
.setDrops( Materials.ITEM.SALTPETER , 4 , 8 ) // .setDrops( MmmMaterials.ITEM.SALTPETER , 4 , 8 ) //
.setExperience( 0 , 1 ); .setExperience( 0 , 1 );
} }

View file

@ -1,7 +1,7 @@
package mmm.materials; package mmm.materials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -25,7 +25,7 @@ public class MPlanks
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHarvestLevel( "axe" , 0 ); this.setHarvestLevel( "axe" , 0 );
URegistry.setIdentifiers( this , "materials" , "planks" , wood.NAME ); CRegistry.setIdentifiers( this , "materials" , "planks" , wood.NAME );
} }

View file

@ -1,8 +1,8 @@
package mmm.materials; package mmm.materials;
import mmm.utils.I_UTrapBlock; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.blocks.I_TrapBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockFalling; import net.minecraft.block.BlockFalling;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -22,12 +22,12 @@ import net.minecraftforge.common.IPlantable;
public class MQuicksand public class MQuicksand
extends BlockFalling extends BlockFalling
implements I_UTrapBlock implements I_TrapBlock
{ {
public final IBlockState forType; public final IBlockState forType;
public MQuicksand( String name , IBlockState forType ) public MQuicksand( final String name , final IBlockState forType )
{ {
super( Material.SAND ); super( Material.SAND );
this.forType = forType; this.forType = forType;
@ -35,7 +35,7 @@ public class MQuicksand
this.setSoundType( SoundType.SAND ); this.setSoundType( SoundType.SAND );
this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS );
this.setHarvestLevel( "shovel" , 0 ); this.setHarvestLevel( "shovel" , 0 );
URegistry.setIdentifiers( this , "materials" , "trap" , name ); CRegistry.setIdentifiers( this , "materials" , "trap" , name );
} }
@ -56,7 +56,7 @@ public class MQuicksand
@Override @Override
public MapColor getMapColor( IBlockState state ) public MapColor getMapColor( final IBlockState state )
{ {
return this.forType.getMapColor( ); return this.forType.getMapColor( );
} }
@ -79,8 +79,8 @@ public class MQuicksand
@Override @Override
public boolean canSustainPlant( IBlockState state , IBlockAccess world , BlockPos pos , EnumFacing direction , public boolean canSustainPlant( final IBlockState state , final IBlockAccess world , final BlockPos pos ,
IPlantable plantable ) final EnumFacing direction , final IPlantable plantable )
{ {
switch ( plantable.getPlantType( world , pos.offset( direction ) ) ) { switch ( plantable.getPlantType( world , pos.offset( direction ) ) ) {

View file

@ -1,7 +1,7 @@
package mmm.materials; package mmm.materials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -36,8 +36,8 @@ public class MRock
this.setResistance( resistance ); this.setResistance( resistance );
this.setSoundType( SoundType.STONE ); this.setSoundType( SoundType.STONE );
this.setHarvestLevel( "pickaxe" , harvestLevel ); this.setHarvestLevel( "pickaxe" , harvestLevel );
URegistry.setIdentifiers( this , "materials" , "rock" , name ); CRegistry.setIdentifiers( this , "materials" , "rock" , name );
URegistry.addBlock( this ); CRegistry.addBlock( this );
} }
} }

View file

@ -3,10 +3,11 @@ package mmm.materials;
import java.util.List; import java.util.List;
import mmm.utils.I_UOreGenerationRegistrar; import mmm.MmmMaterials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import mmm.core.api.I_OreGenerationRegistrar;
import mmm.world.WLocation; import mmm.world.WLocation;
import mmm.world.WLocationInBiome; import mmm.world.WLocationInBiomeClass;
import mmm.world.gen.WGOreCondition; import mmm.world.gen.WGOreCondition;
import mmm.world.gen.WGOreParameters; import mmm.world.gen.WGOreParameters;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -16,7 +17,7 @@ import net.minecraft.world.biome.BiomeSwamp;
public class MRocks public class MRocks
implements I_UOreGenerationRegistrar implements I_OreGenerationRegistrar
{ {
public final MRock LIMESTONE; public final MRock LIMESTONE;
@ -25,9 +26,9 @@ public class MRocks
public final MRock BASALT; public final MRock BASALT;
MRocks( ) public MRocks( )
{ {
URegistry.addOreGenerationRegistrar( this ); CRegistry.addOreGenerationRegistrar( this );
this.LIMESTONE = new MRock( "limestone" , MapColor.SNOW , 0 , 1f , 7.5f ); this.LIMESTONE = new MRock( "limestone" , MapColor.SNOW , 0 , 1f , 7.5f );
this.CHALK = new MRock( "chalk" , MapColor.SNOW , 0 , 1f , 5f ); this.CHALK = new MRock( "chalk" , MapColor.SNOW , 0 , 1f , 5f );
@ -41,13 +42,13 @@ public class MRocks
{ {
conditions.add( new WGOreCondition( // conditions.add( new WGOreCondition( //
WLocation.inOverworld( ) , // WLocation.inOverworld( ) , //
new WGOreParameters( Materials.ROCK.LIMESTONE , 15 , 40 ) ) ); new WGOreParameters( MmmMaterials.ROCK.LIMESTONE , 15 , 40 ) ) );
conditions.add( new WGOreCondition( // conditions.add( new WGOreCondition( //
new WLocationInBiome<>( BiomePlains.class ) , // new WLocationInBiomeClass<>( BiomePlains.class ) , //
new WGOreParameters( Materials.ROCK.SLATE , 15 , 40 ) ) ); new WGOreParameters( MmmMaterials.ROCK.SLATE , 15 , 40 ) ) );
conditions.add( new WGOreCondition( // conditions.add( new WGOreCondition( //
new WLocationInBiome<>( BiomeSwamp.class ) , // new WLocationInBiomeClass<>( BiomeSwamp.class ) , //
new WGOreParameters( Materials.ROCK.SLATE , 20 , 60 ) ) ); new WGOreParameters( MmmMaterials.ROCK.SLATE , 20 , 60 ) ) );
} }
} }

View file

@ -3,7 +3,7 @@ package mmm.materials;
import java.util.Random; import java.util.Random;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.IGrowable; import net.minecraft.block.IGrowable;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
@ -46,7 +46,7 @@ public class MSapling
this.setDefaultState( this.blockState.getBaseState( ).withProperty( MSapling.STAGE , 0 ) ); this.setDefaultState( this.blockState.getBaseState( ).withProperty( MSapling.STAGE , 0 ) );
URegistry.setIdentifiers( this , "materials" , "sapling" , wood.NAME ); CRegistry.setIdentifiers( this , "materials" , "sapling" , wood.NAME );
} }

View file

@ -1,8 +1,8 @@
package mmm.materials; package mmm.materials;
import mmm.utils.I_UTintedBlock; import mmm.core.api.blocks.I_TintedBlock;
import mmm.utils.I_UTintedItem; import mmm.core.api.items.I_TintedItem;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
@ -21,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class MSwampPit public class MSwampPit
extends MQuicksand extends MQuicksand
implements I_UTintedBlock , I_UTintedItem implements I_TintedBlock , I_TintedItem
{ {
public MSwampPit( ) public MSwampPit( )
@ -40,8 +40,8 @@ public class MSwampPit
@Override @Override
public boolean canSustainPlant( IBlockState state , IBlockAccess world , BlockPos pos , EnumFacing direction , public boolean canSustainPlant( final IBlockState state , final IBlockAccess world , final BlockPos pos ,
IPlantable plantable ) final EnumFacing direction , final IPlantable plantable )
{ {
return false; return false;
} }

View file

@ -1,4 +1,4 @@
package mmm.utils; package mmm.materials;
import java.util.ArrayList; import java.util.ArrayList;
@ -8,22 +8,23 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import mmm.core.api.blocks.I_TrapBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
public enum UTrapBlocks { public enum MTrapBlocks {
INSTANCE; INSTANCE;
private final ArrayListMultimap< IBlockState , I_UTrapBlock > traps = ArrayListMultimap.create( ); private final ArrayListMultimap< IBlockState , I_TrapBlock > traps = ArrayListMultimap.create( );
private final ArrayListMultimap< IBlockState , IBlockState > replacements = ArrayListMultimap.create( ); private final ArrayListMultimap< IBlockState , IBlockState > replacements = ArrayListMultimap.create( );
private final LinkedHashMultimap< IBlockState , String > trapTypes = LinkedHashMultimap.create( ); private final LinkedHashMultimap< IBlockState , String > trapTypes = LinkedHashMultimap.create( );
public void register( final I_UTrapBlock block ) public void register( final I_TrapBlock block )
{ {
for ( IBlockState state : block.getReplacedBlocks( ) ) { for ( final IBlockState state : block.getReplacedBlocks( ) ) {
this.traps.put( state , block ); this.traps.put( state , block );
this.trapTypes.put( state , block.getTrapType( ) ); this.trapTypes.put( state , block.getTrapType( ) );
this.replacements.put( state , ( (Block) block ).getDefaultState( ) ); this.replacements.put( state , ( (Block) block ).getDefaultState( ) );
@ -39,11 +40,11 @@ public enum UTrapBlocks {
public List< IBlockState > getReplacements( final IBlockState blockState , final String trapType ) public List< IBlockState > getReplacements( final IBlockState blockState , final String trapType )
{ {
ArrayList< IBlockState > out = Lists.newArrayList( ); final ArrayList< IBlockState > out = Lists.newArrayList( );
List< I_UTrapBlock > traps = this.traps.get( blockState ); final List< I_TrapBlock > traps = this.traps.get( blockState );
int nTraps = traps.size( ); final int nTraps = traps.size( );
for ( int i = 0 ; i < nTraps ; i++ ) { for ( int i = 0 ; i < nTraps ; i++ ) {
I_UTrapBlock trap = traps.get( i ); final I_TrapBlock trap = traps.get( i );
if ( trap.getTrapType( ).equals( trapType ) ) { if ( trap.getTrapType( ).equals( trapType ) ) {
out.add( ( (Block) trap ).getDefaultState( ) ); out.add( ( (Block) trap ).getDefaultState( ) );
} }

View file

@ -1,7 +1,7 @@
package mmm.materials; package mmm.materials;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.block.BlockSand; import net.minecraft.block.BlockSand;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
@ -15,16 +15,16 @@ public class MTraps
public final MMud MUD; public final MMud MUD;
MTraps( ) public MTraps( )
{ {
// FIXME recipes to convert quicksand into sand or mud into dirt // FIXME recipes to convert quicksand into sand or mud into dirt
URegistry.addBlock( this.QUICKSAND = new MQuicksand( "sand" , // CRegistry.addBlock( this.QUICKSAND = new MQuicksand( "sand" , //
Blocks.SAND.getDefaultState( ) // Blocks.SAND.getDefaultState( ) //
.withProperty( BlockSand.VARIANT , BlockSand.EnumType.SAND ) ) ); .withProperty( BlockSand.VARIANT , BlockSand.EnumType.SAND ) ) );
URegistry.addBlock( this.RED_QUICKSAND = new MQuicksand( "red_sand" , // CRegistry.addBlock( this.RED_QUICKSAND = new MQuicksand( "red_sand" , //
Blocks.SAND.getDefaultState( ) // Blocks.SAND.getDefaultState( ) //
.withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) ); .withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) );
URegistry.addBlock( this.SWAMP_PIT = new MSwampPit( ) ); CRegistry.addBlock( this.SWAMP_PIT = new MSwampPit( ) );
URegistry.addBlock( this.MUD = new MMud( ) ); CRegistry.addBlock( this.MUD = new MMud( ) );
} }
} }

View file

@ -3,8 +3,8 @@ package mmm.materials;
import java.util.Random; import java.util.Random;
import mmm.utils.I_URecipeRegistrar; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.I_RecipeRegistrar;
import mmm.world.trees.A_WTTreeGenerator; import mmm.world.trees.A_WTTreeGenerator;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockLog; import net.minecraft.block.BlockLog;
@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class MTree public class MTree
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
public static interface I_SaplingChecker public static interface I_SaplingChecker
{ {
@ -215,20 +215,20 @@ public class MTree
public MTree register( ) public MTree register( )
{ {
URegistry.addBlock( this.LOG ); CRegistry.addBlock( this.LOG );
URegistry.addBlock( this.LEAVES ); CRegistry.addBlock( this.LEAVES );
URegistry.addBlock( this.PLANKS ); CRegistry.addBlock( this.PLANKS );
final Item sapling = URegistry.addBlock( this.SAPLING ); final Item sapling = CRegistry.addBlock( this.SAPLING );
if ( this.baseFlammability != 0 ) { if ( this.baseFlammability != 0 ) {
Blocks.FIRE.setFireInfo( this.LOG , this.baseFireEncouragement , this.baseFlammability ); Blocks.FIRE.setFireInfo( this.LOG , this.baseFireEncouragement , this.baseFlammability );
Blocks.FIRE.setFireInfo( this.LEAVES , this.baseFireEncouragement * 6 , this.baseFlammability * 12 ); Blocks.FIRE.setFireInfo( this.LEAVES , this.baseFireEncouragement * 6 , this.baseFlammability * 12 );
Blocks.FIRE.setFireInfo( this.PLANKS , this.baseFireEncouragement , this.baseFlammability * 4 ); Blocks.FIRE.setFireInfo( this.PLANKS , this.baseFireEncouragement , this.baseFlammability * 4 );
Blocks.FIRE.setFireInfo( this.SAPLING , this.baseFireEncouragement * 2 , this.baseFlammability * 8 ); Blocks.FIRE.setFireInfo( this.SAPLING , this.baseFireEncouragement * 2 , this.baseFlammability * 8 );
URegistry.setFuel( sapling , this.baseFlammability * 30 ); CRegistry.setFuel( sapling , this.baseFlammability * 30 );
} }
URegistry.addRecipeRegistrar( this ); CRegistry.addRecipeRegistrar( this );
return this; return this;
} }
@ -266,13 +266,13 @@ public class MTree
public int getBaseFireEncouragement( ) public int getBaseFireEncouragement( )
{ {
return baseFireEncouragement; return this.baseFireEncouragement;
} }
public int getBaseFlammability( ) public int getBaseFlammability( )
{ {
return baseFlammability; return this.baseFlammability;
} }

View file

@ -3,9 +3,9 @@ package mmm.materials;
import mmm.utils.UMaths; import mmm.utils.UMaths;
import mmm.world.trees.WTBamboo; import mmm.world.trees.WTBamboo;
import mmm.world.trees.WTHevea;
import mmm.world.trees.WTHeveaBig; import mmm.world.trees.WTHeveaBig;
import mmm.world.trees.WTHeveaMega; import mmm.world.trees.WTHeveaMega;
import mmm.world.trees.WTHevea;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -17,7 +17,7 @@ public class MTrees
public final MTree BAMBOO; public final MTree BAMBOO;
MTrees( ) public MTrees( )
{ {
this.HEVEA = new MTree( "hevea" ) // this.HEVEA = new MTree( "hevea" ) //
.setBarkColor( MapColor.GRAY ) // .setBarkColor( MapColor.GRAY ) //

View file

@ -1,9 +1,7 @@
package mmm.deco; package mmm.materials;
import mmm.Mmm; import mmm.Mmm;
import mmm.materials.MTree;
import mmm.materials.Materials;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockPlanks;
import net.minecraft.block.material.MapColor; import net.minecraft.block.material.MapColor;
@ -12,18 +10,8 @@ import net.minecraft.util.ResourceLocation;
public abstract class DWoodType public abstract class MWood
{ {
public static final DWoodType OAK = new DWoodType.Vanilla( "oak" , BlockPlanks.EnumType.OAK );
public static final DWoodType BIRCH = new DWoodType.Vanilla( "birch" , BlockPlanks.EnumType.BIRCH );
public static final DWoodType SPRUCE = new DWoodType.Vanilla( "spruce" , BlockPlanks.EnumType.SPRUCE );
public static final DWoodType JUNGLE = new DWoodType.Vanilla( "jungle" , BlockPlanks.EnumType.JUNGLE );
public static final DWoodType DARK_OAK = new DWoodType.Vanilla( "dark_oak" , BlockPlanks.EnumType.DARK_OAK );
public static final DWoodType ACACIA = new DWoodType.Vanilla( "acacia" , BlockPlanks.EnumType.ACACIA );
public static final DWoodType HEVEA = new DWoodType.MmmTree( Materials.TREE.HEVEA );
public static final DWoodType BAMBOO = new DWoodType.MmmTree( Materials.TREE.BAMBOO );
public abstract String getSuffix( ); public abstract String getSuffix( );
@ -44,13 +32,13 @@ public abstract class DWoodType
// ******************************************************************************************* // *******************************************************************************************
public static final class Vanilla public static final class Vanilla
extends DWoodType extends MWood
{ {
private final String suffix; private final String suffix;
private final BlockPlanks.EnumType type; private final BlockPlanks.EnumType type;
private Vanilla( final String suffix , final BlockPlanks.EnumType type ) public Vanilla( final String suffix , final BlockPlanks.EnumType type )
{ {
this.suffix = suffix; this.suffix = suffix;
this.type = type; this.type = type;
@ -97,13 +85,13 @@ public abstract class DWoodType
// ******************************************************************************************* // *******************************************************************************************
public static final class MmmTree public static final class MmmTree
extends DWoodType extends MWood
{ {
private final MTree materials; private final MTree materials;
private final ResourceLocation slabName; private final ResourceLocation slabName;
private MmmTree( final MTree materials ) public MmmTree( final MTree materials )
{ {
this.materials = materials; this.materials = materials;
this.slabName = new ResourceLocation( Mmm.ID , "deco/slabs/" + materials.NAME ); this.slabName = new ResourceLocation( Mmm.ID , "deco/slabs/" + materials.NAME );

View file

@ -0,0 +1,35 @@
package mmm.materials;
import mmm.MmmMaterials;
import net.minecraft.block.BlockPlanks;
public class MWoods
{
public final MWood OAK;
public final MWood BIRCH;
public final MWood SPRUCE;
public final MWood JUNGLE;
public final MWood DARK_OAK;
public final MWood ACACIA;
public final MWood HEVEA;
public final MWood BAMBOO;
public MWoods( )
{
this.OAK = new MWood.Vanilla( "oak" , BlockPlanks.EnumType.OAK );
this.BIRCH = new MWood.Vanilla( "birch" , BlockPlanks.EnumType.BIRCH );
this.SPRUCE = new MWood.Vanilla( "spruce" , BlockPlanks.EnumType.SPRUCE );
this.JUNGLE = new MWood.Vanilla( "jungle" , BlockPlanks.EnumType.JUNGLE );
this.DARK_OAK = new MWood.Vanilla( "dark_oak" , BlockPlanks.EnumType.DARK_OAK );
this.ACACIA = new MWood.Vanilla( "acacia" , BlockPlanks.EnumType.ACACIA );
this.HEVEA = new MWood.MmmTree( MmmMaterials.TREE.HEVEA );
this.BAMBOO = new MWood.MmmTree( MmmMaterials.TREE.BAMBOO );
}
}

View file

@ -1,40 +0,0 @@
package mmm.proxy;
import mmm.Mmm;
import mmm.deco.DecorativeBlocks;
import mmm.food.Food;
import mmm.materials.Materials;
import mmm.tech.Tech;
import mmm.utils.UAccessors;
import mmm.utils.URegistry;
import mmm.utils.USeat;
import mmm.world.World;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
public abstract class PCommon
{
public void preInit( final FMLPreInitializationEvent event )
{
UAccessors.preInit( );
Materials.preInit( );
World.preInit( );
Tech.preInit( );
Food.preInit( );
DecorativeBlocks.preInit( );
URegistry.registerRecipes( );
}
public void init( final FMLInitializationEvent event )
{
USeat.register( Mmm.get( ) );
World.init( );
}
}

View file

@ -1,8 +0,0 @@
package mmm.proxy;
public class PServer
extends PCommon
{
// EMPTY
}

View file

@ -0,0 +1,69 @@
package mmm.tech;
import io.netty.buffer.ByteBuf;
import mmm.core.api.I_Message;
import mmm.core.api.tech.E_ActivationMode;
import mmm.core.api.tech.I_ConfigurableActivation;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
public class TActivationModeMessage
implements I_Message
{
private E_ActivationMode mode;
public TActivationModeMessage( )
{
// EMPTY
}
public TActivationModeMessage( final E_ActivationMode mode )
{
this.mode = mode;
}
@Override
public void fromBytes( final ByteBuf buf )
{
switch ( buf.readByte( ) ) {
default:
// XXX warning
case 0:
this.mode = E_ActivationMode.ALWAYS_ACTIVE;
break;
case 1:
this.mode = E_ActivationMode.POWERED;
break;
case 2:
this.mode = E_ActivationMode.UNPOWERED;
break;
case 3:
this.mode = E_ActivationMode.DISABLED;
break;
}
}
@Override
public void toBytes( final ByteBuf buf )
{
buf.writeByte( this.mode.ordinal( ) );
}
@Override
public void handleOnServer( final EntityPlayerMP player )
{
final Container curCont = player.openContainer;
if ( curCont instanceof I_ConfigurableActivation ) {
( (I_ConfigurableActivation) curCont ).setActivationMode( this.mode );
}
}
}

View file

@ -1,22 +0,0 @@
package mmm.tech;
import mmm.tech.base.TechBase;
import mmm.tech.tools.TechTools;
public class Tech
{
static {
TechBase.preInit( );
TechTools.preInit( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -1,24 +0,0 @@
package mmm.tech.base;
public enum E_TBActivationMode {
ALWAYS_ACTIVE ,
POWERED ,
UNPOWERED ,
DISABLED;
private static final E_TBActivationMode[] VALUES = E_TBActivationMode.values( );
public String getDisplayName( )
{
return "gui.mmm.tech.base.am." + this.toString( ).toLowerCase( );
}
public E_TBActivationMode next( )
{
return E_TBActivationMode.VALUES[ ( this.ordinal( ) + 1 ) % E_TBActivationMode.VALUES.length ];
}
}

View file

@ -1,12 +0,0 @@
package mmm.tech.base;
public interface I_TBConfigurableActivation
{
public E_TBActivationMode getActivationMode( );
public void setActivationMode( E_TBActivationMode mode );
}

View file

@ -1,67 +0,0 @@
package mmm.tech.base;
import io.netty.buffer.ByteBuf;
import mmm.utils.I_UMessage;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
public class TBActivationModeMessage
implements I_UMessage
{
private E_TBActivationMode mode;
public TBActivationModeMessage( )
{
// EMPTY
}
public TBActivationModeMessage( final E_TBActivationMode mode )
{
this.mode = mode;
}
@Override
public void fromBytes( final ByteBuf buf )
{
switch ( buf.readByte( ) ) {
default:
// XXX warning
case 0:
this.mode = E_TBActivationMode.ALWAYS_ACTIVE;
break;
case 1:
this.mode = E_TBActivationMode.POWERED;
break;
case 2:
this.mode = E_TBActivationMode.UNPOWERED;
break;
case 3:
this.mode = E_TBActivationMode.DISABLED;
break;
}
}
@Override
public void toBytes( final ByteBuf buf )
{
buf.writeByte( this.mode.ordinal( ) );
}
@Override
public void handleOnServer( final EntityPlayerMP player )
{
final Container curCont = player.openContainer;
if ( curCont instanceof I_TBConfigurableActivation ) {
( (I_TBConfigurableActivation) curCont ).setActivationMode( this.mode );
}
}
}

View file

@ -0,0 +1,24 @@
package mmm.tech.base;
import mmm.tech.base.alloy_furnace.TBAlloyFurnace;
public class TBMachines
{
public final TBAlloyFurnace ALLOY_FURNACE;
public TBMachines( )
{
this.ALLOY_FURNACE = new TBAlloyFurnace( );
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -1,24 +0,0 @@
package mmm.tech.base;
import mmm.tech.base.alloy_furnace.AlloyFurnace;
import mmm.utils.UNetwork;
public class TechBase
{
public static final AlloyFurnace ALLOY_FURNACE;
static {
UNetwork.addServerMessage( TBActivationModeMessage.class );
ALLOY_FURNACE = AlloyFurnace.INSTANCE;
}
public static void preInit( )
{
// EMPTY
}
}

View file

@ -7,10 +7,11 @@ import java.util.Random;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import mmm.utils.I_URecipeRegistrar; import mmm.MmmTech;
import mmm.core.CGui;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.utils.UMaths; import mmm.utils.UMaths;
import mmm.utils.URegistry;
import mmm.utils.gui.GUIUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.BlockHorizontal; import net.minecraft.block.BlockHorizontal;
@ -49,7 +50,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class TBAFBlock public class TBAFBlock
extends BlockContainer extends BlockContainer
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
private static final AxisAlignedBB AABB_BOTTOM = UMaths.makeBlockAABB( 0 , 0 , 0 , 16 , 10 , 16 ); private static final AxisAlignedBB AABB_BOTTOM = UMaths.makeBlockAABB( 0 , 0 , 0 , 16 , 10 , 16 );
private static final AxisAlignedBB AABB_TOP = UMaths.makeBlockAABB( 4 , 10 , 4 , 12 , 16 , 12 ); private static final AxisAlignedBB AABB_TOP = UMaths.makeBlockAABB( 4 , 10 , 4 , 12 , 16 , 12 );
@ -80,7 +81,7 @@ public class TBAFBlock
.withProperty( TBAFBlock.FACING , EnumFacing.NORTH ) // .withProperty( TBAFBlock.FACING , EnumFacing.NORTH ) //
.withProperty( TBAFBlock.POWERED , Boolean.valueOf( false ) ) ); .withProperty( TBAFBlock.POWERED , Boolean.valueOf( false ) ) );
URegistry.setIdentifiers( this , "tech" , "base" , "alloy_furnace" , active ? "active" : "inactive" ); CRegistry.setIdentifiers( this , "tech" , "base" , "alloy_furnace" , active ? "active" : "inactive" );
} }
@ -88,7 +89,7 @@ public class TBAFBlock
public void registerRecipes( ) public void registerRecipes( )
{ {
if ( !this.active ) { if ( !this.active ) {
GameRegistry.addShapedRecipe( new ItemStack( AlloyFurnace.INSTANCE.ITEM ) , // GameRegistry.addShapedRecipe( new ItemStack( MmmTech.MACHINES.ALLOY_FURNACE.ITEM ) , //
"BBB" , // "BBB" , //
"BFB" , // "BFB" , //
"BBB" , // "BBB" , //
@ -118,9 +119,9 @@ public class TBAFBlock
IBlockState nState; IBlockState nState;
Block nBlock; Block nBlock;
if ( burning ) { if ( burning ) {
nBlock = AlloyFurnace.INSTANCE.ACTIVE; nBlock = MmmTech.MACHINES.ALLOY_FURNACE.ACTIVE;
} else { } else {
nBlock = AlloyFurnace.INSTANCE.INACTIVE; nBlock = MmmTech.MACHINES.ALLOY_FURNACE.INACTIVE;
} }
nState = nBlock.getDefaultState( ) // nState = nBlock.getDefaultState( ) //
.withProperty( TBAFBlock.FACING , iblockstate.getValue( TBAFBlock.FACING ) ) // .withProperty( TBAFBlock.FACING , iblockstate.getValue( TBAFBlock.FACING ) ) //
@ -261,7 +262,7 @@ public class TBAFBlock
@Nullable @Nullable
public Item getItemDropped( final IBlockState state , final Random rand , final int fortune ) public Item getItemDropped( final IBlockState state , final Random rand , final int fortune )
{ {
return AlloyFurnace.INSTANCE.ITEM; return MmmTech.MACHINES.ALLOY_FURNACE.ITEM;
} }
@ -375,7 +376,7 @@ public class TBAFBlock
if ( ! ( te instanceof TBAFTileEntity ) || playerIn.isSneaking( ) ) { if ( ! ( te instanceof TBAFTileEntity ) || playerIn.isSneaking( ) ) {
return false; return false;
} }
GUIUtils.openTileEntityGUI( playerIn , worldIn , pos ); CGui.openTileEntityGUI( playerIn , worldIn , pos );
return true; return true;
} }
@ -392,7 +393,7 @@ public class TBAFBlock
InventoryHelper.dropInventoryItems( worldIn , pos , afte.fuel ); InventoryHelper.dropInventoryItems( worldIn , pos , afte.fuel );
InventoryHelper.dropInventoryItems( worldIn , pos , afte.output ); InventoryHelper.dropInventoryItems( worldIn , pos , afte.output );
final ItemStack stack = new ItemStack( AlloyFurnace.INSTANCE.ITEM , 1 ); final ItemStack stack = new ItemStack( MmmTech.MACHINES.ALLOY_FURNACE.ITEM , 1 );
if ( afte.hasCustomName( ) ) { if ( afte.hasCustomName( ) ) {
stack.setStackDisplayName( afte.getName( ) ); stack.setStackDisplayName( afte.getName( ) );
} }

View file

@ -1,13 +1,13 @@
package mmm.tech.base.alloy_furnace; package mmm.tech.base.alloy_furnace;
import mmm.core.CNetwork;
import mmm.core.api.tech.E_ActivationMode;
import mmm.core.api.tech.I_ConfigurableActivation;
import mmm.materials.MAlloyRecipe; import mmm.materials.MAlloyRecipe;
import mmm.tech.base.E_TBActivationMode; import mmm.tech.TActivationModeMessage;
import mmm.tech.base.I_TBConfigurableActivation;
import mmm.tech.base.TBActivationModeMessage;
import mmm.utils.UInventoryDisplay; import mmm.utils.UInventoryDisplay;
import mmm.utils.UInventoryGrid; import mmm.utils.UInventoryGrid;
import mmm.utils.UNetwork;
import mmm.utils.gui.UGContainer; import mmm.utils.gui.UGContainer;
import mmm.utils.gui.UGSlotDisplay; import mmm.utils.gui.UGSlotDisplay;
import mmm.utils.gui.UGSlotFuel; import mmm.utils.gui.UGSlotFuel;
@ -26,7 +26,7 @@ import net.minecraft.world.World;
public class TBAFContainer public class TBAFContainer
extends UGContainer extends UGContainer
implements I_TBConfigurableActivation implements I_ConfigurableActivation
{ {
public final TBAFTileEntity tileEntity; public final TBAFTileEntity tileEntity;
public final World world; public final World world;
@ -154,25 +154,25 @@ public class TBAFContainer
@Override @Override
public E_TBActivationMode getActivationMode( ) public E_ActivationMode getActivationMode( )
{ {
final TileEntity te = this.world.getTileEntity( this.position ); final TileEntity te = this.world.getTileEntity( this.position );
if ( te instanceof TBAFTileEntity ) { if ( te instanceof TBAFTileEntity ) {
return ( (TBAFTileEntity) te ).getActivationMode( ); return ( (TBAFTileEntity) te ).getActivationMode( );
} }
return E_TBActivationMode.DISABLED; return E_ActivationMode.DISABLED;
} }
@Override @Override
public void setActivationMode( final E_TBActivationMode mode ) public void setActivationMode( final E_ActivationMode mode )
{ {
if ( this.world.isRemote ) { if ( this.world.isRemote ) {
final TileEntity te = this.world.getTileEntity( this.position ); final TileEntity te = this.world.getTileEntity( this.position );
if ( te instanceof TBAFTileEntity ) { if ( te instanceof TBAFTileEntity ) {
( (TBAFTileEntity) te ).setActivationMode( mode ); ( (TBAFTileEntity) te ).setActivationMode( mode );
} }
UNetwork.sendToServer( new TBActivationModeMessage( mode ) ); CNetwork.sendToServer( new TActivationModeMessage( mode ) );
} else { } else {
this.tileEntity.setActivationMode( mode ); this.tileEntity.setActivationMode( mode );
this.tileEntity.forceUpdate( ); this.tileEntity.forceUpdate( );
@ -196,7 +196,7 @@ public class TBAFContainer
final TileEntity te = this.world.getTileEntity( this.position ); final TileEntity te = this.world.getTileEntity( this.position );
if ( te instanceof TBAFTileEntity ) { if ( te instanceof TBAFTileEntity ) {
( (TBAFTileEntity) te ).flags = flags; ( (TBAFTileEntity) te ).flags = flags;
UNetwork.sendToServer( new TBAFMessage( flags ) ); CNetwork.sendToServer( new TBAFMessage( flags ) );
} }
} else { } else {
this.tileEntity.flags = flags; this.tileEntity.flags = flags;

View file

@ -4,8 +4,8 @@ package mmm.tech.base.alloy_furnace;
import java.util.ArrayList; import java.util.ArrayList;
import mmm.Mmm; import mmm.Mmm;
import mmm.core.CNetwork;
import mmm.materials.MAlloyRecipe; import mmm.materials.MAlloyRecipe;
import mmm.utils.UNetwork;
import mmm.utils.gui.A_UGTab; import mmm.utils.gui.A_UGTab;
import mmm.utils.gui.A_UGTabbedContainerScreen; import mmm.utils.gui.A_UGTabbedContainerScreen;
import mmm.utils.gui.UGArrowButton; import mmm.utils.gui.UGArrowButton;
@ -177,7 +177,7 @@ public class TBAFGui
gui.setRecipe( gui.currentRecipe - 1 ); gui.setRecipe( gui.currentRecipe - 1 );
} else if ( button == this.bConfirm ) { } else if ( button == this.bConfirm ) {
final MAlloyRecipe recipe = gui.recipes.get( gui.currentRecipe ); final MAlloyRecipe recipe = gui.recipes.get( gui.currentRecipe );
UNetwork.sendToServer( new TBAFMessage( recipe.name , true ) ); CNetwork.sendToServer( new TBAFMessage( recipe.name , true ) );
gui.container.tileEntity.recipe = recipe; gui.container.tileEntity.recipe = recipe;
} else { } else {
return false; return false;
@ -342,7 +342,7 @@ public class TBAFGui
} }
this.container.setCurrentRecipe( rName , false ); this.container.setCurrentRecipe( rName , false );
UNetwork.sendToServer( new TBAFMessage( rName , false ) ); CNetwork.sendToServer( new TBAFMessage( rName , false ) );
( (RecipeTab) this.tabs[ 1 ] ).enableButtons( ); ( (RecipeTab) this.tabs[ 1 ] ).enableButtons( );
} }

View file

@ -2,7 +2,7 @@ package mmm.tech.base.alloy_furnace;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import mmm.utils.I_UMessage; import mmm.core.api.I_Message;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.network.ByteBufUtils;
public class TBAFMessage public class TBAFMessage
implements I_UMessage implements I_Message
{ {
private static final int MT_RECIPE = 0; private static final int MT_RECIPE = 0;
private static final int MT_SET_RECIPE = 1; private static final int MT_SET_RECIPE = 1;

View file

@ -1,10 +1,10 @@
package mmm.tech.base.alloy_furnace; package mmm.tech.base.alloy_furnace;
import mmm.MmmMaterials;
import mmm.core.api.tech.E_ActivationMode;
import mmm.core.api.tech.I_ConfigurableActivation;
import mmm.materials.MAlloyRecipe; import mmm.materials.MAlloyRecipe;
import mmm.materials.Materials;
import mmm.tech.base.E_TBActivationMode;
import mmm.tech.base.I_TBConfigurableActivation;
import mmm.utils.UInventoryGrid; import mmm.utils.UInventoryGrid;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
@ -31,7 +31,7 @@ import net.minecraftforge.items.wrapper.InvWrapper;
public class TBAFTileEntity public class TBAFTileEntity
extends TileEntity extends TileEntity
implements ITickable , I_TBConfigurableActivation , IWorldNameable implements ITickable , I_ConfigurableActivation , IWorldNameable
{ {
/** Input hopper allows invalid input? */ /** Input hopper allows invalid input? */
public static final int F_IH_INVALID = 1 << 0; public static final int F_IH_INVALID = 1 << 0;
@ -100,7 +100,7 @@ public class TBAFTileEntity
private int alloyCurrent; private int alloyCurrent;
private int burnCurrent; private int burnCurrent;
private int burnTotal; private int burnTotal;
private E_TBActivationMode activationMode; private E_ActivationMode activationMode;
public int flags; public int flags;
@ -115,7 +115,7 @@ public class TBAFTileEntity
this.fuel = new FuelInventory( "Fuel" , 2 , 2 ); this.fuel = new FuelInventory( "Fuel" , 2 , 2 );
this.output = new Inventory( "Output" , 2 , 5 ); this.output = new Inventory( "Output" , 2 , 5 );
this.recipe = MAlloyRecipe.REGISTRY.getRecipes( ).get( 0 ); this.recipe = MAlloyRecipe.REGISTRY.getRecipes( ).get( 0 );
this.activationMode = E_TBActivationMode.ALWAYS_ACTIVE; this.activationMode = E_ActivationMode.ALWAYS_ACTIVE;
this.flags = TBAFTileEntity.F_OH_INVALID_INPUT | TBAFTileEntity.F_OH_INVALID_FUEL this.flags = TBAFTileEntity.F_OH_INVALID_INPUT | TBAFTileEntity.F_OH_INVALID_FUEL
| TBAFTileEntity.F_CMP_INPUT_VALID; | TBAFTileEntity.F_CMP_INPUT_VALID;
@ -230,7 +230,7 @@ public class TBAFTileEntity
if ( this.alloyCurrent == 0 ) { if ( this.alloyCurrent == 0 ) {
this.addOutput( this.alloying.output ); this.addOutput( this.alloying.output );
if ( this.alloying.slag != 0 ) { if ( this.alloying.slag != 0 ) {
this.addOutput( new ItemStack( Materials.ITEM.SLAG , this.alloying.slag ) ); this.addOutput( new ItemStack( MmmMaterials.ITEM.SLAG , this.alloying.slag ) );
} }
this.alloying = null; this.alloying = null;
} }
@ -309,14 +309,14 @@ public class TBAFTileEntity
@Override @Override
public E_TBActivationMode getActivationMode( ) public E_ActivationMode getActivationMode( )
{ {
return this.activationMode; return this.activationMode;
} }
@Override @Override
public void setActivationMode( final E_TBActivationMode mode ) public void setActivationMode( final E_ActivationMode mode )
{ {
this.activationMode = mode; this.activationMode = mode;
} }
@ -325,7 +325,7 @@ public class TBAFTileEntity
public void cancelAlloying( ) public void cancelAlloying( )
{ {
if ( this.alloying != null ) { if ( this.alloying != null ) {
this.addOutput( new ItemStack( Materials.ITEM.SLAG , this.alloying.getTotalInputItems( ) ) ); this.addOutput( new ItemStack( MmmMaterials.ITEM.SLAG , this.alloying.getTotalInputItems( ) ) );
this.alloying = null; this.alloying = null;
this.alloyCurrent = 0; this.alloyCurrent = 0;
} }
@ -559,16 +559,16 @@ public class TBAFTileEntity
default: default:
// XXX log // XXX log
case 0: case 0:
this.activationMode = E_TBActivationMode.ALWAYS_ACTIVE; this.activationMode = E_ActivationMode.ALWAYS_ACTIVE;
break; break;
case 1: case 1:
this.activationMode = E_TBActivationMode.POWERED; this.activationMode = E_ActivationMode.POWERED;
break; break;
case 2: case 2:
this.activationMode = E_TBActivationMode.UNPOWERED; this.activationMode = E_ActivationMode.UNPOWERED;
break; break;
case 3: case 3:
this.activationMode = E_TBActivationMode.DISABLED; this.activationMode = E_ActivationMode.DISABLED;
break; break;
} }
this.flags = compound.getShort( "Flags" ); this.flags = compound.getShort( "Flags" );

View file

@ -1,9 +1,9 @@
package mmm.tech.base.alloy_furnace; package mmm.tech.base.alloy_furnace;
import mmm.utils.UNetwork; import mmm.core.CGui;
import mmm.utils.URegistry; import mmm.core.CNetwork;
import mmm.utils.gui.GUIUtils; import mmm.core.CRegistry;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
@ -11,10 +11,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public enum AlloyFurnace { public class TBAlloyFurnace
{
INSTANCE;
public final CreativeTabs CREATIVE_TAB = CreativeTabs.DECORATIONS; public final CreativeTabs CREATIVE_TAB = CreativeTabs.DECORATIONS;
public final TBAFBlock INACTIVE; public final TBAFBlock INACTIVE;
@ -22,7 +20,7 @@ public enum AlloyFurnace {
public final Item ITEM; public final Item ITEM;
private AlloyFurnace( ) public TBAlloyFurnace( )
{ {
this.INACTIVE = new TBAFBlock( false ); this.INACTIVE = new TBAFBlock( false );
this.INACTIVE.setCreativeTab( this.CREATIVE_TAB ); this.INACTIVE.setCreativeTab( this.CREATIVE_TAB );
@ -33,15 +31,16 @@ public enum AlloyFurnace {
this.ITEM = new ItemBlock( this.INACTIVE )// this.ITEM = new ItemBlock( this.INACTIVE )//
.setMaxStackSize( 16 )// .setMaxStackSize( 16 )//
.setCreativeTab( this.CREATIVE_TAB ); .setCreativeTab( this.CREATIVE_TAB );
URegistry.setIdentifiers( this.ITEM , "tech" , "base" , "alloy_furnace" ); CRegistry.setIdentifiers( this.ITEM , "tech" , "base" , "alloy_furnace" );
URegistry.addBlock( this.INACTIVE , this.ITEM ); CRegistry.addBlock( this.INACTIVE , this.ITEM );
URegistry.addBlock( this.ACTIVE , null ); CRegistry.addBlock( this.ACTIVE , null );
GameRegistry.registerTileEntity( TBAFTileEntity.class , "mmm:tech/base/alloy_furnace" ); GameRegistry.registerTileEntity( TBAFTileEntity.class , "mmm:tech/base/alloy_furnace" );
GUIUtils.registerTileEntityGUI( TBAFTileEntity.class , "mmm.tech.base.alloy_furnace.TBAFContainer" , CGui.registerTileEntityGUI( TBAFTileEntity.class , //
"mmm.tech.base.alloy_furnace.TBAFContainer" , //
"mmm.tech.base.alloy_furnace.TBAFGui" ); "mmm.tech.base.alloy_furnace.TBAFGui" );
UNetwork.addServerMessage( TBAFMessage.class ); CNetwork.addServerMessage( TBAFMessage.class );
} }
} }

View file

@ -1,8 +1,8 @@
package mmm.tech.tools; package mmm.tech.tools;
import mmm.utils.I_URecipeRegistrar; import mmm.core.CRegistry;
import mmm.utils.URegistry; import mmm.core.api.I_RecipeRegistrar;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -12,13 +12,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
public class TTArmor public class TTArmor
extends ItemArmor extends ItemArmor
implements I_URecipeRegistrar implements I_RecipeRegistrar
{ {
public TTArmor( final ArmorMaterial materialIn , final EntityEquipmentSlot equipmentSlotIn ) public TTArmor( final ArmorMaterial materialIn , final EntityEquipmentSlot equipmentSlotIn )
{ {
super( materialIn , materialIn.ordinal( ) , equipmentSlotIn ); super( materialIn , materialIn.ordinal( ) , equipmentSlotIn );
URegistry.setIdentifiers( this , "tech" , "tools" , materialIn.toString( ).toLowerCase( ) , "armor" , CRegistry.setIdentifiers( this , "tech" , "tools" , materialIn.toString( ).toLowerCase( ) , "armor" ,
equipmentSlotIn.getName( ) ); equipmentSlotIn.getName( ) );
} }

View file

@ -1,7 +1,7 @@
package mmm.tech.tools; package mmm.tech.tools;
import mmm.utils.URegistry; import mmm.core.CRegistry;
import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemArmor.ArmorMaterial;
@ -28,9 +28,9 @@ public class TTArmorSet
reductionAmounts , enchantability , soundOnEquip , toughness ); reductionAmounts , enchantability , soundOnEquip , toughness );
this.ARMOR_MATERIAL.customCraftingMaterial = material; this.ARMOR_MATERIAL.customCraftingMaterial = material;
URegistry.addItem( this.HELMET = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.HEAD ) ); CRegistry.addItem( this.HELMET = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.HEAD ) );
URegistry.addItem( this.CHESTPLATE = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.CHEST ) ); CRegistry.addItem( this.CHESTPLATE = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.CHEST ) );
URegistry.addItem( this.LEGGINGS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.LEGS ) ); CRegistry.addItem( this.LEGGINGS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.LEGS ) );
URegistry.addItem( this.BOOTS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.FEET ) ); CRegistry.addItem( this.BOOTS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.FEET ) );
} }
} }

Some files were not shown because too many files have changed in this diff Show more