mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-18 19:29:17 +00:00
Clean Up and Add Comments
A clean up and I add crates with the new blocks from 1.8.
This commit is contained in:
1 parent
02ec97b031
commit
801c6dff92
12 files changed
+413
-38
No files matched your search
@@ -76,6 +76,7 @@ public class BlockForestryLeaves extends BlockLeavesBase implements ITileEntityP
|
||||
public BlockForestryLeaves() {
|
||||
super(Material.leaves, false);
|
||||
this.setCreativeTab(Tabs.tabArboriculture);
|
||||
setStepSound(soundTypeGrass);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ModelLeaves extends ModelBlockOverlay<BlockForestryLeaves> {
|
||||
}
|
||||
|
||||
// Render the plain leaf block.
|
||||
baker.renderStandardBlock(block, pos, tile.getLeaveSprite(Proxies.render.fancyGraphicsEnabled()));
|
||||
baker.renderStandardBlock(block, pos, tile.getLeaveSprite(Proxies.render.fancyGraphicsEnabled()), 0);
|
||||
|
||||
// Render overlay for fruit leaves.
|
||||
TextureAtlasSprite fruitSprite = tile.getFruitSprite();
|
||||
|
||||
@@ -13,7 +13,10 @@ import forestry.core.render.StateMapperForestry;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class StateMapperSapling extends StateMapperForestry {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,9 @@ import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.model.IColoredBakedQuad;
|
||||
|
||||
/**
|
||||
* A model baker to make custom models in the mod
|
||||
*/
|
||||
public class ModelBaker implements IModelBaker {
|
||||
|
||||
protected double renderMinX;
|
||||
@@ -77,10 +80,10 @@ public class ModelBaker implements IModelBaker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, BlockPos pos, TextureAtlasSprite[] textures) {
|
||||
public boolean renderStandardBlock(Block block, BlockPos pos, TextureAtlasSprite[] textures, int colorIndex) {
|
||||
setRenderBoundsFromBlock(block);
|
||||
|
||||
setColorIndex(0);
|
||||
setColorIndex(colorIndex);
|
||||
|
||||
renderFaceXNeg(pos, textures[EnumFacing.WEST.ordinal()]);
|
||||
renderFaceXPos(pos, textures[EnumFacing.EAST.ordinal()]);
|
||||
@@ -93,10 +96,10 @@ public class ModelBaker implements IModelBaker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderStandardBlock(Block block, BlockPos pos, TextureAtlasSprite texture) {
|
||||
public boolean renderStandardBlock(Block block, BlockPos pos, TextureAtlasSprite texture, int colorIndex) {
|
||||
setRenderBoundsFromBlock(block);
|
||||
|
||||
setColorIndex(0);
|
||||
setColorIndex(colorIndex);
|
||||
|
||||
renderFaceXNeg(pos, texture);
|
||||
renderFaceXPos(pos, texture);
|
||||
|
||||
@@ -29,6 +29,9 @@ import forestry.api.core.IModelBaker;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockAccess;
|
||||
import forestry.core.blocks.propertys.UnlistedBlockPos;
|
||||
|
||||
/**
|
||||
* A ovelay block model to make a block with 2 or more layers
|
||||
*/
|
||||
public abstract class ModelBlockOverlay<B extends Block> implements ISmartItemModel, ISmartBlockModel {
|
||||
|
||||
protected void renderBottomFace(IBlockAccess world, B block, BlockPos pos, IModelBaker baker, TextureAtlasSprite sprite, int colorIndex) {
|
||||
@@ -173,9 +176,9 @@ public abstract class ModelBlockOverlay<B extends Block> implements ISmartItemMo
|
||||
|
||||
return baker.bakeModel(true);
|
||||
}
|
||||
|
||||
protected abstract void renderInventory(B block, ItemStack item, IModelBaker baker);
|
||||
|
||||
protected abstract void renderInventory(B block, ItemStack item, IModelBaker renderer);
|
||||
|
||||
protected abstract boolean renderInWorld(B block, IBlockAccess world, BlockPos pos, IModelBaker renderer);
|
||||
protected abstract boolean renderInWorld(B block, IBlockAccess world, BlockPos pos, IModelBaker baker);
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class ModelCrate implements IModelCustomData{
|
||||
* @param modID The modId of the creat item
|
||||
* @param location The location of the model from the contained item
|
||||
*/
|
||||
public ModelCrate(ModelResourceLocation baseLocation, EnumWorldBlockLayer containedLayer, String UID, String modID, ResourceLocation location){
|
||||
private ModelCrate(ModelResourceLocation baseLocation, EnumWorldBlockLayer containedLayer, String UID, String modID, ResourceLocation location){
|
||||
this.baseLocation = baseLocation;
|
||||
this.containedLayer = containedLayer;
|
||||
this.containedUID = UID;
|
||||
@@ -71,6 +71,11 @@ public class ModelCrate implements IModelCustomData{
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param loc The location of the model
|
||||
* @return A model from the {@link ModelLoaderRegistry}
|
||||
*/
|
||||
private static IModel getModel(ResourceLocation loc){
|
||||
IModel model;
|
||||
try{
|
||||
@@ -83,6 +88,9 @@ public class ModelCrate implements IModelCustomData{
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* To bake the base and the contained model
|
||||
*/
|
||||
private static ImmutableMap<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> buildModels(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, IModel crateModel, ModelCrate modelToBake){
|
||||
ImmutableMap.Builder<Optional<EnumWorldBlockLayer>, IFlexibleBakedModel> builder = ImmutableMap.builder();
|
||||
|
||||
@@ -104,7 +112,7 @@ public class ModelCrate implements IModelCustomData{
|
||||
IModel missing = ModelLoaderRegistry.getMissingModel();
|
||||
IModel creat;
|
||||
try {
|
||||
creat = ModelLoaderRegistry.getModel(new ModelResourceLocation(modID + ":" + "crates", containedUID));
|
||||
creat = ModelLoaderRegistry.getModel(new ModelResourceLocation(modID + ":crates", containedUID));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return missing.bake(state, format, bakedTextureGetter);
|
||||
@@ -125,6 +133,9 @@ public class ModelCrate implements IModelCustomData{
|
||||
return TRSRTransformation.identity();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a crate model from the customData
|
||||
*/
|
||||
@Override
|
||||
public IModel process(ImmutableMap<String, String> customData){
|
||||
ImmutableMap.Builder<Optional<EnumWorldBlockLayer>, ModelResourceLocation> builder = ImmutableMap.builder();
|
||||
@@ -156,7 +167,10 @@ public class ModelCrate implements IModelCustomData{
|
||||
}
|
||||
}
|
||||
}
|
||||
if(baseLocation == null || layer == null || location == null || UID == null || modID == null) {
|
||||
if(modID == null){
|
||||
modID = "forestry";
|
||||
}
|
||||
if(baseLocation == null || layer == null || location == null || UID == null) {
|
||||
return instance;
|
||||
}
|
||||
return new ModelCrate(baseLocation, layer, UID, modID, location);
|
||||
@@ -182,6 +196,9 @@ public class ModelCrate implements IModelCustomData{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The model loader to load crate models from the blockstate file
|
||||
*/
|
||||
public static enum Loader implements ICustomModelLoader{
|
||||
instance;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
public class ModelFarmBlock extends ModelBlockOverlay<BlockFarm> {
|
||||
|
||||
@Override
|
||||
public void renderInventory(BlockFarm blockFarm, ItemStack item, IModelBaker backer) {
|
||||
public void renderInventory(BlockFarm blockFarm, ItemStack item, IModelBaker baker) {
|
||||
if (blockFarm == null) {
|
||||
return;
|
||||
}
|
||||
@@ -23,29 +23,29 @@ public class ModelFarmBlock extends ModelBlockOverlay<BlockFarm> {
|
||||
TextureAtlasSprite[] sprites = getSprites(type);
|
||||
TextureAtlasSprite[] overlaySprites = getOverlaySprites(EnumFarmBlockType.VALUES[item.getItemDamage()]);
|
||||
|
||||
backer.renderFaceYNeg(null, sprites[0]);
|
||||
backer.renderFaceYNeg(null, overlaySprites[0]);
|
||||
baker.renderFaceYNeg(null, sprites[0]);
|
||||
baker.renderFaceYNeg(null, overlaySprites[0]);
|
||||
|
||||
backer.renderFaceYPos(null, sprites[1]);
|
||||
backer.renderFaceYPos(null, overlaySprites[1]);
|
||||
baker.renderFaceYPos(null, sprites[1]);
|
||||
baker.renderFaceYPos(null, overlaySprites[1]);
|
||||
|
||||
backer.renderFaceZNeg(null, sprites[2]);
|
||||
backer.renderFaceZNeg(null, overlaySprites[2]);
|
||||
baker.renderFaceZNeg(null, sprites[2]);
|
||||
baker.renderFaceZNeg(null, overlaySprites[2]);
|
||||
|
||||
backer.renderFaceZPos(null, sprites[3]);
|
||||
backer.renderFaceZPos(null, overlaySprites[3]);
|
||||
baker.renderFaceZPos(null, sprites[3]);
|
||||
baker.renderFaceZPos(null, overlaySprites[3]);
|
||||
|
||||
backer.renderFaceXNeg(null, sprites[4]);
|
||||
backer.renderFaceXNeg(null, overlaySprites[4]);
|
||||
baker.renderFaceXNeg(null, sprites[4]);
|
||||
baker.renderFaceXNeg(null, overlaySprites[4]);
|
||||
|
||||
backer.renderFaceXPos(null, sprites[5]);
|
||||
backer.renderFaceXPos(null, overlaySprites[5]);
|
||||
baker.renderFaceXPos(null, sprites[5]);
|
||||
baker.renderFaceXPos(null, overlaySprites[5]);
|
||||
|
||||
blockFarm.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderInWorld(BlockFarm blockFarm, IBlockAccess world, BlockPos pos, IModelBaker backer) {
|
||||
public boolean renderInWorld(BlockFarm blockFarm, IBlockAccess world, BlockPos pos, IModelBaker baker) {
|
||||
|
||||
TileFarm farm = (TileFarm) world.getTileEntity(pos);
|
||||
|
||||
@@ -53,8 +53,8 @@ public class ModelFarmBlock extends ModelBlockOverlay<BlockFarm> {
|
||||
TextureAtlasSprite[] texturesOverlay = getOverlaySprites(farm.getFarmBlockType());
|
||||
|
||||
// Render the plain block.
|
||||
backer.renderStandardBlock(blockFarm, pos, textures);
|
||||
renderFarmOverlay(world, blockFarm, pos, backer, texturesOverlay);
|
||||
baker.renderStandardBlock(blockFarm, pos, textures, 0);
|
||||
renderFarmOverlay(world, blockFarm, pos, baker, texturesOverlay);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,13 @@ public class PluginCore extends ForestryPlugin {
|
||||
crateRegistry.registerCrate(Blocks.cobblestone, "cratedCobblestone");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.dirt, 1, 0), "cratedDirt");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.dirt, 1, 2), "cratedPodzol");
|
||||
crateRegistry.registerCrate(Blocks.stone, "cratedStone");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.stone, 1, 0), "cratedStone");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.stone, 1, 1), "cratedGranite");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.stone, 1, 3), "cratedDiorite");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.stone, 1, 5), "cratedAndesite");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.prismarine, 1, 0), "cratedPrismarine");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.prismarine, 1, 1), "cratedPrismarinebrick");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.prismarine, 1, 2), "cratedPrismarinedark");
|
||||
crateRegistry.registerCrate(Blocks.brick_block, "cratedBrick");
|
||||
crateRegistry.registerCrate(Blocks.cactus, "cratedCacti");
|
||||
crateRegistry.registerCrate(new ItemStack(Blocks.sand, 1, 0), "cratedSand");
|
||||
|
||||
@@ -272,6 +272,8 @@ public class PluginFactory extends ForestryPlugin {
|
||||
int appleJuiceAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.apple");
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.apple)}, Fluids.JUICE.getFluid(appleJuiceAmount),
|
||||
PluginCore.items.mulch.getItemStack(), appleMulchAmount);
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{new ItemStack(Items.carrot)}, Fluids.JUICE.getFluid(appleJuiceAmount),
|
||||
PluginCore.items.mulch.getItemStack(), appleMulchAmount);
|
||||
|
||||
int seedOilAmount = ForestryAPI.activeMode.getIntegerSetting("squeezer.liquid.seed");
|
||||
FluidStack seedOil = Fluids.SEEDOIL.getFluid(seedOilAmount);
|
||||
@@ -303,6 +305,7 @@ public class PluginFactory extends ForestryPlugin {
|
||||
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.cactus), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.cactus"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Items.wheat), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Items.potato), (2 * ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.wheat")), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Items.reeds), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.cane"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.brown_mushroom), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.mushroom"), Fluids.BIOMASS);
|
||||
RecipeUtil.addFermenterRecipes(new ItemStack(Blocks.red_mushroom), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.mushroom"), Fluids.BIOMASS);
|
||||
|
||||
@@ -37,6 +37,7 @@ import forestry.farming.logic.FarmableGenericSapling;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.Plugin;
|
||||
import forestry.plugins.PluginCore;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
@Plugin(pluginID = "BiomesOPlenty", name = "BiomesOPlenty", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.plugin.biomesoplenty.description")
|
||||
public class PluginBiomesOPlenty extends ForestryPlugin {
|
||||
@@ -97,12 +98,12 @@ public class PluginBiomesOPlenty extends ForestryPlugin {
|
||||
FMLInterModComms.sendMessage(Constants.MOD, "add-farmable-sapling", String.format("farmArboreal@%s.-1", saplingName));
|
||||
}
|
||||
|
||||
if (saplings != null && persimmon != null) {
|
||||
if (PluginManager.Module.FARMING.isEnabled() && saplings != null && persimmon != null) {
|
||||
Farmables.farmables.get("farmArboreal").add(new FarmableGenericSapling(saplings, 15, persimmon));
|
||||
}
|
||||
|
||||
Block boPTurnip = GameRegistry.findBlock(BoP, "turnip");
|
||||
if (boPTurnip != null) {
|
||||
if (PluginManager.Module.FARMING.isEnabled() && boPTurnip != null) {
|
||||
Item boPTurnipSeeds = GameRegistry.findItem(BoP, "turnipSeeds");
|
||||
if (boPTurnipSeeds != null) {
|
||||
Farmables.farmables.get("farmVegetables").add(new FarmableGenericCrop(new ItemStack(boPTurnipSeeds, 1, 0), boPTurnip, 7));
|
||||
|
||||
@@ -37,6 +37,7 @@ import forestry.farming.logic.FarmableGenericCrop;
|
||||
import forestry.plugins.ForestryPlugin;
|
||||
import forestry.plugins.Plugin;
|
||||
import forestry.plugins.PluginCore;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
@Plugin(pluginID = "Natura", name = "Natura", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.plugin.natura.description")
|
||||
public class PluginNatura extends ForestryPlugin {
|
||||
@@ -220,9 +221,11 @@ public class PluginNatura extends ForestryPlugin {
|
||||
RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[]{aSeedList}, Fluids.SEEDOIL.getFluid(amount));
|
||||
}
|
||||
|
||||
Block cropBlock = GameRegistry.findBlock(NATURA, "N Crops");
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedBarley, cropBlock, 3));
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedCotton, cropBlock, 8));
|
||||
if(PluginManager.Module.FARMING.isEnabled()){
|
||||
Block cropBlock = GameRegistry.findBlock(NATURA, "N Crops");
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedBarley, cropBlock, 3));
|
||||
Farmables.farmables.get("farmWheat").add(new FarmableGenericCrop(seedCotton, cropBlock, 8));
|
||||
}
|
||||
|
||||
List<ItemStack> berries = new ArrayList<>();
|
||||
if (berryBlight != null) {
|
||||
|
||||
Reference in new issue
Block a user