From 75abf8b9d3fc54801d8184ede5674bb326cc20d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Tue, 12 Jul 2016 14:49:11 +0200 Subject: [PATCH] REFACTOR ALL THE THINGS! --- src/java/mmm/Mmm.java | 8 +- src/java/mmm/MmmDeco.java | 45 +++ src/java/mmm/MmmFood.java | 22 ++ .../Materials.java => MmmMaterials.java} | 34 +- src/java/mmm/MmmTech.java | 31 ++ src/java/mmm/MmmWorld.java | 45 +++ .../UAccessors.java => core/CAccessors.java} | 14 +- .../gui/GUIUtils.java => core/CGui.java} | 49 +-- .../UNetwork.java => core/CNetwork.java} | 33 +- .../PClient.java => core/CProxyClient.java} | 13 +- src/java/mmm/core/CProxyCommon.java | 37 ++ .../URegistry.java => core/CRegistry.java} | 113 +++--- .../api/I_Message.java} | 4 +- .../api/I_OreGenerationRegistrar.java} | 4 +- src/java/mmm/core/api/I_RecipeRegistrar.java | 9 + .../mmm/core/api/I_RequiresClientInit.java | 7 + .../mmm/core/api/I_RequiresClientPreInit.java | 7 + .../mmm/core/api/blocks/I_ColoredBlock.java | 7 + src/java/mmm/core/api/blocks/I_SeatBlock.java | 7 + .../api/blocks/I_StateMapperProvider.java} | 7 +- .../api/blocks/I_SupportBlock.java} | 8 +- .../api/blocks/I_TintedBlock.java} | 7 +- .../api/blocks/I_TrapBlock.java} | 4 +- .../core/api/items/I_ItemModelProvider.java | 14 + .../api/items/I_ItemModelProviderBasic.java} | 6 +- .../api/items/I_ItemWithVariants.java} | 6 +- .../api/items/I_TintedItem.java} | 7 +- .../mmm/core/api/tech/E_ActivationMode.java | 24 ++ .../api/tech/I_ConfigurableActivation.java | 12 + .../api/world/I_BiomeWithOres.java} | 4 +- .../api/world/I_DefaultPopulateHandler.java} | 9 +- .../api/world/I_LocationCheck.java} | 22 +- .../mmm/core/api/world/I_TrappedBiome.java | 7 + src/java/mmm/deco/DChair.java | 230 ------------- src/java/mmm/deco/DChairs.java | 259 ++++++++++++++ src/java/mmm/deco/DFence.java | 20 -- src/java/mmm/deco/DFences.java | 16 - .../USeat.java => deco/DSeatEntity.java} | 21 +- src/java/mmm/deco/DStairs.java | 109 +++--- src/java/mmm/deco/DTable.java | 291 ---------------- src/java/mmm/deco/DTables.java | 321 ++++++++++++++++++ src/java/mmm/deco/DecorativeBlocks.java | 111 ------ src/java/mmm/deco/fences/DFence.java | 21 ++ .../mmm/deco/{ => fences}/DFenceBlock.java | 15 +- .../mmm/deco/{ => fences}/DFenceGate.java | 19 +- src/java/mmm/deco/fences/DFences.java | 20 ++ .../mmm/deco/{ => slabs}/A_DSlabBlock.java | 12 +- .../mmm/deco/{ => slabs}/DSlabDouble.java | 2 +- src/java/mmm/deco/{ => slabs}/DSlabHalf.java | 2 +- .../{DSlab.java => slabs/DSlabParts.java} | 30 +- src/java/mmm/deco/slabs/DSlabs.java | 26 ++ src/java/mmm/deco/{ => thrones}/DThrone.java | 13 +- .../mmm/deco/{ => thrones}/DThroneBlock.java | 38 ++- src/java/mmm/deco/thrones/DThrones.java | 31 ++ src/java/mmm/food/FMilkBucket.java | 8 +- src/java/mmm/food/FMilkType.java | 47 +-- src/java/mmm/food/FMilkable.java | 27 +- src/java/mmm/food/FMilks.java | 57 ++++ src/java/mmm/food/Food.java | 17 - src/java/mmm/materials/MAlloyRecipe.java | 2 +- src/java/mmm/materials/MAlloys.java | 45 +-- src/java/mmm/materials/MItems.java | 39 +-- src/java/mmm/materials/MLeaves.java | 10 +- src/java/mmm/materials/MLog.java | 4 +- src/java/mmm/materials/MMetal.java | 16 +- src/java/mmm/materials/MMetalBlock.java | 4 +- src/java/mmm/materials/MMetalItem.java | 4 +- src/java/mmm/materials/MMetals.java | 12 +- src/java/mmm/materials/MMud.java | 8 +- src/java/mmm/materials/MOre.java | 10 +- src/java/mmm/materials/MOres.java | 59 ++-- src/java/mmm/materials/MPlanks.java | 4 +- src/java/mmm/materials/MQuicksand.java | 16 +- src/java/mmm/materials/MRock.java | 6 +- src/java/mmm/materials/MRocks.java | 23 +- src/java/mmm/materials/MSapling.java | 4 +- src/java/mmm/materials/MSwampPit.java | 10 +- .../MTrapBlocks.java} | 19 +- src/java/mmm/materials/MTraps.java | 12 +- src/java/mmm/materials/MTree.java | 22 +- src/java/mmm/materials/MTrees.java | 4 +- .../DWoodType.java => materials/MWood.java} | 24 +- src/java/mmm/materials/MWoods.java | 35 ++ src/java/mmm/proxy/PCommon.java | 40 --- src/java/mmm/proxy/PServer.java | 8 - src/java/mmm/tech/TActivationModeMessage.java | 69 ++++ src/java/mmm/tech/Tech.java | 22 -- .../mmm/tech/base/E_TBActivationMode.java | 24 -- .../tech/base/I_TBConfigurableActivation.java | 12 - .../tech/base/TBActivationModeMessage.java | 67 ---- src/java/mmm/tech/base/TBMachines.java | 24 ++ src/java/mmm/tech/base/TechBase.java | 24 -- .../tech/base/alloy_furnace/TBAFBlock.java | 23 +- .../base/alloy_furnace/TBAFContainer.java | 20 +- .../mmm/tech/base/alloy_furnace/TBAFGui.java | 6 +- .../tech/base/alloy_furnace/TBAFMessage.java | 4 +- .../base/alloy_furnace/TBAFTileEntity.java | 28 +- ...{AlloyFurnace.java => TBAlloyFurnace.java} | 25 +- src/java/mmm/tech/tools/TTArmor.java | 8 +- src/java/mmm/tech/tools/TTArmorSet.java | 10 +- src/java/mmm/tech/tools/TTArmors.java | 32 ++ src/java/mmm/tech/tools/TTAxe.java | 8 +- src/java/mmm/tech/tools/TTHoe.java | 8 +- src/java/mmm/tech/tools/TTPickaxe.java | 8 +- src/java/mmm/tech/tools/TTShovel.java | 8 +- src/java/mmm/tech/tools/TTSword.java | 8 +- src/java/mmm/tech/tools/TTToolSet.java | 16 +- src/java/mmm/tech/tools/TTTools.java | 24 ++ src/java/mmm/tech/tools/TechTools.java | 44 --- src/java/mmm/utils/I_UBlockSeat.java | 7 - src/java/mmm/utils/I_UColoredBlock.java | 7 - src/java/mmm/utils/I_UItemModelProvider.java | 10 - src/java/mmm/utils/I_URecipeRegistrar.java | 9 - src/java/mmm/utils/I_URequiresClientInit.java | 7 - .../mmm/utils/I_URequiresClientPreInit.java | 7 - .../mmm/utils/UBlockItemWithVariants.java | 6 +- src/java/mmm/utils/UInventoryDisplay.java | 8 +- .../utils/gui/A_UGTabbedContainerScreen.java | 42 +-- src/java/mmm/utils/gui/UGArrowButton.java | 8 +- src/java/mmm/utils/gui/UGui.java | 29 ++ src/java/mmm/world/WDefaultGenWatcher.java | 11 +- src/java/mmm/world/WLocation.java | 15 +- ...nBiome.java => WLocationInBiomeClass.java} | 7 +- src/java/mmm/world/WLocationInDimension.java | 3 +- src/java/mmm/world/World.java | 124 ------- src/java/mmm/world/biome/A_WBLimestone.java | 15 +- .../mmm/world/biome/I_WBTrappedBiome.java | 7 - src/java/mmm/world/biome/WBBambooForest.java | 9 +- .../WBBuilder.java} | 38 +-- .../mmm/world/biome/WBLimestoneMountains.java | 8 +- .../mmm/world/biome/WBLimestonePlateau.java | 3 +- .../mmm/world/biome/WBTropicalForest.java | 9 +- src/java/mmm/world/biome/WBTropicalSwamp.java | 12 +- src/java/mmm/world/biome/WBiomes.java | 261 ++++++++++++++ src/java/mmm/world/gen/WGBambooPatch.java | 8 +- src/java/mmm/world/gen/WGBasalt.java | 6 +- src/java/mmm/world/gen/WGLimestoneChaos.java | 4 +- src/java/mmm/world/gen/WGLimestoneLayer.java | 4 +- src/java/mmm/world/gen/WGOre.java | 6 +- src/java/mmm/world/gen/WGOreCondition.java | 9 +- src/java/mmm/world/gen/WGTrapBlocks.java | 18 +- src/java/mmm/world/trees/WTBamboo.java | 6 +- src/java/mmm/world/trees/WTHevea.java | 4 +- src/java/mmm/world/trees/WTHeveaMega.java | 4 +- 144 files changed, 2223 insertions(+), 1859 deletions(-) create mode 100644 src/java/mmm/MmmDeco.java create mode 100644 src/java/mmm/MmmFood.java rename src/java/mmm/{materials/Materials.java => MmmMaterials.java} (71%) create mode 100644 src/java/mmm/MmmTech.java create mode 100644 src/java/mmm/MmmWorld.java rename src/java/mmm/{utils/UAccessors.java => core/CAccessors.java} (80%) rename src/java/mmm/{utils/gui/GUIUtils.java => core/CGui.java} (75%) rename src/java/mmm/{utils/UNetwork.java => core/CNetwork.java} (53%) rename src/java/mmm/{proxy/PClient.java => core/CProxyClient.java} (60%) create mode 100644 src/java/mmm/core/CProxyCommon.java rename src/java/mmm/{utils/URegistry.java => core/CRegistry.java} (59%) rename src/java/mmm/{utils/I_UMessage.java => core/api/I_Message.java} (90%) rename src/java/mmm/{utils/I_UOreGenerationRegistrar.java => core/api/I_OreGenerationRegistrar.java} (68%) create mode 100644 src/java/mmm/core/api/I_RecipeRegistrar.java create mode 100644 src/java/mmm/core/api/I_RequiresClientInit.java create mode 100644 src/java/mmm/core/api/I_RequiresClientPreInit.java create mode 100644 src/java/mmm/core/api/blocks/I_ColoredBlock.java create mode 100644 src/java/mmm/core/api/blocks/I_SeatBlock.java rename src/java/mmm/{utils/I_UStateMapperProvider.java => core/api/blocks/I_StateMapperProvider.java} (61%) rename src/java/mmm/{utils/I_USupportBlock.java => core/api/blocks/I_SupportBlock.java} (84%) rename src/java/mmm/{utils/I_UTintedBlock.java => core/api/blocks/I_TintedBlock.java} (67%) rename src/java/mmm/{utils/I_UTrapBlock.java => core/api/blocks/I_TrapBlock.java} (69%) create mode 100644 src/java/mmm/core/api/items/I_ItemModelProvider.java rename src/java/mmm/{utils/I_UItemModelProviderBasic.java => core/api/items/I_ItemModelProviderBasic.java} (72%) rename src/java/mmm/{utils/I_UItemWithVariants.java => core/api/items/I_ItemWithVariants.java} (76%) rename src/java/mmm/{utils/I_UTintedItem.java => core/api/items/I_TintedItem.java} (72%) create mode 100644 src/java/mmm/core/api/tech/E_ActivationMode.java create mode 100644 src/java/mmm/core/api/tech/I_ConfigurableActivation.java rename src/java/mmm/{world/I_WBiomeWithOres.java => core/api/world/I_BiomeWithOres.java} (70%) rename src/java/mmm/{world/I_WDefaultPopulateHandler.java => core/api/world/I_DefaultPopulateHandler.java} (65%) rename src/java/mmm/{world/I_WLocationCheck.java => core/api/world/I_LocationCheck.java} (70%) create mode 100644 src/java/mmm/core/api/world/I_TrappedBiome.java delete mode 100644 src/java/mmm/deco/DChair.java create mode 100644 src/java/mmm/deco/DChairs.java delete mode 100644 src/java/mmm/deco/DFence.java delete mode 100644 src/java/mmm/deco/DFences.java rename src/java/mmm/{utils/USeat.java => deco/DSeatEntity.java} (83%) delete mode 100644 src/java/mmm/deco/DTable.java create mode 100644 src/java/mmm/deco/DTables.java delete mode 100644 src/java/mmm/deco/DecorativeBlocks.java create mode 100644 src/java/mmm/deco/fences/DFence.java rename src/java/mmm/deco/{ => fences}/DFenceBlock.java (72%) rename src/java/mmm/deco/{ => fences}/DFenceGate.java (72%) create mode 100644 src/java/mmm/deco/fences/DFences.java rename src/java/mmm/deco/{ => slabs}/A_DSlabBlock.java (91%) rename src/java/mmm/deco/{ => slabs}/DSlabDouble.java (97%) rename src/java/mmm/deco/{ => slabs}/DSlabHalf.java (91%) rename src/java/mmm/deco/{DSlab.java => slabs/DSlabParts.java} (65%) create mode 100644 src/java/mmm/deco/slabs/DSlabs.java rename src/java/mmm/deco/{ => thrones}/DThrone.java (55%) rename src/java/mmm/deco/{ => thrones}/DThroneBlock.java (91%) create mode 100644 src/java/mmm/deco/thrones/DThrones.java create mode 100644 src/java/mmm/food/FMilks.java delete mode 100644 src/java/mmm/food/Food.java rename src/java/mmm/{utils/UTrapBlocks.java => materials/MTrapBlocks.java} (70%) rename src/java/mmm/{deco/DWoodType.java => materials/MWood.java} (67%) create mode 100644 src/java/mmm/materials/MWoods.java delete mode 100644 src/java/mmm/proxy/PCommon.java delete mode 100644 src/java/mmm/proxy/PServer.java create mode 100644 src/java/mmm/tech/TActivationModeMessage.java delete mode 100644 src/java/mmm/tech/Tech.java delete mode 100644 src/java/mmm/tech/base/E_TBActivationMode.java delete mode 100644 src/java/mmm/tech/base/I_TBConfigurableActivation.java delete mode 100644 src/java/mmm/tech/base/TBActivationModeMessage.java create mode 100644 src/java/mmm/tech/base/TBMachines.java delete mode 100644 src/java/mmm/tech/base/TechBase.java rename src/java/mmm/tech/base/alloy_furnace/{AlloyFurnace.java => TBAlloyFurnace.java} (64%) create mode 100644 src/java/mmm/tech/tools/TTArmors.java create mode 100644 src/java/mmm/tech/tools/TTTools.java delete mode 100644 src/java/mmm/tech/tools/TechTools.java delete mode 100644 src/java/mmm/utils/I_UBlockSeat.java delete mode 100644 src/java/mmm/utils/I_UColoredBlock.java delete mode 100644 src/java/mmm/utils/I_UItemModelProvider.java delete mode 100644 src/java/mmm/utils/I_URecipeRegistrar.java delete mode 100644 src/java/mmm/utils/I_URequiresClientInit.java delete mode 100644 src/java/mmm/utils/I_URequiresClientPreInit.java create mode 100644 src/java/mmm/utils/gui/UGui.java rename src/java/mmm/world/{WLocationInBiome.java => WLocationInBiomeClass.java} (75%) delete mode 100644 src/java/mmm/world/World.java delete mode 100644 src/java/mmm/world/biome/I_WBTrappedBiome.java rename src/java/mmm/world/{WBiomeHelper.java => biome/WBBuilder.java} (77%) create mode 100644 src/java/mmm/world/biome/WBiomes.java diff --git a/src/java/mmm/Mmm.java b/src/java/mmm/Mmm.java index 0b98cb9..b9431a8 100644 --- a/src/java/mmm/Mmm.java +++ b/src/java/mmm/Mmm.java @@ -1,7 +1,7 @@ package mmm; -import mmm.proxy.PCommon; +import mmm.core.CProxyCommon; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -15,14 +15,14 @@ public class Mmm public static final String ID = "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 + "."; @Mod.Instance( Mmm.ID ) private static Mmm instance; - @SidedProxy( clientSide = "mmm.proxy.PClient" , serverSide = "mmm.proxy.PServer" ) - private static PCommon proxy = null; + @SidedProxy( clientSide = "mmm.core.CProxyClient" , serverSide = "mmm.core.CProxyCommon" ) + private static CProxyCommon proxy = null; public static Mmm get( ) diff --git a/src/java/mmm/MmmDeco.java b/src/java/mmm/MmmDeco.java new file mode 100644 index 0000000..34edcbb --- /dev/null +++ b/src/java/mmm/MmmDeco.java @@ -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 ); + } + +} diff --git a/src/java/mmm/MmmFood.java b/src/java/mmm/MmmFood.java new file mode 100644 index 0000000..60675b3 --- /dev/null +++ b/src/java/mmm/MmmFood.java @@ -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 + } + +} diff --git a/src/java/mmm/materials/Materials.java b/src/java/mmm/MmmMaterials.java similarity index 71% rename from src/java/mmm/materials/Materials.java rename to src/java/mmm/MmmMaterials.java index 67999c1..155f6ff 100644 --- a/src/java/mmm/materials/Materials.java +++ b/src/java/mmm/MmmMaterials.java @@ -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.BlockStone; 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 MMetals METAL; public static final MAlloys ALLOY; public static final MTrees TREE; + public static final MWoods WOOD; public static final MItems ITEM; public static final MOres ORE; public static final MTraps TRAP; @@ -27,6 +38,7 @@ public class Materials METAL = new MMetals( ); ALLOY = new MAlloys( ); TREE = new MTrees( ); + WOOD = new MWoods( ); ITEM = new MItems( ); ORE = new MOres( ); TRAP = new MTraps( ); @@ -37,8 +49,8 @@ public class Materials public static Item makeFuel( final String name , final int burnTime ) { - final Item fuel = Materials.makeItem( name ); - URegistry.setFuel( fuel , burnTime ); + final Item fuel = MmmMaterials.makeItem( name ); + CRegistry.setFuel( fuel , burnTime ); return fuel; } @@ -46,19 +58,13 @@ public class Materials public static Item makeItem( final String name ) { final Item stone = new Item( ); - URegistry.setIdentifiers( stone , "materials" , "stone" , name ); + CRegistry.setIdentifiers( stone , "materials" , "stone" , name ); stone.setCreativeTab( CreativeTabs.MATERIALS ); - URegistry.addItem( stone ); + CRegistry.addItem( stone ); return stone; } - public static void preInit( ) - { - // EMPTY - } - - public static boolean isRock( final IBlockState bs ) { final Block block = bs.getBlock( ); @@ -74,7 +80,7 @@ public class Materials } - private Materials( ) + public static void preInit( ) { // EMPTY } diff --git a/src/java/mmm/MmmTech.java b/src/java/mmm/MmmTech.java new file mode 100644 index 0000000..3980e1f --- /dev/null +++ b/src/java/mmm/MmmTech.java @@ -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 + } + +} diff --git a/src/java/mmm/MmmWorld.java b/src/java/mmm/MmmWorld.java new file mode 100644 index 0000000..8b9dbb5 --- /dev/null +++ b/src/java/mmm/MmmWorld.java @@ -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 ); + } + +} diff --git a/src/java/mmm/utils/UAccessors.java b/src/java/mmm/core/CAccessors.java similarity index 80% rename from src/java/mmm/utils/UAccessors.java rename to src/java/mmm/core/CAccessors.java index 4bc8278..e3e58c0 100644 --- a/src/java/mmm/utils/UAccessors.java +++ b/src/java/mmm/core/CAccessors.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core; import java.lang.invoke.MethodHandle; @@ -11,14 +11,14 @@ import net.minecraft.launchwrapper.Launch; /** Accessors for various Minecraft fields */ -public class UAccessors +public class CAccessors { private static final boolean isDeobfuscated; 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; try { f = cls.getDeclaredField( fn ); @@ -40,8 +40,8 @@ public class UAccessors static { isDeobfuscated = (Boolean) Launch.blackboard.get( "fml.deobfuscatedEnvironment" ); - fg_Block_blockHardness = UAccessors.createGetter( Block.class , "blockHardness" , "field_149782_v" ); - fg_Block_blockResistance = UAccessors.createGetter( Block.class , "blockResistance" , "field_149781_w" ); + fg_Block_blockHardness = CAccessors.createGetter( Block.class , "blockHardness" , "field_149782_v" ); + 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 ) 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 ) throws Throwable { - return (float) UAccessors.fg_Block_blockResistance.invokeExact( block ); + return (float) CAccessors.fg_Block_blockResistance.invokeExact( block ); } } diff --git a/src/java/mmm/utils/gui/GUIUtils.java b/src/java/mmm/core/CGui.java similarity index 75% rename from src/java/mmm/utils/gui/GUIUtils.java rename to src/java/mmm/core/CGui.java index 2cff43c..ceace77 100644 --- a/src/java/mmm/utils/gui/GUIUtils.java +++ b/src/java/mmm/core/CGui.java @@ -1,13 +1,10 @@ -package mmm.utils.gui; +package mmm.core; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.HashMap; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import com.google.common.collect.Maps; import mmm.Mmm; @@ -15,7 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; @@ -27,44 +23,27 @@ import net.minecraftforge.fml.relauncher.SideOnly; -public enum GUIUtils - 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; - +public class CGui + implements IGuiHandler +{ private static final HashMap< Class< ? extends TileEntity > , Constructor< ? > > SERVER_SIDE // = Maps.newHashMap( ); private static final HashMap< Class< ? extends TileEntity > , Constructor< ? > > CLIENT_SIDE // = Maps.newHashMap( ); - static final Logger LOGGER = LogManager.getLogger( ); - - public static final ResourceLocation GUI_TEXTURE = new ResourceLocation( "mmm" , "textures/gui/gui-common.png" ); + static { + new CGui( ); + } public static void registerTileEntityGUI( final Class< ? extends TileEntity > teClass , 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 ); } - GUIUtils.addTileEntityConstructor( GUIUtils.SERVER_SIDE , teClass , Container.class , containerClassName , + CGui.addTileEntityConstructor( CGui.SERVER_SIDE , teClass , Container.class , containerClassName , "container" ); if ( FMLLaunchHandler.side( ) == Side.CLIENT ) { String clsName = "net.minecraft.client.gui.inventory.GuiContainer"; @@ -77,7 +56,7 @@ public enum GUIUtils } catch ( final ClassNotFoundException 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 ) ) { 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 ); } @@ -132,7 +111,7 @@ public enum GUIUtils final int y , final int z ) { 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; } @@ -144,7 +123,7 @@ public enum GUIUtils final int y , final int z ) { 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; } diff --git a/src/java/mmm/utils/UNetwork.java b/src/java/mmm/core/CNetwork.java similarity index 53% rename from src/java/mmm/utils/UNetwork.java rename to src/java/mmm/core/CNetwork.java index a99f037..fd357c1 100644 --- a/src/java/mmm/utils/UNetwork.java +++ b/src/java/mmm/core/CNetwork.java @@ -1,7 +1,8 @@ -package mmm.utils; +package mmm.core; import mmm.Mmm; +import mmm.core.api.I_Message; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayerMP; 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 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( // - ( final I_UMessage m , final MessageContext ctx ) -> { + CNetwork.NET.registerMessage( // + ( final I_Message m , final MessageContext ctx ) -> { final IThreadListener main = Minecraft.getMinecraft( ); main.addScheduledTask( ( ) -> m.handleOnClient( Minecraft.getMinecraft( ).thePlayer ) ); 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( // - ( final I_UMessage m , final MessageContext ctx ) -> { + CNetwork.NET.registerMessage( // + ( final I_Message m , final MessageContext ctx ) -> { final IThreadListener main = (WorldServer) ctx.getServerHandler( ).playerEntity.worldObj; main.addScheduledTask( ( ) -> m.handleOnServer( ctx.getServerHandler( ).playerEntity ) ); 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 ); } } diff --git a/src/java/mmm/proxy/PClient.java b/src/java/mmm/core/CProxyClient.java similarity index 60% rename from src/java/mmm/proxy/PClient.java rename to src/java/mmm/core/CProxyClient.java index 47364ed..0c4ad68 100644 --- a/src/java/mmm/proxy/PClient.java +++ b/src/java/mmm/core/CProxyClient.java @@ -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.FMLPreInitializationEvent; -public class PClient - extends PCommon +public class CProxyClient + extends CProxyCommon { @Override public void preInit( final FMLPreInitializationEvent event ) { super.preInit( event ); - URegistry.preInitClient( ); + CRegistry.preInitClient( ); } @Override - public void init( FMLInitializationEvent event ) + public void init( final FMLInitializationEvent event ) { super.init( event ); - URegistry.initClient( ); + CRegistry.initClient( ); } } \ No newline at end of file diff --git a/src/java/mmm/core/CProxyCommon.java b/src/java/mmm/core/CProxyCommon.java new file mode 100644 index 0000000..c1a80dc --- /dev/null +++ b/src/java/mmm/core/CProxyCommon.java @@ -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( ); + } + +} \ No newline at end of file diff --git a/src/java/mmm/utils/URegistry.java b/src/java/mmm/core/CRegistry.java similarity index 59% rename from src/java/mmm/utils/URegistry.java rename to src/java/mmm/core/CRegistry.java index e38fdbb..00013c5 100644 --- a/src/java/mmm/utils/URegistry.java +++ b/src/java/mmm/core/CRegistry.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core; import java.util.ArrayList; @@ -8,6 +8,19 @@ import java.util.HashMap; import java.util.HashSet; 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.client.Minecraft; 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 @@ -39,7 +52,7 @@ public class URegistry public int getBurnTime( final ItemStack fuel ) { final Item item = fuel.getItem( ); - final Object fuelInfo = URegistry.FUELS.get( item ); + final Object fuelInfo = CRegistry.FUELS.get( item ); if ( fuelInfo != null ) { if ( item.getHasSubtypes( ) ) { 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_UOreGenerationRegistrar > ORE_GEN_REGISTRARS = new HashSet<>( ); + private static final HashSet< I_RecipeRegistrar > RECIPE_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< Block > BLOCKS = new HashSet< Block >( ); @@ -64,7 +77,7 @@ public class URegistry private static final FuelHandler FUEL_HANDLER = new FuelHandler( ); 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 ) { - if ( URegistry.ITEMS.add( item ) ) { + if ( CRegistry.ITEMS.add( item ) ) { GameRegistry.register( item ); - URegistry.addRecipeRegistrar( item ); - if ( item instanceof I_URequiresClientInit ) { - URegistry.ITEMS_CLIENT_INIT.add( item ); + CRegistry.addRecipeRegistrar( item ); + if ( item instanceof I_RequiresClientInit ) { + CRegistry.ITEMS_CLIENT_INIT.add( item ); } } } @@ -114,34 +127,34 @@ public class URegistry public static Item addBlock( final Block block ) { Item item; - if ( block instanceof I_UColoredBlock ) { + if ( block instanceof I_ColoredBlock ) { item = new ItemCloth( block ); } else { item = new ItemBlock( block ); } item.setRegistryName( block.getRegistryName( ) ); - return URegistry.addBlock( block , item ); + return CRegistry.addBlock( block , item ); } public static Item addBlock( final Block block , final Item blockItem ) { - if ( URegistry.BLOCKS.add( block ) ) { + if ( CRegistry.BLOCKS.add( block ) ) { GameRegistry.register( block ); - URegistry.addRecipeRegistrar( block ); - URegistry.addOreGenerationRegistrar( block ); - if ( block instanceof I_UTrapBlock ) { - UTrapBlocks.INSTANCE.register( (I_UTrapBlock) block ); + CRegistry.addRecipeRegistrar( block ); + CRegistry.addOreGenerationRegistrar( block ); + if ( block instanceof I_TrapBlock ) { + MTrapBlocks.INSTANCE.register( (I_TrapBlock) block ); } - if ( block instanceof I_URequiresClientPreInit ) { - URegistry.BLOCKS_CLIENT_PREINIT.add( block ); + if ( block instanceof I_RequiresClientPreInit ) { + CRegistry.BLOCKS_CLIENT_PREINIT.add( block ); } - if ( block instanceof I_URequiresClientInit ) { - URegistry.BLOCKS_CLIENT_INIT.add( block ); + if ( block instanceof I_RequiresClientInit ) { + CRegistry.BLOCKS_CLIENT_INIT.add( block ); } if ( blockItem != null ) { - URegistry.addItem( blockItem ); + CRegistry.addItem( blockItem ); } } return blockItem; @@ -158,7 +171,7 @@ public class URegistry } else { 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" ); } - Object obj = URegistry.FUELS.get( item ); + Object obj = CRegistry.FUELS.get( item ); if ( obj == null ) { obj = new int[ 16 ]; - URegistry.FUELS.put( item , obj ); + CRegistry.FUELS.put( item , obj ); } ( (int[]) obj )[ meta ] = value; @@ -180,29 +193,29 @@ public class URegistry public static void addRecipeRegistrar( final Object object ) { - if ( object instanceof I_URecipeRegistrar ) { - URegistry.RECIPE_REGISTRARS.add( (I_URecipeRegistrar) object ); + if ( object instanceof I_RecipeRegistrar ) { + CRegistry.RECIPE_REGISTRARS.add( (I_RecipeRegistrar) object ); } } public static void addOreGenerationRegistrar( final Object object ) { - if ( object instanceof I_UOreGenerationRegistrar ) { - URegistry.ORE_GEN_REGISTRARS.add( (I_UOreGenerationRegistrar) object ); + if ( object instanceof I_OreGenerationRegistrar ) { + 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( ) { - for ( final I_URecipeRegistrar registrar : URegistry.RECIPE_REGISTRARS ) { + for ( final I_RecipeRegistrar registrar : CRegistry.RECIPE_REGISTRARS ) { registrar.registerRecipes( ); } } @@ -211,33 +224,33 @@ public class URegistry @SideOnly( Side.CLIENT ) public static void preInitClient( ) { - for ( final Item item : URegistry.ITEMS ) { + for ( final Item item : CRegistry.ITEMS ) { // 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( ) , "inventory" ); ModelLoader.setCustomModelResourceLocation( item , 0 , location ); } - if ( ! ( item instanceof I_URequiresClientPreInit ) ) { + if ( ! ( item instanceof I_RequiresClientPreInit ) ) { continue; } // Item models - if ( item instanceof I_UItemModelProviderBasic ) { + if ( item instanceof I_ItemModelProviderBasic ) { ModelLoader.setCustomModelResourceLocation( item , 0 , - ( (I_UItemModelProviderBasic) item ).getModelResourceLocation( ) ); - } else if ( item instanceof I_UItemWithVariants ) { - final I_UItemWithVariants iwv = (I_UItemWithVariants) item; + ( (I_ItemModelProviderBasic) item ).getModelResourceLocation( ) ); + } else if ( item instanceof I_ItemWithVariants ) { + final I_ItemWithVariants iwv = (I_ItemWithVariants) item; for ( int i = 0 ; i < iwv.getVariantsCount( ) ; i++ ) { ModelLoader.setCustomModelResourceLocation( item , i , iwv.getModelResourceLocation( i ) ); } } } - for ( final Block block : URegistry.BLOCKS_CLIENT_PREINIT ) { - if ( block instanceof I_UStateMapperProvider ) { - ModelLoader.setCustomStateMapper( block , ( (I_UStateMapperProvider) block ).getStateMapper( ) ); + for ( final Block block : CRegistry.BLOCKS_CLIENT_PREINIT ) { + if ( block instanceof I_StateMapperProvider ) { + ModelLoader.setCustomStateMapper( block , ( (I_StateMapperProvider) block ).getStateMapper( ) ); } } } @@ -249,22 +262,22 @@ public class URegistry final BlockColors blockColors = Minecraft.getMinecraft( ).getBlockColors( ); 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 - if ( block instanceof I_UTintedBlock ) { - blockColors.registerBlockColorHandler( ( (I_UTintedBlock) block ).getBlockTint( ) , block ); + if ( block instanceof I_TintedBlock ) { + blockColors.registerBlockColorHandler( ( (I_TintedBlock) block ).getBlockTint( ) , block ); } // Register tinted block items - if ( block instanceof I_UTintedItem ) { - itemColors.registerItemColorHandler( ( (I_UTintedItem) block ).getItemTint( ) , block ); + if ( block instanceof I_TintedItem ) { + 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 - if ( item instanceof I_UTintedItem ) { - itemColors.registerItemColorHandler( ( (I_UTintedItem) item ).getItemTint( ) , item ); + if ( item instanceof I_TintedItem ) { + itemColors.registerItemColorHandler( ( (I_TintedItem) item ).getItemTint( ) , item ); } } } diff --git a/src/java/mmm/utils/I_UMessage.java b/src/java/mmm/core/api/I_Message.java similarity index 90% rename from src/java/mmm/utils/I_UMessage.java rename to src/java/mmm/core/api/I_Message.java index 8a51828..1030c52 100644 --- a/src/java/mmm/utils/I_UMessage.java +++ b/src/java/mmm/core/api/I_Message.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core.api; 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 { diff --git a/src/java/mmm/utils/I_UOreGenerationRegistrar.java b/src/java/mmm/core/api/I_OreGenerationRegistrar.java similarity index 68% rename from src/java/mmm/utils/I_UOreGenerationRegistrar.java rename to src/java/mmm/core/api/I_OreGenerationRegistrar.java index ce74d18..77bade7 100644 --- a/src/java/mmm/utils/I_UOreGenerationRegistrar.java +++ b/src/java/mmm/core/api/I_OreGenerationRegistrar.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core.api; 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 ); diff --git a/src/java/mmm/core/api/I_RecipeRegistrar.java b/src/java/mmm/core/api/I_RecipeRegistrar.java new file mode 100644 index 0000000..df3889f --- /dev/null +++ b/src/java/mmm/core/api/I_RecipeRegistrar.java @@ -0,0 +1,9 @@ +package mmm.core.api; + + +public interface I_RecipeRegistrar +{ + + public void registerRecipes( ); + +} diff --git a/src/java/mmm/core/api/I_RequiresClientInit.java b/src/java/mmm/core/api/I_RequiresClientInit.java new file mode 100644 index 0000000..986209b --- /dev/null +++ b/src/java/mmm/core/api/I_RequiresClientInit.java @@ -0,0 +1,7 @@ +package mmm.core.api; + + +public interface I_RequiresClientInit +{ + // EMPTY +} diff --git a/src/java/mmm/core/api/I_RequiresClientPreInit.java b/src/java/mmm/core/api/I_RequiresClientPreInit.java new file mode 100644 index 0000000..a3fc2b4 --- /dev/null +++ b/src/java/mmm/core/api/I_RequiresClientPreInit.java @@ -0,0 +1,7 @@ +package mmm.core.api; + + +public interface I_RequiresClientPreInit +{ + // EMPTY +} diff --git a/src/java/mmm/core/api/blocks/I_ColoredBlock.java b/src/java/mmm/core/api/blocks/I_ColoredBlock.java new file mode 100644 index 0000000..d4f00ad --- /dev/null +++ b/src/java/mmm/core/api/blocks/I_ColoredBlock.java @@ -0,0 +1,7 @@ +package mmm.core.api.blocks; + + +public interface I_ColoredBlock +{ + // EMPTY +} diff --git a/src/java/mmm/core/api/blocks/I_SeatBlock.java b/src/java/mmm/core/api/blocks/I_SeatBlock.java new file mode 100644 index 0000000..fb8f582 --- /dev/null +++ b/src/java/mmm/core/api/blocks/I_SeatBlock.java @@ -0,0 +1,7 @@ +package mmm.core.api.blocks; + + +public interface I_SeatBlock +{ + // EMPTY +} diff --git a/src/java/mmm/utils/I_UStateMapperProvider.java b/src/java/mmm/core/api/blocks/I_StateMapperProvider.java similarity index 61% rename from src/java/mmm/utils/I_UStateMapperProvider.java rename to src/java/mmm/core/api/blocks/I_StateMapperProvider.java index 10fa9b8..e6e4d13 100644 --- a/src/java/mmm/utils/I_UStateMapperProvider.java +++ b/src/java/mmm/core/api/blocks/I_StateMapperProvider.java @@ -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.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; -public interface I_UStateMapperProvider - extends I_URequiresClientPreInit +public interface I_StateMapperProvider + extends I_RequiresClientPreInit { @SideOnly( Side.CLIENT ) diff --git a/src/java/mmm/utils/I_USupportBlock.java b/src/java/mmm/core/api/blocks/I_SupportBlock.java similarity index 84% rename from src/java/mmm/utils/I_USupportBlock.java rename to src/java/mmm/core/api/blocks/I_SupportBlock.java index 000cbd8..8e94246 100644 --- a/src/java/mmm/utils/I_USupportBlock.java +++ b/src/java/mmm/core/api/blocks/I_SupportBlock.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core.api.blocks; 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 ) @@ -23,14 +23,14 @@ public interface I_USupportBlock } 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 , final Block block ) { - final boolean rv = !I_USupportBlock.check( worldIn , pos ); + final boolean rv = !I_SupportBlock.check( worldIn , pos ); if ( rv ) { block.dropBlockAsItem( worldIn , pos , state , 0 ); worldIn.setBlockToAir( pos ); diff --git a/src/java/mmm/utils/I_UTintedBlock.java b/src/java/mmm/core/api/blocks/I_TintedBlock.java similarity index 67% rename from src/java/mmm/utils/I_UTintedBlock.java rename to src/java/mmm/core/api/blocks/I_TintedBlock.java index 01788f7..46a8013 100644 --- a/src/java/mmm/utils/I_UTintedBlock.java +++ b/src/java/mmm/core/api/blocks/I_TintedBlock.java @@ -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.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -8,8 +9,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; /** For blocks that need to register a tint */ -public interface I_UTintedBlock - extends I_URequiresClientInit +public interface I_TintedBlock + extends I_RequiresClientInit { @SideOnly( Side.CLIENT ) diff --git a/src/java/mmm/utils/I_UTrapBlock.java b/src/java/mmm/core/api/blocks/I_TrapBlock.java similarity index 69% rename from src/java/mmm/utils/I_UTrapBlock.java rename to src/java/mmm/core/api/blocks/I_TrapBlock.java index d9e5064..c44d695 100644 --- a/src/java/mmm/utils/I_UTrapBlock.java +++ b/src/java/mmm/core/api/blocks/I_TrapBlock.java @@ -1,11 +1,11 @@ -package mmm.utils; +package mmm.core.api.blocks; import net.minecraft.block.state.IBlockState; -public interface I_UTrapBlock +public interface I_TrapBlock { public String getTrapType( ); diff --git a/src/java/mmm/core/api/items/I_ItemModelProvider.java b/src/java/mmm/core/api/items/I_ItemModelProvider.java new file mode 100644 index 0000000..8122112 --- /dev/null +++ b/src/java/mmm/core/api/items/I_ItemModelProvider.java @@ -0,0 +1,14 @@ +package mmm.core.api.items; + + +import mmm.core.api.I_RequiresClientPreInit; + + + +public interface I_ItemModelProvider + extends I_RequiresClientPreInit +{ + + // EMPTY + +} diff --git a/src/java/mmm/utils/I_UItemModelProviderBasic.java b/src/java/mmm/core/api/items/I_ItemModelProviderBasic.java similarity index 72% rename from src/java/mmm/utils/I_UItemModelProviderBasic.java rename to src/java/mmm/core/api/items/I_ItemModelProviderBasic.java index d911f5e..b3f6767 100644 --- a/src/java/mmm/utils/I_UItemModelProviderBasic.java +++ b/src/java/mmm/core/api/items/I_ItemModelProviderBasic.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core.api.items; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -7,8 +7,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; -public interface I_UItemModelProviderBasic - extends I_UItemModelProvider +public interface I_ItemModelProviderBasic + extends I_ItemModelProvider { @SideOnly( Side.CLIENT ) diff --git a/src/java/mmm/utils/I_UItemWithVariants.java b/src/java/mmm/core/api/items/I_ItemWithVariants.java similarity index 76% rename from src/java/mmm/utils/I_UItemWithVariants.java rename to src/java/mmm/core/api/items/I_ItemWithVariants.java index ba64aaa..b83806a 100644 --- a/src/java/mmm/utils/I_UItemWithVariants.java +++ b/src/java/mmm/core/api/items/I_ItemWithVariants.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.core.api.items; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -7,8 +7,8 @@ import net.minecraftforge.fml.relauncher.SideOnly; -public interface I_UItemWithVariants - extends I_UItemModelProvider +public interface I_ItemWithVariants + extends I_ItemModelProvider { public int getVariantsCount( ); diff --git a/src/java/mmm/utils/I_UTintedItem.java b/src/java/mmm/core/api/items/I_TintedItem.java similarity index 72% rename from src/java/mmm/utils/I_UTintedItem.java rename to src/java/mmm/core/api/items/I_TintedItem.java index 7aa8035..f4ad6a1 100644 --- a/src/java/mmm/utils/I_UTintedItem.java +++ b/src/java/mmm/core/api/items/I_TintedItem.java @@ -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.minecraftforge.fml.relauncher.Side; 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 * to be tinted. */ -public interface I_UTintedItem - extends I_URequiresClientInit +public interface I_TintedItem + extends I_RequiresClientInit { @SideOnly( Side.CLIENT ) diff --git a/src/java/mmm/core/api/tech/E_ActivationMode.java b/src/java/mmm/core/api/tech/E_ActivationMode.java new file mode 100644 index 0000000..c8e9ad1 --- /dev/null +++ b/src/java/mmm/core/api/tech/E_ActivationMode.java @@ -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 ]; + } +} diff --git a/src/java/mmm/core/api/tech/I_ConfigurableActivation.java b/src/java/mmm/core/api/tech/I_ConfigurableActivation.java new file mode 100644 index 0000000..b16b2ad --- /dev/null +++ b/src/java/mmm/core/api/tech/I_ConfigurableActivation.java @@ -0,0 +1,12 @@ +package mmm.core.api.tech; + + +public interface I_ConfigurableActivation +{ + + public E_ActivationMode getActivationMode( ); + + + public void setActivationMode( E_ActivationMode mode ); + +} diff --git a/src/java/mmm/world/I_WBiomeWithOres.java b/src/java/mmm/core/api/world/I_BiomeWithOres.java similarity index 70% rename from src/java/mmm/world/I_WBiomeWithOres.java rename to src/java/mmm/core/api/world/I_BiomeWithOres.java index 62ef805..76da6bb 100644 --- a/src/java/mmm/world/I_WBiomeWithOres.java +++ b/src/java/mmm/core/api/world/I_BiomeWithOres.java @@ -1,4 +1,4 @@ -package mmm.world; +package mmm.core.api.world; 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 ); diff --git a/src/java/mmm/world/I_WDefaultPopulateHandler.java b/src/java/mmm/core/api/world/I_DefaultPopulateHandler.java similarity index 65% rename from src/java/mmm/world/I_WDefaultPopulateHandler.java rename to src/java/mmm/core/api/world/I_DefaultPopulateHandler.java index 3134b63..e954f0a 100644 --- a/src/java/mmm/world/I_WDefaultPopulateHandler.java +++ b/src/java/mmm/core/api/world/I_DefaultPopulateHandler.java @@ -1,10 +1,13 @@ -package mmm.world; +package mmm.core.api.world; + import net.minecraftforge.event.terraingen.PopulateChunkEvent; -public interface I_WDefaultPopulateHandler + + +public interface I_DefaultPopulateHandler { - + public boolean onDefaultPopulate( PopulateChunkEvent.Populate event ); } diff --git a/src/java/mmm/world/I_WLocationCheck.java b/src/java/mmm/core/api/world/I_LocationCheck.java similarity index 70% rename from src/java/mmm/world/I_WLocationCheck.java rename to src/java/mmm/core/api/world/I_LocationCheck.java index ef375dd..3229037 100644 --- a/src/java/mmm/world/I_WLocationCheck.java +++ b/src/java/mmm/core/api/world/I_LocationCheck.java @@ -1,4 +1,4 @@ -package mmm.world; +package mmm.core.api.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 ); - default I_WLocationCheck and( final I_WLocationCheck other ) + default I_LocationCheck and( final I_LocationCheck other ) { - final I_WLocationCheck self = this; - return new I_WLocationCheck( ) { + final I_LocationCheck self = this; + return new I_LocationCheck( ) { @Override public boolean checkLocation( final World world , final int chunkX , final int chunkZ , 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; - return new I_WLocationCheck( ) { + final I_LocationCheck self = this; + return new I_LocationCheck( ) { @Override public boolean checkLocation( final World world , final int chunkX , final int chunkZ , final IChunkProvider provider ) @@ -42,10 +42,10 @@ public interface I_WLocationCheck } - default I_WLocationCheck invert( ) + default I_LocationCheck invert( ) { - final I_WLocationCheck self = this; - return new I_WLocationCheck( ) { + final I_LocationCheck self = this; + return new I_LocationCheck( ) { @Override public boolean checkLocation( final World world , final int chunkX , final int chunkZ , final IChunkProvider provider ) diff --git a/src/java/mmm/core/api/world/I_TrappedBiome.java b/src/java/mmm/core/api/world/I_TrappedBiome.java new file mode 100644 index 0000000..6ceadc9 --- /dev/null +++ b/src/java/mmm/core/api/world/I_TrappedBiome.java @@ -0,0 +1,7 @@ +package mmm.core.api.world; + + +public interface I_TrappedBiome +{ + public float getTrapBlockChance( ); +} diff --git a/src/java/mmm/deco/DChair.java b/src/java/mmm/deco/DChair.java deleted file mode 100644 index 0168cb7..0000000 --- a/src/java/mmm/deco/DChair.java +++ /dev/null @@ -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 ); - } -} diff --git a/src/java/mmm/deco/DChairs.java b/src/java/mmm/deco/DChairs.java new file mode 100644 index 0000000..186b906 --- /dev/null +++ b/src/java/mmm/deco/DChairs.java @@ -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 ) ); + } +} diff --git a/src/java/mmm/deco/DFence.java b/src/java/mmm/deco/DFence.java deleted file mode 100644 index da10b59..0000000 --- a/src/java/mmm/deco/DFence.java +++ /dev/null @@ -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 ) ); - } - -} diff --git a/src/java/mmm/deco/DFences.java b/src/java/mmm/deco/DFences.java deleted file mode 100644 index dc81871..0000000 --- a/src/java/mmm/deco/DFences.java +++ /dev/null @@ -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 ); - } - -} diff --git a/src/java/mmm/utils/USeat.java b/src/java/mmm/deco/DSeatEntity.java similarity index 83% rename from src/java/mmm/utils/USeat.java rename to src/java/mmm/deco/DSeatEntity.java index 6a74625..83a1b1e 100644 --- a/src/java/mmm/utils/USeat.java +++ b/src/java/mmm/deco/DSeatEntity.java @@ -1,9 +1,10 @@ -package mmm.utils; +package mmm.deco; import java.util.List; import mmm.Mmm; +import mmm.core.api.blocks.I_SeatBlock; import net.minecraft.block.Block; import net.minecraft.entity.Entity; 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 { 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; } - final List< USeat > seats = world.getEntitiesWithinAABB( USeat.class , + final List< DSeatEntity > seats = world.getEntitiesWithinAABB( DSeatEntity.class , new AxisAlignedBB( pos ).expand( 1 , 1 , 1 ) ); - USeat seat = null; - for ( final USeat existingSeat : seats ) { + DSeatEntity seat = null; + for ( final DSeatEntity existingSeat : seats ) { if ( !existingSeat.pos.equals( pos ) ) { continue; } @@ -47,7 +48,7 @@ public class USeat } if ( seat == null ) { - seat = new USeat( world , pos , yOffset ); + seat = new DSeatEntity( world , pos , yOffset ); world.spawnEntityInWorld( seat ); } player.startRiding( seat ); @@ -61,7 +62,7 @@ public class USeat public double yOffset; - public USeat( final World world ) + public DSeatEntity( final World 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 ); @@ -149,7 +150,7 @@ public class USeat } final Block block = this.worldObj.getBlockState( this.pos ).getBlock( ); - if ( ! ( block instanceof I_UBlockSeat ) ) { + if ( ! ( block instanceof I_SeatBlock ) ) { this.setDead( ); return; } diff --git a/src/java/mmm/deco/DStairs.java b/src/java/mmm/deco/DStairs.java index 7715fde..055afff 100644 --- a/src/java/mmm/deco/DStairs.java +++ b/src/java/mmm/deco/DStairs.java @@ -1,9 +1,10 @@ package mmm.deco; +import mmm.MmmMaterials; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import mmm.materials.MTree; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockStairs; import net.minecraft.block.BlockStone; @@ -15,56 +16,76 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class DStairs - extends BlockStairs - implements I_URecipeRegistrar { - public static DStairs fromVanillaSmoothStone( final BlockStone.EnumType type ) - { - final IBlockState bs = Blocks.STONE.getDefaultState( ).withProperty( BlockStone.VARIANT , type ); - final DStairs stairs = new DStairs( bs , type.getName( ).replace( "smooth_" , "" ) ); - URegistry.addBlock( stairs ); - return stairs; - } - - public static DStairs fromWood( final MTree materials ) + public static class StairsBlock + extends BlockStairs + implements I_RecipeRegistrar { - final DStairs stairs = new DStairs( materials.PLANKS.getDefaultState( ) , materials.NAME ); - URegistry.addBlock( stairs ); - if ( materials.getBaseFlammability( ) != 0 ) { - Blocks.FIRE.setFireInfo( stairs , materials.getBaseFireEncouragement( ) , - materials.getBaseFlammability( ) * 4 ); + public static StairsBlock fromVanillaSmoothStone( final BlockStone.EnumType type ) + { + final IBlockState bs = Blocks.STONE.getDefaultState( ).withProperty( BlockStone.VARIANT , type ); + final StairsBlock stairs = new StairsBlock( bs , type.getName( ).replace( "smooth_" , "" ) ); + CRegistry.addBlock( stairs ); + return stairs; } - return stairs; + + + public static StairsBlock fromWood( final MTree materials ) + { + final StairsBlock stairs = new StairsBlock( materials.PLANKS.getDefaultState( ) , materials.NAME ); + CRegistry.addBlock( stairs ); + if ( materials.getBaseFlammability( ) != 0 ) { + Blocks.FIRE.setFireInfo( stairs , materials.getBaseFireEncouragement( ) , + materials.getBaseFlammability( ) * 4 ); + } + return stairs; + } + + public final IBlockState modelState; + public final Block modelBlock; + + + public StairsBlock( final Block modelBlock , final String name ) + { + this( modelBlock.getDefaultState( ) , name ); + } + + + public StairsBlock( final IBlockState modelState , final String name ) + { + super( modelState ); + this.modelState = modelState; + this.modelBlock = modelState.getBlock( ); + CRegistry.setIdentifiers( this , "deco" , "stairs" , name ); + } + + + @Override + public void registerRecipes( ) + { + GameRegistry.addShapedRecipe( new ItemStack( this ) , // + "B " , // + "BB " , // + "BBB" , // + 'B' , new ItemStack( this.modelBlock , 4 , this.modelBlock.getMetaFromState( this.modelState ) ) ); + } + } - public final IBlockState modelState; - public final Block modelBlock; + public final StairsBlock GRANITE; + public final StairsBlock DIORITE; + public final StairsBlock ANDESITE; + public final StairsBlock HEVEA; + public final StairsBlock BAMBOO; - public DStairs( final Block modelBlock , final String name ) + public DStairs( ) { - this( modelBlock.getDefaultState( ) , name ); + 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 ); } - - - public DStairs( final IBlockState modelState , final String name ) - { - super( modelState ); - this.modelState = modelState; - this.modelBlock = modelState.getBlock( ); - URegistry.setIdentifiers( this , "deco" , "stairs" , name ); - } - - - @Override - public void registerRecipes( ) - { - GameRegistry.addShapedRecipe( new ItemStack( this ) , // - "B " , // - "BB " , // - "BBB" , // - 'B' , new ItemStack( this.modelBlock , 4 , this.modelBlock.getMetaFromState( this.modelState ) ) ); - } - } diff --git a/src/java/mmm/deco/DTable.java b/src/java/mmm/deco/DTable.java deleted file mode 100644 index a04ecc3..0000000 --- a/src/java/mmm/deco/DTable.java +++ /dev/null @@ -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 ); - } - -} diff --git a/src/java/mmm/deco/DTables.java b/src/java/mmm/deco/DTables.java new file mode 100644 index 0000000..44e4c71 --- /dev/null +++ b/src/java/mmm/deco/DTables.java @@ -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 ) ); + } +} diff --git a/src/java/mmm/deco/DecorativeBlocks.java b/src/java/mmm/deco/DecorativeBlocks.java deleted file mode 100644 index 2206685..0000000 --- a/src/java/mmm/deco/DecorativeBlocks.java +++ /dev/null @@ -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 - } - -} diff --git a/src/java/mmm/deco/fences/DFence.java b/src/java/mmm/deco/fences/DFence.java new file mode 100644 index 0000000..6f1fcf4 --- /dev/null +++ b/src/java/mmm/deco/fences/DFence.java @@ -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 ) ); + } + +} diff --git a/src/java/mmm/deco/DFenceBlock.java b/src/java/mmm/deco/fences/DFenceBlock.java similarity index 72% rename from src/java/mmm/deco/DFenceBlock.java rename to src/java/mmm/deco/fences/DFenceBlock.java index d33a321..6bb8cdd 100644 --- a/src/java/mmm/deco/DFenceBlock.java +++ b/src/java/mmm/deco/fences/DFenceBlock.java @@ -1,8 +1,9 @@ -package mmm.deco; +package mmm.deco.fences; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; +import mmm.materials.MWood; import net.minecraft.block.BlockFence; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -14,13 +15,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class DFenceBlock 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( ) ); this.woodType = woodType; @@ -28,7 +29,7 @@ public class DFenceBlock this.setResistance( 5.f ); this.setSoundType( SoundType.WOOD ); this.setHarvestLevel( "axe" , 0 ); - URegistry.setIdentifiers( this , "deco" , "fence" , woodType.getSuffix( ) ); + CRegistry.setIdentifiers( this , "deco" , "fence" , woodType.getSuffix( ) ); } diff --git a/src/java/mmm/deco/DFenceGate.java b/src/java/mmm/deco/fences/DFenceGate.java similarity index 72% rename from src/java/mmm/deco/DFenceGate.java rename to src/java/mmm/deco/fences/DFenceGate.java index 928d4ba..f9c2f34 100644 --- a/src/java/mmm/deco/DFenceGate.java +++ b/src/java/mmm/deco/fences/DFenceGate.java @@ -1,9 +1,10 @@ -package mmm.deco; +package mmm.deco.fences; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.I_UStateMapperProvider; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; +import mmm.core.api.blocks.I_StateMapperProvider; +import mmm.materials.MWood; import mmm.utils.UStateMapper; import net.minecraft.block.BlockFenceGate; import net.minecraft.block.BlockPlanks; @@ -19,13 +20,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class DFenceGate 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 ); this.woodType = woodType; @@ -33,12 +34,12 @@ public class DFenceGate this.setResistance( 5.f ); this.setSoundType( SoundType.WOOD ); this.setHarvestLevel( "axe" , 0 ); - URegistry.setIdentifiers( this , "deco" , "fence" , "gate" , woodType.getSuffix( ) ); + CRegistry.setIdentifiers( this , "deco" , "fence" , "gate" , woodType.getSuffix( ) ); } @Override - public MapColor getMapColor( IBlockState state ) + public MapColor getMapColor( final IBlockState state ) { return this.woodType.getMapColor( ); } diff --git a/src/java/mmm/deco/fences/DFences.java b/src/java/mmm/deco/fences/DFences.java new file mode 100644 index 0000000..a4b6b2e --- /dev/null +++ b/src/java/mmm/deco/fences/DFences.java @@ -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 ); + } + +} diff --git a/src/java/mmm/deco/A_DSlabBlock.java b/src/java/mmm/deco/slabs/A_DSlabBlock.java similarity index 91% rename from src/java/mmm/deco/A_DSlabBlock.java rename to src/java/mmm/deco/slabs/A_DSlabBlock.java index c03ed99..5525149 100644 --- a/src/java/mmm/deco/A_DSlabBlock.java +++ b/src/java/mmm/deco/slabs/A_DSlabBlock.java @@ -1,8 +1,8 @@ -package mmm.deco; +package mmm.deco.slabs; -import mmm.utils.UAccessors; -import mmm.utils.URegistry; +import mmm.core.CAccessors; +import mmm.core.CRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockSlab; import net.minecraft.block.properties.IProperty; @@ -45,8 +45,8 @@ public abstract class A_DSlabBlock this.setSoundType( this.modelBlock.getSoundType( ) ); try { - this.setHardness( UAccessors.getBlockHardness( this.modelBlock ) ); - this.setResistance( UAccessors.getBlockResistance( this.modelBlock ) + 0.5f ); + this.setHardness( CAccessors.getBlockHardness( this.modelBlock ) ); + this.setResistance( CAccessors.getBlockResistance( this.modelBlock ) + 0.5f ); } catch ( final Throwable e ) { if ( e instanceof RuntimeException ) { throw (RuntimeException) e; @@ -61,7 +61,7 @@ public abstract class A_DSlabBlock } this.setDefaultState( state.withProperty( A_DSlabBlock.VARIANT , E_Variant.DEFAULT ) ); - URegistry.setIdentifiers( this , "deco" , "slabs" , name ); + CRegistry.setIdentifiers( this , "deco" , "slabs" , name ); } diff --git a/src/java/mmm/deco/DSlabDouble.java b/src/java/mmm/deco/slabs/DSlabDouble.java similarity index 97% rename from src/java/mmm/deco/DSlabDouble.java rename to src/java/mmm/deco/slabs/DSlabDouble.java index 565dfea..db47042 100644 --- a/src/java/mmm/deco/DSlabDouble.java +++ b/src/java/mmm/deco/slabs/DSlabDouble.java @@ -1,4 +1,4 @@ -package mmm.deco; +package mmm.deco.slabs; import java.util.Random; diff --git a/src/java/mmm/deco/DSlabHalf.java b/src/java/mmm/deco/slabs/DSlabHalf.java similarity index 91% rename from src/java/mmm/deco/DSlabHalf.java rename to src/java/mmm/deco/slabs/DSlabHalf.java index b9e08e8..2b67142 100644 --- a/src/java/mmm/deco/DSlabHalf.java +++ b/src/java/mmm/deco/slabs/DSlabHalf.java @@ -1,4 +1,4 @@ -package mmm.deco; +package mmm.deco.slabs; import net.minecraft.block.state.IBlockState; diff --git a/src/java/mmm/deco/DSlab.java b/src/java/mmm/deco/slabs/DSlabParts.java similarity index 65% rename from src/java/mmm/deco/DSlab.java rename to src/java/mmm/deco/slabs/DSlabParts.java index 6eae237..c720569 100644 --- a/src/java/mmm/deco/DSlab.java +++ b/src/java/mmm/deco/slabs/DSlabParts.java @@ -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.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockStone; import net.minecraft.block.state.IBlockState; @@ -14,20 +14,20 @@ import net.minecraftforge.fml.common.registry.GameRegistry; -public class DSlab - implements I_URecipeRegistrar +public class DSlabParts + 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 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 ) { Blocks.FIRE.setFireInfo( slab.HALF , materials.getBaseFireEncouragement( ) , materials.getBaseFlammability( ) * 4 ); @@ -42,22 +42,22 @@ public class DSlab public final ItemSlab ITEM; - public DSlab( final Block modelBlock , final String name ) + public DSlabParts( final Block modelBlock , final String 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.DOUBLE = new DSlabDouble( this.HALF , name ); 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 ); - URegistry.addBlock( this.DOUBLE , null ); - URegistry.addRecipeRegistrar( this ); + CRegistry.addBlock( this.HALF , this.ITEM ); + CRegistry.addBlock( this.DOUBLE , null ); + CRegistry.addRecipeRegistrar( this ); } diff --git a/src/java/mmm/deco/slabs/DSlabs.java b/src/java/mmm/deco/slabs/DSlabs.java new file mode 100644 index 0000000..7896091 --- /dev/null +++ b/src/java/mmm/deco/slabs/DSlabs.java @@ -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 ); + } +} diff --git a/src/java/mmm/deco/DThrone.java b/src/java/mmm/deco/thrones/DThrone.java similarity index 55% rename from src/java/mmm/deco/DThrone.java rename to src/java/mmm/deco/thrones/DThrone.java index 55e65da..b8d577f 100644 --- a/src/java/mmm/deco/DThrone.java +++ b/src/java/mmm/deco/thrones/DThrone.java @@ -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.URegistry; import net.minecraft.item.Item; @@ -15,11 +16,11 @@ public class DThrone public final Item ITEM; - public DThrone( final DWoodType woodType ) + public DThrone( final MWood woodType ) { - URegistry.addBlock( this.BOTTOM = new DThroneBlock( this , woodType , false ) , null ); - URegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null ); - this.ITEM = new UBlockItemWithVariants( this.BOTTOM , "deco" , "throne" , woodType.getSuffix() ) // + CRegistry.addBlock( this.BOTTOM = new DThroneBlock( this , woodType , false ) , null ); + CRegistry.addBlock( this.TOP = new DThroneBlock( this , woodType , true ) , null ); + this.ITEM = new UBlockItemWithVariants( this.BOTTOM , "deco" , "throne" , woodType.getSuffix( ) ) // .useColorVariants( ) // .register( ); } diff --git a/src/java/mmm/deco/DThroneBlock.java b/src/java/mmm/deco/thrones/DThroneBlock.java similarity index 91% rename from src/java/mmm/deco/DThroneBlock.java rename to src/java/mmm/deco/thrones/DThroneBlock.java index 97b3b5c..ab9b346 100644 --- a/src/java/mmm/deco/DThroneBlock.java +++ b/src/java/mmm/deco/thrones/DThroneBlock.java @@ -1,15 +1,16 @@ -package mmm.deco; +package mmm.deco.thrones; import java.util.List; import java.util.Random; -import mmm.utils.I_UBlockSeat; -import mmm.utils.I_UColoredBlock; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.I_USupportBlock; +import mmm.core.api.I_RecipeRegistrar; +import mmm.core.api.blocks.I_ColoredBlock; +import mmm.core.api.blocks.I_SeatBlock; +import mmm.core.api.blocks.I_SupportBlock; +import mmm.deco.DSeatEntity; +import mmm.materials.MWood; import mmm.utils.UMaths; -import mmm.utils.USeat; import net.minecraft.block.Block; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.SoundType; @@ -47,7 +48,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class DThroneBlock extends Block - implements I_UColoredBlock , I_UBlockSeat , I_URecipeRegistrar + implements I_ColoredBlock , I_SeatBlock , I_RecipeRegistrar { public static final PropertyDirection FACING; @@ -65,12 +66,12 @@ public class DThroneBlock COLOR = PropertyEnum.< EnumDyeColor > create( "color" , EnumDyeColor.class ); } - public final DWoodType woodType; + public final MWood woodType; public final DThrone parts; 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 ); this.woodType = woodType; @@ -78,8 +79,8 @@ public class DThroneBlock this.isTop = isTop; this.setCreativeTab( CreativeTabs.DECORATIONS ); - this.setRegistryName( "mmm:deco/throne/" + woodType.getSuffix() + "/" + ( isTop ? "top" : "bottom" ) ); - this.setUnlocalizedName( "mmm.deco.throne." + woodType.getSuffix() ); + this.setRegistryName( "mmm:deco/throne/" + woodType.getSuffix( ) + "/" + ( isTop ? "top" : "bottom" ) ); + this.setUnlocalizedName( "mmm.deco.throne." + woodType.getSuffix( ) ); if ( this.isTop ) { this.setDefaultState( this.blockState.getBaseState( ) // @@ -131,7 +132,7 @@ public class DThroneBlock public AxisAlignedBB getBoundingBox( final IBlockState state , final IBlockAccess source , final BlockPos pos ) { if ( this.isTop ) { - switch ( state.getValue( DChair.FACING ) ) { + switch ( state.getValue( DThroneBlock.FACING ) ) { case EAST: return DThroneBlock.COLLISION_TOP_EAST; case NORTH: @@ -226,7 +227,7 @@ public class DThroneBlock public boolean canPlaceBlockAt( final World worldIn , final BlockPos 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 // ************************************************************************************************* - 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; } @@ -303,7 +305,7 @@ public class DThroneBlock { DThroneBlock.dropping = true; 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 ) { world.setBlockToAir( otherPos ); } @@ -335,7 +337,7 @@ public class DThroneBlock final Block blockIn ) { 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 { 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" , // "BBB" , // '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 , // 'E' , Items.EMERALD // ); diff --git a/src/java/mmm/deco/thrones/DThrones.java b/src/java/mmm/deco/thrones/DThrones.java new file mode 100644 index 0000000..dc98da3 --- /dev/null +++ b/src/java/mmm/deco/thrones/DThrones.java @@ -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 ); + } +} diff --git a/src/java/mmm/food/FMilkBucket.java b/src/java/mmm/food/FMilkBucket.java index 8fe4045..22993b8 100644 --- a/src/java/mmm/food/FMilkBucket.java +++ b/src/java/mmm/food/FMilkBucket.java @@ -1,8 +1,8 @@ package mmm.food; -import mmm.utils.I_UItemModelProviderBasic; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.items.I_ItemModelProviderBasic; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Items; @@ -12,7 +12,7 @@ import net.minecraft.item.Item; public class FMilkBucket extends Item - implements I_UItemModelProviderBasic + implements I_ItemModelProviderBasic { public final FMilkType milkType; @@ -22,7 +22,7 @@ public class FMilkBucket { super( ); this.milkType = milkType; - URegistry.setIdentifiers( this , "food" , "milk" , milkType.name ); + CRegistry.setIdentifiers( this , "food" , "milk" , milkType.name ); this.setMaxStackSize( 1 ); this.setCreativeTab( CreativeTabs.MISC ); } diff --git a/src/java/mmm/food/FMilkType.java b/src/java/mmm/food/FMilkType.java index 4221dec..c232ef3 100644 --- a/src/java/mmm/food/FMilkType.java +++ b/src/java/mmm/food/FMilkType.java @@ -3,15 +3,9 @@ package mmm.food; import java.util.function.Predicate; -import com.google.common.collect.HashMultimap; - -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.entity.passive.EntityAnimal; 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.item.Item; @@ -19,35 +13,6 @@ import net.minecraft.item.Item; 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 boolean isVanilla; public final Class< ? extends EntityAnimal > animal; @@ -56,7 +21,7 @@ public class FMilkType private Predicate< EntityAnimal > extraCheck; - private FMilkType( ) + public FMilkType( ) { this( "cow" , true , EntityCow.class , Items.MILK_BUCKET ); } @@ -76,10 +41,10 @@ public class FMilkType this.animal = animal; if ( bucket == null ) { bucket = new FMilkBucket( this ); - URegistry.addItem( bucket ); + CRegistry.addItem( bucket ); } this.bucket = bucket; - FMilkType.MILK_TYPES.put( animal , this ); + } @@ -92,11 +57,11 @@ public class FMilkType public int getPeriod( ) { - return period; + return this.period; } - public FMilkType setPeriod( int period ) + public FMilkType setPeriod( final int period ) { this.period = period; return this; diff --git a/src/java/mmm/food/FMilkable.java b/src/java/mmm/food/FMilkable.java index 2470894..b518c7c 100644 --- a/src/java/mmm/food/FMilkable.java +++ b/src/java/mmm/food/FMilkable.java @@ -5,8 +5,9 @@ import java.util.Set; import io.netty.buffer.ByteBuf; import mmm.Mmm; -import mmm.utils.I_UMessage; -import mmm.utils.UNetwork; +import mmm.MmmFood; +import mmm.core.CNetwork; +import mmm.core.api.I_Message; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.Entity; import net.minecraft.entity.passive.EntityAnimal; @@ -19,10 +20,8 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagLong; import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.CapabilityInject; -import net.minecraftforge.common.capabilities.CapabilityManager; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.event.AttachCapabilitiesEvent; import net.minecraftforge.event.entity.player.PlayerEvent; @@ -105,7 +104,7 @@ public class FMilkable // ************************************************************************************************************* public static class Message - implements I_UMessage + implements I_Message { private int entityId; private long lastMilking; @@ -160,7 +159,7 @@ public class FMilkable @SubscribeEvent 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( ) ); } } @@ -175,7 +174,7 @@ public class FMilkable } final Entity entity = event.getTarget( ); 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 - final Set< FMilkType > milkTypes = FMilkType.MILK_TYPES.get( animal.getClass( ) ); + final Set< FMilkType > milkTypes = MmmFood.MILK.TYPES.get( animal.getClass( ) ); FMilkType milkType = null; for ( final FMilkType type : milkTypes ) { if ( type.check( animal ) ) { @@ -229,7 +228,7 @@ public class FMilkable // Send updates to players if ( !player.worldObj.isRemote ) { - UNetwork.sendToAll( new Message( animal ) ); + CNetwork.sendToAll( new Message( 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; diff --git a/src/java/mmm/food/FMilks.java b/src/java/mmm/food/FMilks.java new file mode 100644 index 0000000..d153dfd --- /dev/null +++ b/src/java/mmm/food/FMilks.java @@ -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; + } +} diff --git a/src/java/mmm/food/Food.java b/src/java/mmm/food/Food.java deleted file mode 100644 index 3dbb5fb..0000000 --- a/src/java/mmm/food/Food.java +++ /dev/null @@ -1,17 +0,0 @@ -package mmm.food; - -public class Food -{ - - static { - FMilkType.preInit( ); - FMilkable.register( ); - } - - - public static void preInit( ) - { - // EMPTY - } - -} diff --git a/src/java/mmm/materials/MAlloyRecipe.java b/src/java/mmm/materials/MAlloyRecipe.java index 6c01d7b..51fa3f7 100644 --- a/src/java/mmm/materials/MAlloyRecipe.java +++ b/src/java/mmm/materials/MAlloyRecipe.java @@ -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++ ) { if ( this.inputs[ i ].isItemEqual( stack ) ) { diff --git a/src/java/mmm/materials/MAlloys.java b/src/java/mmm/materials/MAlloys.java index 1ef6287..1f62f95 100644 --- a/src/java/mmm/materials/MAlloys.java +++ b/src/java/mmm/materials/MAlloys.java @@ -1,8 +1,9 @@ package mmm.materials; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.MmmMaterials; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.block.material.MapColor; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -10,19 +11,19 @@ import net.minecraft.init.Items; public class MAlloys - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public final MMetal BRONZE; public final MMetal STEEL; // public static final MMetal RED_COPPER; - MAlloys( ) + public MAlloys( ) { - URegistry.addRecipeRegistrar( this ); + CRegistry.addRecipeRegistrar( this ); - BRONZE = new MMetal( "bronze" , 0f , 5f , 1 , MapColor.BROWN ); - STEEL = new MMetal( "steel" , 0f , 7f , 2 , MapColor.LIGHT_BLUE ) // + this.BRONZE = new MMetal( "bronze" , 0f , 5f , 1 , MapColor.BROWN ); + this.STEEL = new MMetal( "steel" , 0f , 7f , 2 , MapColor.LIGHT_BLUE ) // .setBlockResistance( 12f ); // RED_COPPER = new MMetal( "red_copper" , 0f , 2f , 1 , MapColor.RED ); } @@ -33,36 +34,36 @@ public class MAlloys { // Bronze MAlloyRecipe.build( ).setName( "materials/bronze" ).setBurnTime( 400 ) // - .addInput( Materials.METAL.COPPER.INGOT ) // - .addInput( Materials.METAL.TIN.NUGGET ) // + .addInput( MmmMaterials.METAL.COPPER.INGOT ) // + .addInput( MmmMaterials.METAL.TIN.NUGGET ) // .setOutput( this.BRONZE.INGOT ).setSlag( 1 ) // .register( ); // Pig iron MAlloyRecipe.build( ).setName( "materials/pig_iron/from_ingot" ).setBurnTime( 1600 ) // - .addInput( Materials.METAL.IRON.INGOT ) // - .addInput( Materials.ROCK.LIMESTONE ) // - .addInput( Materials.ITEM.COKE ) // - .setOutput( Materials.ITEM.PIG_IRON_INGOT , 2 ).setSlag( 3 ) // + .addInput( MmmMaterials.METAL.IRON.INGOT ) // + .addInput( MmmMaterials.ROCK.LIMESTONE ) // + .addInput( MmmMaterials.ITEM.COKE ) // + .setOutput( MmmMaterials.ITEM.PIG_IRON_INGOT , 2 ).setSlag( 3 ) // .register( ); MAlloyRecipe.build( ).setName( "materials/pig_iron/from_ore" ).setBurnTime( 1600 ) // .addInput( Blocks.IRON_ORE ) // - .addInput( Materials.ROCK.LIMESTONE ) // - .addInput( Materials.ITEM.COKE ) // - .setOutput( Materials.ITEM.PIG_IRON_INGOT ).setSlag( 5 ) // + .addInput( MmmMaterials.ROCK.LIMESTONE ) // + .addInput( MmmMaterials.ITEM.COKE ) // + .setOutput( MmmMaterials.ITEM.PIG_IRON_INGOT ).setSlag( 5 ) // .register( ); // Steel MAlloyRecipe.build( ).setName( "materials/steel/from_ingot" ).setBurnTime( 3200 ) // - .addInput( Materials.METAL.IRON.INGOT ) // - .addInput( Materials.ROCK.LIMESTONE ) // - .addInput( Materials.ITEM.PIG_IRON_INGOT ) // + .addInput( MmmMaterials.METAL.IRON.INGOT ) // + .addInput( MmmMaterials.ROCK.LIMESTONE ) // + .addInput( MmmMaterials.ITEM.PIG_IRON_INGOT ) // .setOutput( this.STEEL.INGOT , 2 ).setSlag( 3 ) // .register( ); MAlloyRecipe.build( ).setName( "materials/steel/from_ore" ).setBurnTime( 3200 ) // .addInput( Blocks.IRON_ORE ) // - .addInput( Materials.ROCK.LIMESTONE ) // - .addInput( Materials.ITEM.PIG_IRON_INGOT ) // + .addInput( MmmMaterials.ROCK.LIMESTONE ) // + .addInput( MmmMaterials.ITEM.PIG_IRON_INGOT ) // .setOutput( this.STEEL.INGOT ).setSlag( 5 ) // .register( ); @@ -72,6 +73,6 @@ public class MAlloys // XXX coke is not an alloy 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( ); } } diff --git a/src/java/mmm/materials/MItems.java b/src/java/mmm/materials/MItems.java index 30e7b8e..0e9c555 100644 --- a/src/java/mmm/materials/MItems.java +++ b/src/java/mmm/materials/MItems.java @@ -1,8 +1,9 @@ package mmm.materials; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.MmmMaterials; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -11,7 +12,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class MItems - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public final Item SLAG; public final Item COKE; @@ -25,24 +26,24 @@ public class MItems public final Item SALTPETER; - MItems( ) + public MItems( ) { - URegistry.addRecipeRegistrar( this ); + CRegistry.addRecipeRegistrar( this ); // Items that do not correspond to metals or ores - SLAG = Materials.makeItem( "slag" ); - COKE = Materials.makeFuel( "coke" , 9600 ); - PIG_IRON_INGOT = new MMetalItem( E_MMetalItemType.INGOT , "pig_iron" ); - URegistry.addItem( PIG_IRON_INGOT ); + this.SLAG = MmmMaterials.makeItem( "slag" ); + this.COKE = MmmMaterials.makeFuel( "coke" , 9600 ); + this.PIG_IRON_INGOT = new MMetalItem( E_MMetalItemType.INGOT , "pig_iron" ); + CRegistry.addItem( this.PIG_IRON_INGOT ); // Ore drops - MALACHITE = Materials.makeItem( "malachite" ); - CUPRITE = Materials.makeItem( "cuprite" ); - CASSITERITE = Materials.makeItem( "cassiterite" ); - SPHALERITE = Materials.makeItem( "sphalerite" ); - ROCK_SALT = Materials.makeItem( "rock_salt" ); - SULPHUR_POWDER = Materials.makeItem( "sulphur_powder" ); - SALTPETER = Materials.makeItem( "saltpeter_powder" ); + this.MALACHITE = MmmMaterials.makeItem( "malachite" ); + this.CUPRITE = MmmMaterials.makeItem( "cuprite" ); + this.CASSITERITE = MmmMaterials.makeItem( "cassiterite" ); + this.SPHALERITE = MmmMaterials.makeItem( "sphalerite" ); + this.ROCK_SALT = MmmMaterials.makeItem( "rock_salt" ); + this.SULPHUR_POWDER = MmmMaterials.makeItem( "sulphur_powder" ); + this.SALTPETER = MmmMaterials.makeItem( "saltpeter_powder" ); } @@ -51,12 +52,12 @@ public class MItems { // Green dye from malachite GameRegistry.addShapelessRecipe( new ItemStack( Items.DYE , 1 , 2 ) , - new ItemStack( Materials.ITEM.MALACHITE ) ); + new ItemStack( MmmMaterials.ITEM.MALACHITE ) ); // Gunpowder from saltpeter, sulphur and charcoal GameRegistry.addShapelessRecipe( new ItemStack( Items.GUNPOWDER ) , // - new ItemStack( Materials.ITEM.SALTPETER ) , // - new ItemStack( Materials.ITEM.SULPHUR_POWDER ) , // + new ItemStack( MmmMaterials.ITEM.SALTPETER ) , // + new ItemStack( MmmMaterials.ITEM.SULPHUR_POWDER ) , // new ItemStack( Items.COAL , 1 , 1 ) ); } diff --git a/src/java/mmm/materials/MLeaves.java b/src/java/mmm/materials/MLeaves.java index cd68417..840ff14 100644 --- a/src/java/mmm/materials/MLeaves.java +++ b/src/java/mmm/materials/MLeaves.java @@ -5,9 +5,9 @@ import java.util.Arrays; import java.util.List; import java.util.Random; -import mmm.utils.I_UTintedBlock; -import mmm.utils.I_UTintedItem; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.blocks.I_TintedBlock; +import mmm.core.api.items.I_TintedItem; import net.minecraft.block.Block; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockPlanks; @@ -34,7 +34,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class MLeaves extends BlockLeaves - implements I_UTintedBlock , I_UTintedItem + implements I_TintedBlock , I_TintedItem { private final MTree wood; @@ -48,7 +48,7 @@ public class MLeaves .withProperty( BlockLeaves.CHECK_DECAY , true )// .withProperty( BlockLeaves.DECAYABLE , true ) ); - URegistry.setIdentifiers( this , "materials" , "leaves" , wood.NAME ); + CRegistry.setIdentifiers( this , "materials" , "leaves" , wood.NAME ); } diff --git a/src/java/mmm/materials/MLog.java b/src/java/mmm/materials/MLog.java index 9924426..33fc9d9 100644 --- a/src/java/mmm/materials/MLog.java +++ b/src/java/mmm/materials/MLog.java @@ -1,7 +1,7 @@ package mmm.materials; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.block.Block; import net.minecraft.block.BlockLog; import net.minecraft.block.material.MapColor; @@ -34,7 +34,7 @@ public class MLog this.setDefaultState( this.blockState.getBaseState( )// .withProperty( BlockLog.LOG_AXIS , BlockLog.EnumAxis.Y ) ); - URegistry.setIdentifiers( this , "materials" , "log" , wood.NAME ); + CRegistry.setIdentifiers( this , "materials" , "log" , wood.NAME ); } diff --git a/src/java/mmm/materials/MMetal.java b/src/java/mmm/materials/MMetal.java index 38b80b8..7e02b4e 100644 --- a/src/java/mmm/materials/MMetal.java +++ b/src/java/mmm/materials/MMetal.java @@ -1,8 +1,8 @@ package mmm.materials; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.item.Item; @@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class MMetal - implements I_URecipeRegistrar + implements I_RecipeRegistrar { 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 ); return this; @@ -57,19 +57,19 @@ public class MMetal { boolean custom = false; if ( this.BLOCK instanceof MMetalBlock ) { - URegistry.addBlock( this.BLOCK ); + CRegistry.addBlock( this.BLOCK ); custom = true; } if ( this.INGOT instanceof MMetalItem ) { - URegistry.addItem( this.INGOT ); + CRegistry.addItem( this.INGOT ); custom = true; } if ( this.NUGGET instanceof MMetalItem ) { - URegistry.addItem( this.NUGGET ); + CRegistry.addItem( this.NUGGET ); custom = true; } if ( custom ) { - URegistry.addRecipeRegistrar( this ); + CRegistry.addRecipeRegistrar( this ); } return this; } diff --git a/src/java/mmm/materials/MMetalBlock.java b/src/java/mmm/materials/MMetalBlock.java index f03be61..fb50cfc 100644 --- a/src/java/mmm/materials/MMetalBlock.java +++ b/src/java/mmm/materials/MMetalBlock.java @@ -1,7 +1,7 @@ package mmm.materials; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; @@ -22,7 +22,7 @@ public class MMetalBlock this.setSoundType( SoundType.METAL ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setHarvestLevel( "pickaxe" , harvestLevel ); - URegistry.setIdentifiers( this , "materials" , "block" , name ); + CRegistry.setIdentifiers( this , "materials" , "block" , name ); } } diff --git a/src/java/mmm/materials/MMetalItem.java b/src/java/mmm/materials/MMetalItem.java index 59b830a..cf07a27 100644 --- a/src/java/mmm/materials/MMetalItem.java +++ b/src/java/mmm/materials/MMetalItem.java @@ -1,7 +1,7 @@ package mmm.materials; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; @@ -14,7 +14,7 @@ public class MMetalItem { super( ); this.setCreativeTab( CreativeTabs.MATERIALS ); - URegistry.setIdentifiers( this , "materials" , type.name , name ); + CRegistry.setIdentifiers( this , "materials" , type.name , name ); } } diff --git a/src/java/mmm/materials/MMetals.java b/src/java/mmm/materials/MMetals.java index 160ab7f..1dc6736 100644 --- a/src/java/mmm/materials/MMetals.java +++ b/src/java/mmm/materials/MMetals.java @@ -16,15 +16,15 @@ public class MMetals public final MMetal ZINC; - MMetals( ) + public MMetals( ) { - GOLD = new MMetal( Blocks.GOLD_BLOCK , Items.GOLD_INGOT , Items.GOLD_NUGGET ); - IRON = new MMetal( Blocks.IRON_BLOCK , Items.IRON_INGOT , // + this.GOLD = new MMetal( Blocks.GOLD_BLOCK , Items.GOLD_INGOT , Items.GOLD_NUGGET ); + this.IRON = new MMetal( Blocks.IRON_BLOCK , Items.IRON_INGOT , // new MMetalItem( E_MMetalItemType.NUGGET , "iron" ) ); - COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT ); - TIN = new MMetal( "tin" , 0.6f , 1f , 0 , MapColor.GRAY ); - ZINC = new MMetal( "zinc" , 0.4f , 4f , 1 , MapColor.GRAY ); + this.COPPER = new MMetal( "copper" , 0.4f , 4f , 1 , MapColor.DIRT ); + this.TIN = new MMetal( "tin" , 0.6f , 1f , 0 , MapColor.GRAY ); + this.ZINC = new MMetal( "zinc" , 0.4f , 4f , 1 , MapColor.GRAY ); } } diff --git a/src/java/mmm/materials/MMud.java b/src/java/mmm/materials/MMud.java index 9c0f2f0..a69a03b 100644 --- a/src/java/mmm/materials/MMud.java +++ b/src/java/mmm/materials/MMud.java @@ -1,9 +1,9 @@ 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.URegistry; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; @@ -19,7 +19,7 @@ import net.minecraft.world.World; public class MMud extends Block - implements I_UTrapBlock + implements I_TrapBlock { 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.setSoundType( SoundType.GROUND ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); - URegistry.setIdentifiers( this , "materials" , "trap" , "mud" ); + CRegistry.setIdentifiers( this , "materials" , "trap" , "mud" ); } diff --git a/src/java/mmm/materials/MOre.java b/src/java/mmm/materials/MOre.java index 28f6247..67c5dad 100644 --- a/src/java/mmm/materials/MOre.java +++ b/src/java/mmm/materials/MOre.java @@ -5,8 +5,8 @@ import java.util.Random; import javax.annotation.Nullable; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; @@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class MOre extends Block - implements I_URecipeRegistrar + implements I_RecipeRegistrar { private int dropMin , dropMax; private Item dropItems; @@ -52,12 +52,12 @@ public class MOre this.setHardness( 3.0f ); this.setResistance( 5.0f ); this.setHarvestLevel( "pickaxe" , harvestLevel ); - URegistry.setIdentifiers( this , "materials" , "ore" , name ); + CRegistry.setIdentifiers( this , "materials" , "ore" , name ); this.dropMin = this.dropMax = 1; this.expMin = this.expMax = 0; this.metal = null; this.genQuantity = 0; - URegistry.addBlock( this ); + CRegistry.addBlock( this ); } diff --git a/src/java/mmm/materials/MOres.java b/src/java/mmm/materials/MOres.java index c6aa387..2456cea 100644 --- a/src/java/mmm/materials/MOres.java +++ b/src/java/mmm/materials/MOres.java @@ -3,8 +3,9 @@ package mmm.materials; import java.util.List; -import mmm.utils.I_UOreGenerationRegistrar; -import mmm.utils.URegistry; +import mmm.MmmMaterials; +import mmm.core.CRegistry; +import mmm.core.api.I_OreGenerationRegistrar; import mmm.world.WLocation; import mmm.world.gen.WGOreCondition; import mmm.world.gen.WGOreParameters; @@ -14,7 +15,7 @@ import net.minecraft.init.Blocks; public class MOres - implements I_UOreGenerationRegistrar + implements I_OreGenerationRegistrar { public final MOre COPPER; public final MOre MALACHITE; @@ -30,42 +31,42 @@ public class MOres public final MOre SALTPETER; - MOres( ) + public MOres( ) { - URegistry.addOreGenerationRegistrar( this ); + CRegistry.addOreGenerationRegistrar( this ); - COPPER = new MOre( "copper" , 1 ) // - .setMetal( Materials.METAL.COPPER ); - MALACHITE = new MOre( "malachite" , 1 )// - .setMetal( Materials.METAL.COPPER ) // - .setDrops( Materials.ITEM.MALACHITE ) // + this.COPPER = new MOre( "copper" , 1 ) // + .setMetal( MmmMaterials.METAL.COPPER ); + this.MALACHITE = new MOre( "malachite" , 1 )// + .setMetal( MmmMaterials.METAL.COPPER ) // + .setDrops( MmmMaterials.ITEM.MALACHITE ) // .setExperience( 1 , 3 ); - CUPRITE = new MOre( "cuprite" , 1 ) // - .setMetal( Materials.METAL.COPPER , 2 ) // - .setDrops( Materials.ITEM.CUPRITE ) // + this.CUPRITE = new MOre( "cuprite" , 1 ) // + .setMetal( MmmMaterials.METAL.COPPER , 2 ) // + .setDrops( MmmMaterials.ITEM.CUPRITE ) // .setExperience( 2 , 5 ); - CASSITERITE = new MOre( "cassiterite" , 0 )// - .setMetal( Materials.METAL.TIN , 1 , E_MMetalItemType.NUGGET ) // - .setDrops( Materials.ITEM.CASSITERITE , 2 , 5 ) // + this.CASSITERITE = new MOre( "cassiterite" , 0 )// + .setMetal( MmmMaterials.METAL.TIN , 1 , E_MMetalItemType.NUGGET ) // + .setDrops( MmmMaterials.ITEM.CASSITERITE , 2 , 5 ) // .setExperience( 2 , 5 ); - SPHALERITE = new MOre( "sphalerite" , 1 ) // - .setMetal( Materials.METAL.ZINC ) // - .setDrops( Materials.ITEM.SPHALERITE ) // + this.SPHALERITE = new MOre( "sphalerite" , 1 ) // + .setMetal( MmmMaterials.METAL.ZINC ) // + .setDrops( MmmMaterials.ITEM.SPHALERITE ) // .setExperience( 1 , 3 ); - ROCK_SALT = new MOre( "rock_salt" , 0 ) // - .setDrops( Materials.ITEM.ROCK_SALT , 2 , 5 ) // + this.ROCK_SALT = new MOre( "rock_salt" , 0 ) // + .setDrops( MmmMaterials.ITEM.ROCK_SALT , 2 , 5 ) // .setExperience( 0 , 1 ); - BAUXITE = new MOre( "bauxite" , 1 ); - GALENA = new MOre( "galena" , 1 ); - CINNABAR = new MOre( "cinnabar" , 1 ); - SULPHUR = new MOre( "sulphur" , 0 ) // + this.BAUXITE = new MOre( "bauxite" , 1 ); + this.GALENA = new MOre( "galena" , 1 ); + this.CINNABAR = new MOre( "cinnabar" , 1 ); + this.SULPHUR = new MOre( "sulphur" , 0 ) // .setResistance( 2.0f ) // .setHardness( 1.0f ) // - .setDrops( Materials.ITEM.SULPHUR_POWDER , 3 , 6 ) // + .setDrops( MmmMaterials.ITEM.SULPHUR_POWDER , 3 , 6 ) // .setExperience( 1 , 2 ); - SILVER = new MOre( "silver" , 2 ); - SALTPETER = new MOre( "saltpeter" , 0 ) // - .setDrops( Materials.ITEM.SALTPETER , 4 , 8 ) // + this.SILVER = new MOre( "silver" , 2 ); + this.SALTPETER = new MOre( "saltpeter" , 0 ) // + .setDrops( MmmMaterials.ITEM.SALTPETER , 4 , 8 ) // .setExperience( 0 , 1 ); } diff --git a/src/java/mmm/materials/MPlanks.java b/src/java/mmm/materials/MPlanks.java index 2223290..a98b17d 100644 --- a/src/java/mmm/materials/MPlanks.java +++ b/src/java/mmm/materials/MPlanks.java @@ -1,7 +1,7 @@ package mmm.materials; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; @@ -25,7 +25,7 @@ public class MPlanks this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setHarvestLevel( "axe" , 0 ); - URegistry.setIdentifiers( this , "materials" , "planks" , wood.NAME ); + CRegistry.setIdentifiers( this , "materials" , "planks" , wood.NAME ); } diff --git a/src/java/mmm/materials/MQuicksand.java b/src/java/mmm/materials/MQuicksand.java index f7a8102..af991bd 100644 --- a/src/java/mmm/materials/MQuicksand.java +++ b/src/java/mmm/materials/MQuicksand.java @@ -1,8 +1,8 @@ package mmm.materials; -import mmm.utils.I_UTrapBlock; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.blocks.I_TrapBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockFalling; import net.minecraft.block.SoundType; @@ -22,12 +22,12 @@ import net.minecraftforge.common.IPlantable; public class MQuicksand extends BlockFalling - implements I_UTrapBlock + implements I_TrapBlock { public final IBlockState forType; - public MQuicksand( String name , IBlockState forType ) + public MQuicksand( final String name , final IBlockState forType ) { super( Material.SAND ); this.forType = forType; @@ -35,7 +35,7 @@ public class MQuicksand this.setSoundType( SoundType.SAND ); this.setCreativeTab( CreativeTabs.BUILDING_BLOCKS ); this.setHarvestLevel( "shovel" , 0 ); - URegistry.setIdentifiers( this , "materials" , "trap" , name ); + CRegistry.setIdentifiers( this , "materials" , "trap" , name ); } @@ -56,7 +56,7 @@ public class MQuicksand @Override - public MapColor getMapColor( IBlockState state ) + public MapColor getMapColor( final IBlockState state ) { return this.forType.getMapColor( ); } @@ -79,8 +79,8 @@ public class MQuicksand @Override - public boolean canSustainPlant( IBlockState state , IBlockAccess world , BlockPos pos , EnumFacing direction , - IPlantable plantable ) + public boolean canSustainPlant( final IBlockState state , final IBlockAccess world , final BlockPos pos , + final EnumFacing direction , final IPlantable plantable ) { switch ( plantable.getPlantType( world , pos.offset( direction ) ) ) { diff --git a/src/java/mmm/materials/MRock.java b/src/java/mmm/materials/MRock.java index ed94cd9..fac6b8f 100644 --- a/src/java/mmm/materials/MRock.java +++ b/src/java/mmm/materials/MRock.java @@ -1,7 +1,7 @@ package mmm.materials; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.MapColor; @@ -36,8 +36,8 @@ public class MRock this.setResistance( resistance ); this.setSoundType( SoundType.STONE ); this.setHarvestLevel( "pickaxe" , harvestLevel ); - URegistry.setIdentifiers( this , "materials" , "rock" , name ); - URegistry.addBlock( this ); + CRegistry.setIdentifiers( this , "materials" , "rock" , name ); + CRegistry.addBlock( this ); } } diff --git a/src/java/mmm/materials/MRocks.java b/src/java/mmm/materials/MRocks.java index f552c86..dd7d752 100644 --- a/src/java/mmm/materials/MRocks.java +++ b/src/java/mmm/materials/MRocks.java @@ -3,10 +3,11 @@ package mmm.materials; import java.util.List; -import mmm.utils.I_UOreGenerationRegistrar; -import mmm.utils.URegistry; +import mmm.MmmMaterials; +import mmm.core.CRegistry; +import mmm.core.api.I_OreGenerationRegistrar; import mmm.world.WLocation; -import mmm.world.WLocationInBiome; +import mmm.world.WLocationInBiomeClass; import mmm.world.gen.WGOreCondition; import mmm.world.gen.WGOreParameters; import net.minecraft.block.material.MapColor; @@ -16,7 +17,7 @@ import net.minecraft.world.biome.BiomeSwamp; public class MRocks - implements I_UOreGenerationRegistrar + implements I_OreGenerationRegistrar { public final MRock LIMESTONE; @@ -25,9 +26,9 @@ public class MRocks 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.CHALK = new MRock( "chalk" , MapColor.SNOW , 0 , 1f , 5f ); @@ -41,13 +42,13 @@ public class MRocks { conditions.add( new WGOreCondition( // WLocation.inOverworld( ) , // - new WGOreParameters( Materials.ROCK.LIMESTONE , 15 , 40 ) ) ); + new WGOreParameters( MmmMaterials.ROCK.LIMESTONE , 15 , 40 ) ) ); conditions.add( new WGOreCondition( // - new WLocationInBiome<>( BiomePlains.class ) , // - new WGOreParameters( Materials.ROCK.SLATE , 15 , 40 ) ) ); + new WLocationInBiomeClass<>( BiomePlains.class ) , // + new WGOreParameters( MmmMaterials.ROCK.SLATE , 15 , 40 ) ) ); conditions.add( new WGOreCondition( // - new WLocationInBiome<>( BiomeSwamp.class ) , // - new WGOreParameters( Materials.ROCK.SLATE , 20 , 60 ) ) ); + new WLocationInBiomeClass<>( BiomeSwamp.class ) , // + new WGOreParameters( MmmMaterials.ROCK.SLATE , 20 , 60 ) ) ); } } diff --git a/src/java/mmm/materials/MSapling.java b/src/java/mmm/materials/MSapling.java index d7a101a..abca5d3 100644 --- a/src/java/mmm/materials/MSapling.java +++ b/src/java/mmm/materials/MSapling.java @@ -3,7 +3,7 @@ package mmm.materials; import java.util.Random; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.block.Block; import net.minecraft.block.IGrowable; import net.minecraft.block.SoundType; @@ -46,7 +46,7 @@ public class MSapling this.setDefaultState( this.blockState.getBaseState( ).withProperty( MSapling.STAGE , 0 ) ); - URegistry.setIdentifiers( this , "materials" , "sapling" , wood.NAME ); + CRegistry.setIdentifiers( this , "materials" , "sapling" , wood.NAME ); } diff --git a/src/java/mmm/materials/MSwampPit.java b/src/java/mmm/materials/MSwampPit.java index 7531bad..588c934 100644 --- a/src/java/mmm/materials/MSwampPit.java +++ b/src/java/mmm/materials/MSwampPit.java @@ -1,8 +1,8 @@ package mmm.materials; -import mmm.utils.I_UTintedBlock; -import mmm.utils.I_UTintedItem; +import mmm.core.api.blocks.I_TintedBlock; +import mmm.core.api.items.I_TintedItem; import net.minecraft.block.state.IBlockState; import net.minecraft.client.renderer.color.IBlockColor; import net.minecraft.client.renderer.color.IItemColor; @@ -21,7 +21,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class MSwampPit extends MQuicksand - implements I_UTintedBlock , I_UTintedItem + implements I_TintedBlock , I_TintedItem { public MSwampPit( ) @@ -40,8 +40,8 @@ public class MSwampPit @Override - public boolean canSustainPlant( IBlockState state , IBlockAccess world , BlockPos pos , EnumFacing direction , - IPlantable plantable ) + public boolean canSustainPlant( final IBlockState state , final IBlockAccess world , final BlockPos pos , + final EnumFacing direction , final IPlantable plantable ) { return false; } diff --git a/src/java/mmm/utils/UTrapBlocks.java b/src/java/mmm/materials/MTrapBlocks.java similarity index 70% rename from src/java/mmm/utils/UTrapBlocks.java rename to src/java/mmm/materials/MTrapBlocks.java index 797e7d5..c28dc3c 100644 --- a/src/java/mmm/utils/UTrapBlocks.java +++ b/src/java/mmm/materials/MTrapBlocks.java @@ -1,4 +1,4 @@ -package mmm.utils; +package mmm.materials; 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.Lists; +import mmm.core.api.blocks.I_TrapBlock; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; -public enum UTrapBlocks { +public enum MTrapBlocks { 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 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.trapTypes.put( state , block.getTrapType( ) ); this.replacements.put( state , ( (Block) block ).getDefaultState( ) ); @@ -39,11 +40,11 @@ public enum UTrapBlocks { public List< IBlockState > getReplacements( final IBlockState blockState , final String trapType ) { - ArrayList< IBlockState > out = Lists.newArrayList( ); - List< I_UTrapBlock > traps = this.traps.get( blockState ); - int nTraps = traps.size( ); + final ArrayList< IBlockState > out = Lists.newArrayList( ); + final List< I_TrapBlock > traps = this.traps.get( blockState ); + final int nTraps = traps.size( ); 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 ) ) { out.add( ( (Block) trap ).getDefaultState( ) ); } diff --git a/src/java/mmm/materials/MTraps.java b/src/java/mmm/materials/MTraps.java index 7ddd265..52b666e 100644 --- a/src/java/mmm/materials/MTraps.java +++ b/src/java/mmm/materials/MTraps.java @@ -1,7 +1,7 @@ package mmm.materials; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.block.BlockSand; import net.minecraft.init.Blocks; @@ -15,16 +15,16 @@ public class MTraps public final MMud MUD; - MTraps( ) + public MTraps( ) { // 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( ) // .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( ) // .withProperty( BlockSand.VARIANT , BlockSand.EnumType.RED_SAND ) ) ); - URegistry.addBlock( this.SWAMP_PIT = new MSwampPit( ) ); - URegistry.addBlock( this.MUD = new MMud( ) ); + CRegistry.addBlock( this.SWAMP_PIT = new MSwampPit( ) ); + CRegistry.addBlock( this.MUD = new MMud( ) ); } } diff --git a/src/java/mmm/materials/MTree.java b/src/java/mmm/materials/MTree.java index 98b2a19..f6f6d0b 100644 --- a/src/java/mmm/materials/MTree.java +++ b/src/java/mmm/materials/MTree.java @@ -3,8 +3,8 @@ package mmm.materials; import java.util.Random; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import mmm.world.trees.A_WTTreeGenerator; import net.minecraft.block.Block; import net.minecraft.block.BlockLog; @@ -25,7 +25,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class MTree - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public static interface I_SaplingChecker { @@ -215,20 +215,20 @@ public class MTree public MTree register( ) { - URegistry.addBlock( this.LOG ); - URegistry.addBlock( this.LEAVES ); - URegistry.addBlock( this.PLANKS ); - final Item sapling = URegistry.addBlock( this.SAPLING ); + CRegistry.addBlock( this.LOG ); + CRegistry.addBlock( this.LEAVES ); + CRegistry.addBlock( this.PLANKS ); + final Item sapling = CRegistry.addBlock( this.SAPLING ); if ( this.baseFlammability != 0 ) { Blocks.FIRE.setFireInfo( this.LOG , this.baseFireEncouragement , this.baseFlammability ); 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.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; } @@ -266,13 +266,13 @@ public class MTree public int getBaseFireEncouragement( ) { - return baseFireEncouragement; + return this.baseFireEncouragement; } public int getBaseFlammability( ) { - return baseFlammability; + return this.baseFlammability; } diff --git a/src/java/mmm/materials/MTrees.java b/src/java/mmm/materials/MTrees.java index b049287..8e124e4 100644 --- a/src/java/mmm/materials/MTrees.java +++ b/src/java/mmm/materials/MTrees.java @@ -3,9 +3,9 @@ package mmm.materials; import mmm.utils.UMaths; import mmm.world.trees.WTBamboo; +import mmm.world.trees.WTHevea; import mmm.world.trees.WTHeveaBig; import mmm.world.trees.WTHeveaMega; -import mmm.world.trees.WTHevea; import net.minecraft.block.material.MapColor; @@ -17,7 +17,7 @@ public class MTrees public final MTree BAMBOO; - MTrees( ) + public MTrees( ) { this.HEVEA = new MTree( "hevea" ) // .setBarkColor( MapColor.GRAY ) // diff --git a/src/java/mmm/deco/DWoodType.java b/src/java/mmm/materials/MWood.java similarity index 67% rename from src/java/mmm/deco/DWoodType.java rename to src/java/mmm/materials/MWood.java index 03c005d..0edf9ed 100644 --- a/src/java/mmm/deco/DWoodType.java +++ b/src/java/mmm/materials/MWood.java @@ -1,9 +1,7 @@ -package mmm.deco; +package mmm.materials; import mmm.Mmm; -import mmm.materials.MTree; -import mmm.materials.Materials; import net.minecraft.block.Block; import net.minecraft.block.BlockPlanks; 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( ); @@ -44,13 +32,13 @@ public abstract class DWoodType // ******************************************************************************************* public static final class Vanilla - extends DWoodType + extends MWood { private final String suffix; 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.type = type; @@ -97,13 +85,13 @@ public abstract class DWoodType // ******************************************************************************************* public static final class MmmTree - extends DWoodType + extends MWood { private final MTree materials; private final ResourceLocation slabName; - private MmmTree( final MTree materials ) + public MmmTree( final MTree materials ) { this.materials = materials; this.slabName = new ResourceLocation( Mmm.ID , "deco/slabs/" + materials.NAME ); diff --git a/src/java/mmm/materials/MWoods.java b/src/java/mmm/materials/MWoods.java new file mode 100644 index 0000000..5199294 --- /dev/null +++ b/src/java/mmm/materials/MWoods.java @@ -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 ); + } + +} diff --git a/src/java/mmm/proxy/PCommon.java b/src/java/mmm/proxy/PCommon.java deleted file mode 100644 index 4cb9caf..0000000 --- a/src/java/mmm/proxy/PCommon.java +++ /dev/null @@ -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( ); - } -} \ No newline at end of file diff --git a/src/java/mmm/proxy/PServer.java b/src/java/mmm/proxy/PServer.java deleted file mode 100644 index 8b041e8..0000000 --- a/src/java/mmm/proxy/PServer.java +++ /dev/null @@ -1,8 +0,0 @@ -package mmm.proxy; - - -public class PServer - extends PCommon -{ - // EMPTY -} \ No newline at end of file diff --git a/src/java/mmm/tech/TActivationModeMessage.java b/src/java/mmm/tech/TActivationModeMessage.java new file mode 100644 index 0000000..c2f13c0 --- /dev/null +++ b/src/java/mmm/tech/TActivationModeMessage.java @@ -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 ); + } + } + +} diff --git a/src/java/mmm/tech/Tech.java b/src/java/mmm/tech/Tech.java deleted file mode 100644 index 8621b25..0000000 --- a/src/java/mmm/tech/Tech.java +++ /dev/null @@ -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 - } - -} diff --git a/src/java/mmm/tech/base/E_TBActivationMode.java b/src/java/mmm/tech/base/E_TBActivationMode.java deleted file mode 100644 index cdf2118..0000000 --- a/src/java/mmm/tech/base/E_TBActivationMode.java +++ /dev/null @@ -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 ]; - } -} diff --git a/src/java/mmm/tech/base/I_TBConfigurableActivation.java b/src/java/mmm/tech/base/I_TBConfigurableActivation.java deleted file mode 100644 index da68d52..0000000 --- a/src/java/mmm/tech/base/I_TBConfigurableActivation.java +++ /dev/null @@ -1,12 +0,0 @@ -package mmm.tech.base; - - -public interface I_TBConfigurableActivation -{ - - public E_TBActivationMode getActivationMode( ); - - - public void setActivationMode( E_TBActivationMode mode ); - -} diff --git a/src/java/mmm/tech/base/TBActivationModeMessage.java b/src/java/mmm/tech/base/TBActivationModeMessage.java deleted file mode 100644 index f3c9650..0000000 --- a/src/java/mmm/tech/base/TBActivationModeMessage.java +++ /dev/null @@ -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 ); - } - } - -} diff --git a/src/java/mmm/tech/base/TBMachines.java b/src/java/mmm/tech/base/TBMachines.java new file mode 100644 index 0000000..551559d --- /dev/null +++ b/src/java/mmm/tech/base/TBMachines.java @@ -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 + } + +} diff --git a/src/java/mmm/tech/base/TechBase.java b/src/java/mmm/tech/base/TechBase.java deleted file mode 100644 index 5d38024..0000000 --- a/src/java/mmm/tech/base/TechBase.java +++ /dev/null @@ -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 - } - -} diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java b/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java index 8732388..fe199c7 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFBlock.java @@ -7,10 +7,11 @@ import java.util.Random; 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.URegistry; -import mmm.utils.gui.GUIUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockHorizontal; @@ -49,7 +50,7 @@ import net.minecraftforge.fml.relauncher.SideOnly; public class TBAFBlock 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_TOP = UMaths.makeBlockAABB( 4 , 10 , 4 , 12 , 16 , 12 ); @@ -80,7 +81,7 @@ public class TBAFBlock .withProperty( TBAFBlock.FACING , EnumFacing.NORTH ) // .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( ) { if ( !this.active ) { - GameRegistry.addShapedRecipe( new ItemStack( AlloyFurnace.INSTANCE.ITEM ) , // + GameRegistry.addShapedRecipe( new ItemStack( MmmTech.MACHINES.ALLOY_FURNACE.ITEM ) , // "BBB" , // "BFB" , // "BBB" , // @@ -118,9 +119,9 @@ public class TBAFBlock IBlockState nState; Block nBlock; if ( burning ) { - nBlock = AlloyFurnace.INSTANCE.ACTIVE; + nBlock = MmmTech.MACHINES.ALLOY_FURNACE.ACTIVE; } else { - nBlock = AlloyFurnace.INSTANCE.INACTIVE; + nBlock = MmmTech.MACHINES.ALLOY_FURNACE.INACTIVE; } nState = nBlock.getDefaultState( ) // .withProperty( TBAFBlock.FACING , iblockstate.getValue( TBAFBlock.FACING ) ) // @@ -261,7 +262,7 @@ public class TBAFBlock @Nullable 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( ) ) { return false; } - GUIUtils.openTileEntityGUI( playerIn , worldIn , pos ); + CGui.openTileEntityGUI( playerIn , worldIn , pos ); return true; } @@ -392,7 +393,7 @@ public class TBAFBlock InventoryHelper.dropInventoryItems( worldIn , pos , afte.fuel ); 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( ) ) { stack.setStackDisplayName( afte.getName( ) ); } diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFContainer.java b/src/java/mmm/tech/base/alloy_furnace/TBAFContainer.java index af6de17..32811c1 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFContainer.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFContainer.java @@ -1,13 +1,13 @@ 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.tech.base.E_TBActivationMode; -import mmm.tech.base.I_TBConfigurableActivation; -import mmm.tech.base.TBActivationModeMessage; +import mmm.tech.TActivationModeMessage; import mmm.utils.UInventoryDisplay; import mmm.utils.UInventoryGrid; -import mmm.utils.UNetwork; import mmm.utils.gui.UGContainer; import mmm.utils.gui.UGSlotDisplay; import mmm.utils.gui.UGSlotFuel; @@ -26,7 +26,7 @@ import net.minecraft.world.World; public class TBAFContainer extends UGContainer - implements I_TBConfigurableActivation + implements I_ConfigurableActivation { public final TBAFTileEntity tileEntity; public final World world; @@ -154,25 +154,25 @@ public class TBAFContainer @Override - public E_TBActivationMode getActivationMode( ) + public E_ActivationMode getActivationMode( ) { final TileEntity te = this.world.getTileEntity( this.position ); if ( te instanceof TBAFTileEntity ) { return ( (TBAFTileEntity) te ).getActivationMode( ); } - return E_TBActivationMode.DISABLED; + return E_ActivationMode.DISABLED; } @Override - public void setActivationMode( final E_TBActivationMode mode ) + public void setActivationMode( final E_ActivationMode mode ) { if ( this.world.isRemote ) { final TileEntity te = this.world.getTileEntity( this.position ); if ( te instanceof TBAFTileEntity ) { ( (TBAFTileEntity) te ).setActivationMode( mode ); } - UNetwork.sendToServer( new TBActivationModeMessage( mode ) ); + CNetwork.sendToServer( new TActivationModeMessage( mode ) ); } else { this.tileEntity.setActivationMode( mode ); this.tileEntity.forceUpdate( ); @@ -196,7 +196,7 @@ public class TBAFContainer final TileEntity te = this.world.getTileEntity( this.position ); if ( te instanceof TBAFTileEntity ) { ( (TBAFTileEntity) te ).flags = flags; - UNetwork.sendToServer( new TBAFMessage( flags ) ); + CNetwork.sendToServer( new TBAFMessage( flags ) ); } } else { this.tileEntity.flags = flags; diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java b/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java index ef88d39..1616c72 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java @@ -4,8 +4,8 @@ package mmm.tech.base.alloy_furnace; import java.util.ArrayList; import mmm.Mmm; +import mmm.core.CNetwork; import mmm.materials.MAlloyRecipe; -import mmm.utils.UNetwork; import mmm.utils.gui.A_UGTab; import mmm.utils.gui.A_UGTabbedContainerScreen; import mmm.utils.gui.UGArrowButton; @@ -177,7 +177,7 @@ public class TBAFGui gui.setRecipe( gui.currentRecipe - 1 ); } else if ( button == this.bConfirm ) { 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; } else { return false; @@ -342,7 +342,7 @@ public class TBAFGui } this.container.setCurrentRecipe( rName , false ); - UNetwork.sendToServer( new TBAFMessage( rName , false ) ); + CNetwork.sendToServer( new TBAFMessage( rName , false ) ); ( (RecipeTab) this.tabs[ 1 ] ).enableButtons( ); } diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFMessage.java b/src/java/mmm/tech/base/alloy_furnace/TBAFMessage.java index b1ba0f7..848a50e 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFMessage.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFMessage.java @@ -2,7 +2,7 @@ package mmm.tech.base.alloy_furnace; 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.inventory.Container; import net.minecraft.util.ResourceLocation; @@ -11,7 +11,7 @@ import net.minecraftforge.fml.common.network.ByteBufUtils; public class TBAFMessage - implements I_UMessage + implements I_Message { private static final int MT_RECIPE = 0; private static final int MT_SET_RECIPE = 1; diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFTileEntity.java b/src/java/mmm/tech/base/alloy_furnace/TBAFTileEntity.java index 353d524..4842cc3 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFTileEntity.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFTileEntity.java @@ -1,10 +1,10 @@ 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.Materials; -import mmm.tech.base.E_TBActivationMode; -import mmm.tech.base.I_TBConfigurableActivation; import mmm.utils.UInventoryGrid; import net.minecraft.block.state.IBlockState; import net.minecraft.inventory.Container; @@ -31,7 +31,7 @@ import net.minecraftforge.items.wrapper.InvWrapper; public class TBAFTileEntity extends TileEntity - implements ITickable , I_TBConfigurableActivation , IWorldNameable + implements ITickable , I_ConfigurableActivation , IWorldNameable { /** Input hopper allows invalid input? */ public static final int F_IH_INVALID = 1 << 0; @@ -100,7 +100,7 @@ public class TBAFTileEntity private int alloyCurrent; private int burnCurrent; private int burnTotal; - private E_TBActivationMode activationMode; + private E_ActivationMode activationMode; public int flags; @@ -115,7 +115,7 @@ public class TBAFTileEntity this.fuel = new FuelInventory( "Fuel" , 2 , 2 ); this.output = new Inventory( "Output" , 2 , 5 ); 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 | TBAFTileEntity.F_CMP_INPUT_VALID; @@ -230,7 +230,7 @@ public class TBAFTileEntity if ( this.alloyCurrent == 0 ) { this.addOutput( this.alloying.output ); 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; } @@ -309,14 +309,14 @@ public class TBAFTileEntity @Override - public E_TBActivationMode getActivationMode( ) + public E_ActivationMode getActivationMode( ) { return this.activationMode; } @Override - public void setActivationMode( final E_TBActivationMode mode ) + public void setActivationMode( final E_ActivationMode mode ) { this.activationMode = mode; } @@ -325,7 +325,7 @@ public class TBAFTileEntity public void cancelAlloying( ) { 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.alloyCurrent = 0; } @@ -559,16 +559,16 @@ public class TBAFTileEntity default: // XXX log case 0: - this.activationMode = E_TBActivationMode.ALWAYS_ACTIVE; + this.activationMode = E_ActivationMode.ALWAYS_ACTIVE; break; case 1: - this.activationMode = E_TBActivationMode.POWERED; + this.activationMode = E_ActivationMode.POWERED; break; case 2: - this.activationMode = E_TBActivationMode.UNPOWERED; + this.activationMode = E_ActivationMode.UNPOWERED; break; case 3: - this.activationMode = E_TBActivationMode.DISABLED; + this.activationMode = E_ActivationMode.DISABLED; break; } this.flags = compound.getShort( "Flags" ); diff --git a/src/java/mmm/tech/base/alloy_furnace/AlloyFurnace.java b/src/java/mmm/tech/base/alloy_furnace/TBAlloyFurnace.java similarity index 64% rename from src/java/mmm/tech/base/alloy_furnace/AlloyFurnace.java rename to src/java/mmm/tech/base/alloy_furnace/TBAlloyFurnace.java index 606dcb9..0dbefc5 100644 --- a/src/java/mmm/tech/base/alloy_furnace/AlloyFurnace.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAlloyFurnace.java @@ -1,9 +1,9 @@ package mmm.tech.base.alloy_furnace; -import mmm.utils.UNetwork; -import mmm.utils.URegistry; -import mmm.utils.gui.GUIUtils; +import mmm.core.CGui; +import mmm.core.CNetwork; +import mmm.core.CRegistry; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; @@ -11,10 +11,8 @@ import net.minecraftforge.fml.common.registry.GameRegistry; -public enum AlloyFurnace { - - INSTANCE; - +public class TBAlloyFurnace +{ public final CreativeTabs CREATIVE_TAB = CreativeTabs.DECORATIONS; public final TBAFBlock INACTIVE; @@ -22,7 +20,7 @@ public enum AlloyFurnace { public final Item ITEM; - private AlloyFurnace( ) + public TBAlloyFurnace( ) { this.INACTIVE = new TBAFBlock( false ); this.INACTIVE.setCreativeTab( this.CREATIVE_TAB ); @@ -33,15 +31,16 @@ public enum AlloyFurnace { this.ITEM = new ItemBlock( this.INACTIVE )// .setMaxStackSize( 16 )// .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 ); - URegistry.addBlock( this.ACTIVE , null ); + CRegistry.addBlock( this.INACTIVE , this.ITEM ); + CRegistry.addBlock( this.ACTIVE , null ); 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" ); - UNetwork.addServerMessage( TBAFMessage.class ); + CNetwork.addServerMessage( TBAFMessage.class ); } } diff --git a/src/java/mmm/tech/tools/TTArmor.java b/src/java/mmm/tech/tools/TTArmor.java index 856067a..0b78033 100644 --- a/src/java/mmm/tech/tools/TTArmor.java +++ b/src/java/mmm/tech/tools/TTArmor.java @@ -1,8 +1,8 @@ package mmm.tech.tools; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; @@ -12,13 +12,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class TTArmor extends ItemArmor - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public TTArmor( final ArmorMaterial materialIn , final EntityEquipmentSlot 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( ) ); } diff --git a/src/java/mmm/tech/tools/TTArmorSet.java b/src/java/mmm/tech/tools/TTArmorSet.java index b5a49e7..31ebc9a 100644 --- a/src/java/mmm/tech/tools/TTArmorSet.java +++ b/src/java/mmm/tech/tools/TTArmorSet.java @@ -1,7 +1,7 @@ package mmm.tech.tools; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor.ArmorMaterial; @@ -28,9 +28,9 @@ public class TTArmorSet reductionAmounts , enchantability , soundOnEquip , toughness ); this.ARMOR_MATERIAL.customCraftingMaterial = material; - URegistry.addItem( this.HELMET = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.HEAD ) ); - URegistry.addItem( this.CHESTPLATE = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.CHEST ) ); - URegistry.addItem( this.LEGGINGS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.LEGS ) ); - URegistry.addItem( this.BOOTS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.FEET ) ); + CRegistry.addItem( this.HELMET = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.HEAD ) ); + CRegistry.addItem( this.CHESTPLATE = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.CHEST ) ); + CRegistry.addItem( this.LEGGINGS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.LEGS ) ); + CRegistry.addItem( this.BOOTS = new TTArmor( this.ARMOR_MATERIAL , EntityEquipmentSlot.FEET ) ); } } diff --git a/src/java/mmm/tech/tools/TTArmors.java b/src/java/mmm/tech/tools/TTArmors.java new file mode 100644 index 0000000..dc6d472 --- /dev/null +++ b/src/java/mmm/tech/tools/TTArmors.java @@ -0,0 +1,32 @@ +package mmm.tech.tools; + + +import mmm.MmmMaterials; +import net.minecraft.init.SoundEvents; + + + +public class TTArmors +{ + public final TTArmorSet COPPER; + public final TTArmorSet BRONZE; + public final TTArmorSet STEEL; + + + public TTArmors( ) + { + this.COPPER = new TTArmorSet( "copper" , MmmMaterials.METAL.COPPER.INGOT , // + 10 , new int[] { + 1 , 3 , 4 , 1 + } , 15 , SoundEvents.ITEM_ARMOR_EQUIP_GENERIC , 0 ); + this.BRONZE = new TTArmorSet( "bronze" , MmmMaterials.ALLOY.BRONZE.INGOT , // + 13 , new int[] { + 1 , 4 , 5 , 2 + } , 20 , SoundEvents.ITEM_ARMOR_EQUIP_GENERIC , 0 ); + this.STEEL = new TTArmorSet( "steel" , MmmMaterials.ALLOY.STEEL.INGOT , // + 22 , new int[] { + 2 , 6 , 7 , 3 + } , 9 , SoundEvents.ITEM_ARMOR_EQUIP_GENERIC , 1 ); + } + +} diff --git a/src/java/mmm/tech/tools/TTAxe.java b/src/java/mmm/tech/tools/TTAxe.java index b0391dd..80181a2 100644 --- a/src/java/mmm/tech/tools/TTAxe.java +++ b/src/java/mmm/tech/tools/TTAxe.java @@ -1,8 +1,8 @@ package mmm.tech.tools; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.init.Items; import net.minecraft.item.ItemAxe; import net.minecraft.item.ItemStack; @@ -12,13 +12,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class TTAxe extends ItemAxe - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public TTAxe( final ToolMaterial material , final float damage , final float attackSpeed ) { super( material , damage , attackSpeed ); - URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "axe" ); + CRegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "axe" ); } diff --git a/src/java/mmm/tech/tools/TTHoe.java b/src/java/mmm/tech/tools/TTHoe.java index 7a4f66c..f652e66 100644 --- a/src/java/mmm/tech/tools/TTHoe.java +++ b/src/java/mmm/tech/tools/TTHoe.java @@ -1,8 +1,8 @@ package mmm.tech.tools; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.init.Items; import net.minecraft.item.ItemHoe; import net.minecraft.item.ItemStack; @@ -12,12 +12,12 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class TTHoe extends ItemHoe - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public TTHoe( final ToolMaterial material ) { super( material ); - URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "hoe" ); + CRegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "hoe" ); } diff --git a/src/java/mmm/tech/tools/TTPickaxe.java b/src/java/mmm/tech/tools/TTPickaxe.java index 4a3285c..9517d8b 100644 --- a/src/java/mmm/tech/tools/TTPickaxe.java +++ b/src/java/mmm/tech/tools/TTPickaxe.java @@ -1,8 +1,8 @@ package mmm.tech.tools; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.init.Items; import net.minecraft.item.ItemPickaxe; import net.minecraft.item.ItemStack; @@ -12,13 +12,13 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class TTPickaxe extends ItemPickaxe - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public TTPickaxe( final ToolMaterial material ) { super( material ); - URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "pickaxe" ); + CRegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "pickaxe" ); } diff --git a/src/java/mmm/tech/tools/TTShovel.java b/src/java/mmm/tech/tools/TTShovel.java index 3ca5716..15e4ce4 100644 --- a/src/java/mmm/tech/tools/TTShovel.java +++ b/src/java/mmm/tech/tools/TTShovel.java @@ -1,8 +1,8 @@ package mmm.tech.tools; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.init.Items; import net.minecraft.item.ItemSpade; import net.minecraft.item.ItemStack; @@ -12,12 +12,12 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class TTShovel extends ItemSpade - implements I_URecipeRegistrar + implements I_RecipeRegistrar { public TTShovel( final ToolMaterial material ) { super( material ); - URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "shovel" ); + CRegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "shovel" ); } diff --git a/src/java/mmm/tech/tools/TTSword.java b/src/java/mmm/tech/tools/TTSword.java index e71f8f1..4e4fc34 100644 --- a/src/java/mmm/tech/tools/TTSword.java +++ b/src/java/mmm/tech/tools/TTSword.java @@ -1,8 +1,8 @@ package mmm.tech.tools; -import mmm.utils.I_URecipeRegistrar; -import mmm.utils.URegistry; +import mmm.core.CRegistry; +import mmm.core.api.I_RecipeRegistrar; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; @@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry; public class TTSword extends ItemSword - implements I_URecipeRegistrar + implements I_RecipeRegistrar { protected final ToolMaterial material; @@ -21,7 +21,7 @@ public class TTSword { super( material ); this.material = material; - URegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "sword" ); + CRegistry.setIdentifiers( this , "tech" , "tools" , material.toString( ).toLowerCase( ) , "sword" ); } diff --git a/src/java/mmm/tech/tools/TTToolSet.java b/src/java/mmm/tech/tools/TTToolSet.java index 1d8f20c..862b67a 100644 --- a/src/java/mmm/tech/tools/TTToolSet.java +++ b/src/java/mmm/tech/tools/TTToolSet.java @@ -1,7 +1,7 @@ package mmm.tech.tools; -import mmm.utils.URegistry; +import mmm.core.CRegistry; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemAxe; @@ -17,7 +17,7 @@ import net.minecraftforge.common.util.EnumHelper; public class TTToolSet { - public final ToolMaterial TOOL_MATERIAL; + public final ToolMaterial MATERIAL; public final ItemSpade SHOVEL; public final ItemAxe AXE; @@ -31,15 +31,15 @@ public class TTToolSet final float efficiency , final float damage , final int enchantability , final float axeDamage , final float axeSpeed ) { - this.TOOL_MATERIAL = EnumHelper + this.MATERIAL = EnumHelper .addToolMaterial( name.toUpperCase( ) , harvestLevel , maxUses , efficiency , damage , enchantability )// .setRepairItem( new ItemStack( material ) ); - URegistry.addItem( this.SHOVEL = new TTShovel( this.TOOL_MATERIAL ) ); - URegistry.addItem( this.AXE = new TTAxe( this.TOOL_MATERIAL , axeDamage , axeSpeed ) ); - URegistry.addItem( this.PICKAXE = new TTPickaxe( this.TOOL_MATERIAL ) ); - URegistry.addItem( this.HOE = new TTHoe( this.TOOL_MATERIAL ) ); + CRegistry.addItem( this.SHOVEL = new TTShovel( this.MATERIAL ) ); + CRegistry.addItem( this.AXE = new TTAxe( this.MATERIAL , axeDamage , axeSpeed ) ); + CRegistry.addItem( this.PICKAXE = new TTPickaxe( this.MATERIAL ) ); + CRegistry.addItem( this.HOE = new TTHoe( this.MATERIAL ) ); - URegistry.addItem( this.SWORD = new TTSword( this.TOOL_MATERIAL ) ); + CRegistry.addItem( this.SWORD = new TTSword( this.MATERIAL ) ); } } diff --git a/src/java/mmm/tech/tools/TTTools.java b/src/java/mmm/tech/tools/TTTools.java new file mode 100644 index 0000000..956c25f --- /dev/null +++ b/src/java/mmm/tech/tools/TTTools.java @@ -0,0 +1,24 @@ +package mmm.tech.tools; + + +import mmm.MmmMaterials; + + + +public class TTTools +{ + public final TTToolSet COPPER_TOOLS; + public final TTToolSet BRONZE_TOOLS; + public final TTToolSet STEEL_TOOLS; + + + public TTTools( ) + { + this.COPPER_TOOLS = new TTToolSet( "copper" , MmmMaterials.METAL.COPPER.INGOT , // + 2 , 192 , 5.0f , 1.5f , 16 , 7 , -3 ); + this.BRONZE_TOOLS = new TTToolSet( "bronze" , MmmMaterials.ALLOY.BRONZE.INGOT , // + 2 , 212 , 5.5f , 1.75f , 20 , 7.5f , -3.1f ); + this.STEEL_TOOLS = new TTToolSet( "steel" , MmmMaterials.ALLOY.STEEL.INGOT , // + 3 , 800 , 7f , 2.5f , 12 , 8.0f , -3f ); + } +} diff --git a/src/java/mmm/tech/tools/TechTools.java b/src/java/mmm/tech/tools/TechTools.java deleted file mode 100644 index 367abf3..0000000 --- a/src/java/mmm/tech/tools/TechTools.java +++ /dev/null @@ -1,44 +0,0 @@ -package mmm.tech.tools; - - -import mmm.materials.Materials; -import net.minecraft.init.SoundEvents; - - - -public class TechTools -{ - public static final TTToolSet COPPER_TOOLS; - public static final TTArmorSet COPPER_ARMOR; - - public static final TTToolSet BRONZE_TOOLS; - public static final TTArmorSet BRONZE_ARMOR; - - public static final TTToolSet STEEL_TOOLS; - public static final TTArmorSet STEEL_ARMOR; - - static { - COPPER_TOOLS = new TTToolSet( "copper" , Materials.METAL.COPPER.INGOT , 2 , 192 , 5.0f , 1.5f , 16 , 7 , -3 ); - COPPER_ARMOR = new TTArmorSet( "copper" , Materials.METAL.COPPER.INGOT , 10 , new int[] { - 1 , 3 , 4 , 1 - } , 15 , SoundEvents.ITEM_ARMOR_EQUIP_GENERIC , 0 ); - - BRONZE_TOOLS = new TTToolSet( "bronze" , Materials.ALLOY.BRONZE.INGOT , 2 , 212 , 5.5f , 1.75f , 20 , 7.5f , - -3.1f ); - BRONZE_ARMOR = new TTArmorSet( "bronze" , Materials.ALLOY.BRONZE.INGOT , 13 , new int[] { - 1 , 4 , 5 , 2 - } , 20 , SoundEvents.ITEM_ARMOR_EQUIP_GENERIC , 0 ); - - STEEL_TOOLS = new TTToolSet( "steel" , Materials.ALLOY.STEEL.INGOT , 3 , 800 , 7f , 2.5f , 12 , 8.0f , -3f ); - STEEL_ARMOR = new TTArmorSet( "steel" , Materials.ALLOY.STEEL.INGOT , 22 , new int[] { - 2 , 6 , 7 , 3 - } , 9 , SoundEvents.ITEM_ARMOR_EQUIP_GENERIC , 1 ); - } - - - public static void preInit( ) - { - // EMPTY - } - -} diff --git a/src/java/mmm/utils/I_UBlockSeat.java b/src/java/mmm/utils/I_UBlockSeat.java deleted file mode 100644 index b073f53..0000000 --- a/src/java/mmm/utils/I_UBlockSeat.java +++ /dev/null @@ -1,7 +0,0 @@ -package mmm.utils; - - -public interface I_UBlockSeat -{ - // EMPTY -} diff --git a/src/java/mmm/utils/I_UColoredBlock.java b/src/java/mmm/utils/I_UColoredBlock.java deleted file mode 100644 index 75c7e7f..0000000 --- a/src/java/mmm/utils/I_UColoredBlock.java +++ /dev/null @@ -1,7 +0,0 @@ -package mmm.utils; - - -public interface I_UColoredBlock -{ - // EMPTY -} diff --git a/src/java/mmm/utils/I_UItemModelProvider.java b/src/java/mmm/utils/I_UItemModelProvider.java deleted file mode 100644 index cda3014..0000000 --- a/src/java/mmm/utils/I_UItemModelProvider.java +++ /dev/null @@ -1,10 +0,0 @@ -package mmm.utils; - - -public interface I_UItemModelProvider - extends I_URequiresClientPreInit -{ - - // EMPTY - -} diff --git a/src/java/mmm/utils/I_URecipeRegistrar.java b/src/java/mmm/utils/I_URecipeRegistrar.java deleted file mode 100644 index 8af9b90..0000000 --- a/src/java/mmm/utils/I_URecipeRegistrar.java +++ /dev/null @@ -1,9 +0,0 @@ -package mmm.utils; - - -public interface I_URecipeRegistrar -{ - - public void registerRecipes( ); - -} diff --git a/src/java/mmm/utils/I_URequiresClientInit.java b/src/java/mmm/utils/I_URequiresClientInit.java deleted file mode 100644 index d1a786f..0000000 --- a/src/java/mmm/utils/I_URequiresClientInit.java +++ /dev/null @@ -1,7 +0,0 @@ -package mmm.utils; - - -public interface I_URequiresClientInit -{ - // EMPTY -} diff --git a/src/java/mmm/utils/I_URequiresClientPreInit.java b/src/java/mmm/utils/I_URequiresClientPreInit.java deleted file mode 100644 index 1e4b725..0000000 --- a/src/java/mmm/utils/I_URequiresClientPreInit.java +++ /dev/null @@ -1,7 +0,0 @@ -package mmm.utils; - - -public interface I_URequiresClientPreInit -{ - // EMPTY -} diff --git a/src/java/mmm/utils/UBlockItemWithVariants.java b/src/java/mmm/utils/UBlockItemWithVariants.java index c038e90..271a737 100644 --- a/src/java/mmm/utils/UBlockItemWithVariants.java +++ b/src/java/mmm/utils/UBlockItemWithVariants.java @@ -2,6 +2,8 @@ package mmm.utils; import mmm.Mmm; +import mmm.core.CRegistry; +import mmm.core.api.items.I_ItemWithVariants; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.EnumDyeColor; @@ -13,7 +15,7 @@ import net.minecraft.util.ResourceLocation; public class UBlockItemWithVariants extends ItemBlock - implements I_UItemWithVariants + implements I_ItemWithVariants { private final String[] baseName; private String[] variants; @@ -66,7 +68,7 @@ public class UBlockItemWithVariants sbRegPath.append( this.baseName[ i ] ); } this.setRegistryName( Mmm.ID , sbRegPath.toString( ) ); - URegistry.addItem( this ); + CRegistry.addItem( this ); return this; } diff --git a/src/java/mmm/utils/UInventoryDisplay.java b/src/java/mmm/utils/UInventoryDisplay.java index 6bbe8b7..0a006a9 100644 --- a/src/java/mmm/utils/UInventoryDisplay.java +++ b/src/java/mmm/utils/UInventoryDisplay.java @@ -18,7 +18,7 @@ public class UInventoryDisplay { public final String name; public final int size; - private ItemStack[] contents; + private final ItemStack[] contents; public UInventoryDisplay( final String name , final int size ) @@ -66,21 +66,21 @@ public class UInventoryDisplay @Override - public ItemStack decrStackSize( int index , int count ) + public ItemStack decrStackSize( final int index , final int count ) { return null; } @Override - public ItemStack removeStackFromSlot( int index ) + public ItemStack removeStackFromSlot( final int index ) { return null; } @Override - public void setInventorySlotContents( int index , ItemStack stack ) + public void setInventorySlotContents( final int index , final ItemStack stack ) { this.contents[ index ] = stack; this.markDirty( ); diff --git a/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java b/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java index 93ac686..cee1c6e 100644 --- a/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java +++ b/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java @@ -54,12 +54,12 @@ public abstract class A_UGTabbedContainerScreen< CTYPE extends UGContainer > final int x = ( this.width - this.xSize ) / 2; final int y = ( this.height - this.ySize ) / 2; - for ( int tabIndex = 0 ; tabIndex < this.tabs.length ; tabIndex ++ ) { - A_UGTab tab = this.tabs[ tabIndex ]; + for ( int tabIndex = 0 ; tabIndex < this.tabs.length ; tabIndex++ ) { + final A_UGTab tab = this.tabs[ tabIndex ]; tab.buttons.clear( ); tab.initGui( x , y ); - for ( int i = 0 ; i < tab.buttons.size( ) ; i ++ ) { - tab.buttons.get( i ).visible = ( this.currentTab == tabIndex ); + for ( int i = 0 ; i < tab.buttons.size( ) ; i++ ) { + tab.buttons.get( i ).visible = this.currentTab == tabIndex; } this.buttonList.addAll( tab.buttons ); } @@ -89,7 +89,7 @@ public abstract class A_UGTabbedContainerScreen< CTYPE extends UGContainer > GlStateManager.color( 1f , 1f , 1f , 1f ); GlStateManager.enableBlend( ); GlStateManager.disableLighting( ); - this.mc.getTextureManager( ).bindTexture( GUIUtils.GUI_TEXTURE ); + this.mc.getTextureManager( ).bindTexture( UGui.GUI_TEXTURE ); for ( int tabIndex = 0 ; tabIndex < this.tabs.length ; tabIndex++ ) { if ( tabIndex != this.currentTab ) { this.drawTabBackground( tabIndex ); @@ -103,7 +103,7 @@ public abstract class A_UGTabbedContainerScreen< CTYPE extends UGContainer > GlStateManager.disableLighting( ); // Active tab - this.mc.getTextureManager( ).bindTexture( GUIUtils.GUI_TEXTURE ); + this.mc.getTextureManager( ).bindTexture( UGui.GUI_TEXTURE ); this.drawTabBackground( this.currentTab ); // Tab icons @@ -160,34 +160,34 @@ public abstract class A_UGTabbedContainerScreen< CTYPE extends UGContainer > protected boolean isInTab( final int tab , final int mouseX , final int mouseY ) { - final int tabOffsetX = tab * GUIUtils.TAB_WIDTH; - final int tabX = this.guiLeft + tabOffsetX + GUIUtils.TAB_BORDER; - final int tabY = this.guiTop - GUIUtils.TAB_HEIGHT + GUIUtils.TAB_BORDER; - return mouseX >= tabX && mouseY >= tabY && mouseX <= tabX + GUIUtils.TAB_WIDTH - && mouseY <= tabY + GUIUtils.TAB_HEIGHT; + final int tabOffsetX = tab * UGui.TAB_WIDTH; + final int tabX = this.guiLeft + tabOffsetX + UGui.TAB_BORDER; + final int tabY = this.guiTop - UGui.TAB_HEIGHT + UGui.TAB_BORDER; + return mouseX >= tabX && mouseY >= tabY && mouseX <= tabX + UGui.TAB_WIDTH + && mouseY <= tabY + UGui.TAB_HEIGHT; } protected void drawTabBackground( final int tab ) { final boolean selected = this.currentTab == tab; - final int tabOffsetX = tab * GUIUtils.TAB_WIDTH; - final int tabX = this.guiLeft + tabOffsetX + GUIUtils.TAB_BORDER; - final int tabY = this.guiTop - GUIUtils.TAB_HEIGHT + GUIUtils.TAB_BORDER; + final int tabOffsetX = tab * UGui.TAB_WIDTH; + final int tabX = this.guiLeft + tabOffsetX + UGui.TAB_BORDER; + final int tabY = this.guiTop - UGui.TAB_HEIGHT + UGui.TAB_BORDER; this.drawTexturedModalRect( tabX , tabY , // - GUIUtils.TAB_TEXTURE_X , GUIUtils.TAB_TEXTURE_Y + ( selected ? GUIUtils.TAB_HEIGHT : 0 ) , // - GUIUtils.TAB_WIDTH , GUIUtils.TAB_HEIGHT ); + UGui.TAB_TEXTURE_X , UGui.TAB_TEXTURE_Y + ( selected ? UGui.TAB_HEIGHT : 0 ) , // + UGui.TAB_WIDTH , UGui.TAB_HEIGHT ); } protected void drawTabIcon( final int tab ) { - final int tabOffsetX = tab * GUIUtils.TAB_WIDTH; - final int tabX = this.guiLeft + tabOffsetX + GUIUtils.TAB_BORDER; - final int tabY = this.guiTop - GUIUtils.TAB_HEIGHT + GUIUtils.TAB_BORDER; - this.drawTexturedModalRect( tabX + GUIUtils.TAB_ICON_X , tabY + GUIUtils.TAB_ICON_Y , // + final int tabOffsetX = tab * UGui.TAB_WIDTH; + final int tabX = this.guiLeft + tabOffsetX + UGui.TAB_BORDER; + final int tabY = this.guiTop - UGui.TAB_HEIGHT + UGui.TAB_BORDER; + this.drawTexturedModalRect( tabX + UGui.TAB_ICON_X , tabY + UGui.TAB_ICON_Y , // this.tabs[ tab ].getIconX( ) , this.tabs[ tab ].getIconY( ) , // - GUIUtils.TAB_ICON_WIDTH , GUIUtils.TAB_ICON_HEIGHT ); + UGui.TAB_ICON_WIDTH , UGui.TAB_ICON_HEIGHT ); } diff --git a/src/java/mmm/utils/gui/UGArrowButton.java b/src/java/mmm/utils/gui/UGArrowButton.java index 38693e0..27a05c3 100644 --- a/src/java/mmm/utils/gui/UGArrowButton.java +++ b/src/java/mmm/utils/gui/UGArrowButton.java @@ -18,7 +18,7 @@ public class UGArrowButton public UGArrowButton( final int buttonID , final int x , final int y , final boolean forward ) { - super( buttonID , x , y , GUIUtils.ABT_WIDTH , GUIUtils.ABT_HEIGHT , "" ); + super( buttonID , x , y , UGui.ABT_WIDTH , UGui.ABT_HEIGHT , "" ); this.forward = forward; } @@ -29,10 +29,10 @@ public class UGArrowButton if ( !this.visible ) { return; } - mc.getTextureManager( ).bindTexture( GUIUtils.GUI_TEXTURE ); + mc.getTextureManager( ).bindTexture( UGui.GUI_TEXTURE ); GlStateManager.color( 1f , 1f , 1f , 1f ); - int texX = GUIUtils.ABT_TEXTURE_X; + int texX = UGui.ABT_TEXTURE_X; if ( !this.enabled ) { texX += this.width * 2; } else if ( mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width @@ -40,7 +40,7 @@ public class UGArrowButton texX += this.width; } - int texY = GUIUtils.ABT_TEXTURE_Y; + int texY = UGui.ABT_TEXTURE_Y; if ( !this.forward ) { texY += this.height; } diff --git a/src/java/mmm/utils/gui/UGui.java b/src/java/mmm/utils/gui/UGui.java new file mode 100644 index 0000000..374b895 --- /dev/null +++ b/src/java/mmm/utils/gui/UGui.java @@ -0,0 +1,29 @@ +package mmm.utils.gui; + + +import net.minecraft.util.ResourceLocation; + + + +public enum UGui { + 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; + + public static final ResourceLocation GUI_TEXTURE = new ResourceLocation( "mmm" , "textures/gui/gui-common.png" ); + +} diff --git a/src/java/mmm/world/WDefaultGenWatcher.java b/src/java/mmm/world/WDefaultGenWatcher.java index f556f25..aabfe09 100644 --- a/src/java/mmm/world/WDefaultGenWatcher.java +++ b/src/java/mmm/world/WDefaultGenWatcher.java @@ -3,7 +3,8 @@ package mmm.world; import java.util.Random; -import mmm.world.biome.I_WBTrappedBiome; +import mmm.core.api.world.I_DefaultPopulateHandler; +import mmm.core.api.world.I_TrappedBiome; import mmm.world.gen.WGBasalt; import mmm.world.gen.WGTrapBlocks; import net.minecraft.util.math.BlockPos; @@ -24,8 +25,8 @@ public class WDefaultGenWatcher { final BlockPos bp = new BlockPos( event.getChunkX( ) * 16 , 0 , event.getChunkZ( ) * 16 ); final Biome biome = event.getWorld( ).getBiomeGenForCoords( bp ); - if ( biome instanceof I_WDefaultPopulateHandler - && ! ( (I_WDefaultPopulateHandler) biome ).onDefaultPopulate( event ) ) { + if ( biome instanceof I_DefaultPopulateHandler + && ! ( (I_DefaultPopulateHandler) biome ).onDefaultPopulate( event ) ) { event.setResult( Result.DENY ); } } @@ -51,8 +52,8 @@ public class WDefaultGenWatcher traps = new WGTrapBlocks( false , .05f ); } else if ( biome instanceof BiomeSwamp ) { traps = new WGTrapBlocks( false , .1f ); - } else if ( biome instanceof I_WBTrappedBiome ) { - traps = new WGTrapBlocks( false , ( (I_WBTrappedBiome) biome ).getTrapBlockChance( ) ); + } else if ( biome instanceof I_TrappedBiome ) { + traps = new WGTrapBlocks( false , ( (I_TrappedBiome) biome ).getTrapBlockChance( ) ); } else { return; } diff --git a/src/java/mmm/world/WLocation.java b/src/java/mmm/world/WLocation.java index af73939..010238d 100644 --- a/src/java/mmm/world/WLocation.java +++ b/src/java/mmm/world/WLocation.java @@ -1,23 +1,24 @@ package mmm.world; +import mmm.core.api.world.I_LocationCheck; import net.minecraft.world.biome.Biome; public class WLocation { - private static I_WLocationCheck inOverworld; - private static I_WLocationCheck inTheNether; + private static I_LocationCheck inOverworld; + private static I_LocationCheck inTheNether; - public static I_WLocationCheck inDimension( final int dimension ) + public static I_LocationCheck inDimension( final int dimension ) { return new WLocationInDimension( dimension ); } - public static I_WLocationCheck inOverworld( ) + public static I_LocationCheck inOverworld( ) { if ( WLocation.inOverworld == null ) { WLocation.inOverworld = WLocation.inDimension( 0 ); @@ -26,7 +27,7 @@ public class WLocation } - public static I_WLocationCheck inTheNether( ) + public static I_LocationCheck inTheNether( ) { if ( WLocation.inTheNether == null ) { WLocation.inTheNether = WLocation.inDimension( -1 ); @@ -35,8 +36,8 @@ public class WLocation } - public static < T extends Biome > WLocationInBiome< T > inBiome( final Class< T > biomeType ) + public static < T extends Biome > WLocationInBiomeClass< T > inBiome( final Class< T > biomeType ) { - return new WLocationInBiome<>( biomeType ); + return new WLocationInBiomeClass<>( biomeType ); } } diff --git a/src/java/mmm/world/WLocationInBiome.java b/src/java/mmm/world/WLocationInBiomeClass.java similarity index 75% rename from src/java/mmm/world/WLocationInBiome.java rename to src/java/mmm/world/WLocationInBiomeClass.java index f56c1b3..dc4b3ca 100644 --- a/src/java/mmm/world/WLocationInBiome.java +++ b/src/java/mmm/world/WLocationInBiomeClass.java @@ -1,6 +1,7 @@ package mmm.world; +import mmm.core.api.world.I_LocationCheck; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; @@ -8,13 +9,13 @@ import net.minecraft.world.chunk.IChunkProvider; -public class WLocationInBiome< T extends Biome > - implements I_WLocationCheck +public class WLocationInBiomeClass< T extends Biome > + implements I_LocationCheck { public final Class< T > biomeType; - public WLocationInBiome( final Class< T > biomeType ) + public WLocationInBiomeClass( final Class< T > biomeType ) { this.biomeType = biomeType; } diff --git a/src/java/mmm/world/WLocationInDimension.java b/src/java/mmm/world/WLocationInDimension.java index 098ac23..260f1d4 100644 --- a/src/java/mmm/world/WLocationInDimension.java +++ b/src/java/mmm/world/WLocationInDimension.java @@ -1,13 +1,14 @@ package mmm.world; +import mmm.core.api.world.I_LocationCheck; import net.minecraft.world.World; import net.minecraft.world.chunk.IChunkProvider; public class WLocationInDimension - implements I_WLocationCheck + implements I_LocationCheck { public final int dimension; diff --git a/src/java/mmm/world/World.java b/src/java/mmm/world/World.java deleted file mode 100644 index 9f80888..0000000 --- a/src/java/mmm/world/World.java +++ /dev/null @@ -1,124 +0,0 @@ -package mmm.world; - - -import java.util.ArrayList; - -import mmm.utils.I_UOreGenerationRegistrar; -import mmm.utils.URegistry; -import mmm.world.biome.WBBambooForest; -import mmm.world.biome.WBLimestoneMountains; -import mmm.world.biome.WBLimestonePlateau; -import mmm.world.biome.WBTropicalForest; -import mmm.world.biome.WBTropicalSwamp; -import mmm.world.gen.WGOre; -import mmm.world.gen.WGOreCondition; -import net.minecraftforge.common.BiomeManager.BiomeType; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.registry.GameRegistry; - - - -public class World -{ - - static { - final WDefaultGenWatcher dgw = new WDefaultGenWatcher( ); - MinecraftForge.TERRAIN_GEN_BUS.register( dgw ); - MinecraftForge.EVENT_BUS.register( dgw ); - - WBiomeHelper helper; - - helper = new WBiomeHelper( WBLimestoneMountains::new ); - helper.setNames( "Limestone Mountains" , "limestone/mountains" ) // - .setElevation( 1f , .5f ) // - .setWeather( .3f , .2f ) // - .setWaterColor( 0xe0ff7f ) // - .setType( BiomeType.COOL , 5 ) // - .setType( BiomeType.WARM , 2 ) // - .register( ); - helper.startMutation( ); - helper.setNames( "Limestone Mountains (T)" , "limestone/mountains/t" ) // - .setExtraProperty( "Trees" ) // - .register( ); - helper.setNames( "Limestone Mountains (TC)" , "limestone/mountains/tc" ) // - .setExtraProperty( "Chaos" ) // - .register( ); - helper.setNames( "Limestone Mountains (C)" , "limestone/mountains/c" ) // - .removeExtraProperty( "Trees" ) // - .register( ); - - helper = new WBiomeHelper( WBLimestonePlateau::new ); - helper.setNames( "Limestone Plateau" , "limestone/plateau" ) // - .setElevation( .5f , .02f ) // - .setWeather( .6f , .5f ) // - .setWaterColor( 0xe0ff7f ) // - .setType( BiomeType.COOL , 5 ) // - .setType( BiomeType.WARM , 5 ) // - .register( ); - helper.startMutation( ); - helper.setNames( "Chaotic Limestone Plateau" , "limestone/plateau/chaotic" )// - .setWeather( .8f , .5f ) // - .setElevation( .6f , .07f ) // - .setExtraProperty( "ChaosChance" , 4 ) // - .register( ); - helper.setNames( "Chaotic Limestone Forest" , "limestone/forest/chaotic" ) // - .setExtraProperty( "Trees" )// - .register( ); - helper.setNames( "Limestone Forest" , "limestone/forest" ) // - .setElevation( .5f , .02f ) // - .setWeather( .7f , .5f ) // - .removeExtraProperty( "ChaosChance" )// - .register( ); - - helper = new WBiomeHelper( WBTropicalSwamp::new ); - helper.setNames( "Tropical Swamp" , "swamp/tropical" ) // - .setElevation( -.2f , .1f ) // - .setWeather( .95f , .95f ) // - .setWaterColor( 0xe0ffae ) // Same as vanilla swamps - .setType( BiomeType.WARM , 2 ) // - .register( ); - - helper = new WBiomeHelper( WBBambooForest::new ); - helper.setNames( "Bamboo Forest" , "forest/bamboo" ) // - .setElevation( .1f , .1f ) // - .setWeather( .9f , .95f ) // - .setType( BiomeType.WARM , 3 ) // - .register( ); - helper.setNames( "Dense Bamboo Forest" , "forest/bamboo/dense" ) // - .setType( BiomeType.WARM , 1 ) // - .setExtraProperty( "Dense" ).register( ); - helper.setNames( "Bamboo Forest Hills" , "forest/bamboo/hills" ) // - .setElevation( .45f , .3f ) // - .removeExtraProperty( "Dense" ) // - .setType( BiomeType.WARM , 2 ) // - .register( ); - - helper = new WBiomeHelper( WBTropicalForest::new ); - helper.setNames( "Tropical Forest" , "forest/tropical" ) // - .setElevation( .1f , .1f ) // - .setWeather( .9f , .95f ) // - .setType( BiomeType.WARM , 2 ) // - .register( ); - helper.setNames( "Tropical Forest Hills" , "forest/tropical/hills" ) // - .setElevation( .45f , .3f ) // - .setType( BiomeType.WARM , 2 ) // - .register( ); - } - - - public static void preInit( ) - { - // EMPTY - } - - - public static void init( ) - { - final ArrayList< WGOreCondition > conditions = new ArrayList<>( ); - for ( final I_UOreGenerationRegistrar registrar : URegistry.getOreGenerationRegistrars( ) ) { - registrar.addConditions( conditions ); - } - GameRegistry.registerWorldGenerator( new WGOre( conditions ) , 0 ); - } - -} diff --git a/src/java/mmm/world/biome/A_WBLimestone.java b/src/java/mmm/world/biome/A_WBLimestone.java index 23c50ef..3fdb42d 100644 --- a/src/java/mmm/world/biome/A_WBLimestone.java +++ b/src/java/mmm/world/biome/A_WBLimestone.java @@ -6,9 +6,9 @@ import java.util.Random; import com.google.common.base.Predicate; import com.google.common.base.Predicates; -import mmm.materials.Materials; -import mmm.world.I_WBiomeWithOres; -import mmm.world.I_WDefaultPopulateHandler; +import mmm.MmmMaterials; +import mmm.core.api.world.I_BiomeWithOres; +import mmm.core.api.world.I_DefaultPopulateHandler; import mmm.world.gen.WGLimestoneLayer; import mmm.world.gen.WGOreParameters; import net.minecraft.block.state.IBlockState; @@ -24,7 +24,7 @@ import net.minecraftforge.event.terraingen.PopulateChunkEvent; public abstract class A_WBLimestone extends Biome - implements I_WDefaultPopulateHandler , I_WBiomeWithOres + implements I_DefaultPopulateHandler , I_BiomeWithOres { public A_WBLimestone( final BiomeProperties properties ) @@ -68,12 +68,13 @@ public abstract class A_WBLimestone public WGOreParameters[] getBiomeOres( final World worldIn ) { final Predicate< IBlockState > stoneOrLimestone = Predicates.or( BlockMatcher.forBlock( Blocks.STONE ) , - BlockMatcher.forBlock( Materials.ROCK.LIMESTONE ) ); + BlockMatcher.forBlock( MmmMaterials.ROCK.LIMESTONE ) ); return new WGOreParameters[] { - new WGOreParameters( Materials.ROCK.CHALK.getDefaultState( ) , 15 , 20 , // + new WGOreParameters( MmmMaterials.ROCK.CHALK.getDefaultState( ) , 15 , 20 , // worldIn.getSeaLevel( ) - 20 , 255 , // stoneOrLimestone ) , - new WGOreParameters( Materials.ORE.BAUXITE.getDefaultState( ) , 10 , 9 , 45 , 255 , stoneOrLimestone ) + new WGOreParameters( MmmMaterials.ORE.BAUXITE.getDefaultState( ) , 10 , 9 , 45 , 255 , + stoneOrLimestone ) }; } diff --git a/src/java/mmm/world/biome/I_WBTrappedBiome.java b/src/java/mmm/world/biome/I_WBTrappedBiome.java deleted file mode 100644 index ccd86ca..0000000 --- a/src/java/mmm/world/biome/I_WBTrappedBiome.java +++ /dev/null @@ -1,7 +0,0 @@ -package mmm.world.biome; - - -public interface I_WBTrappedBiome -{ - public float getTrapBlockChance( ); -} diff --git a/src/java/mmm/world/biome/WBBambooForest.java b/src/java/mmm/world/biome/WBBambooForest.java index 628df4a..4a3034f 100644 --- a/src/java/mmm/world/biome/WBBambooForest.java +++ b/src/java/mmm/world/biome/WBBambooForest.java @@ -3,8 +3,7 @@ package mmm.world.biome; import java.util.Random; -import mmm.materials.Materials; -import mmm.world.WBiomeHelper; +import mmm.MmmMaterials; import mmm.world.gen.WGBambooPatch; import mmm.world.trees.A_WTTreeGenerator; import mmm.world.trees.WTBamboo; @@ -30,13 +29,13 @@ public class WBBambooForest protected static final A_WTTreeGenerator TG_BAMBOO_BIG = new WTBamboo( true , false ); protected static final A_WTTreeGenerator TG_BAMBOO = new WTBamboo( false , false ); protected static final WorldGenShrub TG_BAMBOO_SHRUB = new WorldGenShrub( // - Materials.TREE.BAMBOO.LOG.getDefaultState( ) , // - Materials.TREE.BAMBOO.LEAVES.getDefaultState( ).withProperty( BlockLeaves.CHECK_DECAY , false ) ); + MmmMaterials.TREE.BAMBOO.LOG.getDefaultState( ) , // + MmmMaterials.TREE.BAMBOO.LEAVES.getDefaultState( ).withProperty( BlockLeaves.CHECK_DECAY , false ) ); private final int bigThreshold; - public WBBambooForest( final WBiomeHelper helper ) + public WBBambooForest( final WBBuilder helper ) { super( helper.getProperties( ) ); diff --git a/src/java/mmm/world/WBiomeHelper.java b/src/java/mmm/world/biome/WBBuilder.java similarity index 77% rename from src/java/mmm/world/WBiomeHelper.java rename to src/java/mmm/world/biome/WBBuilder.java index 6fa7e67..c3015bf 100644 --- a/src/java/mmm/world/WBiomeHelper.java +++ b/src/java/mmm/world/biome/WBBuilder.java @@ -1,4 +1,4 @@ -package mmm.world; +package mmm.world.biome; import java.util.EnumMap; @@ -14,12 +14,12 @@ import net.minecraftforge.fml.common.registry.GameRegistry; -public class WBiomeHelper +public class WBBuilder { private static final String BIOME_REG_BASE = "mmm:biome/"; - private final Function< WBiomeHelper , ? extends Biome > constructor; + private final Function< WBBuilder , ? extends Biome > constructor; private String name; private String regPath; @@ -36,21 +36,21 @@ public class WBiomeHelper private Biome.BiomeProperties cachedProperties; - public WBiomeHelper( final Function< WBiomeHelper , ? extends Biome > constructor ) + public WBBuilder( final Function< WBBuilder , ? extends Biome > constructor ) { this.constructor = constructor; } - public WBiomeHelper startMutation( ) + public WBBuilder startMutation( ) { - this.mutationBase = WBiomeHelper.BIOME_REG_BASE + this.regPath; + this.mutationBase = WBBuilder.BIOME_REG_BASE + this.regPath; this.cachedProperties = null; return this; } - public WBiomeHelper clearMutation( ) + public WBBuilder clearMutation( ) { this.mutationBase = null; this.cachedProperties = null; @@ -58,7 +58,7 @@ public class WBiomeHelper } - public WBiomeHelper setNames( final String name , final String regPath ) + public WBBuilder setNames( final String name , final String regPath ) { this.name = name; this.regPath = regPath; @@ -67,7 +67,7 @@ public class WBiomeHelper } - public WBiomeHelper setElevation( final float baseHeight , final float variation ) + public WBBuilder setElevation( final float baseHeight , final float variation ) { this.baseHeight = baseHeight; this.heightVariation = variation; @@ -76,7 +76,7 @@ public class WBiomeHelper } - public WBiomeHelper setWeather( final float rainfall , final float temperature ) + public WBBuilder setWeather( final float rainfall , final float temperature ) { this.rainfall = rainfall; this.temperature = temperature; @@ -85,7 +85,7 @@ public class WBiomeHelper } - public WBiomeHelper setWaterColor( final int filter ) + public WBBuilder setWaterColor( final int filter ) { this.waterColor = filter; this.cachedProperties = null; @@ -93,7 +93,7 @@ public class WBiomeHelper } - public WBiomeHelper setType( final BiomeType biomeType , final int weight ) + public WBBuilder setType( final BiomeType biomeType , final int weight ) { if ( weight > 0 ) { this.biomeTypes.put( biomeType , weight ); @@ -104,14 +104,14 @@ public class WBiomeHelper } - public WBiomeHelper clearTags( ) + public WBBuilder clearTags( ) { this.bdTags = null; return this; } - public WBiomeHelper setTags( final BiomeDictionary.Type... tags ) + public WBBuilder setTags( final BiomeDictionary.Type... tags ) { if ( this.bdTags == null ) { this.bdTags = new EnumMap<>( BiomeDictionary.Type.class ); @@ -123,7 +123,7 @@ public class WBiomeHelper } - public WBiomeHelper removeTags( final BiomeDictionary.Type... tags ) + public WBBuilder removeTags( final BiomeDictionary.Type... tags ) { if ( this.bdTags == null ) { return this; @@ -138,21 +138,21 @@ public class WBiomeHelper } - public WBiomeHelper setExtraProperty( final String name ) + public WBBuilder setExtraProperty( final String name ) { this.extra.put( name , name ); return this; } - public WBiomeHelper setExtraProperty( final String name , final Object value ) + public WBBuilder setExtraProperty( final String name , final Object value ) { this.extra.put( name , value ); return this; } - public WBiomeHelper removeExtraProperty( final String name ) + public WBBuilder removeExtraProperty( final String name ) { this.extra.remove( name ); return this; @@ -212,7 +212,7 @@ public class WBiomeHelper public Biome register( ) { final Biome biome = this.constructor.apply( this ); - biome.setRegistryName( WBiomeHelper.BIOME_REG_BASE + this.regPath ); + biome.setRegistryName( WBBuilder.BIOME_REG_BASE + this.regPath ); this.cachedProperties = null; GameRegistry.register( biome ); for ( final Map.Entry< BiomeType , Integer > entry : this.biomeTypes.entrySet( ) ) { diff --git a/src/java/mmm/world/biome/WBLimestoneMountains.java b/src/java/mmm/world/biome/WBLimestoneMountains.java index 17a50cb..b88deb8 100644 --- a/src/java/mmm/world/biome/WBLimestoneMountains.java +++ b/src/java/mmm/world/biome/WBLimestoneMountains.java @@ -3,12 +3,12 @@ package mmm.world.biome; import java.util.Random; -import mmm.world.WBiomeHelper; import net.minecraft.block.BlockDirt; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.world.World; +import net.minecraft.world.biome.Biome; import net.minecraft.world.chunk.ChunkPrimer; import net.minecraft.world.gen.feature.WorldGenAbstractTree; import net.minecraft.world.gen.feature.WorldGenTaiga2; @@ -30,7 +30,7 @@ public class WBLimestoneMountains private final boolean chaoticAreas; - public WBLimestoneMountains( final WBiomeHelper helper ) + public WBLimestoneMountains( final WBBuilder helper ) { super( helper.getProperties( ) ); @@ -68,7 +68,7 @@ public class WBLimestoneMountains } this.generateBiomeTerrain( worldIn , rand , chunkPrimerIn , x , z , noiseVal ); - double gcn = GRASS_COLOR_NOISE.getValue( z / 32. , x / 32. ); + final double gcn = Biome.GRASS_COLOR_NOISE.getValue( z / 32. , x / 32. ); if ( gcn > .25 && this.chaoticAreas ) { this.genChaoticArea( rand , chunkPrimerIn , x , z , (int) ( ( gcn - .25 ) * 6 ) ); } @@ -76,7 +76,7 @@ public class WBLimestoneMountains private void genChaoticArea( final Random rand , final ChunkPrimer chunkPrimerIn , final int x , final int z , - int heightMax ) + final int heightMax ) { final int chunkX = x & 15 , chunkZ = z & 15; final int groundY = this.findGround( chunkPrimerIn , chunkX , chunkZ ); diff --git a/src/java/mmm/world/biome/WBLimestonePlateau.java b/src/java/mmm/world/biome/WBLimestonePlateau.java index e1dd1c1..975b81c 100644 --- a/src/java/mmm/world/biome/WBLimestonePlateau.java +++ b/src/java/mmm/world/biome/WBLimestonePlateau.java @@ -3,7 +3,6 @@ package mmm.world.biome; import java.util.Random; -import mmm.world.WBiomeHelper; import mmm.world.gen.WGLimestoneChaos; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; @@ -24,7 +23,7 @@ public class WBLimestonePlateau private final int chaosChance; - public WBLimestonePlateau( final WBiomeHelper helper ) + public WBLimestonePlateau( final WBBuilder helper ) { super( helper.getProperties( ) ); diff --git a/src/java/mmm/world/biome/WBTropicalForest.java b/src/java/mmm/world/biome/WBTropicalForest.java index f219c38..0663bf4 100644 --- a/src/java/mmm/world/biome/WBTropicalForest.java +++ b/src/java/mmm/world/biome/WBTropicalForest.java @@ -3,8 +3,7 @@ package mmm.world.biome; import java.util.Random; -import mmm.materials.Materials; -import mmm.world.WBiomeHelper; +import mmm.MmmMaterials; import mmm.world.trees.A_WTTreeGenerator; import mmm.world.trees.WTHevea; import mmm.world.trees.WTHeveaBig; @@ -34,8 +33,8 @@ public class WBTropicalForest .withProperty( BlockOldLeaf.VARIANT , BlockPlanks.EnumType.JUNGLE ) .withProperty( BlockLeaves.CHECK_DECAY , false ); - private static final IBlockState HEVEA_LOG = Materials.TREE.HEVEA.LOG.getDefaultState( ); - private static final IBlockState HEVEA_LEAF = Materials.TREE.HEVEA.LEAVES.getDefaultState( ) // + private static final IBlockState HEVEA_LOG = MmmMaterials.TREE.HEVEA.LOG.getDefaultState( ); + private static final IBlockState HEVEA_LEAF = MmmMaterials.TREE.HEVEA.LEAVES.getDefaultState( ) // .withProperty( BlockLeaves.CHECK_DECAY , false ); private static final A_WTTreeGenerator TG_HEVEA_GIANT = new WTHeveaMega( false ); @@ -50,7 +49,7 @@ public class WBTropicalForest WBTropicalForest.JUNGLE_LOG , WBTropicalForest.JUNGLE_LEAF ); - public WBTropicalForest( final WBiomeHelper helper ) + public WBTropicalForest( final WBBuilder helper ) { super( helper ); this.theBiomeDecorator.treesPerChunk = 100; diff --git a/src/java/mmm/world/biome/WBTropicalSwamp.java b/src/java/mmm/world/biome/WBTropicalSwamp.java index 5515e07..46a6763 100644 --- a/src/java/mmm/world/biome/WBTropicalSwamp.java +++ b/src/java/mmm/world/biome/WBTropicalSwamp.java @@ -3,9 +3,9 @@ package mmm.world.biome; import java.util.Random; -import mmm.materials.Materials; -import mmm.world.I_WBiomeWithOres; -import mmm.world.WBiomeHelper; +import mmm.MmmMaterials; +import mmm.core.api.world.I_BiomeWithOres; +import mmm.core.api.world.I_TrappedBiome; import mmm.world.gen.WGBambooPatch; import mmm.world.gen.WGOreParameters; import mmm.world.trees.A_WTTreeGenerator; @@ -37,7 +37,7 @@ import net.minecraft.world.gen.feature.WorldGenerator; public class WBTropicalSwamp extends Biome - implements I_WBiomeWithOres , I_WBTrappedBiome + implements I_BiomeWithOres , I_TrappedBiome { private static final IBlockState OAK_LOG = Blocks.LOG.getDefaultState( ) // .withProperty( BlockOldLog.VARIANT , BlockPlanks.EnumType.OAK ); @@ -55,7 +55,7 @@ public class WBTropicalSwamp WBTropicalSwamp.OAK_LOG , WBTropicalSwamp.OAK_LEAF ); - public WBTropicalSwamp( final WBiomeHelper helper ) + public WBTropicalSwamp( final WBBuilder helper ) { super( helper.getProperties( ) ); @@ -123,7 +123,7 @@ public class WBTropicalSwamp public WGOreParameters[] getBiomeOres( final World world ) { return new WGOreParameters[] { - new WGOreParameters( Materials.ROCK.SLATE , 20 , 60 ) + new WGOreParameters( MmmMaterials.ROCK.SLATE , 20 , 60 ) }; } diff --git a/src/java/mmm/world/biome/WBiomes.java b/src/java/mmm/world/biome/WBiomes.java new file mode 100644 index 0000000..5256edf --- /dev/null +++ b/src/java/mmm/world/biome/WBiomes.java @@ -0,0 +1,261 @@ +package mmm.world.biome; + + +import net.minecraft.world.biome.Biome; +import net.minecraftforge.common.BiomeManager.BiomeType; + + + +public class WBiomes +{ + + // **************************************************************************** + // * MOUNTAINS + // **************************************************************************** + + public static class Mountain + { + + // **************************************************************************** + // * MOUNTAINS > LIMESTONE + // **************************************************************************** + + public static class Limestone + { + public final Biome NORMAL; + public final Biome TREES; + public final Biome CHAOTIC; + public final Biome TREES_CHAOTIC; + + + private Limestone( ) + { + final WBBuilder helper = new WBBuilder( WBLimestoneMountains::new ); + this.NORMAL = helper // + .setNames( "Limestone Mountains" , "limestone/mountains" ) // + .setElevation( 1f , .5f ) // + .setWeather( .3f , .2f ) // + .setWaterColor( 0xe0ff7f ) // + .setType( BiomeType.COOL , 5 ) // + .setType( BiomeType.WARM , 2 ) // + .register( ); + helper.startMutation( ); + this.TREES = helper // + .setNames( "Limestone Mountains (T)" , "limestone/mountains/t" ) // + .setExtraProperty( "Trees" ) // + .register( ); + this.TREES_CHAOTIC = helper // + .setNames( "Limestone Mountains (TC)" , "limestone/mountains/tc" ) // + .setExtraProperty( "Chaos" ) // + .register( ); + this.CHAOTIC = helper // + .setNames( "Limestone Mountains (C)" , "limestone/mountains/c" ) // + .removeExtraProperty( "Trees" ) // + .register( ); + } + } + + public final Limestone LIMESTONE = new Limestone( ); + + + private Mountain( ) + { + // EMPTY + } + } + + public final Mountain MOUNTAIN = new Mountain( ); + + // **************************************************************************** + // * PLATEAUS + // **************************************************************************** + + public static class Plateau + { + + // **************************************************************************** + // * PLATEAUS > LIMESTONE + // **************************************************************************** + + public static class Limestone + { + public final Biome NORMAL; + public final Biome CHAOTIC; + + + private Limestone( ) + { + final WBBuilder helper = new WBBuilder( WBLimestonePlateau::new ); + this.NORMAL = helper // + .setNames( "Limestone Plateau" , "limestone/plateau" ) // + .setElevation( .5f , .02f ) // + .setWeather( .6f , .5f ) // + .setWaterColor( 0xe0ff7f ) // + .setType( BiomeType.COOL , 5 ) // + .setType( BiomeType.WARM , 5 ) // + .register( ); + helper.startMutation( ); + this.CHAOTIC = helper // + .setNames( "Chaotic Limestone Plateau" , "limestone/plateau/chaotic" )// + .setWeather( .8f , .5f ) // + .setElevation( .6f , .07f ) // + .setExtraProperty( "ChaosChance" , 4 ) // + .register( ); + } + } + + public final Limestone LIMESTONE = new Limestone( ); + + + private Plateau( ) + { + // EMPTY + } + } + + public final Plateau PLATEAU = new Plateau( ); + + // **************************************************************************** + // * FOREST + // **************************************************************************** + + public static class Forest + { + + // **************************************************************************** + // * FOREST > LIMESTONE + // **************************************************************************** + + public static class Limestone + { + + public final Biome NORMAL; + public final Biome CHAOTIC; + + + private Limestone( ) + { + final WBBuilder helper = new WBBuilder( WBLimestonePlateau::new ); + this.NORMAL = helper // + .setNames( "Limestone Forest" , "limestone/forest" ) // + .setElevation( .5f , .02f ) // + .setWeather( .7f , .5f ) // + .setExtraProperty( "Trees" )// + .setWaterColor( 0xe0ff7f ) // + .setType( BiomeType.COOL , 5 ) // + .setType( BiomeType.WARM , 5 ) // + .register( ); + + helper.startMutation( ); + this.CHAOTIC = helper // + .setNames( "Chaotic Limestone Forest" , "limestone/forest/chaotic" ) // + .setExtraProperty( "ChaosChance" , 4 ) // + .register( ); + } + + } + + public final Limestone LIMESTONE = new Limestone( ); + + // **************************************************************************** + // * FOREST > TROPICAL + // **************************************************************************** + + public static class Tropical + { + + public final Biome NORMAL; + public final Biome HILLS; + + + private Tropical( ) + { + final WBBuilder helper = new WBBuilder( WBTropicalForest::new ); + this.NORMAL = helper // + .setNames( "Tropical Forest" , "forest/tropical" ) // + .setElevation( .1f , .1f ) // + .setWeather( .9f , .95f ) // + .setType( BiomeType.WARM , 2 ) // + .register( ); + this.HILLS = helper // + .setNames( "Tropical Forest Hills" , "forest/tropical/hills" ) // + .setElevation( .45f , .3f ) // + .setType( BiomeType.WARM , 2 ) // + .register( ); + } + + } + + public final Tropical TROPICAL = new Tropical( ); + + // **************************************************************************** + // * FOREST > BAMBOO + // **************************************************************************** + + public static class Bamboo + { + + public final Biome NORMAL; + public final Biome DENSE; + public final Biome HILLS; + + + private Bamboo( ) + { + final WBBuilder helper = new WBBuilder( WBBambooForest::new ); + this.NORMAL = helper.setNames( "Bamboo Forest" , "forest/bamboo" ) // + .setElevation( .1f , .1f ) // + .setWeather( .9f , .95f ) // + .setType( BiomeType.WARM , 3 ) // + .register( ); + this.DENSE = helper.setNames( "Dense Bamboo Forest" , "forest/bamboo/dense" ) // + .setType( BiomeType.WARM , 1 ) // + .setExtraProperty( "Dense" ).register( ); + this.HILLS = helper.setNames( "Bamboo Forest Hills" , "forest/bamboo/hills" ) // + .setElevation( .45f , .3f ) // + .removeExtraProperty( "Dense" ) // + .setType( BiomeType.WARM , 2 ) // + .register( ); + } + + } + + public final Bamboo BAMBOO = new Bamboo( ); + + + private Forest( ) + { + // EMPTY + } + + } + + public final Forest FOREST = new Forest( ); + + // **************************************************************************** + // * SWAMP + // **************************************************************************** + + public static class Swamp + { + public final Biome TROPICAL; + + + private Swamp( ) + { + WBBuilder helper; + helper = new WBBuilder( WBTropicalSwamp::new ); + this.TROPICAL = helper // + .setNames( "Tropical Swamp" , "swamp/tropical" ) // + .setElevation( -.2f , .1f ) // + .setWeather( .95f , .95f ) // + .setWaterColor( 0xe0ffae ) // Same as vanilla swamps + .setType( BiomeType.WARM , 2 ) // + .register( ); + + } + + } + + public final Swamp SWAMP = new Swamp( ); +} diff --git a/src/java/mmm/world/gen/WGBambooPatch.java b/src/java/mmm/world/gen/WGBambooPatch.java index 5fade71..5ff8f28 100644 --- a/src/java/mmm/world/gen/WGBambooPatch.java +++ b/src/java/mmm/world/gen/WGBambooPatch.java @@ -6,7 +6,7 @@ import java.util.Random; import com.google.common.collect.Lists; -import mmm.materials.Materials; +import mmm.MmmMaterials; import mmm.world.trees.A_WTTreeGenerator; import mmm.world.trees.WTBamboo; import net.minecraft.block.material.Material; @@ -92,7 +92,7 @@ public class WGBambooPatch l = l.up( ); } while ( world.getBlockState( l ).getMaterial( ) != Material.AIR ); } - if ( !Materials.TREE.BAMBOO.canSaplingStay( world , l ) ) { + if ( !MmmMaterials.TREE.BAMBOO.canSaplingStay( world , l ) ) { continue; } @@ -110,7 +110,7 @@ public class WGBambooPatch if ( rnd <= wa ) { WGBambooPatch.TG_BAMBOO_BIG.generate( world , rand , l ); } else if ( rnd <= 10 ) { - this.setBlockAndNotifyAdequately( world , l , Materials.TREE.BAMBOO.SAPLING.getDefaultState( ) ); + this.setBlockAndNotifyAdequately( world , l , MmmMaterials.TREE.BAMBOO.SAPLING.getDefaultState( ) ); } else { WGBambooPatch.TG_BAMBOO.generate( world , rand , l ); } @@ -130,7 +130,7 @@ public class WGBambooPatch for ( int x = -1 ; x <= 1 ; x++ ) { for ( int z = -1 ; z <= 1 ; z++ ) { if ( ( x != 0 || z != 0 ) - && Materials.TREE.BAMBOO.canSaplingStay( world , position.add( x , 1 , z ) ) ) { + && MmmMaterials.TREE.BAMBOO.canSaplingStay( world , position.add( x , 1 , z ) ) ) { return true; } } diff --git a/src/java/mmm/world/gen/WGBasalt.java b/src/java/mmm/world/gen/WGBasalt.java index b91ed19..28c020e 100644 --- a/src/java/mmm/world/gen/WGBasalt.java +++ b/src/java/mmm/world/gen/WGBasalt.java @@ -3,7 +3,7 @@ package mmm.world.gen; import java.util.Random; -import mmm.materials.Materials; +import mmm.MmmMaterials; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; @@ -16,7 +16,7 @@ import net.minecraft.world.gen.feature.WorldGenerator; public class WGBasalt extends WorldGenerator { - private static final IBlockState BS_BASALT = Materials.ROCK.BASALT.getDefaultState( ); + private static final IBlockState BS_BASALT = MmmMaterials.ROCK.BASALT.getDefaultState( ); public WGBasalt( final boolean notify ) @@ -92,7 +92,7 @@ public class WGBasalt mbps.setPos( mbp.getX( ) + i , yb , mbp.getZ( ) + j ); // System.err.println( "pos = " + mbps ); - if ( Materials.isRock( world.getBlockState( mbps ) ) ) { + if ( MmmMaterials.isRock( world.getBlockState( mbps ) ) ) { rockNearLava[ offset ] = true; } } diff --git a/src/java/mmm/world/gen/WGLimestoneChaos.java b/src/java/mmm/world/gen/WGLimestoneChaos.java index 3e51f73..02f4d62 100644 --- a/src/java/mmm/world/gen/WGLimestoneChaos.java +++ b/src/java/mmm/world/gen/WGLimestoneChaos.java @@ -3,7 +3,7 @@ package mmm.world.gen; import java.util.Random; -import mmm.materials.Materials; +import mmm.MmmMaterials; import net.minecraft.block.BlockDirt; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; @@ -18,7 +18,7 @@ public class WGLimestoneChaos extends WorldGenerator { - private static final IBlockState BS_LIMESTONE = Materials.ROCK.LIMESTONE.getDefaultState( ); + private static final IBlockState BS_LIMESTONE = MmmMaterials.ROCK.LIMESTONE.getDefaultState( ); private static final IBlockState BS_STONE = Blocks.STONE.getDefaultState( ); private static final IBlockState BS_AIR = Blocks.AIR.getDefaultState( ); private static final IBlockState BS_COARSE_DIRT = Blocks.DIRT.getDefaultState( ).withProperty( BlockDirt.VARIANT , diff --git a/src/java/mmm/world/gen/WGLimestoneLayer.java b/src/java/mmm/world/gen/WGLimestoneLayer.java index 1782d3b..486dbff 100644 --- a/src/java/mmm/world/gen/WGLimestoneLayer.java +++ b/src/java/mmm/world/gen/WGLimestoneLayer.java @@ -3,7 +3,7 @@ package mmm.world.gen; import java.util.Random; -import mmm.materials.Materials; +import mmm.MmmMaterials; import net.minecraft.block.BlockDirt; import net.minecraft.block.BlockStone; import net.minecraft.block.state.IBlockState; @@ -32,7 +32,7 @@ public class WGLimestoneLayer private static final IBlockState BS_GRAVEL = Blocks.GRAVEL.getDefaultState( ); - private static final IBlockState BS_LIMESTONE = Materials.ROCK.LIMESTONE.getDefaultState( ); + private static final IBlockState BS_LIMESTONE = MmmMaterials.ROCK.LIMESTONE.getDefaultState( ); @Override diff --git a/src/java/mmm/world/gen/WGOre.java b/src/java/mmm/world/gen/WGOre.java index b9e3fbd..0fb30c0 100644 --- a/src/java/mmm/world/gen/WGOre.java +++ b/src/java/mmm/world/gen/WGOre.java @@ -4,7 +4,7 @@ package mmm.world.gen; import java.util.ArrayList; import java.util.Random; -import mmm.world.I_WBiomeWithOres; +import mmm.core.api.world.I_BiomeWithOres; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; @@ -32,8 +32,8 @@ public class WGOre final IChunkGenerator chunkGenerator , final IChunkProvider chunkProvider ) { final Biome biome = world.getBiomeGenForCoords( new BlockPos( chunkX * 16 , 0 , chunkZ * 16 ) ); - if ( biome instanceof I_WBiomeWithOres ) { - for ( final WGOreParameters parameters : ( (I_WBiomeWithOres) biome ).getBiomeOres( world ) ) { + if ( biome instanceof I_BiomeWithOres ) { + for ( final WGOreParameters parameters : ( (I_BiomeWithOres) biome ).getBiomeOres( world ) ) { parameters.generate( world , random , chunkX , chunkZ ); } } diff --git a/src/java/mmm/world/gen/WGOreCondition.java b/src/java/mmm/world/gen/WGOreCondition.java index 817cc66..567c53a 100644 --- a/src/java/mmm/world/gen/WGOreCondition.java +++ b/src/java/mmm/world/gen/WGOreCondition.java @@ -1,15 +1,18 @@ package mmm.world.gen; -import mmm.world.I_WLocationCheck; + +import mmm.core.api.world.I_LocationCheck; + + public class WGOreCondition { - public final I_WLocationCheck conditions; + public final I_LocationCheck conditions; public final WGOreParameters parameters; - public WGOreCondition( final I_WLocationCheck conditions , final WGOreParameters parameters ) + public WGOreCondition( final I_LocationCheck conditions , final WGOreParameters parameters ) { this.conditions = conditions; this.parameters = parameters; diff --git a/src/java/mmm/world/gen/WGTrapBlocks.java b/src/java/mmm/world/gen/WGTrapBlocks.java index 17cd698..5643a72 100644 --- a/src/java/mmm/world/gen/WGTrapBlocks.java +++ b/src/java/mmm/world/gen/WGTrapBlocks.java @@ -7,7 +7,7 @@ import java.util.Random; import com.google.common.collect.Lists; -import mmm.utils.UTrapBlocks; +import mmm.materials.MTrapBlocks; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; @@ -49,7 +49,7 @@ public class WGTrapBlocks final int minDepth = Math.max( 0 , worldIn.getSeaLevel( ) - 20 ); boolean found = false; while ( check.getY( ) > minDepth ) { - IBlockState bs = worldIn.getBlockState( check ); + final IBlockState bs = worldIn.getBlockState( check ); final Material material = bs.getMaterial( ); if ( material.isLiquid( ) ) { return false; @@ -70,9 +70,9 @@ public class WGTrapBlocks } // Find possible trap types - BlockPos bp = new BlockPos( check ); - int sqr = radius * radius; - ArrayList< String > types = Lists.newArrayList( ); + final BlockPos bp = new BlockPos( check ); + final int sqr = radius * radius; + final ArrayList< String > types = Lists.newArrayList( ); for ( int x = -radius ; x <= radius ; x++ ) { for ( int y = -radius ; y <= radius ; y++ ) { for ( int z = -radius ; z <= radius ; z++ ) { @@ -82,8 +82,8 @@ public class WGTrapBlocks final BlockPos pos = bp.add( x , y , z ); final IBlockState atPos = worldIn.getBlockState( pos ); - final List< String > trapTypes = UTrapBlocks.INSTANCE.getTrapTypes( atPos ); - for ( String rep : trapTypes ) { + final List< String > trapTypes = MTrapBlocks.INSTANCE.getTrapTypes( atPos ); + for ( final String rep : trapTypes ) { if ( !types.contains( rep ) ) { types.add( rep ); } @@ -95,7 +95,7 @@ public class WGTrapBlocks return false; } - String trapType = types.get( rand.nextInt( types.size( ) ) ); + final String trapType = types.get( rand.nextInt( types.size( ) ) ); for ( int x = -radius ; x <= radius ; x++ ) { for ( int y = -radius ; y <= radius ; y++ ) { for ( int z = -radius ; z <= radius ; z++ ) { @@ -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 = UTrapBlocks.INSTANCE.getReplacements( atPos , trapType ); + final List< IBlockState > replacements = MTrapBlocks.INSTANCE.getReplacements( atPos , trapType ); final int nReplacements = replacements.size( ); if ( nReplacements == 0 ) { continue; diff --git a/src/java/mmm/world/trees/WTBamboo.java b/src/java/mmm/world/trees/WTBamboo.java index 32ce6bc..f177ca9 100644 --- a/src/java/mmm/world/trees/WTBamboo.java +++ b/src/java/mmm/world/trees/WTBamboo.java @@ -3,8 +3,8 @@ package mmm.world.trees; import java.util.Random; +import mmm.MmmMaterials; import mmm.materials.MTree; -import mmm.materials.Materials; import net.minecraft.block.BlockLeaves; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; @@ -26,11 +26,11 @@ public class WTBamboo public WTBamboo( final boolean big , final boolean notify ) { - this( big , notify , Materials.TREE.BAMBOO ); + this( big , notify , MmmMaterials.TREE.BAMBOO ); } - private WTBamboo( final boolean big , final boolean notify , MTree materials ) + private WTBamboo( final boolean big , final boolean notify , final MTree materials ) { super( notify , materials ); this.minHeight = big ? 13 : 5; diff --git a/src/java/mmm/world/trees/WTHevea.java b/src/java/mmm/world/trees/WTHevea.java index e4980ca..0d112bd 100644 --- a/src/java/mmm/world/trees/WTHevea.java +++ b/src/java/mmm/world/trees/WTHevea.java @@ -3,7 +3,7 @@ package mmm.world.trees; import java.util.Random; -import mmm.materials.Materials; +import mmm.MmmMaterials; import net.minecraft.block.BlockLeaves; import net.minecraft.block.state.IBlockState; import net.minecraft.util.math.BlockPos; @@ -22,7 +22,7 @@ public class WTHevea public WTHevea( final boolean notify ) { - super( notify , Materials.TREE.HEVEA ); + super( notify , MmmMaterials.TREE.HEVEA ); } diff --git a/src/java/mmm/world/trees/WTHeveaMega.java b/src/java/mmm/world/trees/WTHeveaMega.java index 32e0bce..9cb7e13 100644 --- a/src/java/mmm/world/trees/WTHeveaMega.java +++ b/src/java/mmm/world/trees/WTHeveaMega.java @@ -3,8 +3,8 @@ package mmm.world.trees; import java.util.Random; +import mmm.MmmMaterials; import mmm.materials.MTree; -import mmm.materials.Materials; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockLog; import net.minecraft.block.state.IBlockState; @@ -60,7 +60,7 @@ public class WTHeveaMega public WTHeveaMega( final boolean notify ) { - super( notify , Materials.TREE.HEVEA ); + super( notify , MmmMaterials.TREE.HEVEA ); }