Merge pull request #47 from EoD/fix-item-remapping-v2

Fix item remapping v2
This commit is contained in:
Fenn committed 2014-09-15 11:14:26 +01:00
commit 652d905ca1
2 files changed
+35 -29

No files matched your search

@@ -1,9 +1,13 @@
package info.jbcs.minecraft.chisel;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.event.FMLMissingMappingsEvent.MissingMapping;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@@ -87,40 +91,43 @@ public class Chisel
}
// Fix mapping of snakestoneSand, snakestoneStone, limestoneStairs, marbleStairs when loading an old (1.5.4) save
else if(m.type == Type.BLOCK)
else if (m.type == Type.BLOCK)
{
Block block = null;
if(General.cleanTags(m.name).equals("sandSnakestone"))
if (General.cleanTags(m.name).equals("sandSnakestone"))
block = GameRegistry.findBlock(Chisel.MOD_ID, "tile.snakestoneSand");
else if(General.cleanTags(m.name).equals("snakestone"))
else if (General.cleanTags(m.name).equals("snakestone"))
block = GameRegistry.findBlock(Chisel.MOD_ID, "tile.snakestoneStone");
else
block = GameRegistry.findBlock(Chisel.MOD_ID, General.cleanTags(m.name));
if(block != null)
if (block != null)
{
m.remap(block);
FMLLog.getLogger().info("Remapping block " + m.name + " to " + General.getName(block));
} else
}
else
FMLLog.getLogger().warn("Block " + m.name + " could not get remapped.");
} else if(m.type == Type.ITEM)
}
else if (m.type == Type.ITEM)
{
Item item = null;
if(General.cleanTags(m.name).equals("sandSnakestone"))
if (General.cleanTags(m.name).equals("sandSnakestone"))
item = GameRegistry.findItem(Chisel.MOD_ID, "tile.snakestoneSand");
else if(General.cleanTags(m.name).equals("snakestone"))
else if (General.cleanTags(m.name).equals("snakestone"))
item = GameRegistry.findItem(Chisel.MOD_ID, "tile.snakestoneStone");
else
item = GameRegistry.findItem(Chisel.MOD_ID, General.cleanTags(m.name));
if(item != null)
if (item != null)
{
m.remap(item);
FMLLog.getLogger().info("Remapping item " + m.name + " to " + General.getName(item));
} else
}
else
FMLLog.getLogger().warn("Item " + m.name + " could not get remapped.");
}
}
@@ -229,13 +236,12 @@ public class Chisel
Random random = new Random();
@SubscribeEvent
public void onPlayerClick(PlayerInteractEvent event)
{
public void onPlayerClick(PlayerInteractEvent event) {
if(event.action != PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) return;
if(!Configurations.enableChiseling) return;
if (!Configurations.enableChiseling) return;
EntityPlayer player = event.entityPlayer;
ItemStack stack = player.getHeldItem();
if(stack == null || stack.getItem() != chisel) return;
if (stack == null || stack.getItem() != chisel) return;
World world = event.world;
int x = event.x;
@@ -266,14 +272,14 @@ public class Chisel
long cooldown = 20;
long time = world.getWorldInfo().getWorldTotalTime();
if(time > useTime - cooldown && time < useTime + cooldown) return; //noReplace = true;
if(time>useTime-cooldown && time<useTime+cooldown) return; //noReplace = true;
}
CarvingVariation[] variations = ItemChisel.carving.getVariations(block, blockMeta);
if(variations == null || variations.length < 2) return; //noReplace = true;
else
{
int index = blockMeta + 1;
int index = blockMeta +1;
while(variations[index].block.equals(block) && variations[index].damage == blockMeta)
{
index++;
@@ -349,12 +355,11 @@ public class Chisel
}
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event)
{
if(!Configurations.enableChiseling) return;
public void onBlockBreak(BlockEvent.BreakEvent event) {
if (!Configurations.enableChiseling) return;
EntityPlayer player = event.getPlayer();
ItemStack stack = player.getHeldItem();
if(stack == null || stack.getItem() != chisel) return;
if (stack == null || stack.getItem() != chisel) return;
event.setCanceled(true);
}