mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-20 12:09:39 +00:00
Add grammars for wood products, generalize for new trees
This commit is contained in:
1 parent
e8fa5ebca9
commit
9af62513e5
10 files changed
+123
-67
No files matched your search
@@ -92,4 +92,9 @@ public enum WoodType {
|
||||
return WoodType.LARCH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class BlockArbFence extends BlockFence implements IWoodTyped {
|
||||
CAT0, CAT1
|
||||
}
|
||||
|
||||
public static final int fencesPerCat = 16;
|
||||
private final FenceCat cat;
|
||||
|
||||
public BlockArbFence(FenceCat cat) {
|
||||
@@ -49,7 +50,8 @@ public class BlockArbFence extends BlockFence implements IWoodTyped {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
int count = (cat == FenceCat.CAT0 ? 16 : 8);
|
||||
int totalWoods = WoodType.values().length;
|
||||
int count = Math.min(totalWoods - (cat.ordinal() * fencesPerCat), fencesPerCat);
|
||||
for (int i = 0; i < count; i++)
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
@@ -88,7 +90,10 @@ public class BlockArbFence extends BlockFence implements IWoodTyped {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return getWoodType(meta).getPlankIcon();
|
||||
WoodType woodType = getWoodType(meta);
|
||||
if (woodType == null)
|
||||
return null;
|
||||
return woodType.getPlankIcon();
|
||||
}
|
||||
|
||||
public boolean isFence(IBlockAccess world, int x, int y, int z) {
|
||||
@@ -119,10 +124,11 @@ public class BlockArbFence extends BlockFence implements IWoodTyped {
|
||||
|
||||
@Override
|
||||
public WoodType getWoodType(int meta) {
|
||||
if(cat.ordinal() * 16 + meta < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[cat.ordinal() * 16 + meta];
|
||||
int woodOrdinal = cat.ordinal() * fencesPerCat + meta;
|
||||
if(woodOrdinal < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[woodOrdinal];
|
||||
else
|
||||
return WoodType.LARCH;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
public enum LogCat {
|
||||
CAT0, CAT1, CAT2, CAT3, CAT4, CAT5, CAT6, CAT7
|
||||
}
|
||||
public static final short logsPerCat = 4;
|
||||
|
||||
protected final LogCat cat;
|
||||
|
||||
@@ -100,12 +101,9 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
if(cat == LogCat.CAT6) {
|
||||
itemList.add(new ItemStack(this, 1, 0));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
int totalWoods = WoodType.values().length;
|
||||
int count = Math.min(totalWoods - (cat.ordinal() * logsPerCat), logsPerCat);
|
||||
for (int i = 0; i < count; i++)
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
@@ -195,8 +193,9 @@ public class BlockLog extends Block implements IWoodTyped {
|
||||
@Override
|
||||
public WoodType getWoodType(int meta) {
|
||||
meta = getTypeFromMeta(meta);
|
||||
if(meta + cat.ordinal() * 4 < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[meta + cat.ordinal() * 4];
|
||||
int woodOrdinal = meta + cat.ordinal() * logsPerCat;
|
||||
if(woodOrdinal < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[woodOrdinal];
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class BlockPlanks extends Block implements IWoodTyped {
|
||||
CAT0, CAT1
|
||||
}
|
||||
|
||||
public static final int planksPerCat = 16;
|
||||
protected final PlankCat cat;
|
||||
|
||||
public BlockPlanks(PlankCat cat) {
|
||||
@@ -50,7 +51,8 @@ public class BlockPlanks extends Block implements IWoodTyped {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
int count = (cat == PlankCat.CAT0 ? 16 : 8);
|
||||
int totalWoods = WoodType.values().length;
|
||||
int count = Math.min(totalWoods - (cat.ordinal() * planksPerCat), planksPerCat);
|
||||
for (int i = 0; i < count; i++)
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
@@ -65,7 +67,10 @@ public class BlockPlanks extends Block implements IWoodTyped {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return getWoodType(meta).getPlankIcon();
|
||||
WoodType woodType = getWoodType(meta);
|
||||
if (woodType == null)
|
||||
return null;
|
||||
return woodType.getPlankIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,10 +106,11 @@ public class BlockPlanks extends Block implements IWoodTyped {
|
||||
|
||||
@Override
|
||||
public WoodType getWoodType(int meta) {
|
||||
if(cat.ordinal() * 16 + meta < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[cat.ordinal() * 16 + meta];
|
||||
int woodOrdinal = cat.ordinal() * planksPerCat + meta;
|
||||
if(woodOrdinal < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[woodOrdinal];
|
||||
else
|
||||
return WoodType.LARCH;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,6 +38,7 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
CAT0, CAT1, CAT2
|
||||
}
|
||||
|
||||
public static final int slabsPerCat = 8;
|
||||
private final SlabCat cat;
|
||||
|
||||
public BlockSlab(SlabCat cat) {
|
||||
@@ -64,7 +65,9 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
WoodType type = WoodType.VALUES[(8 * cat.ordinal()) + (meta & 7)];
|
||||
WoodType type = getWoodType(meta);
|
||||
if (type == null)
|
||||
return null;
|
||||
return type.getPlankIcon();
|
||||
}
|
||||
|
||||
@@ -86,8 +89,10 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) {
|
||||
for (int i = 0; i < 8; ++i)
|
||||
itemList.add(new ItemStack(item, 1, i));
|
||||
int totalWoods = WoodType.values().length;
|
||||
int count = Math.min(totalWoods - (cat.ordinal() * slabsPerCat), slabsPerCat);
|
||||
for (int i = 0; i < count; i++)
|
||||
itemList.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
|
||||
/* PROPERTIES */
|
||||
@@ -108,10 +113,11 @@ public class BlockSlab extends net.minecraft.block.BlockSlab implements IWoodTyp
|
||||
|
||||
@Override
|
||||
public WoodType getWoodType(int meta) {
|
||||
if(meta + cat.ordinal() * 8 < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[meta + cat.ordinal() * 8];
|
||||
int woodOrdinal = meta + cat.ordinal() * slabsPerCat;
|
||||
if(woodOrdinal < WoodType.VALUES.length)
|
||||
return WoodType.VALUES[woodOrdinal];
|
||||
else
|
||||
return WoodType.LARCH;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
package forestry.arboriculture.items;
|
||||
|
||||
import forestry.arboriculture.WoodType;
|
||||
import forestry.arboriculture.gadgets.BlockArbStairs;
|
||||
import forestry.arboriculture.gadgets.TileStairs;
|
||||
import forestry.core.config.Defaults;
|
||||
import forestry.core.config.ForestryBlock;
|
||||
import forestry.core.items.ItemForestryBlock;
|
||||
import forestry.core.utils.StringUtil;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -61,9 +64,24 @@ public class ItemStairs extends ItemForestryBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
WoodType type = WoodType.getFromCompound(stack.getTagCompound());
|
||||
return getBlock().getUnlocalizedName() + "." + type.ordinal(); //To change body of generated methods, choose Tools | Templates.
|
||||
public String getItemStackDisplayName(ItemStack itemStack) {
|
||||
BlockArbStairs block = (BlockArbStairs) getBlock();
|
||||
WoodType woodType = WoodType.getFromCompound(itemStack.getTagCompound());
|
||||
if (woodType == null)
|
||||
return null;
|
||||
|
||||
String displayName;
|
||||
String customUnlocalizedName = "stairs." + woodType.ordinal() + ".name";
|
||||
if (StringUtil.canTranslateTile(customUnlocalizedName)) {
|
||||
displayName = StringUtil.localizeTile(customUnlocalizedName);
|
||||
} else {
|
||||
String woodGrammar = StringUtil.localize("stairs.grammar");
|
||||
String woodTypeName = StringUtil.localize("trees.woodType." + woodType);
|
||||
|
||||
displayName = woodGrammar.replaceAll("%TYPE", woodTypeName);
|
||||
}
|
||||
|
||||
return displayName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,8 +33,16 @@ public class ItemWoodBlock extends ItemForestryBlock {
|
||||
if (woodType == null)
|
||||
return null;
|
||||
|
||||
String unlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name";
|
||||
String displayName = StringUtil.localizeTile(unlocalizedName);
|
||||
String displayName;
|
||||
String customUnlocalizedName = block.getBlockKind() + "." + woodType.ordinal() + ".name";
|
||||
if (StringUtil.canTranslateTile(customUnlocalizedName)) {
|
||||
displayName = StringUtil.localizeTile(customUnlocalizedName);
|
||||
} else {
|
||||
String woodGrammar = StringUtil.localize(block.getBlockKind() + ".grammar");
|
||||
String woodTypeName = StringUtil.localize("trees.woodType." + woodType);
|
||||
|
||||
displayName = woodGrammar.replaceAll("%TYPE", woodTypeName);
|
||||
}
|
||||
|
||||
if (this.getBlock() instanceof IWoodFireproof)
|
||||
displayName = StringUtil.localizeAndFormatRaw("tile.for.fireproof", displayName);
|
||||
|
||||
@@ -22,6 +22,10 @@ public class StringUtil {
|
||||
return StatCollector.canTranslate("for." + key);
|
||||
}
|
||||
|
||||
public static boolean canTranslateTile(String key) {
|
||||
return StatCollector.canTranslate("tile.for." + key);
|
||||
}
|
||||
|
||||
public static String localize(String key) {
|
||||
return StatCollector.translateToLocal("for." + key).replace("\\n", "\n").replace("@", "%").replace("\\%", "@");
|
||||
}
|
||||
|
||||
@@ -10,6 +10,22 @@
|
||||
******************************************************************************/
|
||||
package forestry.plugins;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import cpw.mods.fml.common.IFuelHandler;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
||||
@@ -17,6 +33,7 @@ import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.VillagerRegistry;
|
||||
|
||||
import forestry.api.arboriculture.EnumGermlingType;
|
||||
import forestry.api.arboriculture.ITree;
|
||||
import forestry.api.arboriculture.ITreeRoot;
|
||||
@@ -123,19 +140,6 @@ import forestry.core.items.ItemFruit.EnumFruit;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.RecipeUtil;
|
||||
import forestry.core.utils.ShapedRecipeCustom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.WeightedRandomChestContent;
|
||||
import net.minecraftforge.common.ChestGenHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
@Plugin(pluginID = "Arboriculture", name = "Arboriculture", author = "Binnie & SirSengir", url = Defaults.URL, unlocalizedDescription = "for.plugin.arboriculture.description")
|
||||
public class PluginArboriculture extends ForestryPlugin {
|
||||
@@ -178,7 +182,7 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
ForestryBlock.slabs3);
|
||||
private static final EnumSet<ForestryBlock> fences = EnumSet.of(
|
||||
ForestryBlock.fences1,
|
||||
ForestryBlock.fences1);
|
||||
ForestryBlock.fences2);
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
@@ -467,10 +471,15 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
Proxies.common.addPriorityRecipe(ForestryBlock.slabs3.getItemStack(6, i), "###", '#', ForestryBlock.planks2.getItemStack(1, i));
|
||||
|
||||
// Fence recipes
|
||||
for (int i = 0; i < 16; i++)
|
||||
Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i));
|
||||
for (int i = 0; i < 8; i++)
|
||||
Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i));
|
||||
for (WoodType woodType : WoodType.values()) {
|
||||
int i = woodType.ordinal();
|
||||
if (i < 16)
|
||||
Proxies.common.addRecipe(ForestryBlock.fences1.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks1.getItemStack(1, i));
|
||||
else if (i < 32)
|
||||
Proxies.common.addRecipe(ForestryBlock.fences2.getItemStack(4, i), "###", "# #", '#', ForestryBlock.planks2.getItemStack(1, i % 16));
|
||||
else
|
||||
throw new RuntimeException("Wood type has no fences defined");
|
||||
}
|
||||
|
||||
// Treealyzer
|
||||
RecipeManagers.carpenterManager.addRecipe(100, Fluids.WATER.getFluid(2000), null, ForestryItem.treealyzer.getItemStack(), "X#X", "X#X", "RDR",
|
||||
@@ -494,30 +503,25 @@ public class PluginArboriculture extends ForestryPlugin {
|
||||
RecipeUtil.injectLeveledRecipe(ForestryItem.sapling.getItemStack(), GameMode.getGameMode().getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
|
||||
|
||||
// Stairs
|
||||
for (int i = 0; i < 16; i++) {
|
||||
WoodType type = WoodType.VALUES[i];
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
type.saveToCompound(compound);
|
||||
for (WoodType woodType : WoodType.values()) {
|
||||
ForestryBlock planks;
|
||||
int i = woodType.ordinal();
|
||||
if (i < 16)
|
||||
planks = ForestryBlock.planks1;
|
||||
else if (i < 32)
|
||||
planks = ForestryBlock.planks2;
|
||||
else
|
||||
throw new RuntimeException("Wood type has no planks defined");
|
||||
|
||||
ItemStack stairs = ForestryBlock.stairs.getItemStack(4, 0);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
woodType.saveToCompound(compound);
|
||||
|
||||
ItemStack stairs = ForestryBlock.stairs.getItemStack(4);
|
||||
stairs.setTagCompound(compound);
|
||||
Proxies.common.addPriorityRecipe(stairs,
|
||||
"# ",
|
||||
"## ",
|
||||
"###", '#', ForestryBlock.planks1.getItemStack(1, i));
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
WoodType type = WoodType.VALUES[16 + i];
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
type.saveToCompound(compound);
|
||||
|
||||
ItemStack stairs = ForestryBlock.stairs.getItemStack(4, 0);
|
||||
stairs.setTagCompound(compound);
|
||||
Proxies.common.addPriorityRecipe(stairs,
|
||||
"# ",
|
||||
"## ",
|
||||
"###",
|
||||
'#', ForestryBlock.planks2.getItemStack(1, i));
|
||||
"###", '#', planks.getItemStack(1, i % 16));
|
||||
}
|
||||
|
||||
// Grafter
|
||||
|
||||
Reference in new issue
Block a user