More refactoring
This commit is contained in:
parent
3d18adf7f4
commit
f44e8bd7b7
22 changed files with 53 additions and 64 deletions
|
@ -8,10 +8,10 @@ import mmm.materials.MItems;
|
||||||
import mmm.materials.MMetals;
|
import mmm.materials.MMetals;
|
||||||
import mmm.materials.MOres;
|
import mmm.materials.MOres;
|
||||||
import mmm.materials.MRocks;
|
import mmm.materials.MRocks;
|
||||||
import mmm.materials.MTraps;
|
|
||||||
import mmm.materials.MTrees;
|
|
||||||
import mmm.materials.MWoodAchievementHandler;
|
|
||||||
import mmm.materials.MWoods;
|
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.Block;
|
||||||
import net.minecraft.block.BlockStone;
|
import net.minecraft.block.BlockStone;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
|
|
@ -15,12 +15,10 @@ import mmm.core.api.I_RequiresClientPreInit;
|
||||||
import mmm.core.api.blocks.I_ColoredBlock;
|
import mmm.core.api.blocks.I_ColoredBlock;
|
||||||
import mmm.core.api.blocks.I_StateMapperProvider;
|
import mmm.core.api.blocks.I_StateMapperProvider;
|
||||||
import mmm.core.api.blocks.I_TintedBlock;
|
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_ItemModelProvider;
|
||||||
import mmm.core.api.items.I_ItemModelProviderBasic;
|
import mmm.core.api.items.I_ItemModelProviderBasic;
|
||||||
import mmm.core.api.items.I_ItemWithVariants;
|
import mmm.core.api.items.I_ItemWithVariants;
|
||||||
import mmm.core.api.items.I_TintedItem;
|
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;
|
||||||
|
@ -143,9 +141,6 @@ public class CRegistry
|
||||||
GameRegistry.register( block );
|
GameRegistry.register( block );
|
||||||
CRegistry.addRecipeRegistrar( block );
|
CRegistry.addRecipeRegistrar( block );
|
||||||
CRegistry.addOreGenerationRegistrar( block );
|
CRegistry.addOreGenerationRegistrar( block );
|
||||||
if ( block instanceof I_TrapBlock ) {
|
|
||||||
MTrapBlocks.INSTANCE.register( (I_TrapBlock) block );
|
|
||||||
}
|
|
||||||
if ( block instanceof I_RequiresClientPreInit ) {
|
if ( block instanceof I_RequiresClientPreInit ) {
|
||||||
CRegistry.BLOCKS_CLIENT_PREINIT.add( block );
|
CRegistry.BLOCKS_CLIENT_PREINIT.add( block );
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import mmm.MmmDeco;
|
||||||
import mmm.MmmMaterials;
|
import mmm.MmmMaterials;
|
||||||
import mmm.core.CRegistry;
|
import mmm.core.CRegistry;
|
||||||
import mmm.core.api.I_RecipeRegistrar;
|
import mmm.core.api.I_RecipeRegistrar;
|
||||||
import mmm.materials.MTree;
|
import mmm.materials.trees.MTree;
|
||||||
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;
|
||||||
|
|
|
@ -4,7 +4,7 @@ package mmm.deco.slabs;
|
||||||
import mmm.core.CRegistry;
|
import mmm.core.CRegistry;
|
||||||
import mmm.core.api.I_RecipeRegistrar;
|
import mmm.core.api.I_RecipeRegistrar;
|
||||||
import mmm.deco.DSmoothStone;
|
import mmm.deco.DSmoothStone;
|
||||||
import mmm.materials.MTree;
|
import mmm.materials.trees.MTree;
|
||||||
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;
|
||||||
|
|
|
@ -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( ) );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package mmm.materials;
|
||||||
|
|
||||||
|
|
||||||
import mmm.Mmm;
|
import mmm.Mmm;
|
||||||
|
import mmm.materials.trees.MTree;
|
||||||
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;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.traps;
|
||||||
|
|
||||||
|
|
||||||
import mmm.core.CRegistry;
|
import mmm.core.CRegistry;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.traps;
|
||||||
|
|
||||||
|
|
||||||
import mmm.core.CRegistry;
|
import mmm.core.CRegistry;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.traps;
|
||||||
|
|
||||||
|
|
||||||
import mmm.core.api.blocks.I_TintedBlock;
|
import mmm.core.api.blocks.I_TintedBlock;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.traps;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
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.LinkedHashMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import mmm.core.CRegistry;
|
||||||
import mmm.core.api.blocks.I_TrapBlock;
|
import mmm.core.api.blocks.I_TrapBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockSand;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum MTrapBlocks {
|
public class MTraps
|
||||||
INSTANCE;
|
{
|
||||||
|
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 , 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_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( ) ) {
|
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 , asMcBlock.getDefaultState( ) );
|
||||||
}
|
}
|
||||||
|
CRegistry.addBlock( asMcBlock );
|
||||||
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,5 +81,4 @@ public enum MTrapBlocks {
|
||||||
{
|
{
|
||||||
return Lists.newArrayList( this.trapTypes.get( blockState ) );
|
return Lists.newArrayList( this.trapTypes.get( blockState ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import mmm.core.CRegistry;
|
import mmm.core.CRegistry;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import mmm.core.CRegistry;
|
import mmm.core.CRegistry;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import mmm.utils.UMaths;
|
import mmm.utils.UMaths;
|
|
@ -1,4 +1,4 @@
|
||||||
package mmm.materials;
|
package mmm.materials.trees;
|
||||||
|
|
||||||
|
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
|
@ -7,7 +7,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import mmm.materials.MTrapBlocks;
|
import mmm.MmmMaterials;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -82,7 +82,7 @@ public class WGTrapBlocks
|
||||||
|
|
||||||
final BlockPos pos = bp.add( x , y , z );
|
final BlockPos pos = bp.add( x , y , z );
|
||||||
final IBlockState atPos = worldIn.getBlockState( pos );
|
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 ) {
|
for ( final String rep : trapTypes ) {
|
||||||
if ( !types.contains( rep ) ) {
|
if ( !types.contains( rep ) ) {
|
||||||
types.add( rep );
|
types.add( rep );
|
||||||
|
@ -105,7 +105,7 @@ public class WGTrapBlocks
|
||||||
|
|
||||||
final BlockPos pos = bp.add( x , y , z );
|
final BlockPos pos = bp.add( x , y , z );
|
||||||
final IBlockState atPos = worldIn.getBlockState( pos );
|
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( );
|
final int nReplacements = replacements.size( );
|
||||||
if ( nReplacements == 0 ) {
|
if ( nReplacements == 0 ) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -3,8 +3,8 @@ package mmm.world.trees;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mmm.materials.MSapling;
|
import mmm.materials.trees.MSapling;
|
||||||
import mmm.materials.MTree;
|
import mmm.materials.trees.MTree;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockBush;
|
import net.minecraft.block.BlockBush;
|
||||||
import net.minecraft.block.BlockFlower;
|
import net.minecraft.block.BlockFlower;
|
||||||
|
|
|
@ -4,7 +4,7 @@ package mmm.world.trees;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mmm.MmmMaterials;
|
import mmm.MmmMaterials;
|
||||||
import mmm.materials.MTree;
|
import mmm.materials.trees.MTree;
|
||||||
import net.minecraft.block.BlockLeaves;
|
import net.minecraft.block.BlockLeaves;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
|
@ -3,7 +3,7 @@ package mmm.world.trees;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mmm.materials.MLog;
|
import mmm.materials.trees.MLog;
|
||||||
import net.minecraft.block.BlockLog;
|
import net.minecraft.block.BlockLog;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
|
@ -4,7 +4,7 @@ package mmm.world.trees;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import mmm.MmmMaterials;
|
import mmm.MmmMaterials;
|
||||||
import mmm.materials.MTree;
|
import mmm.materials.trees.MTree;
|
||||||
import net.minecraft.block.BlockLeaves;
|
import net.minecraft.block.BlockLeaves;
|
||||||
import net.minecraft.block.BlockLog;
|
import net.minecraft.block.BlockLog;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
|
Reference in a new issue