2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2018-07-01 21:17:28 +00:00
|
|
|
* Copyright (c) 2016-2018.
|
2016-06-23 03:49:47 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation version 2.1
|
|
|
|
* of the License.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2014-04-03 01:33:13 +00:00
|
|
|
package net.minecraftforge.event;
|
|
|
|
|
Initial update to 1.8, Super beta. Most rendering related hooks are out due to major changes in 1.8.
Some notes:
Almost all int x, int y, int z parameters have been changed to BlockPos class
ForgeDirection has been removed, replaced by net.minecraft.util.EnumFacing.
All FML classes have moved from packet cpw.mods.fml to net.minecraftforge.fml
Fluid Rendering has been disabled for the time being, to be re-evaulated and a test mod created for it.
Minecraft now uses a Model based system for rendering blocks and Items. The intention is to expand the model format to better suit modder's needed once it is evaulated.
As such, The model loaders from Forge have been removed, to be replaced by expanding vanilla's model format.
Metadata has been extracted out in Minecraft to IBlockState, which holds a list of properties instead of magic number metadata. DO NOT listen to the fearmongering, you can do EVERYTHING with block states you could previously with metadata.
Stencil Bits are disabled entirely by for the main Display, Modders must enable and recreate the FrameBuffer if they wish to use Stencil Bits.
2014-11-26 03:56:35 +00:00
|
|
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
2014-04-03 01:33:13 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
2016-11-17 18:44:31 +00:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2014-04-03 01:33:13 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* AnvilUpdateEvent is fired when a player places items in both the left and right slots of a anvil.
|
|
|
|
* If the event is canceled, vanilla behavior will not run, and the output will be set to null.
|
|
|
|
* If the event is not canceled, but the output is not null, it will set the output and not run vanilla behavior.
|
|
|
|
* if the output is null, and the event is not canceled, vanilla behavior will execute.
|
|
|
|
*/
|
|
|
|
@Cancelable
|
|
|
|
public class AnvilUpdateEvent extends Event
|
|
|
|
{
|
2016-11-17 18:44:31 +00:00
|
|
|
@Nonnull
|
2016-03-24 08:44:52 +00:00
|
|
|
private final ItemStack left; // The left side of the input
|
2016-11-17 18:44:31 +00:00
|
|
|
@Nonnull
|
2016-03-24 08:44:52 +00:00
|
|
|
private final ItemStack right; // The right side of the input
|
|
|
|
private final String name; // The name to set the item, if the user specified one.
|
2016-11-17 18:44:31 +00:00
|
|
|
@Nonnull
|
2016-03-24 08:44:52 +00:00
|
|
|
private ItemStack output; // Set this to set the output stack
|
|
|
|
private int cost; // The base cost, set this to change it if output != null
|
|
|
|
private int materialCost; // The number of items from the right slot to be consumed during the repair. Leave as 0 to consume the entire stack.
|
2014-04-03 01:33:13 +00:00
|
|
|
|
2016-11-17 18:44:31 +00:00
|
|
|
public AnvilUpdateEvent(@Nonnull ItemStack left, @Nonnull ItemStack right, String name, int cost)
|
2014-04-03 01:33:13 +00:00
|
|
|
{
|
|
|
|
this.left = left;
|
|
|
|
this.right = right;
|
2016-12-21 23:52:30 +00:00
|
|
|
this.output = ItemStack.EMPTY;
|
2014-04-03 01:33:13 +00:00
|
|
|
this.name = name;
|
2016-03-24 08:44:52 +00:00
|
|
|
this.setCost(cost);
|
|
|
|
this.setMaterialCost(0);
|
2014-04-03 01:33:13 +00:00
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
2016-11-17 18:44:31 +00:00
|
|
|
@Nonnull
|
2016-03-24 08:44:52 +00:00
|
|
|
public ItemStack getLeft() { return left; }
|
2016-11-17 18:44:31 +00:00
|
|
|
@Nonnull
|
2016-03-24 08:44:52 +00:00
|
|
|
public ItemStack getRight() { return right; }
|
|
|
|
public String getName() { return name; }
|
2016-11-17 18:44:31 +00:00
|
|
|
@Nonnull
|
2016-03-24 08:44:52 +00:00
|
|
|
public ItemStack getOutput() { return output; }
|
2016-11-17 18:44:31 +00:00
|
|
|
public void setOutput(@Nonnull ItemStack output) { this.output = output; }
|
2016-03-24 08:44:52 +00:00
|
|
|
public int getCost() { return cost; }
|
|
|
|
public void setCost(int cost) { this.cost = cost; }
|
|
|
|
public int getMaterialCost() { return materialCost; }
|
|
|
|
public void setMaterialCost(int materialCost) { this.materialCost = materialCost; }
|
2014-04-03 01:33:13 +00:00
|
|
|
}
|