mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-26 23:03:18 +00:00
Fix crate renderin, fix sprinkler rendering and fix butterfly rendering.
This commit is contained in:
1 parent
c30c3d7575
commit
03c1c26258
19 files changed
+466
-352
No files matched your search
@@ -387,6 +387,6 @@ public class PluginCore extends BlankForestryPlugin {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites(TextureStitchEvent.Pre event) {
|
||||
TextureManager.registerSprites();
|
||||
TextureManager.getInstance().registerSprites();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public abstract class BlockRegistry {
|
||||
@@ -28,7 +29,7 @@ public abstract class BlockRegistry {
|
||||
block.setUnlocalizedName("for." + name);
|
||||
GameRegistry.registerBlock(block, null, name);
|
||||
GameRegistry.registerItem(itemBlock, name);
|
||||
ModelManager.getInstance().registerBlock(block);
|
||||
Proxies.common.registerBlock(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ public abstract class BlockRegistry {
|
||||
}
|
||||
block.setUnlocalizedName("for." + name);
|
||||
GameRegistry.registerBlock(block, itemClass, name, itemCtorArgs);
|
||||
ModelManager.getInstance().registerBlock(block);
|
||||
Proxies.common.registerBlock(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ package forestry.core.items;
|
||||
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.color.ItemColors;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -29,7 +31,7 @@ import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Translator;
|
||||
|
||||
public class ItemCrated extends ItemForestry {
|
||||
public class ItemCrated extends ItemForestry implements IItemColor {
|
||||
|
||||
private final ItemStack contained;
|
||||
private final boolean usesOreDict;
|
||||
@@ -87,13 +89,17 @@ public class ItemCrated extends ItemForestry {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: crate rendering
|
||||
// @Override
|
||||
// public int getColorFromItemstack(ItemStack stack, int renderPass) {
|
||||
// if (getContained() == null || renderPass == 100) {
|
||||
// return super.getColorFromItemstack(stack, renderPass);
|
||||
// }
|
||||
// return getContained().getItem().getColorFromItemstack(getContained(), renderPass);
|
||||
// }
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int renderPass) {
|
||||
ItemColors colors = Proxies.common.getClientInstance().getItemColors();
|
||||
if (getContained() == null || renderPass == 100) {
|
||||
return -1;
|
||||
}
|
||||
int color = colors.getColorFromItemstack(contained, renderPass);
|
||||
if(color != -1){
|
||||
return color;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.plugins.PluginManager;
|
||||
|
||||
public abstract class ItemRegistry {
|
||||
@@ -26,7 +27,7 @@ public abstract class ItemRegistry {
|
||||
}
|
||||
item.setUnlocalizedName("for." + name);
|
||||
GameRegistry.registerItem(item, name);
|
||||
ModelManager.getInstance().registerItem(item);
|
||||
Proxies.common.registerItem(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
******************************************************************************/
|
||||
package forestry.core.models;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -25,7 +27,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
public abstract class BlankItemModel implements IBakedModel {
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return new ItemOverrideList(Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,7 +57,7 @@ public abstract class BlankItemModel implements IBakedModel {
|
||||
|
||||
@Override
|
||||
public ItemCameraTransforms getItemCameraTransforms() {
|
||||
return null;
|
||||
return ItemCameraTransforms.DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,241 +1,296 @@
|
||||
// TODO: fix crate rendering
|
||||
/*******************************************************************************
|
||||
* 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.models;
|
||||
|
||||
///*******************************************************************************
|
||||
// * 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.models;
|
||||
//
|
||||
//import com.google.common.base.Charsets;
|
||||
//import com.google.common.collect.ImmutableMap;
|
||||
//import com.google.common.collect.Maps;
|
||||
//
|
||||
//import javax.vecmath.Vector3f;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStreamReader;
|
||||
//import java.io.Reader;
|
||||
//import java.io.StringReader;
|
||||
//import java.util.IdentityHashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import net.minecraft.client.Minecraft;
|
||||
//import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
//import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
//import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
//import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
//import net.minecraft.client.resources.IResource;
|
||||
//import net.minecraft.client.resources.model.IBakedModel;
|
||||
//import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
//import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
//import net.minecraft.item.Item;
|
||||
//import net.minecraft.item.ItemStack;
|
||||
//import net.minecraft.util.ResourceLocation;
|
||||
//
|
||||
//import net.minecraftforge.client.ItemModelMesherForge;
|
||||
//import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
//import net.minecraftforge.client.model.IFlexibleBakedModel;
|
||||
//import net.minecraftforge.client.model.IModel;
|
||||
//import net.minecraftforge.client.model.IModelState;
|
||||
//import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
||||
//import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
//import net.minecraftforge.client.model.MultiModel;
|
||||
//import net.minecraftforge.client.model.SimpleModelState;
|
||||
//import net.minecraftforge.client.model.TRSRTransformation;
|
||||
//import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
//import net.minecraftforge.fml.relauncher.Side;
|
||||
//import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
//
|
||||
//import forestry.core.items.ItemCrated;
|
||||
//import forestry.core.utils.ItemStackUtil;
|
||||
//import forestry.core.utils.Log;
|
||||
//import forestry.storage.PluginStorage;
|
||||
//
|
||||
//import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
//
|
||||
//@SideOnly(Side.CLIENT)
|
||||
//public class ModelCrate extends BlankItemModel {
|
||||
//
|
||||
// private final Map<String, IModel> crates = Maps.newHashMap();
|
||||
//
|
||||
// private static IModel crateModel;
|
||||
// private static ModelBlock MODEL_GENERATED;
|
||||
// private static ModelBlock MODEL_COMPASS;
|
||||
// private static ModelBlock MODEL_CLOCK;
|
||||
//
|
||||
// /**
|
||||
// * Init the model
|
||||
// */
|
||||
// public static void initModel(ModelBakeEvent event){
|
||||
// try {
|
||||
// crateModel = ModelLoaderRegistry.getModel(new ModelResourceLocation("forestry:crate-filled", "inventory"));
|
||||
// MODEL_GENERATED = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.modelLoader, 14);
|
||||
// MODEL_COMPASS = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.modelLoader, 15);
|
||||
// MODEL_CLOCK = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.modelLoader, 16);
|
||||
// } catch (Exception e) {
|
||||
// Log.error("Failed to init the crate model.", e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Bake the crate content models
|
||||
// */
|
||||
// private ImmutableMap<String, IFlexibleBakedModel> bakeContentModels(ItemCrated crateItem) {
|
||||
// ImmutableMap.Builder<String, IFlexibleBakedModel> pb = ImmutableMap.builder();
|
||||
//
|
||||
// IFlexibleBakedModel containedModel = getModel(crateItem.getContained());
|
||||
//
|
||||
// IdentityHashMap<Item, TIntObjectHashMap<ModelResourceLocation>> modelResourceLocations = ObfuscationReflectionHelper.getPrivateValue(ItemModelMesherForge.class, (ItemModelMesherForge) Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), 0);
|
||||
//
|
||||
// ModelResourceLocation modelResource = modelResourceLocations.get(crateItem.getContained().getItem()).get(crateItem.getContained().getItemDamage());
|
||||
// ResourceLocation location = getItemLocation(modelResource);
|
||||
//
|
||||
// if (hasItemModel(location)) {
|
||||
// pb.put(String.valueOf(0), new TRSRBakedModel(containedModel, -0.0625F, 0, 0.0625F, 0.5F));
|
||||
// pb.put(String.valueOf(1), new TRSRBakedModel(containedModel, -0.0625F, 0, -0.0625F, 0.5F));
|
||||
// } else {
|
||||
// pb.put(String.valueOf(0), new TRSRBakedModel(containedModel, -0.0625F, 0, 0, 0.5F));
|
||||
// }
|
||||
// return pb.build();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The item model {@link ResourceLocation} from a {@link ModelResourceLocation}
|
||||
// */
|
||||
// private ResourceLocation getItemLocation(ModelResourceLocation modelResource) {
|
||||
// ResourceLocation resourcelocation = new ResourceLocation(modelResource.toString().replaceAll("#.*", ""));
|
||||
// return new ResourceLocation(resourcelocation.getResourceDomain(), "item/" + resourcelocation.getResourcePath());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return Return true, when the model a item model is
|
||||
// */
|
||||
// private boolean hasItemModel(ResourceLocation location) {
|
||||
// try {
|
||||
// ModelBlock modelBlock = loadModel(location);
|
||||
// if (modelBlock == null) {
|
||||
// return false;
|
||||
// } else {
|
||||
// ModelBlock rootModelBlock = modelBlock.getRootModel();
|
||||
// return rootModelBlock == MODEL_GENERATED || rootModelBlock == MODEL_COMPASS || rootModelBlock == MODEL_CLOCK;
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private ModelBlock loadModel(ResourceLocation location) throws IOException {
|
||||
// String s = location.getResourcePath();
|
||||
//
|
||||
// if ("builtin/generated".equals(s)) {
|
||||
// return MODEL_GENERATED;
|
||||
// } else if ("builtin/compass".equals(s)) {
|
||||
// return MODEL_COMPASS;
|
||||
// } else if ("builtin/clock".equals(s)) {
|
||||
// return MODEL_CLOCK;
|
||||
// } else {
|
||||
// Reader reader;
|
||||
//
|
||||
// if (s.startsWith("builtin/")) {
|
||||
// String s1 = s.substring("builtin/".length());
|
||||
// if (s1.equals("missing")) {
|
||||
// reader = new StringReader("{ \"textures\": { \"particle\": \"missingno\", \"missingno\": \"missingno\"}, \"elements\": [ { \"from\": [ 0, 0, 0 ], \"to\": [ 16, 16, 16 ], \"faces\": { \"down\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"down\", \"texture\": \"#missingno\" }, \"up\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"up\", \"texture\": \"#missingno\" }, \"north\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"north\", \"texture\": \"#missingno\" }, \"south\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"south\", \"texture\": \"#missingno\" }, \"west\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"west\", \"texture\": \"#missingno\" }, \"east\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"east\", \"texture\": \"#missingno\" } }}]}");
|
||||
// } else {
|
||||
// throw new FileNotFoundException(location.toString());
|
||||
// }
|
||||
// } else {
|
||||
// IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.getModelLocation(location));
|
||||
// reader = new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8);
|
||||
// }
|
||||
//
|
||||
// ModelBlock model;
|
||||
//
|
||||
// try {
|
||||
// ModelBlock modelblock = ModelBlock.deserialize(reader);
|
||||
// modelblock.name = location.toString();
|
||||
// model = modelblock;
|
||||
// } finally {
|
||||
// try {
|
||||
// reader.close();
|
||||
// } catch (IOException e) {
|
||||
// Log.error("Failed to close crate model reader.", e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (model != null && model.getParentLocation() != null) {
|
||||
// if (model.getParentLocation().getResourcePath().equals("builtin/generated")) {
|
||||
// model.parent = MODEL_GENERATED;
|
||||
// } else {
|
||||
// try {
|
||||
// model.parent = loadModel(model.getParentLocation());
|
||||
// } catch (IOException e) {
|
||||
// Log.error("Failed to load model.", e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return model;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private ResourceLocation getModelLocation(ResourceLocation resourceLocation) {
|
||||
// return new ResourceLocation(resourceLocation.getResourceDomain(), "models/" + resourceLocation.getResourcePath() + ".json");
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return The baked model from the filled crate
|
||||
// */
|
||||
// private IFlexibleBakedModel getModel(ItemStack stack) {
|
||||
// IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
|
||||
// if (model == null) {
|
||||
// return null;
|
||||
// } else if (model instanceof IFlexibleBakedModel) {
|
||||
// return (IFlexibleBakedModel) model;
|
||||
// } else {
|
||||
// return new IFlexibleBakedModel.Wrapper(model, DefaultVertexFormats.ITEM);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Bake the crated model
|
||||
// */
|
||||
// @Override
|
||||
// public IBakedModel handleItemState(ItemStack stack) {
|
||||
// ItemCrated crated = (ItemCrated) stack.getItem();
|
||||
// String crateUID = ItemStackUtil.getItemNameFromRegistry(crated).getResourcePath();
|
||||
// if (crates.get(crateUID) == null) {
|
||||
// IFlexibleBakedModel baseBaked = getModel(new ItemStack(PluginStorage.items.crate, 1, 1));
|
||||
// //Set the crate color index to 100
|
||||
// for (BakedQuad quad : baseBaked.getGeneralQuads()) {
|
||||
// ObfuscationReflectionHelper.setPrivateValue(BakedQuad.class, quad, 100, 1);
|
||||
// }
|
||||
// crates.put(crateUID, new MultiModel.Baked(null, true, new IPerspectiveAwareModel.MapWrapper(baseBaked, getTransformations()), bakeContentModels(crated)));
|
||||
// }
|
||||
// return crates.get(crateUID);
|
||||
// }
|
||||
//
|
||||
// public static IModelState getTransformations() {
|
||||
// TRSRTransformation thirdperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(
|
||||
// new Vector3f(0, 1f / 16, -3f / 16),
|
||||
// TRSRTransformation.quatFromYXZDegrees(new Vector3f(-90, 0, 0)),
|
||||
// new Vector3f(0.55f, 0.55f, 0.55f),
|
||||
// null));
|
||||
// TRSRTransformation firstperson = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(
|
||||
// new Vector3f(0, 4f / 16, 2f / 16),
|
||||
// TRSRTransformation.quatFromYXZDegrees(new Vector3f(0, -135, 25)),
|
||||
// new Vector3f(1.7f, 1.7f, 1.7f),
|
||||
// null));
|
||||
// return new SimpleModelState(ImmutableMap.of(TransformType.THIRD_PERSON, thirdperson, TransformType.FIRST_PERSON, firstperson));
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean isGui3d() {
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.block.model.ItemOverride;
|
||||
import net.minecraft.client.renderer.block.model.ModelBlock;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.MultipartBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.ItemModelMesherForge;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
import net.minecraftforge.client.model.IPerspectiveAwareModel;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.MultiModel;
|
||||
import net.minecraftforge.client.model.SimpleModelState;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.common.model.TRSRTransformation;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import forestry.api.core.IModelBaker;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
import forestry.storage.PluginStorage;
|
||||
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ModelCrate extends BlankItemModel {
|
||||
|
||||
private final Map<String, IBakedModel> crates = Maps.newHashMap();
|
||||
|
||||
private static IModel crateModel;
|
||||
private static ModelBlock MODEL_GENERATED;
|
||||
private static ModelBlock MODEL_ENTITY;
|
||||
|
||||
|
||||
//Init the model
|
||||
public static void initModel(ModelBakeEvent event){
|
||||
try {
|
||||
crateModel = ModelLoaderRegistry.getModel(new ResourceLocation("forestry:item/crate-filled"));
|
||||
MODEL_GENERATED = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.getModelLoader(), 17);
|
||||
MODEL_ENTITY = ObfuscationReflectionHelper.getPrivateValue(ModelBakery.class, event.getModelLoader(), 18);
|
||||
} catch (Exception e) {
|
||||
Log.error("Failed to init the crate model.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Bake the crate content models
|
||||
private List<IBakedModel> bakeContentModels(ItemCrated crateItem, IBakedModel crateModel) {
|
||||
List<IBakedModel> models = new ArrayList();
|
||||
|
||||
IBakedModel containedModel = getModel(crateItem.getContained());
|
||||
|
||||
IdentityHashMap<Item, TIntObjectHashMap<ModelResourceLocation>> modelResourceLocations = ObfuscationReflectionHelper.getPrivateValue(ItemModelMesherForge.class, (ItemModelMesherForge) Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), 0);
|
||||
|
||||
ModelResourceLocation modelResource = modelResourceLocations.get(crateItem.getContained().getItem()).get(crateItem.getContained().getItemDamage());
|
||||
ResourceLocation location = getItemLocation(modelResource);
|
||||
|
||||
models.add(crateModel);
|
||||
|
||||
if (hasItemModel(location)) {
|
||||
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0.0625F, 0.5F));
|
||||
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, -0.0625F, 0.5F));
|
||||
} else {
|
||||
models.add(new TRSRBakedModel(containedModel, -0.0625F, 0, 0, 0.5F));
|
||||
}
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The item model {@link ResourceLocation} from a {@link ModelResourceLocation}
|
||||
*/
|
||||
private ResourceLocation getItemLocation(ModelResourceLocation modelResource) {
|
||||
ResourceLocation resourcelocation = new ResourceLocation(modelResource.toString().replaceAll("#.*", ""));
|
||||
return new ResourceLocation(resourcelocation.getResourceDomain(), "item/" + resourcelocation.getResourcePath());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return true, when the model a item model is
|
||||
*/
|
||||
private boolean hasItemModel(ResourceLocation location) {
|
||||
try {
|
||||
ModelBlock modelBlock = loadModel(location);
|
||||
if (modelBlock == null) {
|
||||
return false;
|
||||
} else {
|
||||
return modelBlock.getRootModel() == MODEL_GENERATED;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected ModelBlock loadModel(ResourceLocation location) throws IOException
|
||||
{
|
||||
Reader reader = null;
|
||||
IResource iresource = null;
|
||||
ModelBlock model;
|
||||
|
||||
try
|
||||
{
|
||||
String s = location.getResourcePath();
|
||||
|
||||
if (!"builtin/generated".equals(s)){
|
||||
if ("builtin/entity".equals(s)){
|
||||
model = MODEL_ENTITY;
|
||||
return model;
|
||||
}
|
||||
|
||||
if (s.startsWith("builtin/")) {
|
||||
String s1 = s.substring("builtin/".length());
|
||||
if (s1.equals("missing")) {
|
||||
reader = new StringReader("{ \"textures\": { \"particle\": \"missingno\", \"missingno\": \"missingno\"}, \"elements\": [ { \"from\": [ 0, 0, 0 ], \"to\": [ 16, 16, 16 ], \"faces\": { \"down\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"down\", \"texture\": \"#missingno\" }, \"up\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"up\", \"texture\": \"#missingno\" }, \"north\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"north\", \"texture\": \"#missingno\" }, \"south\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"south\", \"texture\": \"#missingno\" }, \"west\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"west\", \"texture\": \"#missingno\" }, \"east\": { \"uv\": [ 0, 0, 16, 16 ], \"cullface\": \"east\", \"texture\": \"#missingno\" } }}]}");
|
||||
} else {
|
||||
throw new FileNotFoundException(location.toString());
|
||||
}
|
||||
}else{
|
||||
iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.getModelLocation(location));
|
||||
reader = new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8);
|
||||
}
|
||||
|
||||
model = ModelBlock.deserialize(reader);
|
||||
model.name = location.toString();
|
||||
if (model != null && model.getParentLocation() != null) {
|
||||
if (model.getParentLocation().getResourcePath().equals("builtin/generated")) {
|
||||
model.parent = MODEL_GENERATED;
|
||||
} else {
|
||||
try {
|
||||
model.parent = loadModel(model.getParentLocation());
|
||||
} catch (IOException e) {
|
||||
Log.error("Failed to load model.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
model = MODEL_GENERATED;
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly(reader);
|
||||
IOUtils.closeQuietly((Closeable)iresource);
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private ResourceLocation getModelLocation(ResourceLocation resourceLocation) {
|
||||
return new ResourceLocation(resourceLocation.getResourceDomain(), "models/" + resourceLocation.getResourcePath() + ".json");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The baked model from the filled crate
|
||||
*/
|
||||
private IBakedModel getModel(ItemStack stack) {
|
||||
return Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides() {
|
||||
return new CrateOverrideList();
|
||||
}
|
||||
|
||||
private class CrateOverrideList extends ItemOverrideList{
|
||||
|
||||
public CrateOverrideList() {
|
||||
super(Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Bake the crated model
|
||||
*/
|
||||
@Override
|
||||
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity) {
|
||||
ItemCrated crated = (ItemCrated) stack.getItem();
|
||||
String crateUID = ItemStackUtil.getItemNameFromRegistry(crated).getResourcePath();
|
||||
if (crates.get(crateUID) == null) {
|
||||
IBakedModel baseBaked = getModel(new ItemStack(PluginStorage.items.crate, 1, 1));
|
||||
//Set the crate color index to 100
|
||||
for (BakedQuad quad : baseBaked.getQuads(null, null, 0)) {
|
||||
ObfuscationReflectionHelper.setPrivateValue(BakedQuad.class, quad, 100, 1);
|
||||
}
|
||||
|
||||
crates.put(crateUID, new IPerspectiveAwareModel.MapWrapper(new CrateBakedModel( bakeContentModels(crated, baseBaked)), getTransformations()));
|
||||
}
|
||||
return crates.get(crateUID);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class CrateBakedModel extends BlankItemModel{
|
||||
|
||||
public final List<IBakedModel> models;
|
||||
|
||||
public CrateBakedModel(List<IBakedModel> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
|
||||
List<BakedQuad> quads = new ArrayList();
|
||||
for(IBakedModel bakedModel : models){
|
||||
quads.addAll(bakedModel.getQuads(null, side, rand++));
|
||||
}
|
||||
return quads;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static IModelState getTransformations() {
|
||||
TRSRTransformation thirdperson = get(0, 3, 1, 0, 0, 0, 0.55f);
|
||||
TRSRTransformation firstperson = get(1.13f, 3.2f, 1.13f, 0, -90, 25, 0.68f);
|
||||
ImmutableMap.Builder<TransformType, TRSRTransformation> builder = ImmutableMap.builder();
|
||||
builder.put(TransformType.GROUND, get(0, 2, 0, 0, 0, 0, 0.5f));
|
||||
builder.put(TransformType.HEAD, get(0, 13, 7, 0, 180, 0, 1));
|
||||
builder.put(TransformType.THIRD_PERSON_RIGHT_HAND, thirdperson);
|
||||
builder.put(TransformType.THIRD_PERSON_LEFT_HAND, leftify(thirdperson));
|
||||
builder.put(TransformType.FIRST_PERSON_RIGHT_HAND, firstperson);
|
||||
builder.put(TransformType.FIRST_PERSON_LEFT_HAND, leftify(firstperson));
|
||||
return new SimpleModelState(builder.build());
|
||||
}
|
||||
|
||||
private static TRSRTransformation get(float tx, float ty, float tz, float ax, float ay, float az, float s)
|
||||
{
|
||||
return TRSRTransformation.blockCenterToCorner(new TRSRTransformation(
|
||||
new Vector3f(tx / 16, ty / 16, tz / 16),
|
||||
TRSRTransformation.quatFromXYZDegrees(new Vector3f(ax, ay, az)),
|
||||
new Vector3f(s, s, s),
|
||||
null));
|
||||
}
|
||||
|
||||
private static final TRSRTransformation flipX = new TRSRTransformation(null, null, new Vector3f(-1, 1, 1), null);
|
||||
|
||||
private static TRSRTransformation leftify(TRSRTransformation transform)
|
||||
{
|
||||
return TRSRTransformation.blockCenterToCorner(flipX.compose(TRSRTransformation.blockCornerToCenter(transform)).compose(flipX));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -201,34 +201,10 @@ public class ModelBaker implements IModelBaker {
|
||||
return;
|
||||
}
|
||||
|
||||
/*boolean isEdge;
|
||||
switch (facing) {
|
||||
case WEST:
|
||||
isEdge = renderBounds.minX < 0.0001;
|
||||
break;
|
||||
case DOWN:
|
||||
isEdge = renderBounds.minY < 0.0001;
|
||||
break;
|
||||
case NORTH:
|
||||
isEdge = renderBounds.minZ < 0.0001;
|
||||
break;
|
||||
case UP:
|
||||
isEdge = renderBounds.maxY > 0.9999;
|
||||
break;
|
||||
case SOUTH:
|
||||
isEdge = renderBounds.maxZ > 0.9999;
|
||||
break;
|
||||
case EAST:
|
||||
isEdge = renderBounds.maxX > 0.9999;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}*/
|
||||
|
||||
Vector3f to = new Vector3f((float) renderBounds.minX * 16.0f, (float) renderBounds.minY * 16.0f, (float) renderBounds.minZ * 16.0f);
|
||||
Vector3f from = new Vector3f((float) renderBounds.maxX * 16.0f, (float) renderBounds.maxY * 16.0f, (float) renderBounds.maxZ * 16.0f);
|
||||
|
||||
faces.add(new ModelBakerFace(facing/*, isEdge*/, colorIndex, to, from, defUVs, sprite));
|
||||
faces.add(new ModelBakerFace(facing, colorIndex, to, from, defUVs, sprite));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -253,7 +229,6 @@ public class ModelBaker implements IModelBaker {
|
||||
|
||||
BakedQuad bf = faceBakery.makeBakedQuad(face.to, face.from, bpf, face.spite, myFace, mr, null, true, true);
|
||||
|
||||
//if (face.isEdge) {
|
||||
currentModel.addQuad(myFace, bf);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.lwjgl.util.vector.Vector3f;
|
||||
public class ModelBakerFace {
|
||||
@Nonnull
|
||||
public final EnumFacing face;
|
||||
//public final boolean isEdge;
|
||||
|
||||
public final Vector3f to;
|
||||
public final Vector3f from;
|
||||
@@ -38,10 +37,9 @@ public class ModelBakerFace {
|
||||
|
||||
public final int colorIndex;
|
||||
|
||||
public ModelBakerFace(@Nonnull EnumFacing face/*, boolean isEdge*/, int colorIndex, Vector3f to, Vector3f from, float[] defUVs2, TextureAtlasSprite sprite) {
|
||||
public ModelBakerFace(@Nonnull EnumFacing face, int colorIndex, Vector3f to, Vector3f from, float[] defUVs2, TextureAtlasSprite sprite) {
|
||||
this.colorIndex = colorIndex;
|
||||
this.face = face;
|
||||
//this.isEdge = isEdge;
|
||||
this.to = to;
|
||||
this.from = from;
|
||||
this.uv = defUVs2;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class ModelBakerModel implements IModelBakerModel {
|
||||
|
||||
@Override
|
||||
public boolean isGui3d() {
|
||||
return true;
|
||||
return isGui3d;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,9 +12,11 @@ package forestry.core.proxy;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.UserListOpsEntry;
|
||||
@@ -38,6 +40,14 @@ public class ProxyCommon {
|
||||
public String getMinecraftVersion() {
|
||||
return Loader.instance().getMinecraftModContainer().getVersion();
|
||||
}
|
||||
|
||||
public void registerItem(Item item){
|
||||
|
||||
}
|
||||
|
||||
public void registerBlock(Block block){
|
||||
|
||||
}
|
||||
|
||||
public void registerTickHandlers(WorldGenerator worldGenerator) {
|
||||
TickHandlerCoreServer tickHandlerCoreServer = new TickHandlerCoreServer(worldGenerator);
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
@@ -28,8 +29,10 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import forestry.core.TickHandlerCoreClient;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.multiblock.MultiblockClientTickHandler;
|
||||
import forestry.core.network.packets.PacketFXSignal;
|
||||
import forestry.core.render.TextureManager;
|
||||
import forestry.core.worldgen.WorldGenerator;
|
||||
|
||||
public class ProxyCommonClient extends ProxyCommon {
|
||||
@@ -41,6 +44,18 @@ public class ProxyCommonClient extends ProxyCommon {
|
||||
MinecraftForge.EVENT_BUS.register(new TickHandlerCoreClient());
|
||||
MinecraftForge.EVENT_BUS.register(new MultiblockClientTickHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlock(Block block) {
|
||||
ModelManager.getInstance().registerBlock(block);
|
||||
TextureManager.getInstance().registerBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerItem(Item item) {
|
||||
ModelManager.getInstance().registerItem(item);
|
||||
TextureManager.getInstance().registerItem(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getForestryRoot() {
|
||||
|
||||
@@ -110,9 +110,9 @@ public class ProxyRender {
|
||||
public void registerItemAndBlockColors() {
|
||||
}
|
||||
|
||||
// public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){
|
||||
// return null;
|
||||
// }
|
||||
public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){
|
||||
return null;
|
||||
}
|
||||
|
||||
/* FX */
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ package forestry.core.proxy;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -33,7 +35,9 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
||||
import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.common.animation.ITimeValue;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
import forestry.apiculture.entities.EntityFXBee;
|
||||
import forestry.apiculture.render.ParticleRenderer;
|
||||
import forestry.apiculture.render.TextureHabitatLocator;
|
||||
@@ -46,6 +50,7 @@ import forestry.core.entities.EntityFXSnow;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.models.BlockModelIndex;
|
||||
import forestry.core.models.ModelCrate;
|
||||
import forestry.core.models.ModelIndex;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.render.RenderAnalyzer;
|
||||
@@ -136,8 +141,7 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
public void registerModelCrate(ItemCrated crate) {
|
||||
String cleanItemName = ItemStackUtil.getItemNameFromRegistry(crate).getResourcePath();
|
||||
ModelResourceLocation modelLocation = new ModelResourceLocation("forestry:crate-filled", cleanItemName);
|
||||
// TODO: fix crate rendering
|
||||
// registerModel(new ModelIndex(modelLocation, new ModelCrate()));
|
||||
registerModel(new ModelIndex(modelLocation, new ModelCrate()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -165,10 +169,10 @@ public class ProxyRenderClient extends ProxyRender {
|
||||
ModelManager.getInstance().registerItemAndBlockColors();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){
|
||||
// return Animation.INSTANCE.load(location, parameters);
|
||||
// }
|
||||
@Override
|
||||
public IAnimationStateMachine loadAnimationState(ResourceLocation location, ImmutableMap<String, ITimeValue> parameters){
|
||||
return ModelLoaderRegistry.loadASM(location, parameters);
|
||||
}
|
||||
|
||||
private static boolean shouldSpawnParticle(World world) {
|
||||
if (!Config.enableParticleFX) {
|
||||
|
||||
@@ -16,6 +16,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.color.IBlockColor;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
@@ -26,8 +28,10 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.IItemModelRegister;
|
||||
import forestry.api.core.ISpriteProvider;
|
||||
import forestry.api.core.ISpriteRegister;
|
||||
import forestry.api.core.IStateMapperRegister;
|
||||
import forestry.api.core.ITextureManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
|
||||
@@ -39,6 +43,8 @@ public class TextureManager implements ITextureManager {
|
||||
private static final Map<String, TextureAtlasSprite> defaultIcons = new HashMap<>();
|
||||
private static final DefaultSpriteProvider defaultIconProvider = new DefaultSpriteProvider();
|
||||
private static final List<ISpriteProvider> iconProviders = new ArrayList<>();
|
||||
|
||||
private final List<ISpriteRegister> spriteRegisters = new ArrayList<>();
|
||||
|
||||
static {
|
||||
ForestryAPI.textureManager = instance;
|
||||
@@ -130,17 +136,22 @@ public class TextureManager implements ITextureManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void registerSprites() {
|
||||
for (Block block : GameData.getBlockRegistry()) {
|
||||
if (block instanceof ISpriteRegister) {
|
||||
((ISpriteRegister) block).registerSprites(getInstance());
|
||||
}
|
||||
public void registerBlock(Block block) {
|
||||
if (block instanceof ISpriteRegister) {
|
||||
spriteRegisters.add((ISpriteRegister) block);
|
||||
}
|
||||
for (Item item : GameData.getItemRegistry()) {
|
||||
if (item instanceof ISpriteRegister) {
|
||||
((ISpriteRegister) item).registerSprites(getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
public void registerItem(Item item) {
|
||||
if (item instanceof ISpriteRegister) {
|
||||
spriteRegisters.add((ISpriteRegister) item);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerSprites() {
|
||||
for (ISpriteRegister spriteRegister : spriteRegisters) {
|
||||
spriteRegister.registerSprites(getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,13 @@ package forestry.greenhouse.tiles;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.client.model.animation.Animation;
|
||||
import net.minecraftforge.common.animation.TimeValues;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.model.animation.CapabilityAnimation;
|
||||
import net.minecraftforge.common.model.animation.IAnimationStateMachine;
|
||||
|
||||
import forestry.api.core.IClimateControlled;
|
||||
@@ -26,9 +29,9 @@ import forestry.core.fluids.tanks.StandardTank;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.greenhouse.multiblock.IGreenhouseControllerInternal;
|
||||
|
||||
public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {//implements IAnimationProvider {
|
||||
public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {
|
||||
|
||||
// private final IAnimationStateMachine asm;
|
||||
private final IAnimationStateMachine asm;
|
||||
private final TimeValues.VariableValue cycleLength = new TimeValues.VariableValue(4);
|
||||
private final TimeValues.VariableValue clickTime = new TimeValues.VariableValue(Float.NEGATIVE_INFINITY);
|
||||
|
||||
@@ -37,10 +40,10 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {//impleme
|
||||
|
||||
public TileGreenhouseSprinkler() {
|
||||
super(definition);
|
||||
// asm = Proxies.render.loadAnimationState(new ResourceLocation(Constants.RESOURCE_ID, "asms/block/sprinkler.json"), ImmutableMap.of(
|
||||
// "cycle_length", cycleLength,
|
||||
// "click_time", clickTime
|
||||
// ));
|
||||
asm = Proxies.render.loadAnimationState(new ResourceLocation(Constants.RESOURCE_ID, "asms/block/sprinkler.json"), ImmutableMap.of(
|
||||
"cycle_length", cycleLength,
|
||||
"click_time", clickTime
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,17 +70,17 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {//impleme
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
super.setActive(active);
|
||||
// if (worldObj != null && worldObj.isRemote) {
|
||||
// if (asm.currentState().equals("moving") && !isActive()) {
|
||||
// clickTime.setValue(Animation.getWorldTime(getWorld(), Animation.getPartialTickTime()));
|
||||
// asm.transition("stopping");
|
||||
// } else if (asm.currentState().equals("default") && isActive()) {
|
||||
// float time = Animation.getWorldTime(getWorld(), Animation.getPartialTickTime());
|
||||
// clickTime.setValue(time);
|
||||
//
|
||||
// asm.transition("starting");
|
||||
// }
|
||||
// }
|
||||
if (worldObj != null && worldObj.isRemote) {
|
||||
if (asm.currentState().equals("moving") && !isActive()) {
|
||||
clickTime.setValue(Animation.getWorldTime(getWorld(), Animation.getPartialTickTime()));
|
||||
asm.transition("stopping");
|
||||
} else if (asm.currentState().equals("default") && isActive()) {
|
||||
float time = Animation.getWorldTime(getWorld(), Animation.getPartialTickTime());
|
||||
clickTime.setValue(time);
|
||||
|
||||
asm.transition("starting");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean consumeWaterToDoWork(int ticksPerWorkCycle, int fluidPerWorkCycle, StandardTank tank) {
|
||||
@@ -101,10 +104,23 @@ public class TileGreenhouseSprinkler extends TileGreenhouseClimatiser {//impleme
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IAnimationStateMachine asm() {
|
||||
// return asm;
|
||||
// }
|
||||
@Override
|
||||
public boolean hasCapability(Capability<?> capability, EnumFacing side){
|
||||
if(capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return super.hasCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(Capability<T> capability, EnumFacing side){
|
||||
if(capability == CapabilityAnimation.ANIMATION_CAPABILITY)
|
||||
{
|
||||
return CapabilityAnimation.ANIMATION_CAPABILITY.cast(asm);
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
private static class SprinklerDefinition implements IClimitiserDefinition {
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.storage.ICrateRegistry;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.models.ModelManager;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
import forestry.core.utils.Log;
|
||||
@@ -35,6 +36,7 @@ public class CrateRegistry implements ICrateRegistry {
|
||||
ItemCrated crate = new ItemCrated(stack, useOreDict);
|
||||
crate.setUnlocalizedName(crateName);
|
||||
GameRegistry.registerItem(crate, crateName);
|
||||
Proxies.common.registerItem(crate);
|
||||
Proxies.render.registerModelCrate(crate);
|
||||
PluginStorage.registerCrate(crate);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import forestry.core.config.Constants;
|
||||
import forestry.core.config.LocalizedConfiguration;
|
||||
import forestry.core.fluids.Fluids;
|
||||
import forestry.core.items.ItemCrated;
|
||||
import forestry.core.models.ModelCrate;
|
||||
import forestry.core.recipes.RecipeUtil;
|
||||
import forestry.core.utils.IMCUtil;
|
||||
import forestry.core.utils.ItemStackUtil;
|
||||
@@ -501,6 +502,6 @@ public class PluginStorage extends BlankForestryPlugin {
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onBakeModel(ModelBakeEvent event) {
|
||||
// ModelCrate.initModel(event);
|
||||
ModelCrate.initModel(event);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user