mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-24 22:04:33 +00:00
#Murder everything!
This commit is contained in:
1 parent
962f104488
commit
0bcb31c30d
8 files changed
+110
-104
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
||||
mod_version=0.4
|
||||
minecraft_version=1.8
|
||||
forge_version=11.14.2.1435
|
||||
mappings=snapshot_20150606
|
||||
forge_version=11.14.3.1487
|
||||
mappings=snapshot_20150708
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package mantle.blocks.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBlockWithSubtypes
|
||||
{
|
||||
String getSubtypeUnlocalizedName(ItemStack stack);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package mantle.blocks.util;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IBlockWithVariants
|
||||
{
|
||||
String getVariantNameFromStack(ItemStack stack);
|
||||
}
|
||||
+5
-5
@@ -4,15 +4,15 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ItemBlockSubtypes extends ItemBlock
|
||||
public class ItemBlockVariants extends ItemBlock
|
||||
{
|
||||
private final IBlockWithSubtypes blockWithSubtypes;
|
||||
private final IBlockWithVariants blockWithVariants;
|
||||
|
||||
public ItemBlockSubtypes(Block block)
|
||||
public ItemBlockVariants(Block block)
|
||||
{
|
||||
super(block);
|
||||
|
||||
this.blockWithSubtypes = (IBlockWithSubtypes) block;
|
||||
this.blockWithVariants = (IBlockWithVariants) block;
|
||||
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
@@ -27,7 +27,7 @@ public class ItemBlockSubtypes extends ItemBlock
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack)
|
||||
{
|
||||
return super.getUnlocalizedName() + "." + this.blockWithSubtypes.getSubtypeUnlocalizedName(stack);
|
||||
return super.getUnlocalizedName() + "." + this.blockWithVariants.getVariantNameFromStack(stack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package mantle.blocks.util;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
||||
public class PropertyVariant implements IProperty
|
||||
{
|
||||
private String name;
|
||||
|
||||
private BlockVariant defaultVariant;
|
||||
|
||||
private HashMap<Integer, BlockVariant> metaMap;
|
||||
|
||||
protected PropertyVariant(String name, BlockVariant... variants)
|
||||
{
|
||||
this.name = name;
|
||||
this.metaMap = new HashMap<Integer, BlockVariant>();
|
||||
|
||||
this.defaultVariant = variants[0];
|
||||
|
||||
for (BlockVariant variant : variants)
|
||||
{
|
||||
this.metaMap.put(variant.getMeta(), variant);
|
||||
}
|
||||
}
|
||||
|
||||
public static PropertyVariant create(String name, BlockVariant... variants)
|
||||
{
|
||||
return new PropertyVariant(name, variants);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BlockVariant> getAllowedValues()
|
||||
{
|
||||
return this.metaMap.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BlockVariant> getValueClass()
|
||||
{
|
||||
return BlockVariant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(Comparable value)
|
||||
{
|
||||
return ((BlockVariant) value).getName();
|
||||
}
|
||||
|
||||
public BlockVariant fromMeta(int meta)
|
||||
{
|
||||
BlockVariant variant = this.metaMap.get(meta);
|
||||
|
||||
return variant != null ? variant : this.defaultVariant;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package mantle.blocks.util;
|
||||
package mantle.blocks.util.blockstates;
|
||||
|
||||
public class BlockVariant implements Comparable<BlockVariant>
|
||||
{
|
||||
@@ -0,0 +1,65 @@
|
||||
package mantle.blocks.util.blockstates;
|
||||
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PropertyVariant implements IProperty
|
||||
{
|
||||
private String name;
|
||||
|
||||
private BlockVariant defaultVariant;
|
||||
|
||||
private HashMap<Integer, BlockVariant> metaMap;
|
||||
|
||||
protected PropertyVariant(String name, BlockVariant... variants)
|
||||
{
|
||||
this.name = name;
|
||||
this.metaMap = new HashMap<Integer, BlockVariant>();
|
||||
|
||||
this.defaultVariant = variants[0];
|
||||
|
||||
for (BlockVariant variant : variants)
|
||||
{
|
||||
this.metaMap.put(variant.getMeta(), variant);
|
||||
}
|
||||
}
|
||||
|
||||
public static PropertyVariant create(String name, BlockVariant... variants)
|
||||
{
|
||||
return new PropertyVariant(name, variants);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BlockVariant> getAllowedValues()
|
||||
{
|
||||
return this.metaMap.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<BlockVariant> getValueClass()
|
||||
{
|
||||
return BlockVariant.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(Comparable value)
|
||||
{
|
||||
return ((BlockVariant) value).getName();
|
||||
}
|
||||
|
||||
public BlockVariant fromMeta(int meta)
|
||||
{
|
||||
BlockVariant variant = this.metaMap.get(meta);
|
||||
|
||||
return variant != null ? variant : this.defaultVariant;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,51 +27,50 @@ public class ModelVariant
|
||||
this.mc = mc;
|
||||
}
|
||||
|
||||
public String getResource(String resource)
|
||||
{
|
||||
return (MOD_ID + ":") + resource;
|
||||
}
|
||||
|
||||
public void addVariantNames(Block block, String... names)
|
||||
{
|
||||
for (int i = 0; i < names.length; i++)
|
||||
{
|
||||
names[i] = getResource(names[i]);
|
||||
}
|
||||
|
||||
ModelBakery.addVariantName(Item.getItemFromBlock(block), names);
|
||||
}
|
||||
|
||||
public void registerBlockModel(Block block)
|
||||
{
|
||||
ResourceLocation resourceLocation = (ResourceLocation) Block.blockRegistry.getNameForObject(block);
|
||||
|
||||
registerBlockModel(block, 0, resourceLocation.getResourcePath());
|
||||
registerBlockModel(block, 0, resourceLocation.toString());
|
||||
}
|
||||
|
||||
public void registerItemModel(Item item)
|
||||
{
|
||||
ResourceLocation resourceLocation = (ResourceLocation) Item.itemRegistry.getNameForObject(item);
|
||||
|
||||
registerItemModel(item, 0, resourceLocation.getResourcePath());
|
||||
registerItemModel(item, 0, resourceLocation.toString());
|
||||
}
|
||||
|
||||
public void registerBlockModel(Block block, int meta, String modelName)
|
||||
{
|
||||
registerItemModel(Item.getItemFromBlock(block), meta, modelName);
|
||||
}
|
||||
|
||||
public void registerItemModel(Item item, int meta, String resourcePath)
|
||||
{
|
||||
ModelResourceLocation modelResourceLocation = new ModelResourceLocation((this.MOD_ID + ":") + resourcePath, "inventory");
|
||||
|
||||
this.mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation);
|
||||
}
|
||||
|
||||
public void registerBlockModelVariant(Block block, int meta, String resourcePath)
|
||||
{
|
||||
Item item = Item.getItemFromBlock(block);
|
||||
|
||||
registerItemModel(item, meta, resourcePath);
|
||||
|
||||
ModelBakery.addVariantName(item, (this.MOD_ID + ":") + resourcePath);
|
||||
}
|
||||
|
||||
public void registerItemModelVariant(Item item)
|
||||
|
||||
public void registerItemModelVariants(Item item)
|
||||
{
|
||||
for (int i = 0; i < ((IItemWithVariants) item).getVariantNames().length; i++)
|
||||
{
|
||||
String NAME = item.getUnlocalizedName().substring(5) + "_" + ((IItemWithVariants) item).getVariantNames()[i];
|
||||
ModelBakery.addVariantName(item, (this.MOD_ID + ":") + NAME);
|
||||
this.registerItemModel(item, i, NAME);
|
||||
ModelBakery.addVariantName(item, getResource(NAME));
|
||||
this.registerItemModel(item, i, getResource(NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void registerItemSubTypesModel(Item item, CreativeTabs tab)
|
||||
{
|
||||
ArrayList<ItemStack> list = new ArrayList<ItemStack>();
|
||||
@@ -81,4 +80,11 @@ public class ModelVariant
|
||||
this.registerItemModel(item, i.getItemDamage(), item.getUnlocalizedName().substring(5));
|
||||
}
|
||||
}
|
||||
|
||||
public void registerItemModel(Item item, int meta, String resourcePath)
|
||||
{
|
||||
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(resourcePath, "inventory");
|
||||
|
||||
mc.getRenderItem().getItemModelMesher().register(item, meta, modelResourceLocation);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user