mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-21 12:32:23 +00:00
Fix #1145 blocks missing localization
This commit is contained in:
1 parent
09aa0ecd1c
commit
641dea32ac
16 files changed
+73
-104
No files matched your search
@@ -22,6 +22,7 @@ import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.BlockTorch;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -51,13 +52,13 @@ import forestry.api.core.Tabs;
|
||||
import forestry.apiculture.tiles.TileCandle;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
|
||||
public class BlockCandle extends BlockTorch implements IItemModelRegister {
|
||||
public class BlockCandle extends BlockTorch implements IItemModelRegister, ITileEntityProvider {
|
||||
|
||||
private static final ImmutableMap<String, Integer> colours;
|
||||
public static final Set<Item> lightingItems;
|
||||
public static final String colourTagName = "colour";
|
||||
|
||||
private static final PropertyEnum STATE = PropertyEnum.create("state", State.class);
|
||||
private static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
|
||||
|
||||
private enum State implements IStringSerializable {
|
||||
ON, OFF;
|
||||
@@ -96,7 +97,6 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister {
|
||||
}
|
||||
|
||||
public BlockCandle() {
|
||||
super();
|
||||
this.setHardness(0.0F);
|
||||
this.setStepSound(soundTypeWood);
|
||||
setCreativeTab(Tabs.tabApiculture);
|
||||
@@ -117,12 +117,7 @@ public class BlockCandle extends BlockTorch implements IItemModelRegister {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileCandle();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,6 @@ public abstract class BlockTreeContainer extends BlockContainer {
|
||||
((TileTreeContainer) tile).onBlockTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(IBlockState state) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return 3;
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.core.items.ItemBlockTyped;
|
||||
|
||||
public class BlockRegistryCore extends BlockRegistry {
|
||||
public final BlockCore core;
|
||||
@@ -26,7 +25,7 @@ public class BlockRegistryCore extends BlockRegistry {
|
||||
public BlockRegistryCore() {
|
||||
core = registerBlock(new BlockCore(), ItemBlockForestry.class, "core");
|
||||
|
||||
soil = registerBlock(new BlockSoil(), ItemBlockTyped.class, "soil");
|
||||
soil = registerBlock(new BlockSoil(), ItemBlockForestry.class, "soil");
|
||||
soil.setHarvestLevel("shovel", 0, soil.getStateFromMeta(0));
|
||||
soil.setHarvestLevel("shovel", 0, soil.getStateFromMeta(1));
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import forestry.api.core.IModelManager;
|
||||
import forestry.core.CreativeTabForestry;
|
||||
import forestry.core.PluginCore;
|
||||
|
||||
public class BlockResourceOre extends Block implements IItemModelRegister {
|
||||
public class BlockResourceOre extends Block implements IItemModelRegister, IBlockWithMeta {
|
||||
public static final PropertyEnum<EnumResourceType> ORE_RESOURCES = PropertyEnum.create("resource", EnumResourceType.class, new Predicate<EnumResourceType>(){
|
||||
@Override
|
||||
public boolean apply(EnumResourceType input) {
|
||||
@@ -77,7 +77,7 @@ public class BlockResourceOre extends Block implements IItemModelRegister {
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) {
|
||||
ArrayList<ItemStack> drops = new ArrayList();
|
||||
List<ItemStack> drops = new ArrayList<>();
|
||||
EnumResourceType metadata = state.getValue(ORE_RESOURCES);
|
||||
|
||||
if (metadata == EnumResourceType.APATITE) {
|
||||
@@ -126,4 +126,10 @@ public class BlockResourceOre extends Block implements IItemModelRegister {
|
||||
public ItemStack get(EnumResourceType type, int amount) {
|
||||
return new ItemStack(this, amount, type.getMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameFromMeta(int meta) {
|
||||
EnumResourceType resourceType = getStateFromMeta(meta).getValue(ORE_RESOURCES);
|
||||
return resourceType.getName();
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.CreativeTabForestry;
|
||||
|
||||
public class BlockResourceStorage extends Block implements IItemModelRegister {
|
||||
public class BlockResourceStorage extends Block implements IItemModelRegister, IBlockWithMeta {
|
||||
public static final PropertyEnum<EnumResourceType> STORAGE_RESOURCES = PropertyEnum.create("resource", EnumResourceType.class);
|
||||
|
||||
public BlockResourceStorage() {
|
||||
@@ -65,4 +65,10 @@ public class BlockResourceStorage extends Block implements IItemModelRegister {
|
||||
public ItemStack get(EnumResourceType type) {
|
||||
return new ItemStack(this, 1, type.getMeta());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameFromMeta(int meta) {
|
||||
EnumResourceType resourceType = getStateFromMeta(meta).getValue(STORAGE_RESOURCES);
|
||||
return resourceType.getName();
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.blocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -47,15 +47,25 @@ import forestry.core.utils.BlockUtil;
|
||||
/**
|
||||
* Humus, bog earth, peat
|
||||
*/
|
||||
public class BlockSoil extends Block implements IItemTyped, IItemModelRegister {
|
||||
public class BlockSoil extends Block implements IItemModelRegister, IBlockWithMeta {
|
||||
private static final PropertyEnum<SoilType> SOIL = PropertyEnum.create("soil", SoilType.class);
|
||||
|
||||
public enum SoilType implements IStringSerializable {
|
||||
HUMUS, BOG_EARTH, PEAT;
|
||||
HUMUS("humus"),
|
||||
BOG_EARTH("bog.earth"),
|
||||
PEAT("peat");
|
||||
|
||||
@Nonnull
|
||||
private final String name;
|
||||
|
||||
SoilType(@Nonnull String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,8 +249,7 @@ public class BlockSoil extends Block implements IItemTyped, IItemModelRegister {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SoilType getTypeFromMeta(int meta) {
|
||||
public static SoilType getTypeFromMeta(int meta) {
|
||||
int type = meta & 0x03;
|
||||
int maturity = meta >> 2;
|
||||
|
||||
@@ -270,6 +279,12 @@ public class BlockSoil extends Block implements IItemTyped, IItemModelRegister {
|
||||
manager.registerItemModel(item, 2, "soil/peat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameFromMeta(int meta) {
|
||||
SoilType type = getTypeFromMeta(meta);
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
public ItemStack get(SoilType soilType, int amount) {
|
||||
return new ItemStack(this, amount, soilType.ordinal());
|
||||
}
|
||||
|
||||
@@ -57,15 +57,17 @@ public class ItemBlockForestry<B extends Block> extends ItemBlock {
|
||||
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
|
||||
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
|
||||
|
||||
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
|
||||
if (block.hasTileEntity(newState)) {
|
||||
TileForestry tile = TileUtil.getTile(world, pos, TileForestry.class);
|
||||
|
||||
if (tile != null) {
|
||||
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
|
||||
tile.readFromNBT(stack.getTagCompound());
|
||||
tile.setPos(pos);
|
||||
if (tile != null) {
|
||||
if (stack.getItem() instanceof ItemBlockNBT && stack.hasTagCompound()) {
|
||||
tile.readFromNBT(stack.getTagCompound());
|
||||
tile.setPos(pos);
|
||||
}
|
||||
|
||||
tile.rotateAfterPlacement(player, side);
|
||||
}
|
||||
|
||||
tile.rotateAfterPlacement(player, side);
|
||||
}
|
||||
|
||||
return placed;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2011-2014 SirSengir.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the GNU Lesser Public License v3
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.gnu.org/licenses/lgpl-3.0.txt
|
||||
*
|
||||
* Various Contributors including, but not limited to:
|
||||
* SirSengir (original work), CovertJaguar, Player, Binnie, MysteriousAges
|
||||
******************************************************************************/
|
||||
package forestry.core.items;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import forestry.core.blocks.IItemTyped;
|
||||
|
||||
/**
|
||||
* For blocks whose type depends on metadata.
|
||||
* This allows control over which localized name maps to which meta value.
|
||||
*/
|
||||
public class ItemBlockTyped extends ItemBlockForestry<Block> {
|
||||
|
||||
public ItemBlockTyped(Block block) {
|
||||
super(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack itemstack) {
|
||||
Block block = getBlock();
|
||||
if (block instanceof IItemTyped) {
|
||||
IItemTyped blockTyped = (IItemTyped) block;
|
||||
Enum type = blockTyped.getTypeFromMeta(itemstack.getItemDamage());
|
||||
if (type != null) {
|
||||
return getBlock().getUnlocalizedName() + "." + type.ordinal();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return super.getUnlocalizedName(itemstack);
|
||||
}
|
||||
}
|
||||
@@ -165,8 +165,8 @@ public class BlockFarm extends BlockStructure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
switch (getMetaFromState(state)) {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
switch (meta) {
|
||||
case 2:
|
||||
return new TileFarmGearbox();
|
||||
case 3:
|
||||
@@ -180,11 +180,6 @@ public class BlockFarm extends BlockStructure {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return createTileEntity(world, getStateFromMeta(meta));
|
||||
}
|
||||
|
||||
/* MODELS */
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -36,13 +36,13 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.core.blocks.IItemTyped;
|
||||
import forestry.core.blocks.IBlockWithMeta;
|
||||
import forestry.core.config.Constants;
|
||||
import forestry.core.utils.BlockUtil;
|
||||
|
||||
public class BlockMushroom extends BlockBush implements IItemTyped, IItemModelRegister, IGrowable {
|
||||
public class BlockMushroom extends BlockBush implements IItemModelRegister, IGrowable, IBlockWithMeta {
|
||||
|
||||
public static final PropertyEnum MUSHROOM = PropertyEnum.create("mushroom", MushroomType.class);
|
||||
public static final PropertyEnum<MushroomType> MUSHROOM = PropertyEnum.create("mushroom", MushroomType.class);
|
||||
|
||||
public enum MushroomType implements IStringSerializable {
|
||||
BROWN, RED;
|
||||
@@ -57,7 +57,6 @@ public class BlockMushroom extends BlockBush implements IItemTyped, IItemModelRe
|
||||
private final ItemStack[] drops;
|
||||
|
||||
public BlockMushroom() {
|
||||
super();
|
||||
setHardness(0.0f);
|
||||
this.generators = new WorldGenerator[]{new WorldGenBigMushroom(Blocks.brown_mushroom_block), new WorldGenBigMushroom(Blocks.red_mushroom_block)};
|
||||
this.drops = new ItemStack[]{new ItemStack(Blocks.brown_mushroom), new ItemStack(Blocks.red_mushroom)};
|
||||
@@ -73,7 +72,7 @@ public class BlockMushroom extends BlockBush implements IItemTyped, IItemModelRe
|
||||
|
||||
@Override
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return ((MushroomType) state.getValue(MUSHROOM)).ordinal();
|
||||
return state.getValue(MUSHROOM).ordinal();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -147,8 +146,7 @@ public class BlockMushroom extends BlockBush implements IItemTyped, IItemModelRe
|
||||
this.generateTree(worldIn, pos, state, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MushroomType getTypeFromMeta(int meta) {
|
||||
public static MushroomType getTypeFromMeta(int meta) {
|
||||
meta %= MushroomType.values().length;
|
||||
return MushroomType.values()[meta];
|
||||
}
|
||||
@@ -183,4 +181,9 @@ public class BlockMushroom extends BlockBush implements IItemTyped, IItemModelRe
|
||||
this.grow(worldIn, pos, state, rand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNameFromMeta(int meta) {
|
||||
MushroomType type = getTypeFromMeta(meta);
|
||||
return type.getName();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
package forestry.farming.blocks;
|
||||
|
||||
import forestry.core.blocks.BlockRegistry;
|
||||
import forestry.core.items.ItemBlockTyped;
|
||||
import forestry.core.items.ItemBlockForestry;
|
||||
import forestry.farming.items.ItemBlockFarm;
|
||||
|
||||
public class BlockRegistryFarming extends BlockRegistry {
|
||||
@@ -19,7 +19,7 @@ public class BlockRegistryFarming extends BlockRegistry {
|
||||
public final BlockFarm farm;
|
||||
|
||||
public BlockRegistryFarming() {
|
||||
mushroom = registerBlock(new BlockMushroom(), ItemBlockTyped.class, "mushroom");
|
||||
mushroom = registerBlock(new BlockMushroom(), ItemBlockForestry.class, "mushroom");
|
||||
farm = registerBlock(new BlockFarm(), ItemBlockFarm.class, "ffarm");
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class CropPeat extends Crop {
|
||||
}
|
||||
|
||||
BlockSoil blockSoil = (BlockSoil) block;
|
||||
BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(getBlockMeta(pos));
|
||||
BlockSoil.SoilType soilType = BlockSoil.getTypeFromMeta(getBlockMeta(pos));
|
||||
return soilType == BlockSoil.SoilType.PEAT;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class FarmLogicArboreal extends FarmLogicHomogeneous {
|
||||
return false;
|
||||
}
|
||||
BlockSoil blockSoil = (BlockSoil) block;
|
||||
return blockSoil.getTypeFromMeta(soil.getItemDamage()) == BlockSoil.SoilType.HUMUS;
|
||||
return BlockSoil.getTypeFromMeta(soil.getItemDamage()) == BlockSoil.SoilType.HUMUS;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FarmLogicPeat extends FarmLogicWatered {
|
||||
return false;
|
||||
}
|
||||
BlockSoil blockSoil = (BlockSoil) block;
|
||||
BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(itemStack.getItemDamage());
|
||||
BlockSoil.SoilType soilType = BlockSoil.getTypeFromMeta(itemStack.getItemDamage());
|
||||
return soilType == BlockSoil.SoilType.BOG_EARTH || soilType == BlockSoil.SoilType.PEAT;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class FarmLogicPeat extends FarmLogicWatered {
|
||||
}
|
||||
|
||||
BlockSoil blockSoil = (BlockSoil) block;
|
||||
BlockSoil.SoilType soilType = blockSoil.getTypeFromMeta(occupant.getItemDamage());
|
||||
BlockSoil.SoilType soilType = BlockSoil.getTypeFromMeta(occupant.getItemDamage());
|
||||
|
||||
if (soilType == BlockSoil.SoilType.PEAT) {
|
||||
crops.push(new CropPeat(world, position));
|
||||
|
||||
@@ -10,12 +10,11 @@
|
||||
******************************************************************************/
|
||||
package forestry.greenhouse.blocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
@@ -42,6 +41,7 @@ import net.minecraftforge.common.property.IUnlistedProperty;
|
||||
import net.minecraftforge.common.property.Properties;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ICamouflagedBlock;
|
||||
import forestry.api.core.IModelManager;
|
||||
@@ -66,7 +66,7 @@ import forestry.plugins.ForestryPluginUids;
|
||||
|
||||
public abstract class BlockGreenhouse extends BlockStructure {
|
||||
|
||||
public static final PropertyEnum STATE = PropertyEnum.create("state", State.class);
|
||||
public static final PropertyEnum<State> STATE = PropertyEnum.create("state", State.class);
|
||||
|
||||
public static enum State implements IStringSerializable {
|
||||
ON, OFF;
|
||||
@@ -188,7 +188,7 @@ public abstract class BlockGreenhouse extends BlockStructure {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, IBlockState state) {
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
BlockGreenhouseType type = getGreenhouseType();
|
||||
switch (type) {
|
||||
case GEARBOX:
|
||||
@@ -216,11 +216,6 @@ public abstract class BlockGreenhouse extends BlockStructure {
|
||||
return new TileGreenhousePlain();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return createTileEntity(world, getStateFromMeta(meta));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int colorMultiplier(IBlockAccess world, BlockPos pos, int renderPass) {
|
||||
|
||||
Reference in new issue
Block a user