Merge pull request #822 from bonii-xx/master

Add Casting events for CastingTable and CastingBasin, lots of bugfixes, remove console spam for invalid tools
This commit is contained in:
mDiyo committed 2014-08-08 00:31:41 -08:00
commit 41679a1f1a
14 files changed
+115 -70

No files matched your search

+1 -1
View File
@@ -88,7 +88,7 @@ public class TConstruct
public static TProxyCommon proxy;
/* Loads modules in a way that doesn't clutter the @Mod list */
private PulseManager pulsar = new PulseManager(modID, new ForgeCFG("TinkersModules", "Modules: Disabling these will disable a chunk of the mod"));
public static PulseManager pulsar = new PulseManager(modID, new ForgeCFG("TinkersModules", "Modules: Disabling these will disable a chunk of the mod"));
public TConstruct()
{
@@ -103,15 +103,7 @@ public class Arrow extends ToolCore
Item extra = getExtraItem();
ItemStack extraStack = extra != null ? new ItemStack(extra, 1, 0) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, 3), new ItemStack(getHandleItem(), 1, 0), accessoryStack, extraStack, "");
if (tool == null)
{
if (!TinkerTools.supressMissingToolLogs)
{
TConstruct.logger.warn("Creative builder failed tool for Vanilla style" + this.getToolName());
TConstruct.logger.warn("Make sure you do not have item ID conflicts");
}
}
else
if (tool != null)
{
tool.stackSize = 1;
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
@@ -126,18 +118,7 @@ public class Arrow extends ToolCore
tool = ToolBuilder.instance
.buildTool(new ItemStack(getHeadItem(), 1, random.nextInt(18)), new ItemStack(getHandleItem(), 1, random.nextInt(18)), accessoryStack, extraStack, StatCollector.translateToLocal("item.tool.randomarrow"));
if (tool == null)
{
if (!TinkerTools.supressMissingToolLogs)
{
if (!TinkerTools.supressMissingToolLogs)
{
TConstruct.logger.warn("Creative builder failed tool for Vanilla style" + this.getToolName());
TConstruct.logger.warn("Make sure you do not have item ID conflicts");
}
}
}
else
if (tool != null)
{
tool.stackSize = 1;
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
@@ -154,12 +135,7 @@ public class Arrow extends ToolCore
Item extra = getExtraItem();
ItemStack extraStack = extra != null ? new ItemStack(getExtraItem(), 1, id) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name + getToolName());
if (tool == null)
{
TConstruct.logger.warn("Creative builder failed tool for " + name + this.getToolName());
TConstruct.logger.warn("Make sure you do not have item ID conflicts");
}
else
if (tool != null)
{
tool.stackSize = 1;
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
@@ -776,17 +776,9 @@ public abstract class BowBase extends ToolCore
ItemStack extraStack = extra != null ? new ItemStack(getExtraItem(), 1, id) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, 0), accessoryStack, extraStack, name + getToolName());
if (tool == null)
{
if (!TinkerTools.supressMissingToolLogs)
{
TConstruct.logger.warn("Creative builder failed tool for " + name + this.getToolName());
TConstruct.logger.warn("Make sure you do not have item ID conflicts");
}
}
else
{
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add(tool);
}
return;
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add(tool);
}
}
@@ -120,15 +120,7 @@ public class Mattock extends DualHarvestTool
Item extra = getExtraItem();
ItemStack extraStack = extra != null ? new ItemStack(extra, 1, id) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name + getToolName());
if (tool == null)
{
if (!TinkerTools.supressMissingToolLogs)
{
TConstruct.logger.warn("Creative builder failed tool for " + name + this.getToolName());
TConstruct.logger.warn("Make sure you do not have item ID conflicts");
}
}
else
if (tool != null)
{
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add(tool);
@@ -0,0 +1,32 @@
package tconstruct.library.event;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraftforge.fluids.FluidStack;
import tconstruct.library.crafting.CastingRecipe;
/**
* Fires when somebody tries to pour a liquid into a metal cast.
*
* Set result to DENY to prevent casting.
*/
public abstract class SmelteryCastEvent extends Event {
public final CastingRecipe recipe;
public final FluidStack fluid;
public SmelteryCastEvent(CastingRecipe recipe, FluidStack fluid) {
this.recipe = recipe;
this.fluid = fluid;
}
public static class CastingTable extends SmelteryCastEvent {
public CastingTable(CastingRecipe recipe, FluidStack fluid) {
super(recipe, fluid);
}
}
public static class CastingBasin extends SmelteryCastEvent {
public CastingBasin(CastingRecipe recipe, FluidStack fluid) {
super(recipe, fluid);
}
}
}
@@ -0,0 +1,34 @@
package tconstruct.library.event;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.item.ItemStack;
import tconstruct.library.crafting.CastingRecipe;
/**
* Fired when an item is cast in the casting table.
* If consumeCast is set to true, the cast will be destroyed.
*/
public abstract class SmelteryCastedEvent extends Event {
public final CastingRecipe recipe;
public ItemStack output;
public boolean consumeCast;
public SmelteryCastedEvent(CastingRecipe recipe, ItemStack output) {
this.recipe = recipe;
this.consumeCast = recipe.consumeCast;
this.output = output;
}
public static class CastingTable extends SmelteryCastedEvent {
public CastingTable(CastingRecipe recipe, ItemStack output) {
super(recipe, output);
}
}
public static class CastingBasin extends SmelteryCastedEvent {
public CastingBasin(CastingRecipe recipe, ItemStack output) {
super(recipe, output);
}
}
}
@@ -491,7 +491,7 @@ public class AbilityHelper
if (event.getResult() == Result.ALLOW)
{
stack.damageItem(1, player);
damageTool(stack, 1, player, false);
return true;
}
@@ -509,7 +509,7 @@ public class AbilityHelper
else
{
world.setBlock(x, y, z, block1);
stack.damageItem(1, player);
damageTool(stack, 1, player, false);
return true;
}
}
@@ -24,6 +24,7 @@ import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ToolBuilder;
import tconstruct.library.modifier.IModifyable;
import tconstruct.library.modifier.ItemModifier;
import tconstruct.tools.TinkerTools;
import tconstruct.tools.entity.FancyEntityItem;
import cofh.api.energy.IEnergyContainerItem;
import cpw.mods.fml.relauncher.Side;
@@ -554,16 +555,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IMo
Item extra = getExtraItem();
ItemStack extraStack = extra != null ? new ItemStack(extra, 1, id) : null;
ItemStack tool = ToolBuilder.instance.buildTool(new ItemStack(getHeadItem(), 1, id), new ItemStack(getHandleItem(), 1, id), accessoryStack, extraStack, name + getToolName());
if (tool == null)
{
boolean supress = false; //TODO: Find this for iguana tweaks
if (!supress)
{
TConstructRegistry.logger.error("Creative builder failed tool for " + name + this.getToolName());
TConstructRegistry.logger.error("Make sure you do not have item ID conflicts");
}
}
else
if (tool != null)
{
tool.getTagCompound().getCompoundTag("InfiTool").setBoolean("Built", true);
list.add(tool);
@@ -1,5 +1,6 @@
package tconstruct.smeltery.logic;
import cpw.mods.fml.common.eventhandler.Event;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -10,6 +11,7 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidEvent;
@@ -19,6 +21,8 @@ import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import tconstruct.TConstruct;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.event.SmelteryCastEvent;
import tconstruct.library.event.SmelteryCastedEvent;
import tconstruct.library.util.IPattern;
public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
@@ -120,6 +124,13 @@ public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFl
CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(resource, inventory[0]);
if (recipe == null)
return 0;
SmelteryCastEvent event = new SmelteryCastEvent.CastingBasin(recipe, resource);
MinecraftForge.EVENT_BUS.post(event);
if(event.getResult() == Event.Result.DENY)
return 0;
this.capacity = updateCapacity(recipe.castingMetal.amount);
if (inventory[1] == null)
@@ -328,8 +339,11 @@ public class CastingBasinLogic extends InventoryLogic implements IFluidTank, IFl
CastingRecipe recipe = TConstruct.basinCasting.getCastingRecipe(liquid, inventory[0]);
if (recipe != null)
{
inventory[1] = recipe.getResult();
if (recipe.consumeCast)
SmelteryCastedEvent event = new SmelteryCastedEvent.CastingBasin(recipe, recipe.getResult());
MinecraftForge.EVENT_BUS.post(event);
inventory[1] = event.output;
if (event.consumeCast)
inventory[0] = null;
liquid = null;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
@@ -1,5 +1,6 @@
package tconstruct.smeltery.logic;
import cpw.mods.fml.common.eventhandler.Event;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@@ -10,6 +11,7 @@ import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidEvent;
@@ -19,6 +21,8 @@ import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.IFluidTank;
import tconstruct.TConstruct;
import tconstruct.library.crafting.CastingRecipe;
import tconstruct.library.event.SmelteryCastEvent;
import tconstruct.library.event.SmelteryCastedEvent;
import tconstruct.library.util.IPattern;
public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFluidHandler, ISidedInventory
@@ -120,6 +124,13 @@ public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFl
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(resource, inventory[0]);
if (recipe == null)
return 0;
SmelteryCastEvent event = new SmelteryCastEvent.CastingTable(recipe, resource);
MinecraftForge.EVENT_BUS.post(event);
if(event.getResult() == Event.Result.DENY)
return 0;
this.capacity = updateCapacity(recipe.castingMetal.amount);
if (inventory[1] == null)
@@ -329,8 +340,11 @@ public class CastingTableLogic extends InventoryLogic implements IFluidTank, IFl
CastingRecipe recipe = TConstruct.tableCasting.getCastingRecipe(liquid, inventory[0]);
if (recipe != null)
{
inventory[1] = recipe.getResult();
if (recipe.consumeCast)
SmelteryCastedEvent event = new SmelteryCastedEvent.CastingTable(recipe, recipe.getResult());
MinecraftForge.EVENT_BUS.post(event);
inventory[1] = event.output;
if (event.consumeCast)
inventory[0] = null;
liquid = null;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
@@ -201,7 +201,8 @@ public class FaucetLogic extends TileEntity implements IFacingLogic, IActiveLogi
if (!active)
{
active = true;
activateFaucet();
if(!activateFaucet())
active = false;
}
else
{
@@ -24,6 +24,8 @@ import tconstruct.TConstruct;
import tconstruct.armor.player.TPlayerStats;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.event.PartBuilderEvent;
import tconstruct.library.event.SmelteryCastEvent;
import tconstruct.library.event.SmelteryCastedEvent;
import tconstruct.library.event.ToolCraftEvent;
import tconstruct.library.tools.AbilityHelper;
import tconstruct.library.tools.ArrowMaterial;
@@ -143,9 +143,6 @@ public class TinkerTools
public static Item knifeBlade;
public static Item wideGuard;
// Supresses console spam when iguana's tweaks remove stuff
public static boolean supressMissingToolLogs = false;
// Patterns and other materials
public static Item blankPattern;
public static Item materials; //TODO: Untwine this item
@@ -42,7 +42,6 @@ public class PHConstruct
//config.load(); /* Load happens in the constructor */
superfunWorld = config.get("Superfun", "All the world is Superfun", false).getBoolean(false);
TinkerTools.supressMissingToolLogs = config.get("Logging", "Disable tool build messages", false).getBoolean(false);
keepHunger = config.get("Difficulty Changes", "Keep hunger on death", true).getBoolean(true);
keepLevels = config.get("Difficulty Changes", "Keep levels on death", true).getBoolean(true);