add item model overrides

This commit is contained in:
HoosierTransfer 2024-07-02 17:33:33 -04:00
parent 80caa21468
commit a863b8a73f
22 changed files with 453 additions and 92 deletions

View File

@ -23,7 +23,7 @@ dependencies {
} }
teavm.js { teavm.js {
obfuscated = true obfuscated = false
sourceMap = true sourceMap = true
targetFileName = "../classes.js" targetFileName = "../classes.js"
optimization = org.teavm.gradle.api.OptimizationLevel.AGGRESSIVE optimization = org.teavm.gradle.api.OptimizationLevel.AGGRESSIVE

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,18 @@
{
"parent": "builtin/generated",
"textures": {
"layer0": "items/broken_elytra"
},
"display": {
"thirdperson": {
"rotation": [ -90, 0, 0 ],
"translation": [ 0, 1, -3 ],
"scale": [ 0.55, 0.55, 0.55 ]
},
"firstperson": {
"rotation": [ 0, -135, 25 ],
"translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ]
}
}
}

View File

@ -14,5 +14,13 @@
"translation": [ 0, 4, 2 ], "translation": [ 0, 4, 2 ],
"scale": [ 1.7, 1.7, 1.7 ] "scale": [ 1.7, 1.7, 1.7 ]
} }
},
"overrides": [
{
"predicate": {
"broken": 1
},
"model": "item/broken_elytra"
} }
]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

View File

@ -19,6 +19,7 @@ import net.minecraft.client.renderer.block.model.BlockFaceUV;
import net.minecraft.client.renderer.block.model.BlockPart; import net.minecraft.client.renderer.block.model.BlockPart;
import net.minecraft.client.renderer.block.model.BlockPartFace; import net.minecraft.client.renderer.block.model.BlockPartFace;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverride;
import net.minecraft.client.renderer.block.model.ItemTransformVec3f; import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelBlock;
import net.minecraft.client.renderer.block.model.ModelBlockDefinition; import net.minecraft.client.renderer.block.model.ModelBlockDefinition;
@ -40,38 +41,45 @@ import net.minecraft.world.gen.ChunkProviderSettings;
/** /**
* Copyright (c) 2022 lax1dude. All Rights Reserved. * Copyright (c) 2022 lax1dude. All Rights Reserved.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * DISCLAIMED.
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * DIRECT,
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
public class JSONTypeProvider { public class JSONTypeProvider {
private static final Map<Class<?>,JSONTypeSerializer<?,?>> serializers = new HashMap(); private static final Map<Class<?>, JSONTypeSerializer<?, ?>> serializers = new HashMap();
private static final Map<Class<?>,JSONTypeDeserializer<?,?>> deserializers = new HashMap(); private static final Map<Class<?>, JSONTypeDeserializer<?, ?>> deserializers = new HashMap();
private static final List<JSONDataParserImpl> parsers = new ArrayList(); private static final List<JSONDataParserImpl> parsers = new ArrayList();
public static <J> J serialize(Object object) throws JSONException { public static <J> J serialize(Object object) throws JSONException {
JSONTypeSerializer<Object,J> ser = (JSONTypeSerializer<Object,J>) serializers.get(object.getClass()); JSONTypeSerializer<Object, J> ser = (JSONTypeSerializer<Object, J>) serializers.get(object.getClass());
if(ser == null) { if (ser == null) {
for(Entry<Class<?>,JSONTypeSerializer<?,?>> etr : serializers.entrySet()) { for (Entry<Class<?>, JSONTypeSerializer<?, ?>> etr : serializers.entrySet()) {
if(etr.getKey().isInstance(object)) { if (etr.getKey().isInstance(object)) {
ser = (JSONTypeSerializer<Object,J>)etr.getValue(); ser = (JSONTypeSerializer<Object, J>) etr.getValue();
break; break;
} }
} }
} }
if(ser != null) { if (ser != null) {
return ser.serializeToJson(object); return ser.serializeToJson(object);
}else { } else {
throw new JSONException("Could not find a serializer for " + object.getClass().getSimpleName()); throw new JSONException("Could not find a serializer for " + object.getClass().getSimpleName());
} }
} }
@ -81,26 +89,26 @@ public class JSONTypeProvider {
} }
public static <O> O deserializeNoCast(Object object, Class<O> clazz) throws JSONException { public static <O> O deserializeNoCast(Object object, Class<O> clazz) throws JSONException {
JSONTypeDeserializer<Object,O> ser = (JSONTypeDeserializer<Object,O>) deserializers.get(clazz); JSONTypeDeserializer<Object, O> ser = (JSONTypeDeserializer<Object, O>) deserializers.get(clazz);
if(ser != null) { if (ser != null) {
return (O)ser.deserializeFromJson(object); return (O) ser.deserializeFromJson(object);
}else { } else {
throw new JSONException("Could not find a deserializer for " + object.getClass().getSimpleName()); throw new JSONException("Could not find a deserializer for " + object.getClass().getSimpleName());
} }
} }
public static <O,J> JSONTypeSerializer<O,J> getSerializer(Class<O> object) { public static <O, J> JSONTypeSerializer<O, J> getSerializer(Class<O> object) {
return (JSONTypeSerializer<O,J>)serializers.get(object); return (JSONTypeSerializer<O, J>) serializers.get(object);
} }
public static <J,O> JSONTypeDeserializer<J,O> getDeserializer(Class<O> object) { public static <J, O> JSONTypeDeserializer<J, O> getDeserializer(Class<O> object) {
return (JSONTypeDeserializer<J,O>)deserializers.get(object); return (JSONTypeDeserializer<J, O>) deserializers.get(object);
} }
public static Object parse(Object object) { public static Object parse(Object object) {
for(int i = 0, l = parsers.size(); i < l; ++i) { for (int i = 0, l = parsers.size(); i < l; ++i) {
JSONDataParserImpl parser = parsers.get(i); JSONDataParserImpl parser = parsers.get(i);
if(parser.accepts(object)) { if (parser.accepts(object)) {
return parser.parse(object); return parser.parse(object);
} }
} }
@ -109,16 +117,17 @@ public class JSONTypeProvider {
public static void registerType(Class<?> clazz, Object obj) { public static void registerType(Class<?> clazz, Object obj) {
boolean valid = false; boolean valid = false;
if(obj instanceof JSONTypeSerializer<?,?>) { if (obj instanceof JSONTypeSerializer<?, ?>) {
serializers.put(clazz, (JSONTypeSerializer<?,?>)obj); serializers.put(clazz, (JSONTypeSerializer<?, ?>) obj);
valid = true; valid = true;
} }
if(obj instanceof JSONTypeDeserializer<?,?>) { if (obj instanceof JSONTypeDeserializer<?, ?>) {
deserializers.put(clazz, (JSONTypeDeserializer<?,?>)obj); deserializers.put(clazz, (JSONTypeDeserializer<?, ?>) obj);
valid = true; valid = true;
} }
if(!valid) { if (!valid) {
throw new IllegalArgumentException("Object " + obj.getClass().getSimpleName() + " is not a JsonSerializer or JsonDeserializer object"); throw new IllegalArgumentException(
"Object " + obj.getClass().getSimpleName() + " is not a JsonSerializer or JsonDeserializer object");
} }
} }
@ -143,6 +152,8 @@ public class JSONTypeProvider {
registerType(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer()); registerType(ItemCameraTransforms.class, new ItemCameraTransforms.Deserializer());
registerType(ModelBlockDefinition.class, new ModelBlockDefinition.Deserializer()); registerType(ModelBlockDefinition.class, new ModelBlockDefinition.Deserializer());
registerType(ModelBlockDefinition.Variant.class, new ModelBlockDefinition.Variant.Deserializer()); registerType(ModelBlockDefinition.Variant.class, new ModelBlockDefinition.Variant.Deserializer());
registerType(ItemOverride.class, new ItemOverride.Deserializer());
registerType(SoundList.class, new SoundListSerializer()); registerType(SoundList.class, new SoundListSerializer());
registerType(SoundMap.class, new SoundMapDeserializer()); registerType(SoundMap.class, new SoundMapDeserializer());
registerType(TextureMetadataSection.class, new TextureMetadataSectionSerializer()); registerType(TextureMetadataSection.class, new TextureMetadataSectionSerializer());

View File

@ -68,7 +68,8 @@ public class ItemModelGenerator {
} else { } else {
hashmap.put("particle", blockModel.isTexturePresent("particle") ? blockModel.resolveTextureName("particle") hashmap.put("particle", blockModel.isTexturePresent("particle") ? blockModel.resolveTextureName("particle")
: (String) hashmap.get("layer0")); : (String) hashmap.get("layer0"));
return new ModelBlock(arraylist, hashmap, false, false, blockModel.func_181682_g()); return new ModelBlock((ResourceLocation) null, arraylist, hashmap, false, false,
blockModel.func_181682_g(), blockModel.getOverrides());
} }
} }

View File

@ -0,0 +1,70 @@
package net.minecraft.client.renderer.block.model;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nullable;
import org.json.JSONException;
import org.json.JSONObject;
import net.lax1dude.eaglercraft.v1_8.json.JSONTypeDeserializer;
import net.lax1dude.eaglercraft.v1_8.json.JSONTypeProvider;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.IItemPropertyGetter;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class ItemOverride {
private final ResourceLocation location;
private final Map<ResourceLocation, Float> mapResourceValues;
public ItemOverride(ResourceLocation locationIn, Map<ResourceLocation, Float> p_i46571_2_) {
this.location = locationIn;
this.mapResourceValues = p_i46571_2_;
}
public ResourceLocation getLocation() {
return this.location;
}
boolean matchesItemStack(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase livingEntity) {
Item item = stack.getItem();
for (Entry<ResourceLocation, Float> entry : this.mapResourceValues.entrySet()) {
IItemPropertyGetter iitempropertygetter = item.getPropertyGetter((ResourceLocation) entry.getKey());
if (iitempropertygetter == null || iitempropertygetter.apply(stack, worldIn,
livingEntity) < ((Float) entry.getValue()).floatValue()) {
return false;
}
}
return true;
}
public static ItemOverride deserialize(String json) {
return (ItemOverride) JSONTypeProvider.deserialize(new JSONObject(json), ItemOverride.class);
}
public static class Deserializer implements JSONTypeDeserializer<JSONObject, ItemOverride> {
public ItemOverride deserialize(JSONObject jsonObject) throws JSONException {
ResourceLocation resourcelocation = new ResourceLocation(jsonObject.getString("model"));
Map<ResourceLocation, Float> map = this.makeMapResourceValues(jsonObject);
return new ItemOverride(resourcelocation, map);
}
protected Map<ResourceLocation, Float> makeMapResourceValues(JSONObject jsonObject) {
Map<ResourceLocation, Float> map = Maps.<ResourceLocation, Float>newLinkedHashMap();
JSONObject jsonPredicate = jsonObject.getJSONObject("predicate");
for (String key : jsonPredicate.keySet()) {
map.put(new ResourceLocation(key), Float.valueOf(jsonPredicate.getFloat(key)));
}
return map;
}
}
}

View File

@ -0,0 +1,37 @@
package net.minecraft.client.renderer.block.model;
import com.google.common.collect.Lists;
import java.util.List;
import javax.annotation.Nullable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class ItemOverrideList {
public static final ItemOverrideList NONE = new ItemOverrideList();
private final List<ItemOverride> overrides = Lists.<ItemOverride>newArrayList();
private ItemOverrideList() {
}
public ItemOverrideList(List<ItemOverride> overridesIn) {
for (int i = overridesIn.size() - 1; i >= 0; --i) {
this.overrides.add(overridesIn.get(i));
}
}
@Nullable
public ResourceLocation applyOverride(ItemStack stack, @Nullable World worldIn,
@Nullable EntityLivingBase entityIn) {
if (!this.overrides.isEmpty()) {
for (ItemOverride itemoverride : this.overrides) {
if (itemoverride.matchesItemStack(stack, worldIn, entityIn)) {
return itemoverride.getLocation();
}
}
}
return null;
}
}

View File

@ -1,16 +1,21 @@
package net.minecraft.client.renderer.block.model; package net.minecraft.client.renderer.block.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.lax1dude.eaglercraft.v1_8.json.JSONTypeDeserializer; import net.lax1dude.eaglercraft.v1_8.json.JSONTypeDeserializer;
import net.lax1dude.eaglercraft.v1_8.json.JSONTypeProvider; import net.lax1dude.eaglercraft.v1_8.json.JSONTypeProvider;
@ -54,6 +59,7 @@ public class ModelBlock {
private final boolean gui3d; private final boolean gui3d;
private final boolean ambientOcclusion; private final boolean ambientOcclusion;
private ItemCameraTransforms cameraTransforms; private ItemCameraTransforms cameraTransforms;
private final List<ItemOverride> overrides;
public String name; public String name;
protected final Map<String, String> textures; protected final Map<String, String> textures;
protected ModelBlock parent; protected ModelBlock parent;
@ -63,18 +69,23 @@ public class ModelBlock {
return (ModelBlock) JSONTypeProvider.deserialize(new JSONObject(parString1), ModelBlock.class); return (ModelBlock) JSONTypeProvider.deserialize(new JSONObject(parString1), ModelBlock.class);
} }
protected ModelBlock(List<BlockPart> parList, Map<String, String> parMap, boolean parFlag, boolean parFlag2, // protected ModelBlock(List<BlockPart> parList, Map<String, String> parMap,
ItemCameraTransforms parItemCameraTransforms) { // boolean parFlag, boolean parFlag2,
this((ResourceLocation) null, parList, parMap, parFlag, parFlag2, parItemCameraTransforms); // ItemCameraTransforms parItemCameraTransforms) {
} // this((ResourceLocation) null, parList, parMap, parFlag, parFlag2,
// parItemCameraTransforms);
// }
protected ModelBlock(ResourceLocation parResourceLocation, Map<String, String> parMap, boolean parFlag, // protected ModelBlock(ResourceLocation parResourceLocation, Map<String,
boolean parFlag2, ItemCameraTransforms parItemCameraTransforms) { // String> parMap, boolean parFlag,
this(parResourceLocation, Collections.emptyList(), parMap, parFlag, parFlag2, parItemCameraTransforms); // boolean parFlag2, ItemCameraTransforms parItemCameraTransforms) {
} // this(parResourceLocation, Collections.emptyList(), parMap, parFlag, parFlag2,
// parItemCameraTransforms);
// }
private ModelBlock(ResourceLocation parentLocationIn, List<BlockPart> elementsIn, Map<String, String> texturesIn, public ModelBlock(ResourceLocation parentLocationIn, List<BlockPart> elementsIn, Map<String, String> texturesIn,
boolean ambientOcclusionIn, boolean gui3dIn, ItemCameraTransforms cameraTransformsIn) { boolean ambientOcclusionIn, boolean gui3dIn, ItemCameraTransforms cameraTransformsIn,
List<ItemOverride> overridesIn) {
this.name = ""; this.name = "";
this.elements = elementsIn; this.elements = elementsIn;
this.ambientOcclusion = ambientOcclusionIn; this.ambientOcclusion = ambientOcclusionIn;
@ -82,6 +93,7 @@ public class ModelBlock {
this.textures = texturesIn; this.textures = texturesIn;
this.parentLocation = parentLocationIn; this.parentLocation = parentLocationIn;
this.cameraTransforms = cameraTransformsIn; this.cameraTransforms = cameraTransformsIn;
this.overrides = overridesIn;
} }
public List<BlockPart> getElements() { public List<BlockPart> getElements() {
@ -111,6 +123,24 @@ public class ModelBlock {
} }
public Collection<ResourceLocation> getOverrideLocations() {
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (ItemOverride itemoverride : this.overrides) {
set.add(itemoverride.getLocation());
}
return set;
}
protected List<ItemOverride> getOverrides() {
return this.overrides;
}
public ItemOverrideList createOverrides() {
return this.overrides.isEmpty() ? ItemOverrideList.NONE : new ItemOverrideList(this.overrides);
}
public boolean isTexturePresent(String textureName) { public boolean isTexturePresent(String textureName) {
return !"missingno".equals(this.resolveTextureName(textureName)); return !"missingno".equals(this.resolveTextureName(textureName));
} }
@ -221,12 +251,30 @@ public class ModelBlock {
JSONObject jsonobject1 = jsonobject.getJSONObject("display"); JSONObject jsonobject1 = jsonobject.getJSONObject("display");
itemcameratransforms = JSONTypeProvider.deserialize(jsonobject1, ItemCameraTransforms.class); itemcameratransforms = JSONTypeProvider.deserialize(jsonobject1, ItemCameraTransforms.class);
} }
List<ItemOverride> list1 = this.getItemOverrides(jsonobject);
return flag1 ? new ModelBlock(new ResourceLocation(s), map, flag2, true, itemcameratransforms) ResourceLocation resourcelocation = s.isEmpty() ? null : new ResourceLocation(s);
: new ModelBlock(list, map, flag2, true, itemcameratransforms); return new ModelBlock(resourcelocation, list, map, flag2, true, itemcameratransforms, list1);
} }
} }
protected List<ItemOverride> getItemOverrides(JSONObject object) {
List<ItemOverride> list = new ArrayList<>();
if (object.has("overrides")) {
JSONArray overrides = object.getJSONArray("overrides");
for (int i = 0; i < overrides.length(); i++) {
JSONObject overrideObject = overrides.getJSONObject(i);
// Assuming there's a method in ItemOverride or elsewhere for deserializing a
// single JSONObject to an ItemOverride instance
ItemOverride itemOverride = ItemOverride.deserialize(overrideObject.toString());
list.add(itemOverride);
}
}
return list;
}
private Map<String, String> getTextures(JSONObject parJsonObject) { private Map<String, String> getTextures(JSONObject parJsonObject) {
HashMap hashmap = Maps.newHashMap(); HashMap hashmap = Maps.newHashMap();
if (parJsonObject.has("textures")) { if (parJsonObject.has("textures")) {

View File

@ -12,6 +12,7 @@ import com.google.common.collect.Sets;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.util.ResourceLocation;
/** /**
* + * +
@ -67,4 +68,32 @@ public class BlockStateMapper {
return identityhashmap; return identityhashmap;
} }
public Set<ResourceLocation> getBlockstateLocations(Block blockIn) {
if (this.setBuiltInBlocks.contains(blockIn)) {
return Collections.<ResourceLocation>emptySet();
} else {
IStateMapper istatemapper = (IStateMapper) this.blockStateMap.get(blockIn);
if (istatemapper == null) {
return Collections.<ResourceLocation>singleton(Block.blockRegistry.getNameForObject(blockIn));
} else {
Set<ResourceLocation> set = Sets.<ResourceLocation>newHashSet();
for (ModelResourceLocation modelresourcelocation : istatemapper.putStateModelLocations(blockIn)
.values()) {
set.add(new ResourceLocation(modelresourcelocation.getResourceDomain(),
modelresourcelocation.getResourcePath()));
}
return set;
}
}
}
public Map<IBlockState, ModelResourceLocation> getVariants(Block blockIn) {
return this.setBuiltInBlocks.contains(blockIn) ? Collections.<IBlockState, ModelResourceLocation>emptyMap()
: ((IStateMapper) Objects.firstNonNull(this.blockStateMap.get(blockIn), new DefaultStateMapper()))
.putStateModelLocations(blockIn);
}
} }

View File

@ -6,6 +6,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import javax.annotation.Nullable;
import net.hoosiertransfer.EaglerCustomBlock; import net.hoosiertransfer.EaglerCustomBlock;
import net.hoosiertransfer.EaglerItems; import net.hoosiertransfer.EaglerItems;
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager; import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
@ -72,6 +74,7 @@ import net.minecraft.util.MathHelper;
import net.minecraft.util.ReportedException; import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3i; import net.minecraft.util.Vec3i;
import net.minecraft.world.World;
/** /**
* + * +
@ -343,15 +346,33 @@ public class RenderItem implements IResourceManagerReloadListener {
public void func_181564_a(ItemStack parItemStack, ItemCameraTransforms.TransformType parTransformType) { public void func_181564_a(ItemStack parItemStack, ItemCameraTransforms.TransformType parTransformType) {
if (parItemStack != null) { if (parItemStack != null) {
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(parItemStack); IBakedModel ibakedmodel = this.getItemModelWithOverrides(parItemStack, (World) null,
(EntityLivingBase) null);
this.renderItemModelTransform(parItemStack, ibakedmodel, parTransformType); this.renderItemModelTransform(parItemStack, ibakedmodel, parTransformType);
} }
} }
public IBakedModel getItemModelWithOverrides(ItemStack stack, @Nullable World worldIn,
@Nullable EntityLivingBase entitylivingbaseIn) {
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack);
Item item = stack.getItem();
if (item != null && item.hasCustomProperties()) {
ResourceLocation resourcelocation = ibakedmodel.getOverrides().applyOverride(stack, worldIn,
entitylivingbaseIn);
return resourcelocation == null ? ibakedmodel
: this.itemModelMesher.getModelManager()
.getModel(new ModelResourceLocation(resourcelocation, "inventory"));
} else {
return ibakedmodel;
}
}
public void renderItemModelForEntity(ItemStack stack, EntityLivingBase entityToRenderFor, public void renderItemModelForEntity(ItemStack stack, EntityLivingBase entityToRenderFor,
ItemCameraTransforms.TransformType cameraTransformType) { ItemCameraTransforms.TransformType cameraTransformType) {
if (stack != null && entityToRenderFor != null) { if (stack != null && entityToRenderFor != null) {
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); IBakedModel ibakedmodel = this.getItemModelWithOverrides(stack, entityToRenderFor.worldObj,
entityToRenderFor);
if (entityToRenderFor instanceof EntityPlayer) { if (entityToRenderFor instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entityToRenderFor; EntityPlayer entityplayer = (EntityPlayer) entityToRenderFor;
Item item = stack.getItem(); Item item = stack.getItem();
@ -410,7 +431,11 @@ public class RenderItem implements IResourceManagerReloadListener {
} }
public void renderItemIntoGUI(ItemStack stack, int x, int y) { public void renderItemIntoGUI(ItemStack stack, int x, int y) {
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); this.renderItemModelIntoGUI(stack, x, y,
this.getItemModelWithOverrides(stack, (World) null, (EntityLivingBase) null));
}
public void renderItemModelIntoGUI(ItemStack stack, int x, int y, IBakedModel ibakedmodel) {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
this.textureManager.bindTexture(TextureMap.locationBlocksTexture); this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
this.textureManager.getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false); this.textureManager.getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
@ -449,12 +474,18 @@ public class RenderItem implements IResourceManagerReloadListener {
} }
public void renderItemAndEffectIntoGUI(final ItemStack stack, int xPosition, int yPosition) { public void renderItemAndEffectIntoGUI(ItemStack stack, int xPosition, int yPosition) {
this.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().thePlayer, stack, xPosition, yPosition);
}
public void renderItemAndEffectIntoGUI(@Nullable EntityLivingBase p_184391_1_, final ItemStack stack, int xPosition,
int yPosition) {
if (stack != null && stack.getItem() != null) { if (stack != null && stack.getItem() != null) {
this.zLevel += 50.0F; this.zLevel += 50.0F;
try { try {
this.renderItemIntoGUI(stack, xPosition, yPosition); this.renderItemModelIntoGUI(stack, xPosition, yPosition,
this.getItemModelWithOverrides(stack, (World) null, p_184391_1_));
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering item"); CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering item");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being rendered"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being rendered");

View File

@ -5,6 +5,7 @@ import java.util.List;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite; import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
/** /**
@ -38,9 +39,11 @@ import net.minecraft.util.EnumFacing;
*/ */
public class BuiltInModel implements IBakedModel { public class BuiltInModel implements IBakedModel {
private ItemCameraTransforms cameraTransforms; private ItemCameraTransforms cameraTransforms;
private final ItemOverrideList overrideList;
public BuiltInModel(ItemCameraTransforms parItemCameraTransforms) { public BuiltInModel(ItemCameraTransforms parItemCameraTransforms, ItemOverrideList itemOverrides) {
this.cameraTransforms = parItemCameraTransforms; this.cameraTransforms = parItemCameraTransforms;
this.overrideList = itemOverrides;
} }
public List<BakedQuad> getFaceQuads(EnumFacing var1) { public List<BakedQuad> getFaceQuads(EnumFacing var1) {
@ -70,4 +73,8 @@ public class BuiltInModel implements IBakedModel {
public ItemCameraTransforms getItemCameraTransforms() { public ItemCameraTransforms getItemCameraTransforms() {
return this.cameraTransforms; return this.cameraTransforms;
} }
public ItemOverrideList getOverrides() {
return this.overrideList;
}
} }

View File

@ -5,6 +5,7 @@ import java.util.List;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite; import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
/** /**
@ -50,4 +51,7 @@ public interface IBakedModel {
EaglerTextureAtlasSprite getParticleTexture(); EaglerTextureAtlasSprite getParticleTexture();
ItemCameraTransforms getItemCameraTransforms(); ItemCameraTransforms getItemCameraTransforms();
ItemOverrideList getOverrides();
} }

View File

@ -282,20 +282,34 @@ public class ModelBakery {
for (Item item : Item.itemRegistry) { for (Item item : Item.itemRegistry) {
for (String s : this.getVariantNames(item)) { for (String s : this.getVariantNames(item)) {
ResourceLocation resourcelocation = this.getItemLocation(s); ResourceLocation resourcelocation = this.getItemLocation(s);
this.itemLocations.put(s, resourcelocation); ResourceLocation resourcelocation1 = (ResourceLocation) Item.itemRegistry.getNameForObject(item);
if (this.models.get(resourcelocation) == null) { this.loadItemModel(s, resourcelocation, resourcelocation1);
try {
ModelBlock modelblock = this.loadModel(resourcelocation); if (item.hasCustomProperties()) {
this.models.put(resourcelocation, modelblock); ModelBlock modelblock = (ModelBlock) this.models.get(resourcelocation);
} catch (Exception exception) {
LOGGER.warn("Unable to load item model: \'" + resourcelocation + "\' for item: \'" if (modelblock != null) {
+ Item.itemRegistry.getNameForObject(item) + "\'"); for (ResourceLocation resourcelocation2 : modelblock.getOverrideLocations()) {
LOGGER.warn(exception); this.loadItemModel(resourcelocation2.toString(), resourcelocation2, resourcelocation1);
}
}
} }
} }
} }
} }
private void loadItemModel(String p_188634_1_, ResourceLocation p_188634_2_, ResourceLocation p_188634_3_) {
this.itemLocations.put(p_188634_1_, p_188634_2_);
if (this.models.get(p_188634_2_) == null) {
try {
ModelBlock modelblock = this.loadModel(p_188634_2_);
this.models.put(p_188634_2_, modelblock);
} catch (Exception exception) {
LOGGER.warn((String) ("Unable to load item model: \'" + p_188634_2_ + "\' for item: \'" + p_188634_3_
+ "\'"), (Throwable) exception);
}
}
} }
private void registerVariantNames() { private void registerVariantNames() {
@ -491,7 +505,8 @@ public class ModelBakery {
ModelBlock modelblock1 = (ModelBlock) this.models.get(resourcelocation); ModelBlock modelblock1 = (ModelBlock) this.models.get(resourcelocation);
if (modelblock1 != null && modelblock1.isResolved()) { if (modelblock1 != null && modelblock1.isResolved()) {
if (this.isCustomRenderer(modelblock1)) { if (this.isCustomRenderer(modelblock1)) {
this.bakedRegistry.putObject(modelresourcelocation1, new BuiltInModel(modelblock1.func_181682_g())); this.bakedRegistry.putObject(modelresourcelocation1,
new BuiltInModel(modelblock1.func_181682_g(), modelblock1.createOverrides()));
} else { } else {
this.bakedRegistry.putObject(modelresourcelocation1, this.bakedRegistry.putObject(modelresourcelocation1,
this.bakeModel(modelblock1, ModelRotation.X0_Y0, false)); this.bakeModel(modelblock1, ModelRotation.X0_Y0, false));
@ -535,7 +550,8 @@ public class ModelBakery {
private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked) { private IBakedModel bakeModel(ModelBlock modelBlockIn, ModelRotation modelRotationIn, boolean uvLocked) {
EaglerTextureAtlasSprite textureatlassprite = (EaglerTextureAtlasSprite) this.sprites EaglerTextureAtlasSprite textureatlassprite = (EaglerTextureAtlasSprite) this.sprites
.get(new ResourceLocation(modelBlockIn.resolveTextureName("particle"))); .get(new ResourceLocation(modelBlockIn.resolveTextureName("particle")));
SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn)) SimpleBakedModel.Builder simplebakedmodel$builder = (new SimpleBakedModel.Builder(modelBlockIn,
modelBlockIn.createOverrides()))
.setTexture(textureatlassprite); .setTexture(textureatlassprite);
for (BlockPart blockpart : modelBlockIn.getElements()) { for (BlockPart blockpart : modelBlockIn.getElements()) {

View File

@ -8,6 +8,7 @@ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.BreakingFour; import net.minecraft.client.renderer.block.model.BreakingFour;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.block.model.ModelBlock; import net.minecraft.client.renderer.block.model.ModelBlock;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
@ -47,15 +48,18 @@ public class SimpleBakedModel implements IBakedModel {
protected final boolean gui3d; protected final boolean gui3d;
protected final EaglerTextureAtlasSprite texture; protected final EaglerTextureAtlasSprite texture;
protected final ItemCameraTransforms cameraTransforms; protected final ItemCameraTransforms cameraTransforms;
protected final ItemOverrideList itemOverrideList;
public SimpleBakedModel(List<BakedQuad> parList, List<List<BakedQuad>> parList2, boolean parFlag, boolean parFlag2, public SimpleBakedModel(List<BakedQuad> parList, List<List<BakedQuad>> parList2, boolean parFlag, boolean parFlag2,
EaglerTextureAtlasSprite parTextureAtlasSprite, ItemCameraTransforms parItemCameraTransforms) { EaglerTextureAtlasSprite parTextureAtlasSprite, ItemCameraTransforms parItemCameraTransforms,
ItemOverrideList itemOverrideListIn) {
this.generalQuads = parList; this.generalQuads = parList;
this.faceQuads = parList2; this.faceQuads = parList2;
this.ambientOcclusion = parFlag; this.ambientOcclusion = parFlag;
this.gui3d = parFlag2; this.gui3d = parFlag2;
this.texture = parTextureAtlasSprite; this.texture = parTextureAtlasSprite;
this.cameraTransforms = parItemCameraTransforms; this.cameraTransforms = parItemCameraTransforms;
this.itemOverrideList = itemOverrideListIn;
} }
public List<BakedQuad> getFaceQuads(EnumFacing enumfacing) { public List<BakedQuad> getFaceQuads(EnumFacing enumfacing) {
@ -86,21 +90,27 @@ public class SimpleBakedModel implements IBakedModel {
return this.cameraTransforms; return this.cameraTransforms;
} }
public ItemOverrideList getOverrides() {
return this.itemOverrideList;
}
public static class Builder { public static class Builder {
private final List<BakedQuad> builderGeneralQuads; private final List<BakedQuad> builderGeneralQuads;
private final List<List<BakedQuad>> builderFaceQuads; private final List<List<BakedQuad>> builderFaceQuads;
private final ItemOverrideList builderItemOverrideList;
private final boolean builderAmbientOcclusion; private final boolean builderAmbientOcclusion;
private EaglerTextureAtlasSprite builderTexture; private EaglerTextureAtlasSprite builderTexture;
private boolean builderGui3d; private boolean builderGui3d;
private ItemCameraTransforms builderCameraTransforms; private ItemCameraTransforms builderCameraTransforms;
public Builder(ModelBlock parModelBlock) { public Builder(ModelBlock parModelBlock, ItemOverrideList p_i46988_2_) {
this(parModelBlock.isAmbientOcclusion(), parModelBlock.isGui3d(), parModelBlock.func_181682_g()); this(parModelBlock.isAmbientOcclusion(), parModelBlock.isGui3d(), parModelBlock.func_181682_g(),
p_i46988_2_);
} }
public Builder(IBakedModel parIBakedModel, EaglerTextureAtlasSprite parTextureAtlasSprite) { public Builder(IBakedModel parIBakedModel, EaglerTextureAtlasSprite parTextureAtlasSprite) {
this(parIBakedModel.isAmbientOcclusion(), parIBakedModel.isGui3d(), this(parIBakedModel.isAmbientOcclusion(), parIBakedModel.isGui3d(),
parIBakedModel.getItemCameraTransforms()); parIBakedModel.getItemCameraTransforms(), parIBakedModel.getOverrides());
this.builderTexture = parIBakedModel.getParticleTexture(); this.builderTexture = parIBakedModel.getParticleTexture();
EnumFacing[] facings = EnumFacing._VALUES; EnumFacing[] facings = EnumFacing._VALUES;
@ -129,7 +139,8 @@ public class SimpleBakedModel implements IBakedModel {
} }
private Builder(boolean parFlag, boolean parFlag2, ItemCameraTransforms parItemCameraTransforms) { private Builder(boolean parFlag, boolean parFlag2, ItemCameraTransforms parItemCameraTransforms,
ItemOverrideList p_i46990_4_) {
this.builderGeneralQuads = Lists.newArrayList(); this.builderGeneralQuads = Lists.newArrayList();
this.builderFaceQuads = Lists.newArrayListWithCapacity(6); this.builderFaceQuads = Lists.newArrayListWithCapacity(6);
@ -137,6 +148,7 @@ public class SimpleBakedModel implements IBakedModel {
this.builderFaceQuads.add(Lists.newArrayList()); this.builderFaceQuads.add(Lists.newArrayList());
} }
this.builderItemOverrideList = p_i46990_4_;
this.builderAmbientOcclusion = parFlag; this.builderAmbientOcclusion = parFlag;
this.builderGui3d = parFlag2; this.builderGui3d = parFlag2;
this.builderCameraTransforms = parItemCameraTransforms; this.builderCameraTransforms = parItemCameraTransforms;
@ -163,7 +175,7 @@ public class SimpleBakedModel implements IBakedModel {
} else { } else {
return new SimpleBakedModel(this.builderGeneralQuads, this.builderFaceQuads, return new SimpleBakedModel(this.builderGeneralQuads, this.builderFaceQuads,
this.builderAmbientOcclusion, this.builderGui3d, this.builderTexture, this.builderAmbientOcclusion, this.builderGui3d, this.builderTexture,
this.builderCameraTransforms); this.builderCameraTransforms, this.builderItemOverrideList);
} }
} }
} }

View File

@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite; import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
import net.minecraft.client.renderer.block.model.BakedQuad; import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.WeightedRandom; import net.minecraft.util.WeightedRandom;
@ -85,6 +86,10 @@ public class WeightedBakedModel implements IBakedModel {
Math.abs((int) parLong1 >> 16) % this.totalWeight)).model; Math.abs((int) parLong1 >> 16) % this.totalWeight)).model;
} }
public ItemOverrideList getOverrides() {
return this.baseModel.getOverrides();
}
public static class Builder { public static class Builder {
private List<WeightedBakedModel.MyWeighedRandomItem> listItems = Lists.newArrayList(); private List<WeightedBakedModel.MyWeighedRandomItem> listItems = Lists.newArrayList();

View File

@ -0,0 +1,9 @@
package net.minecraft.item;
import javax.annotation.Nullable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.world.World;
public interface IItemPropertyGetter {
float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn);
}

View File

@ -3,6 +3,8 @@ package net.minecraft.item;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nullable;
import net.hoosiertransfer.EaglerCustomBlock; import net.hoosiertransfer.EaglerCustomBlock;
import net.hoosiertransfer.EaglerItems; import net.hoosiertransfer.EaglerItems;
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom; import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
@ -42,9 +44,11 @@ import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionHelper; import net.minecraft.potion.PotionHelper;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.IRegistry;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.RegistryNamespaced; import net.minecraft.util.RegistryNamespaced;
import net.minecraft.util.RegistrySimple;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector; import net.minecraft.util.StatCollector;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
@ -82,10 +86,38 @@ import net.minecraft.world.World;
*/ */
public class Item { public class Item {
public static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = new RegistryNamespaced(); public static final RegistryNamespaced<ResourceLocation, Item> itemRegistry = new RegistryNamespaced();
private static final IItemPropertyGetter DAMAGED_GETTER = new IItemPropertyGetter() {
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return stack.isItemDamaged() ? 1.0F : 0.0F;
}
};
private static final IItemPropertyGetter DAMAGE_GETTER = new IItemPropertyGetter() {
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return MathHelper.clamp_float((float) stack.getItemDamage() / (float) stack.getMaxDamage(), 0.0F, 1.0F);
}
};
private static final IItemPropertyGetter LEFTHANDED_GETTER = new IItemPropertyGetter() {
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
// return entityIn != null && entityIn.getPrimaryHand() != EnumHandSide.RIGHT ?
// 1.0F : 0.0F;
return 0.0F;
}
};
private static final IItemPropertyGetter COOLDOWN_GETTER = new IItemPropertyGetter() {
public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
return entityIn instanceof EntityPlayer
? ((EntityPlayer) entityIn).getCooldownTracker().getCooldown(stack.getItem(), 0.0F)
: 0.0F;
}
};
private final IRegistry<ResourceLocation, IItemPropertyGetter> properties = new RegistrySimple();
private static final Map<Block, Item> BLOCK_TO_ITEM = Maps.newHashMap(); private static final Map<Block, Item> BLOCK_TO_ITEM = Maps.newHashMap();
protected static final EaglercraftUUID ATTACK_DAMAGE_MODIFIER = EaglercraftUUID protected static final EaglercraftUUID ATTACK_DAMAGE_MODIFIER = EaglercraftUUID
.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF"); .fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
protected static final EaglercraftUUID ATTACK_SPEED_MODIFIER = EaglercraftUUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3"); protected static final EaglercraftUUID ATTACK_SPEED_MODIFIER = EaglercraftUUID
.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3");
private CreativeTabs tabToDisplayOn; private CreativeTabs tabToDisplayOn;
/** /**
* + * +
@ -135,6 +167,23 @@ public class Item {
return item; return item;
} }
/**
* Creates a new override param for item models. See usage in clock, compass,
* elytra, etc.
*/
public final void addPropertyOverride(ResourceLocation key, IItemPropertyGetter getter) {
this.properties.putObject(key, getter);
}
@Nullable
public IItemPropertyGetter getPropertyGetter(ResourceLocation key) {
return (IItemPropertyGetter) this.properties.getObject(key);
}
public boolean hasCustomProperties() {
return !this.properties.getKeys().isEmpty();
}
/** /**
* + * +
* Called when an ItemStack with NBT data is read to potentially * Called when an ItemStack with NBT data is read to potentially

View File

@ -1,9 +1,13 @@
package net.minecraft.item; package net.minecraft.item;
import javax.annotation.Nullable;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ItemElytra extends Item { public class ItemElytra extends Item {
@ -11,16 +15,14 @@ public class ItemElytra extends Item {
this.maxStackSize = 1; this.maxStackSize = 1;
this.setMaxDamage(432); this.setMaxDamage(432);
this.setCreativeTab(CreativeTabs.tabTransport); this.setCreativeTab(CreativeTabs.tabTransport);
// this.addPropertyOverride(new ResourceLocation("broken"), new this.addPropertyOverride(new ResourceLocation("broken"), new IItemPropertyGetter() {
// IItemPropertyGetter() { public float apply(ItemStack stack, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
// public float apply(ItemStack stack, @Nullable World worldIn, @Nullable return ItemElytra.isBroken(stack) ? 0.0F : 1.0F;
// EntityLivingBase entityIn) { }
// return ItemElytra.isBroken(stack) ? 0.0F : 1.0F; });
// }
// });
} }
public boolean isBroken(ItemStack stack) { public static boolean isBroken(ItemStack stack) {
return stack.getItemDamage() < stack.getMaxDamage() - 1; return stack.getItemDamage() < stack.getMaxDamage() - 1;
} }

View File

@ -1,5 +1,7 @@
package net.minecraft.util; package net.minecraft.util;
import java.util.Set;
/** /**
* + * +
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code. * This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
@ -37,4 +39,6 @@ public interface IRegistry<K, V> extends Iterable<V> {
* Register an object on this registry. * Register an object on this registry.
*/ */
void putObject(K var1, V var2); void putObject(K var1, V var2);
Set<K> getKeys();
} }