More refactoring

This commit is contained in:
Emmanuel BENOîT 2016-07-12 20:56:55 +02:00
parent 3d18adf7f4
commit f44e8bd7b7
22 changed files with 53 additions and 64 deletions

View file

@ -8,10 +8,10 @@ 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 mmm.materials.traps.MTraps;
import mmm.materials.trees.MTrees;
import mmm.materials.trees.MWoodAchievementHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStone;
import net.minecraft.block.state.IBlockState;

View file

@ -15,12 +15,10 @@ 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.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
@ -143,9 +141,6 @@ public class CRegistry
GameRegistry.register( block );
CRegistry.addRecipeRegistrar( block );
CRegistry.addOreGenerationRegistrar( block );
if ( block instanceof I_TrapBlock ) {
MTrapBlocks.INSTANCE.register( (I_TrapBlock) block );
}
if ( block instanceof I_RequiresClientPreInit ) {
CRegistry.BLOCKS_CLIENT_PREINIT.add( block );
}

View file

@ -5,7 +5,7 @@ import mmm.MmmDeco;
import mmm.MmmMaterials;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.materials.MTree;
import mmm.materials.trees.MTree;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStairs;
import net.minecraft.block.BlockStone;

View file

@ -4,7 +4,7 @@ package mmm.deco.slabs;
import mmm.core.CRegistry;
import mmm.core.api.I_RecipeRegistrar;
import mmm.deco.DSmoothStone;
import mmm.materials.MTree;
import mmm.materials.trees.MTree;
import net.minecraft.block.Block;
import net.minecraft.block.BlockStone;
import net.minecraft.block.state.IBlockState;

View file

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

View file

@ -2,6 +2,7 @@ package mmm.materials;
import mmm.Mmm;
import mmm.materials.trees.MTree;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPlanks;
import net.minecraft.block.material.MapColor;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.traps;
import mmm.core.CRegistry;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.traps;
import mmm.core.CRegistry;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.traps;
import mmm.core.api.blocks.I_TintedBlock;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.traps;
import java.util.ArrayList;
@ -8,27 +8,51 @@ import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
import mmm.core.CRegistry;
import mmm.core.api.blocks.I_TrapBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockSand;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
public enum MTrapBlocks {
INSTANCE;
public class MTraps
{
public final MQuicksand QUICKSAND;
public final MQuicksand RED_QUICKSAND;
public final MSwampPit SWAMP_PIT;
public final MMud MUD;
private final ArrayListMultimap< IBlockState , I_TrapBlock > traps = ArrayListMultimap.create( );
private final ArrayListMultimap< IBlockState , IBlockState > replacements = ArrayListMultimap.create( );
private final LinkedHashMultimap< IBlockState , String > trapTypes = LinkedHashMultimap.create( );
public void register( final I_TrapBlock block )
public MTraps( )
{
// FIXME recipes to convert quicksand into sand or mud into dirt
this.QUICKSAND = this.register( new MQuicksand( "sand" , //
Blocks.SAND.getDefaultState( ) //
.withProperty( BlockSand.VARIANT , BlockSand.EnumType.SAND ) ) );
this.RED_QUICKSAND = this.register( new MQuicksand( "red_sand" , //
Blocks.SAND.getDefaultState( ) //
.withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) );
this.SWAMP_PIT = this.register( new MSwampPit( ) );
this.MUD = this.register( new MMud( ) );
}
public < T extends Block & I_TrapBlock > T register( final T block )
{
Block asMcBlock = (Block) block;
for ( final IBlockState state : block.getReplacedBlocks( ) ) {
this.traps.put( state , block );
this.trapTypes.put( state , block.getTrapType( ) );
this.replacements.put( state , ( (Block) block ).getDefaultState( ) );
this.replacements.put( state , asMcBlock.getDefaultState( ) );
}
CRegistry.addBlock( asMcBlock );
return block;
}
@ -57,5 +81,4 @@ public enum MTrapBlocks {
{
return Lists.newArrayList( this.trapTypes.get( blockState ) );
}
}

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import java.util.Arrays;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import mmm.core.CRegistry;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import mmm.core.CRegistry;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import java.util.Random;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import mmm.utils.UMaths;

View file

@ -1,4 +1,4 @@
package mmm.materials;
package mmm.materials.trees;
import net.minecraft.item.Item;

View file

@ -7,7 +7,7 @@ import java.util.Random;
import com.google.common.collect.Lists;
import mmm.materials.MTrapBlocks;
import mmm.MmmMaterials;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
@ -82,7 +82,7 @@ public class WGTrapBlocks
final BlockPos pos = bp.add( x , y , z );
final IBlockState atPos = worldIn.getBlockState( pos );
final List< String > trapTypes = MTrapBlocks.INSTANCE.getTrapTypes( atPos );
final List< String > trapTypes = MmmMaterials.TRAP.getTrapTypes( atPos );
for ( final String rep : trapTypes ) {
if ( !types.contains( rep ) ) {
types.add( rep );
@ -105,7 +105,7 @@ public class WGTrapBlocks
final BlockPos pos = bp.add( x , y , z );
final IBlockState atPos = worldIn.getBlockState( pos );
final List< IBlockState > replacements = MTrapBlocks.INSTANCE.getReplacements( atPos , trapType );
final List< IBlockState > replacements = MmmMaterials.TRAP.getReplacements( atPos , trapType );
final int nReplacements = replacements.size( );
if ( nReplacements == 0 ) {
continue;

View file

@ -3,8 +3,8 @@ package mmm.world.trees;
import java.util.Random;
import mmm.materials.MSapling;
import mmm.materials.MTree;
import mmm.materials.trees.MSapling;
import mmm.materials.trees.MTree;
import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockFlower;

View file

@ -4,7 +4,7 @@ package mmm.world.trees;
import java.util.Random;
import mmm.MmmMaterials;
import mmm.materials.MTree;
import mmm.materials.trees.MTree;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;

View file

@ -3,7 +3,7 @@ package mmm.world.trees;
import java.util.Random;
import mmm.materials.MLog;
import mmm.materials.trees.MLog;
import net.minecraft.block.BlockLog;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;

View file

@ -4,7 +4,7 @@ package mmm.world.trees;
import java.util.Random;
import mmm.MmmMaterials;
import mmm.materials.MTree;
import mmm.materials.trees.MTree;
import net.minecraft.block.BlockLeaves;
import net.minecraft.block.BlockLog;
import net.minecraft.block.state.IBlockState;