mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-18 03:25:07 +00:00
Adding flower blockstate and blockstatemapper
This commit is contained in:
1 parent
5a64454906
commit
2a23e60cdb
60 files changed
+405
-201
No files matched your search
@@ -12,16 +12,20 @@ import binnie.botany.api.IFlower;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import binnie.botany.core.BotanyCore;
|
||||
import binnie.botany.gardening.Gardening;
|
||||
import binnie.botany.genetics.EnumFlowerType;
|
||||
import binnie.botany.genetics.FlowerDefinition;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.util.TileUtil;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.core.blocks.IColoredBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.SoundType;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyBool;
|
||||
import net.minecraft.block.properties.PropertyInteger;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -36,14 +40,17 @@ 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.client.model.ModelLoader;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class BlockFlower extends BlockContainer implements IColoredBlock, IItemModelRegister {
|
||||
public class BlockFlower extends BlockContainer implements IColoredBlock, IItemModelRegister, IStateMapperRegister {
|
||||
|
||||
public static final AxisAlignedBB FLOWER_BLOCK_AABB = new AxisAlignedBB(0.3D, 0.0D, 0.3D, 0.7D, 0.6D, 0.7D);
|
||||
/* PROPERTYS */
|
||||
public static final PropertyFlower FLOWER = new PropertyFlower("flower", IFlowerType.class);
|
||||
public static final PropertyInteger SECTION = PropertyInteger.create("section", 0, EnumFlowerType.highestSection - 1);
|
||||
public static final PropertyBool FLOWERED = PropertyBool.create("flowered");
|
||||
|
||||
public BlockFlower() {
|
||||
super(Material.PLANTS);
|
||||
@@ -67,6 +74,12 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerStateMapper() {
|
||||
ModelLoader.setCustomStateMapper(this, new StateMapperFlower());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
@@ -116,13 +129,13 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
|
||||
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
|
||||
final TileEntity tile = world.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityFlower) {
|
||||
final TileEntityFlower f = (TileEntityFlower) tile;
|
||||
TileEntityFlower flower = (TileEntityFlower) tile;
|
||||
if(tintIndex == 0){
|
||||
return f.getStemColour();
|
||||
return flower.getStemColour();
|
||||
}else if(tintIndex == 1){
|
||||
return f.getPrimaryColour();
|
||||
return flower.getPrimaryColour();
|
||||
}else{
|
||||
return f.getSecondaryColour();
|
||||
return flower.getSecondaryColour();
|
||||
}
|
||||
}
|
||||
return 16777215;
|
||||
@@ -152,26 +165,30 @@ public class BlockFlower extends BlockContainer implements IColoredBlock, IItemM
|
||||
return EnumBlockRenderType.MODEL;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public EnumOffsetType getOffsetType() {
|
||||
return EnumOffsetType.XZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) {
|
||||
TileEntityFlower flower = TileUtil.getTile(world, pos, TileEntityFlower.class);
|
||||
if(flower != null && flower.getFlower() != null){
|
||||
state = state.withProperty(FLOWER, flower.getFlower().getGenome().getPrimary().getType());
|
||||
if(flower != null && flower.getType() != null){
|
||||
state = state.withProperty(FLOWER, flower.getType());
|
||||
state = state.withProperty(FLOWERED, flower.isFlowered());
|
||||
state = state.withProperty(SECTION, flower.getRenderSection());
|
||||
}else{
|
||||
state = state.withProperty(FLOWER, FlowerDefinition.Dandelion.getSpecies().getType());
|
||||
state = state.withProperty(FLOWERED, false);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, FLOWER);
|
||||
return new BlockStateContainer(this, FLOWER, FLOWERED, SECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,6 @@ import binnie.botany.genetics.Flower;
|
||||
import binnie.core.BinnieCore;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.IModelManager;
|
||||
import forestry.api.genetics.IGenome;
|
||||
import forestry.api.genetics.IIndividual;
|
||||
import forestry.api.genetics.IPollinatable;
|
||||
import forestry.core.config.Config;
|
||||
@@ -96,13 +95,13 @@ public class ItemBotany extends Item implements IColoredItem, IItemModelRegister
|
||||
String primaryColor = genome.getPrimaryColor().getColourName();
|
||||
String secondaryColor = genome.getSecondaryColor().getColourName();
|
||||
String stemColor = genome.getStemColor().getColourName();
|
||||
String colourInfo;
|
||||
String colorInfo;
|
||||
if(!primaryColor.equals(secondaryColor)){
|
||||
colourInfo = Binnie.Language.localise("botany.grammar.flower.secondary");
|
||||
colorInfo = Binnie.Language.localise("botany.grammar.flower.secondary");
|
||||
}else{
|
||||
colourInfo = Binnie.Language.localise("botany.grammar.flower");
|
||||
colorInfo = Binnie.Language.localise("botany.grammar.flower");
|
||||
}
|
||||
list.add(TextFormatting.YELLOW + colourInfo.replaceAll("%PRIMARY", primaryColor).replaceAll("%SECONDARY", secondaryColor).replaceAll("%STEM", stemColor));
|
||||
list.add(TextFormatting.YELLOW + colorInfo.replaceAll("%PRIMARY", primaryColor).replaceAll("%SECONDARY", secondaryColor).replaceAll("%STEM", stemColor));
|
||||
|
||||
if (individual.isAnalyzed()) {
|
||||
if (BinnieCore.proxy.isShiftDown()) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package binnie.botany.flower;
|
||||
|
||||
import java.util.Map;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.botany.api.IFlowerType;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class StateMapperFlower extends StateMapperBase {
|
||||
|
||||
@Override
|
||||
protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
|
||||
final Map<IProperty<?>, Comparable<?>> properties = Maps.newLinkedHashMap(state.getProperties());
|
||||
IFlowerType flowerType = (IFlowerType) state.getValue(BlockFlower.FLOWER);
|
||||
if (flowerType.getSections() < 2) {
|
||||
properties.remove(BlockFlower.SECTION);
|
||||
}else if(flowerType.getSections() <= state.getValue(BlockFlower.SECTION)){
|
||||
properties.put(BlockFlower.SECTION, flowerType.getSections()-1);
|
||||
}
|
||||
|
||||
return new ModelResourceLocation(Constants.BOTANY_MOD_ID + ":flower", getPropertyString(properties));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -537,6 +537,7 @@ public class TileEntityFlower extends TileEntity implements IPollinatable, IButt
|
||||
this.renderInfo = render;
|
||||
this.section = this.renderInfo.section;
|
||||
worldObj.markBlockRangeForRenderUpdate(pos, pos);
|
||||
worldObj.markChunkDirty(pos, this);
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
|
||||
@@ -60,6 +60,8 @@ public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
|
||||
Delphinium(2),
|
||||
Hollyhock(2);
|
||||
|
||||
public static int highestSection = 2;
|
||||
|
||||
int sections;
|
||||
ModelResourceLocation[] flowered;
|
||||
ModelResourceLocation[] unflowered;
|
||||
@@ -119,8 +121,4 @@ public enum EnumFlowerType implements IFlowerType<EnumFlowerType> {
|
||||
public String getName() {
|
||||
return name().toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
// public IIcon getBlank() {
|
||||
// return this.blank;
|
||||
// }
|
||||
}
|
||||
@@ -89,13 +89,13 @@ public class Flower extends Individual implements IFlower {
|
||||
final IAlleleFlowerSpecies primary = this.genome.getPrimary();
|
||||
final IAlleleFlowerSpecies secondary = this.genome.getSecondary();
|
||||
if (!this.isPureBred(EnumFlowerChromosome.SPECIES)) {
|
||||
list.add("§9" + primary.getName() + "-" + secondary.getName() + " Hybrid");
|
||||
list.add("§9" + primary.getName() + "-" + secondary.getName() + " Hybrid");
|
||||
}
|
||||
list.add("§6Age: " + this.getAge());
|
||||
list.add("§6T: " + this.getGenome().getPrimary().getTemperature() + " / " + this.getGenome().getToleranceTemperature());
|
||||
list.add("§6M: " + this.getGenome().getPrimary().getMoisture() + " / " + this.getGenome().getToleranceMoisture());
|
||||
list.add("§6pH: " + this.getGenome().getPrimary().getHumidity() + " / " + this.getGenome().getTolerancePH());
|
||||
list.add("§6Fert: " + this.getGenome().getFertility() + "x");
|
||||
list.add("§6Age: " + this.getAge());
|
||||
list.add("§6T: " + this.getGenome().getPrimary().getTemperature() + " / " + this.getGenome().getToleranceTemperature());
|
||||
list.add("§6M: " + this.getGenome().getPrimary().getMoisture() + " / " + this.getGenome().getToleranceMoisture());
|
||||
list.add("§6pH: " + this.getGenome().getPrimary().getHumidity() + " / " + this.getGenome().getTolerancePH());
|
||||
list.add("§6Fert: " + this.getGenome().getFertility() + "x");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -944,7 +944,6 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
flowerRood.addConversion(new ItemStack(Blocks.RED_FLOWER, 1, 4), Tulip.addVariant(EnumFlowerColor.Crimson));
|
||||
flowerRood.addConversion(new ItemStack(Blocks.RED_FLOWER, 1, 5), Tulip.addVariant(EnumFlowerColor.DarkOrange));
|
||||
}
|
||||
|
||||
public static FlowerDefinition[] VALUES = values();
|
||||
|
||||
private final IAlleleFlowerSpecies species;
|
||||
@@ -1049,6 +1048,12 @@ public enum FlowerDefinition implements IFlowerDefinition {
|
||||
|
||||
public static void preInitFlowers(){
|
||||
MinecraftForge.EVENT_BUS.post(new AlleleSpeciesRegisterEvent(FlowerManager.flowerRoot));
|
||||
for(FlowerDefinition def : values()){
|
||||
IFlowerType type = def.species.getType();
|
||||
if(EnumFlowerType.highestSection < type.getSections()){
|
||||
EnumFlowerType.highestSection = type.getSections();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void initFlowers() {
|
||||
|
||||
@@ -8,7 +8,7 @@ import forestry.core.genetics.alleles.EnumAllele;
|
||||
public class FlowerTemplates {
|
||||
public static IAllele[] getDefaultTemplate() {
|
||||
final IAllele[] alleles = new IAllele[EnumFlowerChromosome.values().length];
|
||||
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Poppy.getSpecies());
|
||||
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.SPECIES, FlowerDefinition.Dandelion.getSpecies());
|
||||
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.PRIMARY, EnumFlowerColor.Red);
|
||||
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.SECONDARY, EnumFlowerColor.Red);
|
||||
AlleleHelper.instance.set(alleles, EnumFlowerChromosome.FERTILITY, EnumAllele.Fertility.NORMAL);
|
||||
|
||||
@@ -32,10 +32,10 @@ public class ModuleGenetics implements IInitializable {
|
||||
FlowerDefinition.preInitFlowers();
|
||||
|
||||
Botany.flower = new BlockFlower();
|
||||
GameRegistry.register(Botany.flower);
|
||||
Botany.proxy.registerBlock(Botany.flower);
|
||||
BinnieCore.proxy.registerTileEntity(TileEntityFlower.class, "botany.tile.flower", null);
|
||||
//Need we this ?
|
||||
GameRegistry.register(new ItemBlock(Botany.flower).setRegistryName(Botany.flower.getRegistryName()));
|
||||
Botany.proxy.registerItem(new ItemBlock(Botany.flower).setRegistryName(Botany.flower.getRegistryName()));
|
||||
|
||||
Botany.flowerItem = new ItemBotany("itemFlower", EnumFlowerStage.FLOWER, "");
|
||||
Botany.pollen = new ItemBotany("pollen", EnumFlowerStage.POLLEN, "Pollen");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package binnie.botany.items;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.item.IItemMisc;
|
||||
import binnie.core.item.IItemMiscProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public enum BotanyItems implements IItemMisc {
|
||||
public enum BotanyItems implements IItemMiscProvider {
|
||||
AshPowder("Ash Powder", "powderAsh"),
|
||||
PulpPowder("Wood Pulp Powder", "powderPulp"),
|
||||
MulchPowder("Mulch Powder", "powderMulch"),
|
||||
@@ -16,26 +16,30 @@ public enum BotanyItems implements IItemMisc {
|
||||
Mortar("Mortar", "mortar"),
|
||||
Weedkiller("Weedkiller", "weedkiller");
|
||||
|
||||
// IIcon icon;
|
||||
String name;
|
||||
String iconPath;
|
||||
String modelPath;
|
||||
|
||||
BotanyItems(final String name, final String iconPath) {
|
||||
BotanyItems(String name, String modelPath) {
|
||||
this.name = name;
|
||||
this.iconPath = iconPath;
|
||||
this.modelPath = modelPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(final List par3List) {
|
||||
public void addInformation(List tooltip) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName(final ItemStack stack) {
|
||||
public String getName(ItemStack stack) {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack get(final int size) {
|
||||
public ItemStack get(int size) {
|
||||
return new ItemStack(Botany.misc, size, this.ordinal());
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//TODO Remove this after test the PacketFlowerUpdate
|
||||
public class MessageFlowerUpdate extends MessageCoordinates {
|
||||
public TileEntityFlower.RenderInfo render;
|
||||
|
||||
|
||||
@@ -11,8 +11,6 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class PacketFlowerUpdate extends SPacketUpdateTileEntity {
|
||||
|
||||
|
||||
public TileEntityFlower.RenderInfo render;
|
||||
|
||||
public PacketFlowerUpdate(BlockPos blockPos, int metadata, NBTTagCompound compound, final TileEntityFlower.RenderInfo render) {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package binnie.botany.proxy;
|
||||
|
||||
import binnie.botany.Botany;
|
||||
import binnie.core.proxy.BinnieModProxy;
|
||||
|
||||
public class Proxy extends BinnieModProxy implements IBotanyProxy {
|
||||
public Proxy() {
|
||||
super(Botany.instance);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ public abstract class AbstractMod implements IPacketProvider, IInitializable {
|
||||
|
||||
@Override
|
||||
public void preInit() {
|
||||
getProxy().setMod(this);
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class BinnieCore extends AbstractMod {
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "binniecore";
|
||||
return Constants.CORE_MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package binnie.core.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IItemMisc extends IItemEnum {
|
||||
// IIcon getIcon(final ItemStack p0);
|
||||
//
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// void registerIcons(final IIconRegister p0);
|
||||
|
||||
void addInformation(final List p0);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package binnie.core.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IItemMiscProvider extends IItemEnum {
|
||||
|
||||
void addInformation(List tooltip);
|
||||
|
||||
String getModelPath();
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
package binnie.core.item;
|
||||
|
||||
import binnie.Constants;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.gui.BinnieCoreGUI;
|
||||
import forestry.api.core.IModelManager;
|
||||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
@@ -15,10 +21,10 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemFieldKit extends ItemCore {
|
||||
// private IIcon fieldKit0;
|
||||
// private IIcon fieldKit1;
|
||||
// private IIcon fieldKit2;
|
||||
// private IIcon fieldKit3;
|
||||
private ModelResourceLocation fieldKit;
|
||||
private ModelResourceLocation fieldKit1;
|
||||
private ModelResourceLocation fieldKit2;
|
||||
private ModelResourceLocation fieldKit3;
|
||||
|
||||
public ItemFieldKit() {
|
||||
super("fieldKit");
|
||||
@@ -27,32 +33,35 @@ public class ItemFieldKit extends ItemCore {
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(64);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
manager.registerItemModel(item, new FieldKitMeshDefinition());
|
||||
fieldKit = new ModelResourceLocation(Constants.CORE_MOD_ID + ":fieldKit", "inventory");
|
||||
fieldKit1 = new ModelResourceLocation(Constants.CORE_MOD_ID + ":fieldKit1", "inventory");
|
||||
fieldKit2 = new ModelResourceLocation(Constants.CORE_MOD_ID + ":fieldKit2", "inventory");
|
||||
fieldKit3 = new ModelResourceLocation(Constants.CORE_MOD_ID + ":fieldKit3", "inventory");
|
||||
ModelBakery.registerItemVariants(item, fieldKit, fieldKit1, fieldKit2, fieldKit3);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerIcons(final IIconRegister register) {
|
||||
// this.fieldKit0 = BinnieCore.proxy.getIcon(register, "fieldKit");
|
||||
// this.fieldKit1 = BinnieCore.proxy.getIcon(register, "fieldKit1");
|
||||
// this.fieldKit2 = BinnieCore.proxy.getIcon(register, "fieldKit2");
|
||||
// this.fieldKit3 = BinnieCore.proxy.getIcon(register, "fieldKit3");
|
||||
// this.itemIcon = this.fieldKit0;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IIcon getIcon(final ItemStack stack, final int pass) {
|
||||
// final int damage = stack.getItemDamage();
|
||||
// if (damage < 24) {
|
||||
// return this.fieldKit3;
|
||||
// }
|
||||
// if (damage < 48) {
|
||||
// return this.fieldKit2;
|
||||
// }
|
||||
// if (damage < 64) {
|
||||
// return this.fieldKit1;
|
||||
// }
|
||||
// return this.fieldKit0;
|
||||
// }
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private class FieldKitMeshDefinition implements ItemMeshDefinition{
|
||||
@Override
|
||||
public ModelResourceLocation getModelLocation(ItemStack stack) {
|
||||
final int damage = stack.getItemDamage();
|
||||
if (damage < 24) {
|
||||
return fieldKit3;
|
||||
}
|
||||
if (damage < 48) {
|
||||
return fieldKit2;
|
||||
}
|
||||
if (damage < 64) {
|
||||
return fieldKit1;
|
||||
}
|
||||
return fieldKit;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import forestry.api.core.Tabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -22,7 +23,7 @@ public class ItemGenesis extends ItemCore {
|
||||
@Override
|
||||
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) {
|
||||
BinnieCore.proxy.openGui(BinnieCoreGUI.Genesis, player, new BlockPos((int) player.posX, (int) player.posY, (int) player.posZ));
|
||||
return super.onItemRightClick(itemStack, world, player, hand);
|
||||
return new ActionResult(EnumActionResult.SUCCESS, itemStack);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,38 +9,37 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ItemMisc extends ItemCore {
|
||||
private IItemMisc[] items;
|
||||
private IItemMiscProvider[] items;
|
||||
|
||||
public ItemMisc() {
|
||||
super("misc");
|
||||
}
|
||||
|
||||
protected ItemMisc(final CreativeTabs tab, final IItemMisc[] items2) {
|
||||
protected ItemMisc(final CreativeTabs tab, final IItemMiscProvider[] items) {
|
||||
super("misc");
|
||||
this.setCreativeTab(tab);
|
||||
this.setHasSubtypes(true);
|
||||
this.setUnlocalizedName("misc");
|
||||
this.items = items2;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) {
|
||||
for (final IItemMisc item : this.items) {
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, List par3List) {
|
||||
for (IItemMiscProvider item : this.items) {
|
||||
if (item.isActive()) {
|
||||
par3List.add(this.getStack(item, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IItemMisc getItem(final int damage) {
|
||||
private IItemMiscProvider getItem(int damage) {
|
||||
return (damage >= this.items.length) ? this.items[0] : this.items[damage];
|
||||
}
|
||||
|
||||
public ItemStack getStack(final IItemMisc type, final int size) {
|
||||
public ItemStack getStack(IItemMiscProvider type, int size) {
|
||||
return new ItemStack(this, size, type.ordinal());
|
||||
}
|
||||
|
||||
@@ -48,7 +47,7 @@ public class ItemMisc extends ItemCore {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
if (item != null) {
|
||||
item.addInformation(tooltip);
|
||||
}
|
||||
@@ -57,35 +56,15 @@ public class ItemMisc extends ItemCore {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void registerModel(Item item, IModelManager manager) {
|
||||
for (IItemMisc type : items) {
|
||||
manager.registerItemModel(item, type.ordinal(), "misc/" + type.name().toLowerCase(Locale.ENGLISH));
|
||||
for (IItemMiscProvider type : items) {
|
||||
manager.registerItemModel(item, type.ordinal(), "misc/" + type.getModelPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
return (item != null) ? item.getName(stack) : "null";
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IIcon getIcon(final ItemStack stack, final int pass) {
|
||||
// final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
// return (item != null) ? item.getIcon(stack) : null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public IIcon getIconFromDamage(final int damage) {
|
||||
// final IItemMisc item = this.getItem(damage);
|
||||
// return (item != null) ? item.getIcon(null) : null;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// public void registerIcons(final IIconRegister register) {
|
||||
// for (final IItemMisc item : this.items) {
|
||||
// item.registerIcons(register);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package binnie.core.item;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
||||
public class ManagerItem {
|
||||
public ItemMisc registerMiscItems(final IItemMisc[] items, final CreativeTabs tab) {
|
||||
public ItemMisc registerMiscItems(final IItemMiscProvider[] items, final CreativeTabs tab) {
|
||||
return new ItemMisc(tab, items);
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,14 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
public class BinnieModProxy implements IBinnieModProxy {
|
||||
private AbstractMod mod;
|
||||
|
||||
public BinnieModProxy(final AbstractMod mod) {
|
||||
this.mod = mod;
|
||||
public BinnieModProxy() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMod(final AbstractMod mod) {
|
||||
this.mod = mod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item registerItem(Item item){
|
||||
return GameRegistry.register(item);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package binnie.core.proxy;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.BinnieCore;
|
||||
import binnie.core.network.BinnieCorePacketID;
|
||||
import binnie.core.network.INetworkedEntity;
|
||||
import binnie.core.network.packet.MessageUpdate;
|
||||
@@ -23,9 +22,7 @@ import java.io.File;
|
||||
public class BinnieProxy extends BinnieModProxy implements IBinnieProxy {
|
||||
private short uniqueTextureUID;
|
||||
|
||||
|
||||
public BinnieProxy() {
|
||||
super(BinnieCore.instance);
|
||||
this.uniqueTextureUID = 1200;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package binnie.core.proxy;
|
||||
|
||||
import binnie.core.AbstractMod;
|
||||
import binnie.core.IInitializable;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
|
||||
public interface IProxyCore extends IInitializable {
|
||||
|
||||
void setMod(AbstractMod mod);
|
||||
|
||||
Item registerItem(Item item);
|
||||
|
||||
Block registerBlock(Block block);
|
||||
|
||||
@@ -27,6 +27,10 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
@Mod(modid = Constants.EXTRA_BEES_MOD_ID, name = "Binnie's Extra Bees", useMetadata = true, dependencies = "required-after:" + Constants.CORE_MOD_ID)
|
||||
public class ExtraBees extends AbstractMod {
|
||||
|
||||
public ExtraBees() {
|
||||
getClass();
|
||||
}
|
||||
|
||||
@Mod.Instance(Constants.EXTRA_BEES_MOD_ID)
|
||||
public static ExtraBees instance;
|
||||
@SidedProxy(clientSide = "binnie.extrabees.proxy.ExtraBeesProxyClient", serverSide = "binnie.extrabees.proxy.ExtraBeesProxyServer")
|
||||
@@ -92,7 +96,7 @@ public class ExtraBees extends AbstractMod {
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "extrabees";
|
||||
return Constants.EXTRA_BEES_MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package binnie.extrabees.core;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.item.IItemMisc;
|
||||
import binnie.core.item.IItemMiscProvider;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -14,7 +14,7 @@ import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public enum ExtraBeeItems implements IItemMisc {
|
||||
public enum ExtraBeeItems implements IItemMiscProvider {
|
||||
ScentedGear("Scented Gear", "scentedGear"),
|
||||
DiamondShard("Diamond Fragment", "diamondShard"),
|
||||
EmeraldShard("Emerald Fragment", "emeraldShard"),
|
||||
@@ -47,8 +47,7 @@ public enum ExtraBeeItems implements IItemMisc {
|
||||
CyaniteDust("Cyanite Grains", "cyaniteDust");
|
||||
|
||||
String name;
|
||||
String iconPath;
|
||||
// IIcon icon;
|
||||
String modelPath;
|
||||
String metalString;
|
||||
String gemString;
|
||||
|
||||
@@ -106,11 +105,11 @@ public enum ExtraBeeItems implements IItemMisc {
|
||||
RecipeManagers.carpenterManager.addRecipe(100, Binnie.Liquid.getFluidStack("for.honey", 500), null, ExtraBeeItems.ScentedGear.get(1), " j ", "bgb", " p ", 'j', Mods.Forestry.item("royalJelly"), 'b', Mods.Forestry.item("beeswax"), 'p', Mods.Forestry.item("pollen"), 'g', gear);
|
||||
}
|
||||
|
||||
ExtraBeeItems(final String name, final String iconPath) {
|
||||
ExtraBeeItems(String name, String modelPath) {
|
||||
this.metalString = null;
|
||||
this.gemString = null;
|
||||
this.name = name;
|
||||
this.iconPath = iconPath;
|
||||
this.modelPath = modelPath;
|
||||
}
|
||||
|
||||
private void setGem(final String string) {
|
||||
@@ -153,6 +152,11 @@ public enum ExtraBeeItems implements IItemMisc {
|
||||
public ItemStack get(final int i) {
|
||||
return new ItemStack(ExtraBees.itemMisc, i, this.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
static {
|
||||
ExtraBeeItems.TinDust.setMetal("Tin");
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package binnie.extrabees.proxy;
|
||||
|
||||
import binnie.core.proxy.BinnieModProxy;
|
||||
import binnie.extrabees.ExtraBees;
|
||||
import binnie.extrabees.genetics.ExtraBeesSpecies;
|
||||
|
||||
public class ExtraBeesProxy extends BinnieModProxy {
|
||||
public ExtraBeesProxy() {
|
||||
super(ExtraBees.instance);
|
||||
}
|
||||
|
||||
public void registerBeeModel(ExtraBeesSpecies type) {
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class ExtraTrees extends AbstractMod {
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "extratrees";
|
||||
return Constants.EXTRA_TREES_MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package binnie.extratrees.item;
|
||||
|
||||
import binnie.core.item.IItemMisc;
|
||||
import binnie.core.item.IItemMiscProvider;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public enum ExtraTreeItems implements IItemMisc {
|
||||
public enum ExtraTreeItems implements IItemMiscProvider {
|
||||
CarpentryHammer("Fake Hammer", "carpentryHammer"),
|
||||
Sawdust("Sawdust", "sawdust"),
|
||||
Bark("Bark", "bark"),
|
||||
@@ -23,23 +23,17 @@ public enum ExtraTreeItems implements IItemMisc {
|
||||
GlassFitting("Glass Fittings", "glassFitting");
|
||||
|
||||
String name;
|
||||
String iconPath;
|
||||
// IIcon icon;
|
||||
String modelPath;
|
||||
|
||||
ExtraTreeItems(final String name, final String iconPath) {
|
||||
ExtraTreeItems(final String name, final String modelPath) {
|
||||
this.name = name;
|
||||
this.iconPath = iconPath;
|
||||
this.modelPath = modelPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IIcon getIcon(final ItemStack stack) {
|
||||
// return this.icon;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void registerIcons(final IIconRegister register) {
|
||||
// this.icon = ExtraTrees.proxy.getIcon(register, this.iconPath);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addInformation(final List par3List) {
|
||||
|
||||
@@ -2,7 +2,7 @@ package binnie.extratrees.item;
|
||||
|
||||
import binnie.Binnie;
|
||||
import binnie.core.Mods;
|
||||
import binnie.core.item.IItemMisc;
|
||||
import binnie.core.item.IItemMiscProvider;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import binnie.extratrees.alcohol.Juice;
|
||||
import forestry.api.recipes.RecipeManagers;
|
||||
@@ -13,7 +13,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public enum Food implements IItemMisc {
|
||||
public enum Food implements IItemMiscProvider {
|
||||
Crabapple(2),
|
||||
Orange(4),
|
||||
Kumquat(2),
|
||||
@@ -110,16 +110,11 @@ public enum Food implements IItemMisc {
|
||||
public ItemStack get(final int i) {
|
||||
return new ItemStack(ExtraTrees.itemFood, i, this.ordinal());
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IIcon getIcon(final ItemStack stack) {
|
||||
// return this.icon;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void registerIcons(final IIconRegister register) {
|
||||
// this.icon = ExtraTrees.proxy.getIcon(register, "food/" + this.toString());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String getModelPath() {
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(final List par3List) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.extratrees.item;
|
||||
|
||||
import binnie.core.item.IItemMisc;
|
||||
import binnie.core.item.IItemMiscProvider;
|
||||
import forestry.api.core.Tabs;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -12,7 +12,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemFood extends net.minecraft.item.ItemFood {
|
||||
IItemMisc[] items;
|
||||
IItemMiscProvider[] items;
|
||||
|
||||
public ItemFood() {
|
||||
super(0, 0.0f, false);
|
||||
@@ -26,18 +26,18 @@ public class ItemFood extends net.minecraft.item.ItemFood {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(final Item par1, final CreativeTabs par2CreativeTabs, final List par3List) {
|
||||
for (final IItemMisc item : this.items) {
|
||||
for (final IItemMiscProvider item : this.items) {
|
||||
if (item.isActive()) {
|
||||
par3List.add(this.getStack(item, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IItemMisc getItem(final int damage) {
|
||||
private IItemMiscProvider getItem(final int damage) {
|
||||
return (damage >= this.items.length) ? this.items[0] : this.items[damage];
|
||||
}
|
||||
|
||||
public ItemStack getStack(final IItemMisc type, final int size) {
|
||||
public ItemStack getStack(final IItemMiscProvider type, final int size) {
|
||||
return new ItemStack(this, size, type.ordinal());
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ItemFood extends net.minecraft.item.ItemFood {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, playerIn, tooltip, advanced);
|
||||
final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
final IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
if (item != null) {
|
||||
item.addInformation(tooltip);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class ItemFood extends net.minecraft.item.ItemFood {
|
||||
|
||||
@Override
|
||||
public String getItemStackDisplayName(final ItemStack stack) {
|
||||
final IItemMisc item = this.getItem(stack.getItemDamage());
|
||||
final IItemMiscProvider item = this.getItem(stack.getItemDamage());
|
||||
return (item != null) ? item.getName(stack) : "null";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package binnie.extratrees.proxy;
|
||||
|
||||
import binnie.core.proxy.BinnieModProxy;
|
||||
import binnie.extratrees.ExtraTrees;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class Proxy extends BinnieModProxy implements IExtraTreeProxy {
|
||||
public Proxy() {
|
||||
super(ExtraTrees.instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomStateMapper(String name, Block block) {
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
@Mod(modid = Constants.GENETICS_MOD_ID, name = "Binnie's Genetics", useMetadata = true, dependencies = "required-after:" + Constants.CORE_MOD_ID)
|
||||
public class Genetics extends AbstractMod {
|
||||
|
||||
|
||||
@Mod.Instance(Constants.GENETICS_MOD_ID)
|
||||
public static Genetics instance;
|
||||
|
||||
@SidedProxy(clientSide = "binnie.genetics.proxy.ProxyClient", serverSide = "binnie.genetics.proxy.ProxyServer")
|
||||
public static Proxy proxy;
|
||||
|
||||
public static String channel = "GEN";
|
||||
public static Item itemGenetics;
|
||||
public static Item itemSerum;
|
||||
@@ -86,7 +88,7 @@ public class Genetics extends AbstractMod {
|
||||
|
||||
@Override
|
||||
public String getModID() {
|
||||
return "genetics";
|
||||
return Constants.GENETICS_MOD_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package binnie.genetics.item;
|
||||
|
||||
import binnie.core.item.IItemMisc;
|
||||
import binnie.core.item.IItemMiscProvider;
|
||||
import binnie.genetics.Genetics;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public enum GeneticsItems implements IItemMisc {
|
||||
public enum GeneticsItems implements IItemMiscProvider {
|
||||
LaboratoryCasing("Reinforced Casing", "casingIron"),
|
||||
DNADye("DNA Dye", "dnaDye"),
|
||||
FluorescentDye("Fluorescent Dye", "dyeFluor"),
|
||||
@@ -22,24 +22,18 @@ public enum GeneticsItems implements IItemMisc {
|
||||
IntegratedCPU("Integrated CPU", "integratedCPU"),
|
||||
IntegratedCasing("Integrated Casing", "casingCircuit");
|
||||
|
||||
// IIcon icon;
|
||||
String name;
|
||||
String iconPath;
|
||||
String modelPath;
|
||||
|
||||
GeneticsItems(final String name, final String iconPath) {
|
||||
GeneticsItems(final String name, final String modelPath) {
|
||||
this.name = name;
|
||||
this.iconPath = iconPath;
|
||||
this.modelPath = modelPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModelPath() {
|
||||
return modelPath;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IIcon getIcon(final ItemStack stack) {
|
||||
// return this.icon;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void registerIcons(final IIconRegister register) {
|
||||
// this.icon = Genetics.proxy.getIcon(register, this.iconPath);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addInformation(final List par3List) {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package binnie.genetics.proxy;
|
||||
|
||||
import binnie.core.proxy.BinnieModProxy;
|
||||
import binnie.genetics.Genetics;
|
||||
|
||||
public class Proxy extends BinnieModProxy implements IGeneticsProxy {
|
||||
public Proxy() {
|
||||
super(Genetics.instance);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user