diff --git a/conf/build.gradle.forge b/conf/build.gradle.forge index 940c0d9..73c9eb3 100644 --- a/conf/build.gradle.forge +++ b/conf/build.gradle.forge @@ -80,24 +80,24 @@ java { srcDir 'src/main/java/' - srcDir '/var/lib/jenkins/jobs/CleanForge-1.7.10/workspace/src/main/java/' - srcDir '/var/lib/jenkins/jobs/CleanForge-1.7.10/workspace/eclipse/Clean/src/main/start/' + srcDir '/var/lib/jenkins/jobs/CleanForge_1.7.10/workspace/src/main/java/' + srcDir '/var/lib/jenkins/jobs/CleanForge_1.7.10/workspace/eclipse/Clean/src/main/start/' } resources { srcDir 'src/main/resources/' - srcDir '/var/lib/jenkins/jobs/CleanForge-1.7.10/workspace/src/main/resources/' + srcDir '/var/lib/jenkins/jobs/CleanForge_1.7.10/workspace/src/main/resources/' } } test { java { - srcDir '/var/lib/jenkins/jobs/CleanForge-1.7.10/workspace/src/test/java/' + srcDir '/var/lib/jenkins/jobs/CleanForge_1.7.10/workspace/src/test/java/' } resources { - srcDir '/var/lib/jenkins/jobs/CleanForge-1.7.10/workspace/src/test/resources/' + srcDir '/var/lib/jenkins/jobs/CleanForge_1.7.10/workspace/src/test/resources/' } } } diff --git a/src/main/java/cpw/mods/fml/common/Loader.java b/src/main/java/cpw/mods/fml/common/Loader.java index d98edb1..d89ac95 100644 --- a/src/main/java/cpw/mods/fml/common/Loader.java +++ b/src/main/java/cpw/mods/fml/common/Loader.java @@ -981,14 +981,7 @@ public void fireRemapEvent(Map remaps) { - if (remaps.isEmpty()) - { - FMLLog.finer("Skipping remap event - no remaps occured"); - } - else - { - modController.propogateStateMessage(new FMLModIdMappingEvent(remaps)); - } + modController.propogateStateMessage(new FMLModIdMappingEvent(remaps)); } public void runtimeDisableMod(String modId) diff --git a/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java b/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java index 7759c5d..dc1e4ff 100644 --- a/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java +++ b/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java @@ -38,7 +38,7 @@ @Override public boolean accept(File file) { - return (file.isFile() && classFile.matcher(file.getName()).find()) || file.isDirectory(); + return (file.isFile() && classFile.matcher(file.getName()).matches()) || file.isDirectory(); } } diff --git a/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java b/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java index 5a67d7d..9bbd579 100644 --- a/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java +++ b/src/main/java/cpw/mods/fml/common/discovery/ITypeDiscoverer.java @@ -5,7 +5,7 @@ * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * + * * Contributors: * cpw - implementation */ @@ -19,7 +19,8 @@ public interface ITypeDiscoverer { - public static Pattern classFile = Pattern.compile("([^\\s$]+).class$"); + // main class part, followed by an optional $ and an "inner class" part. $ cannot be last, otherwise scala breaks + public static Pattern classFile = Pattern.compile("[^\\s\\$]+(\\$[^\\s]+)?\\.class$"); public List discover(ModCandidate candidate, ASMDataTable table); } \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java b/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java index 929bc95..92a2677 100644 --- a/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java +++ b/src/main/java/cpw/mods/fml/common/discovery/ModCandidate.java @@ -80,7 +80,7 @@ public void addClassEntry(String name) { String className = name.substring(0, name.lastIndexOf('.')); // strip the .class - foundClasses.add(className.replace('.', '/')); + foundClasses.add(className); className = className.replace('/','.'); int pkgIdx = className.lastIndexOf('.'); if (pkgIdx > -1) diff --git a/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java b/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java index c25e0ae..87f43a6 100644 --- a/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java +++ b/src/main/java/cpw/mods/fml/common/eventhandler/EventBus.java @@ -123,6 +123,8 @@ public void unregister(Object object) { ArrayList list = listeners.remove(object); + if (list == null) + return; for (IEventListener listener : list) { ListenerList.unregisterAll(busID, listener); diff --git a/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java b/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java index d3b32d5..adb423f 100644 --- a/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java +++ b/src/main/java/cpw/mods/fml/common/registry/FMLControlledNamespacedRegistry.java @@ -9,7 +9,10 @@ import java.util.Map; import java.util.Set; +import org.apache.logging.log4j.Level; + import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.util.ObjectIntIdentityMap; import net.minecraft.util.RegistryNamespaced; @@ -21,6 +24,7 @@ import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.functions.GenericIterableFactory; +import cpw.mods.fml.common.registry.RegistryDelegate.Delegate; public class FMLControlledNamespacedRegistry extends RegistryNamespaced { public static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("fml.debugRegistryEntries", "false")); @@ -51,9 +55,10 @@ { int id = getId(obj); String name = getNameForObject(obj); + boolean isSubstituted = activeSubstitutions.containsKey(name); // id lookup failed -> obj is not in the obj<->id map - if (id < 0) throw new IllegalStateException(String.format("Registry entry for %s %s, name %s, doesn't yield an id.", type, obj, name)); + if (!isSubstituted && id < 0) throw new IllegalStateException(String.format("Registry entry for %s %s, name %s, doesn't yield an id.", type, obj, name)); // id is too high if (id > maxId) throw new IllegalStateException(String.format("Registry entry for %s %s, name %s uses the too large id %d.", type, obj, name)); // name lookup failed -> obj is not in the obj<->name map @@ -62,12 +67,14 @@ if (name.isEmpty()) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, yields an empty name.", type, obj, id)); // non-prefixed name if (name.indexOf(':') == -1) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, has the non-prefixed name %s.", type, obj, id, name)); + // the rest of the tests don't really work for substituted items or blocks + if (isSubstituted) continue; // id -> obj lookup is inconsistent if (getRaw(id) != obj) throw new IllegalStateException(String.format("Registry entry for id %d, name %s, doesn't yield the expected %s %s.", id, name, type, obj)); // name -> obj lookup is inconsistent - if (!(activeSubstitutions.containsKey(name) || activeSubstitutions.containsValue(name)) && getRaw(name) != obj ) throw new IllegalStateException(String.format("Registry entry for name %s, id %d, doesn't yield the expected %s %s.", name, id, type, obj)); + if (getRaw(name) != obj) throw new IllegalStateException(String.format("Registry entry for name %s, id %d, doesn't yield the expected %s %s.", name, id, type, obj)); // name -> id lookup is inconsistent - if (!(activeSubstitutions.containsKey(name) || activeSubstitutions.containsValue(name)) && getId(name) != id) throw new IllegalStateException(String.format("Registry entry for name %s doesn't yield the expected id %d.", name, id)); + if (getId(name) != id) throw new IllegalStateException(String.format("Registry entry for name %s doesn't yield the expected id %d.", name, id)); // id isn't marked as unavailable if (!availabilityMap.get(id)) throw new IllegalStateException(String.format("Registry entry for %s %s, id %d, name %s, marked as empty.", type, obj, id, name)); // entry is blocked, thus should be empty @@ -105,7 +112,8 @@ for (I thing : registry.typeSafeIterable()) { - addObjectRaw(registry.getId(thing), registry.getNameForObject(thing), thing); + int id = registry.getId(thing); + addObjectRaw(id, registry.getNameForObject(thing), thing); } this.activeSubstitutions.putAll(registry.activeSubstitutions); } @@ -475,6 +483,19 @@ { if (getPersistentSubstitutions().containsKey(nameToReplace)) { + I original = getRaw(nameToReplace); + if (superType == Item.class) { + Item sub = (Item) getPersistentSubstitutions().get(nameToReplace); + if (original == null) { + // When we're activated from the server side, we need to set the delegate on the original instance to + // point to us. Go to the "default state" registry to get it + original = (I)GameData.getItemRegistry().getRaw(nameToReplace); + } + FMLLog.log(Level.DEBUG, "Replacing %s with %s (name %s)", original, sub, nameToReplace); + Delegate delegate = (Delegate)((Item)original).delegate; + delegate.changeReference(sub); + ((Delegate)sub.delegate).setName(nameToReplace); + } activeSubstitutions.put(nameToReplace, getPersistentSubstitutions().get(nameToReplace)); } } @@ -502,6 +523,7 @@ FMLLog.severe("The substitute %s for %s is registered into the game independently. This won't work", replacement.getClass().getName(), nameToReplace); throw new IllegalArgumentException("The object substitution is already registered. This won't work"); } + FMLLog.log(Level.DEBUG, "Adding substitution %s with %s (name %s)", original, replacement, nameToReplace); getPersistentSubstitutions().put(nameToReplace, replacement); } @@ -529,4 +551,13 @@ { return Iterators.concat(super.iterator(),getPersistentSubstitutions().values().iterator()); } + + // ONLY CALLED ON ITEM registry + void resetSubstitutionDelegates() + { + for (I item: typeSafeIterable()) { + Delegate delegate = (Delegate)((Item)item).delegate; + delegate.changeReference((Item)item); + } + } } \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/common/registry/GameData.java b/src/main/java/cpw/mods/fml/common/registry/GameData.java index 4924424..bf976ab 100644 --- a/src/main/java/cpw/mods/fml/common/registry/GameData.java +++ b/src/main/java/cpw/mods/fml/common/registry/GameData.java @@ -39,6 +39,7 @@ import com.google.common.collect.HashBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -439,6 +440,7 @@ getMain().iBlockRegistry.dump(); getMain().iItemRegistry.dump(); + getMain().iItemRegistry.resetSubstitutionDelegates(); GameData newData = new GameData(); for (int id : blockedIds) @@ -734,6 +736,8 @@ getMain().set(frozen); } + // the id mapping has reverted, fire remap events for those that care about id changes + Loader.instance().fireRemapEvent(ImmutableMap.of()); // the id mapping has reverted, ensure we sync up the object holders ObjectHolderRegistry.INSTANCE.applyObjectHolders(); } diff --git a/src/main/java/cpw/mods/fml/common/registry/ObjectHolderRef.java b/src/main/java/cpw/mods/fml/common/registry/ObjectHolderRef.java index ef82e9c..27bd1be 100644 --- a/src/main/java/cpw/mods/fml/common/registry/ObjectHolderRef.java +++ b/src/main/java/cpw/mods/fml/common/registry/ObjectHolderRef.java @@ -61,7 +61,7 @@ if (this.injectedObject == null || !isValid()) { - throw new IllegalStateException("The ObjectHolder annotation cannot apply to a field that is not an Item or Block"); + throw new IllegalStateException(String.format("The ObjectHolder annotation cannot apply to a field that is not an Item or Block (found : %s at %s.%s)", field.getType().getName(), field.getClass().getName(), field.getName())); } makeWritable(field); } @@ -116,7 +116,7 @@ if (thing == null) { - FMLLog.warning("Unable to lookup %s for %s. Is there something wrong with the registry?", injectedObject, field); + FMLLog.getLogger().log(Level.DEBUG, "Unable to lookup {} for {}. This means the object wasn't registered. It's likely just mod options.", injectedObject, field); return; } try diff --git a/src/main/java/net/minecraft/item/ItemSkull.java b/src/main/java/net/minecraft/item/ItemSkull.java index 85e0c88..5049d95 100644 --- a/src/main/java/net/minecraft/item/ItemSkull.java +++ b/src/main/java/net/minecraft/item/ItemSkull.java @@ -45,7 +45,7 @@ { return false; } - else if (!p_77648_3_.isSideSolid(p_77648_4_, p_77648_5_, p_77648_6_, net.minecraftforge.common.util.ForgeDirection.getOrientation(p_77648_7_))) + else if (!p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_).getMaterial().isSolid() && !p_77648_3_.isSideSolid(p_77648_4_, p_77648_5_, p_77648_6_, net.minecraftforge.common.util.ForgeDirection.getOrientation(p_77648_7_))) { return false; } diff --git a/src/main/java/net/minecraft/network/NetHandlerPlayServer.java b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java index 2799c13..f4bc399 100644 --- a/src/main/java/net/minecraft/network/NetHandlerPlayServer.java +++ b/src/main/java/net/minecraft/network/NetHandlerPlayServer.java @@ -1097,20 +1097,20 @@ { itemstack = packetbuffer.readItemStackFromBuffer(); - if (itemstack == null) + if (itemstack != null) { - return; - } + if (!ItemWritableBook.func_150930_a(itemstack.getTagCompound())) + { + throw new IOException("Invalid book tag!"); + } - if (!ItemWritableBook.func_150930_a(itemstack.getTagCompound())) - { - throw new IOException("Invalid book tag!"); - } + itemstack1 = this.playerEntity.inventory.getCurrentItem(); - itemstack1 = this.playerEntity.inventory.getCurrentItem(); + if (itemstack1 == null) + { + return; + } - if (itemstack1 != null) - { if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem()) { itemstack1.setTagInfo("pages", itemstack.getTagCompound().getTagList("pages", 8)); diff --git a/src/main/java/net/minecraft/network/PingResponseHandler.java b/src/main/java/net/minecraft/network/PingResponseHandler.java index 1a42d19..b4a8440 100644 --- a/src/main/java/net/minecraft/network/PingResponseHandler.java +++ b/src/main/java/net/minecraft/network/PingResponseHandler.java @@ -30,71 +30,68 @@ try { - try + if (bytebuf.readUnsignedByte() != 254) { - if (bytebuf.readUnsignedByte() != 254) - { - return; - } - - InetSocketAddress inetsocketaddress = (InetSocketAddress)p_channelRead_1_.channel().remoteAddress(); - MinecraftServer minecraftserver = this.field_151257_b.func_151267_d(); - int i = bytebuf.readableBytes(); - String s; - - switch (i) - { - case 0: - logger.debug("Ping: (<1.3.x) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); - s = String.format("%s\u00a7%d\u00a7%d", new Object[] {minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); - this.func_151256_a(p_channelRead_1_, this.func_151255_a(s)); - break; - case 1: - if (bytebuf.readUnsignedByte() != 1) - { - return; - } - - logger.debug("Ping: (1.4-1.5.x) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); - s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", new Object[] {Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); - this.func_151256_a(p_channelRead_1_, this.func_151255_a(s)); - break; - default: - boolean flag1 = bytebuf.readUnsignedByte() == 1; - flag1 &= bytebuf.readUnsignedByte() == 250; - flag1 &= "MC|PingHost".equals(new String(bytebuf.readBytes(bytebuf.readShort() * 2).array(), Charsets.UTF_16BE)); - int j = bytebuf.readUnsignedShort(); - flag1 &= bytebuf.readUnsignedByte() >= 73; - flag1 &= 3 + bytebuf.readBytes(bytebuf.readShort() * 2).array().length + 4 == j; - flag1 &= bytebuf.readInt() <= 65535; - flag1 &= bytebuf.readableBytes() == 0; - - if (!flag1) - { - return; - } - - logger.debug("Ping: (1.6) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); - String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", new Object[] {Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); - ByteBuf bytebuf1 = this.func_151255_a(s1); - - try - { - this.func_151256_a(p_channelRead_1_, bytebuf1); - } - finally - { - bytebuf1.release(); - } - } - - bytebuf.release(); - flag = false; + return; } - catch (RuntimeException runtimeexception) + + InetSocketAddress inetsocketaddress = (InetSocketAddress)p_channelRead_1_.channel().remoteAddress(); + MinecraftServer minecraftserver = this.field_151257_b.func_151267_d(); + int i = bytebuf.readableBytes(); + String s; + + switch (i) { - ; + case 0: + logger.debug("Ping: (<1.3.x) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); + s = String.format("%s\u00a7%d\u00a7%d", new Object[] {minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); + this.func_151256_a(p_channelRead_1_, this.func_151255_a(s)); + break; + case 1: + if (bytebuf.readUnsignedByte() != 1) + { + return; + } + + logger.debug("Ping: (1.4-1.5.x) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); + s = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", new Object[] {Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); + this.func_151256_a(p_channelRead_1_, this.func_151255_a(s)); + break; + default: + boolean flag1 = bytebuf.readUnsignedByte() == 1; + flag1 &= bytebuf.readUnsignedByte() == 250; + flag1 &= "MC|PingHost".equals(new String(bytebuf.readBytes(bytebuf.readShort() * 2).array(), Charsets.UTF_16BE)); + int j = bytebuf.readUnsignedShort(); + flag1 &= bytebuf.readUnsignedByte() >= 73; + flag1 &= 3 + bytebuf.readBytes(bytebuf.readShort() * 2).array().length + 4 == j; + flag1 &= bytebuf.readInt() <= 65535; + flag1 &= bytebuf.readableBytes() == 0; + + if (!flag1) + { + return; + } + + logger.debug("Ping: (1.6) from {}:{}", new Object[] {inetsocketaddress.getAddress(), Integer.valueOf(inetsocketaddress.getPort())}); + String s1 = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", new Object[] {Integer.valueOf(127), minecraftserver.getMinecraftVersion(), minecraftserver.getMOTD(), Integer.valueOf(minecraftserver.getCurrentPlayerCount()), Integer.valueOf(minecraftserver.getMaxPlayers())}); + ByteBuf bytebuf1 = this.func_151255_a(s1); + + try + { + this.func_151256_a(p_channelRead_1_, bytebuf1); + } + finally + { + bytebuf1.release(); + } } + + bytebuf.release(); + flag = false; + } + catch (RuntimeException runtimeexception) + { + ; } finally { diff --git a/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java b/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java index fa477ba..93c63f3 100644 --- a/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/tileentity/TileEntityFurnace.java @@ -304,6 +304,9 @@ } else { + int moddedBurnTime = net.minecraftforge.event.ForgeEventFactory.getFuelBurnTime(p_145952_0_); + if (moddedBurnTime >= 0) return moddedBurnTime; + Item item = p_145952_0_.getItem(); if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air) diff --git a/src/main/java/net/minecraftforge/common/ForgeVersion.java b/src/main/java/net/minecraftforge/common/ForgeVersion.java index 38b392c..5875ab7 100644 --- a/src/main/java/net/minecraftforge/common/ForgeVersion.java +++ b/src/main/java/net/minecraftforge/common/ForgeVersion.java @@ -25,7 +25,7 @@ //This number is incremented every time a interface changes or new major feature is added, and reset every Minecraft version public static final int revisionVersion = 4; //This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code. - public static final int buildVersion = 1472; + public static final int buildVersion = 1566; private static Status status = PENDING; private static String target = null; diff --git a/src/main/java/net/minecraftforge/common/MinecraftForge.java b/src/main/java/net/minecraftforge/common/MinecraftForge.java index 7c43ac9..92bf5a6 100644 --- a/src/main/java/net/minecraftforge/common/MinecraftForge.java +++ b/src/main/java/net/minecraftforge/common/MinecraftForge.java @@ -12,6 +12,7 @@ import net.minecraft.crash.CrashReport; import net.minecraft.item.ItemStack; import net.minecraftforge.common.ForgeHooks.SeedEntry; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; public class MinecraftForge @@ -156,6 +157,8 @@ } UsernameCache.load(); + // Load before all the mods, so MC owns the MC fluids + FluidRegistry.validateFluidRegistry(); } diff --git a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java index ce1a182..df90109 100644 --- a/src/main/java/net/minecraftforge/event/ForgeEventFactory.java +++ b/src/main/java/net/minecraftforge/event/ForgeEventFactory.java @@ -135,6 +135,13 @@ return event.list; } + public static int getFuelBurnTime(ItemStack fuel) + { + FuelBurnTimeEvent event = new FuelBurnTimeEvent(fuel); + MinecraftForge.EVENT_BUS.post(event); + return event.getResult() == Result.DEFAULT ? -1 : event.burnTime; + } + public static int getMaxSpawnPackSize(EntityLiving entity) { LivingPackSizeEvent maxCanSpawnEvent = new LivingPackSizeEvent(entity); diff --git a/src/main/java/net/minecraftforge/event/FuelBurnTimeEvent.java b/src/main/java/net/minecraftforge/event/FuelBurnTimeEvent.java new file mode 100644 index 0000000..1b6c0b1 --- /dev/null +++ b/src/main/java/net/minecraftforge/event/FuelBurnTimeEvent.java @@ -0,0 +1,32 @@ +package net.minecraftforge.event; + +import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.Event.HasResult; + +/** + * FuelBurnTimeEvent is fired whenever a furnace needs the burn time of a fuel.
+ * Normally, a registered {@link cpw.mods.fml.common.IFuelHandler} is preferred, but + * this is useful in the rare situation where IFuelHandler is not effective.
+ *
+ * {@link Result#DEFAULT} allows the normal fuel handling code to proceed. + * {@link Result#ALLOW} or {@link Result#DENY} uses the value of {@link #burnTime} + * for the given {@link fuel}, bypassing both vanilla and IFuelHandler determinations. + *
+ * {@link #fuel} contains the potential fuel.
+ * {@link #burnTime} the results if set by an event handler.
+ *
+ * This event are fired on the {@link MinecraftForge#EVENT_BUS}. + **/ +@HasResult +@Deprecated //Remove in 1.8 +public class FuelBurnTimeEvent extends Event +{ + public final ItemStack fuel; + public int burnTime; + + public FuelBurnTimeEvent(ItemStack fuel) + { + this.fuel = fuel; + } +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java index a127b8c..d6b988b 100644 --- a/src/main/java/net/minecraftforge/fluids/FluidRegistry.java +++ b/src/main/java/net/minecraftforge/fluids/FluidRegistry.java @@ -112,7 +112,7 @@ Integer id = localFluidIDs.remove(oldFluid); localFluidIDs.put(fluid, id); } - BiMap localFluidNames = fluidNames; + BiMap localFluidNames = HashBiMap.create(); for (Entry e : localFluidIDs.entrySet()) { localFluidNames.put(e.getValue(), e.getKey().getName()); } diff --git a/src/main/java/net/minecraftforge/oredict/OreDictionary.java b/src/main/java/net/minecraftforge/oredict/OreDictionary.java index db4f7d4..aaf49e1 100644 --- a/src/main/java/net/minecraftforge/oredict/OreDictionary.java +++ b/src/main/java/net/minecraftforge/oredict/OreDictionary.java @@ -8,6 +8,7 @@ import gnu.trove.set.hash.TIntHashSet; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -20,6 +21,8 @@ import java.util.Map.Entry; import java.util.Set; +import org.apache.logging.log4j.Level; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -35,7 +38,9 @@ import com.google.common.collect.Maps; import cpw.mods.fml.common.FMLLog; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.registry.GameData; public class OreDictionary { @@ -304,7 +309,20 @@ { if (stack == null || stack.getItem() == null) return -1; - int id = Item.getIdFromItem(stack.getItem()); + // HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet + // IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about. + // APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game. + String registryName = stack.getItem().delegate.name(); + int id; + if (registryName == null) + { + FMLLog.log(Level.DEBUG, "Attempted to find the oreIDs for an unregistered object (%s). This won't work very well.", stack); + return -1; + } + else + { + id = GameData.getItemRegistry().getId(registryName); + } TIntList ids = stackToId.get(id); //Try the wildcard first if (ids == null || ids.size() == 0) { @@ -324,7 +342,20 @@ { if (stack == null || stack.getItem() == null) return new int[0]; - int id = Item.getIdFromItem(stack.getItem()); + // HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet + // IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about. + // APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game. + String registryName = stack.getItem().delegate.name(); + int id; + if (registryName == null) + { + FMLLog.log(Level.DEBUG, "Attempted to find the oreIDs for an unregistered object (%s). This won't work very well.", stack); + return new int[0]; + } + else + { + id = GameData.getItemRegistry().getId(registryName); + } TIntList ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16)); TIntList ids2 = stackToId.get(id); if(ids == null && ids2 == null) @@ -359,14 +390,14 @@ /** * Retrieves the List of items that are registered to this ore type at this instant. * If the flag is TRUE, then it will create the list as empty if it did not exist. - * + * * This option should be used by modders who are doing blanket scans in postInit. * It greatly reduces clutter in the OreDictionary is the responsible and proper * way to use the dictionary in a large number of cases. - * + * * The other function above is utilized in OreRecipe and is required for the * operation of that code. - * + * * @param name The ore name, directly calls getOreID if the flag is TRUE * @param alwaysCreateEntry Flag - should a new entry be created if empty * @return An arraylist containing ItemStacks registered for this ore @@ -383,9 +414,9 @@ * Returns whether or not an oreName exists in the dictionary. * This function can be used to safely query the Ore Dictionary without * adding needless clutter to the underlying map structure. - * + * * Please use this when possible and appropriate. - * + * * @param name The ore name * @return Whether or not that name is in the Ore Dictionary. */ @@ -502,7 +533,22 @@ } int oreID = getOreID(name); - int hash = Item.getIdFromItem(ore.getItem()); + // HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet + // IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about. + // APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game. + String registryName = ore.getItem().delegate.name(); + int hash; + if (registryName == null) + { + FMLLog.bigWarning("A broken ore dictionary registration with name %s has occurred. It adds an item (type: %s) which is currently unknown to the game registry. This dictionary item can only support a single value when" + + " registered with ores like this, and NO I am not going to turn this spam off. Just register your ore dictionary entries after the GameRegistry.\n" + + "TO USERS: YES this is a BUG in the mod "+Loader.instance().activeModContainer().getName()+" report it to them!", name, ore.getItem().getClass()); + hash = -1; + } + else + { + hash = GameData.getItemRegistry().getId(registryName); + } if (ore.getItemDamage() != WILDCARD_VALUE) { hash |= ((ore.getItemDamage() + 1) << 16); // +1 so 0 is significant @@ -546,7 +592,18 @@ if (ores == null) continue; for (ItemStack ore : ores) { - int hash = Item.getIdFromItem(ore.getItem()); + // HACK: use the registry name's ID. It is unique and it knows about substitutions + String name = ore.getItem().delegate.name(); + int hash; + if (name == null) + { + FMLLog.log(Level.DEBUG, "Defaulting unregistered ore dictionary entry for ore dictionary %s: type %s to -1", getOreName(id), ore.getItem().getClass()); + hash = -1; + } + else + { + hash = GameData.getItemRegistry().getId(name); + } if (ore.getItemDamage() != WILDCARD_VALUE) { hash |= ((ore.getItemDamage() + 1) << 16); // +1 so meta 0 is significant diff --git a/src/main/resources/fmlversion.properties b/src/main/resources/fmlversion.properties index 4c31801..80cfbc5 100644 --- a/src/main/resources/fmlversion.properties +++ b/src/main/resources/fmlversion.properties @@ -1,6 +1,6 @@ fmlbuild.major.number=7 -fmlbuild.minor.number=10 -fmlbuild.revision.number=138 +fmlbuild.minor.number=99 +fmlbuild.revision.number=39 fmlbuild.build.number=1 fmlbuild.mcversion=1.7.10 fmlbuild.mcpversion=9.05