2016-06-23 03:49:47 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2020-07-02 17:49:11 +00:00
|
|
|
* Copyright (c) 2016-2020.
|
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
|
|
|
|
*/
|
|
|
|
|
2012-09-27 04:18:18 +00:00
|
|
|
package net.minecraftforge.event.entity.player;
|
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
import com.google.common.base.Preconditions;
|
2020-12-28 19:54:30 +00:00
|
|
|
import net.minecraft.block.Block;
|
2016-04-05 00:58:46 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
2020-12-28 19:54:30 +00:00
|
|
|
import net.minecraft.item.Item;
|
2016-04-05 00:58:46 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.util.ActionResultType;
|
|
|
|
import net.minecraft.util.Direction;
|
|
|
|
import net.minecraft.util.Hand;
|
2016-04-05 00:58:46 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2020-12-28 19:54:30 +00:00
|
|
|
import net.minecraft.util.math.BlockRayTraceResult;
|
2020-06-19 14:58:45 +00:00
|
|
|
import net.minecraft.util.math.vector.Vector3d;
|
2014-06-02 22:49:11 +00:00
|
|
|
import net.minecraft.world.World;
|
2016-04-05 00:58:46 +00:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2018-06-11 01:12:46 +00:00
|
|
|
import net.minecraftforge.eventbus.api.Cancelable;
|
2016-04-05 00:58:46 +00:00
|
|
|
|
2016-11-13 22:09:54 +00:00
|
|
|
import javax.annotation.Nonnull;
|
2016-04-05 00:58:46 +00:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2018-06-11 01:12:46 +00:00
|
|
|
import static net.minecraftforge.eventbus.api.Event.Result.DEFAULT;
|
|
|
|
import static net.minecraftforge.eventbus.api.Event.Result.DENY;
|
2012-09-27 04:18:18 +00:00
|
|
|
|
2019-03-25 18:41:08 +00:00
|
|
|
import net.minecraftforge.fml.LogicalSide;
|
2018-09-22 10:40:22 +00:00
|
|
|
|
2014-07-06 20:07:49 +00:00
|
|
|
/**
|
|
|
|
* PlayerInteractEvent is fired when a player interacts in some way.
|
2016-04-05 00:58:46 +00:00
|
|
|
* All subclasses are fired on {@link MinecraftForge#EVENT_BUS}.
|
|
|
|
* See the individual documentation on each subevent for more details.
|
2014-07-06 20:07:49 +00:00
|
|
|
**/
|
2012-09-27 04:18:18 +00:00
|
|
|
public class PlayerInteractEvent extends PlayerEvent
|
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
private final Hand hand;
|
2016-04-05 00:58:46 +00:00
|
|
|
private final BlockPos pos;
|
2017-01-11 23:17:56 +00:00
|
|
|
@Nullable
|
2019-05-23 23:02:15 +00:00
|
|
|
private final Direction face;
|
|
|
|
private ActionResultType cancellationResult = ActionResultType.PASS;
|
2016-04-05 00:58:46 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
private PlayerInteractEvent(PlayerEntity player, Hand hand, BlockPos pos, @Nullable Direction face)
|
2012-09-27 04:18:18 +00:00
|
|
|
{
|
2016-04-05 00:58:46 +00:00
|
|
|
super(Preconditions.checkNotNull(player, "Null player in PlayerInteractEvent!"));
|
|
|
|
this.hand = Preconditions.checkNotNull(hand, "Null hand in PlayerInteractEvent!");
|
|
|
|
this.pos = Preconditions.checkNotNull(pos, "Null position in PlayerInteractEvent!");
|
|
|
|
this.face = face;
|
2012-09-27 04:18:18 +00:00
|
|
|
}
|
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
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
/**
|
|
|
|
* This event is fired on both sides whenever a player right clicks an entity.
|
|
|
|
*
|
|
|
|
* "Interact at" is an interact where the local vector (which part of the entity you clicked) is known.
|
|
|
|
* The state of this event affects whether {@link Entity#applyPlayerInteraction} is called.
|
|
|
|
*
|
2017-04-07 23:38:56 +00:00
|
|
|
* Let result be the return value of {@link Entity#applyPlayerInteraction}, or {@link #cancellationResult} if the event is cancelled.
|
|
|
|
* If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link EntityInteract}.
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
2018-09-20 20:11:02 +00:00
|
|
|
@Cancelable
|
2016-04-05 00:58:46 +00:00
|
|
|
public static class EntityInteractSpecific extends PlayerInteractEvent
|
|
|
|
{
|
2020-06-19 14:58:45 +00:00
|
|
|
private final Vector3d localPos;
|
2016-04-05 00:58:46 +00:00
|
|
|
private final Entity target;
|
|
|
|
|
2020-06-19 14:58:45 +00:00
|
|
|
public EntityInteractSpecific(PlayerEntity player, Hand hand, Entity target, Vector3d localPos)
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
2020-10-29 00:11:57 +00:00
|
|
|
super(player, hand, target.getPosition(), null);
|
2016-04-05 00:58:46 +00:00
|
|
|
this.localPos = localPos;
|
|
|
|
this.target = target;
|
|
|
|
}
|
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
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
/**
|
|
|
|
* Returns the local interaction position. This is a 3D vector, where (0, 0, 0) is centered exactly at the
|
|
|
|
* center of the entity's bounding box at their feet. This means the X and Z values will be in the range
|
|
|
|
* [-width / 2, width / 2] while Y values will be in the range [0, height]
|
|
|
|
* @return The local position
|
|
|
|
*/
|
2020-06-19 14:58:45 +00:00
|
|
|
public Vector3d getLocalPos()
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
|
|
|
return localPos;
|
|
|
|
}
|
2014-06-02 22:49:11 +00:00
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
public Entity getTarget()
|
|
|
|
{
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event is fired on both sides when the player right clicks an entity.
|
|
|
|
* It is responsible for all general entity interactions.
|
|
|
|
*
|
2017-04-07 23:38:56 +00:00
|
|
|
* This event is fired only if the result of the above {@link EntityInteractSpecific} is not {@link EnumActionResult#SUCCESS}.
|
2016-04-05 00:58:46 +00:00
|
|
|
* This event's state affects whether {@link Entity#processInitialInteract} and {@link net.minecraft.item.Item#itemInteractionForEntity} are called.
|
|
|
|
*
|
2017-04-07 23:38:56 +00:00
|
|
|
* Let result be {@link EnumActionResult#SUCCESS} if {@link Entity#processInitialInteract} or {@link net.minecraft.item.Item#itemInteractionForEntity} return true,
|
|
|
|
* or {@link #cancellationResult} if the event is cancelled.
|
|
|
|
* If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link RightClickItem}.
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
2018-09-20 20:11:02 +00:00
|
|
|
@Cancelable
|
2016-04-05 00:58:46 +00:00
|
|
|
public static class EntityInteract extends PlayerInteractEvent
|
2016-02-27 01:27:21 +00:00
|
|
|
{
|
2016-04-05 00:58:46 +00:00
|
|
|
private final Entity target;
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public EntityInteract(PlayerEntity player, Hand hand, Entity target)
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
2020-10-29 00:11:57 +00:00
|
|
|
super(player, hand, target.getPosition(), null);
|
2016-04-05 00:58:46 +00:00
|
|
|
this.target = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Entity getTarget()
|
|
|
|
{
|
|
|
|
return target;
|
|
|
|
}
|
2016-02-27 01:27:21 +00:00
|
|
|
}
|
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
/**
|
2020-12-28 19:54:30 +00:00
|
|
|
* This event is fired on both sides whenever the player right clicks while targeting a block. <br>
|
|
|
|
* This event controls which of {@link Item#onItemUseFirst}, {@link Block#onBlockActivated}, and {@link Item#onItemUse}
|
|
|
|
* will be called. <br>
|
|
|
|
* Canceling the event will cause none of the above three to be called. <br>
|
|
|
|
* <br>
|
|
|
|
* Let result be the first non-pass return value of the above three methods, or pass, if they all pass. <br>
|
|
|
|
* Or {@link #cancellationResult} if the event is cancelled. <br>
|
|
|
|
* If result equals {@link ActionResultType#PASS}, we proceed to {@link RightClickItem}. <br>
|
|
|
|
* <br>
|
|
|
|
* There are various results to this event, see the getters below. <br>
|
|
|
|
* Note that handling things differently on the client vs server may cause desynchronizations!
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
@Cancelable
|
|
|
|
public static class RightClickBlock extends PlayerInteractEvent
|
2012-09-27 04:18:18 +00:00
|
|
|
{
|
2016-04-05 00:58:46 +00:00
|
|
|
private Result useBlock = DEFAULT;
|
|
|
|
private Result useItem = DEFAULT;
|
2020-12-28 19:54:30 +00:00
|
|
|
private BlockRayTraceResult hitVec;
|
2016-04-05 00:58:46 +00:00
|
|
|
|
2020-12-28 19:54:30 +00:00
|
|
|
@Deprecated //Use RayTraceResult version. TODO: Remove 1.17
|
2019-05-23 23:02:15 +00:00
|
|
|
public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face) {
|
2016-11-13 22:09:54 +00:00
|
|
|
super(player, hand, pos, face);
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
|
2020-12-28 19:54:30 +00:00
|
|
|
public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) {
|
|
|
|
super(player, hand, pos, hitVec.getFace());
|
|
|
|
this.hitVec = hitVec;
|
|
|
|
}
|
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
/**
|
|
|
|
* @return If {@link net.minecraft.block.Block#onBlockActivated} should be called
|
|
|
|
*/
|
|
|
|
public Result getUseBlock()
|
|
|
|
{
|
|
|
|
return useBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-07-14 21:28:42 +00:00
|
|
|
* @return If {@link net.minecraft.item.Item#onItemUseFirst} and {@link net.minecraft.item.Item#onItemUse} should be called
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
public Result getUseItem()
|
|
|
|
{
|
|
|
|
return useItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-28 19:54:30 +00:00
|
|
|
* @return The ray trace result targeting the block.
|
|
|
|
*/
|
|
|
|
public BlockRayTraceResult getHitVec()
|
|
|
|
{
|
|
|
|
return hitVec;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DENY: {@link Block#onBlockActivated} will never be called. <br>
|
|
|
|
* DEFAULT: {@link Block#onBlockActivated} will be called if {@link Item#onItemUseFirst} passes. <br>
|
|
|
|
* Note that default activation can be blocked if the user is sneaking and holding an item that does not return true to {@link Item#doesSneakBypassUse}. <br>
|
|
|
|
* ALLOW: {@link Block#onBlockActivated} will always be called, unless {@link Item#onItemUseFirst} does not pass. <br>
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
public void setUseBlock(Result triggerBlock)
|
|
|
|
{
|
|
|
|
this.useBlock = triggerBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-12-28 19:54:30 +00:00
|
|
|
* DENY: Neither {@link Item#onItemUse} or {@link Item#onItemUseFirst} will be called. <br>
|
|
|
|
* DEFAULT: {@link Item#onItemUseFirst} will always be called, and {@link Item#onItemUse} will be called if the block passes. <br>
|
|
|
|
* ALLOW: {@link Item#onItemUseFirst} will always be called, and {@link Item#onItemUse} will be called if the block passes, regardless of cooldowns or emptiness. <br>
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
public void setUseItem(Result triggerItem)
|
|
|
|
{
|
|
|
|
this.useItem = triggerItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setCanceled(boolean canceled)
|
|
|
|
{
|
|
|
|
super.setCanceled(canceled);
|
2016-06-04 01:52:01 +00:00
|
|
|
if (canceled)
|
|
|
|
{
|
|
|
|
useBlock = DENY;
|
|
|
|
useItem = DENY;
|
|
|
|
}
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event is fired on both sides before the player triggers {@link net.minecraft.item.Item#onItemRightClick}.
|
2017-04-07 23:38:56 +00:00
|
|
|
* Note that this is NOT fired if the player is targeting a block {@link RightClickBlock} or entity {@link EntityInteract} {@link EntityInteractSpecific}.
|
|
|
|
*
|
|
|
|
* Let result be the return value of {@link net.minecraft.item.Item#onItemRightClick}, or {@link #cancellationResult} if the event is cancelled.
|
|
|
|
* If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then continue to other hands.
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
@Cancelable
|
|
|
|
public static class RightClickItem extends PlayerInteractEvent
|
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
public RightClickItem(PlayerEntity player, Hand hand)
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
2020-10-29 00:11:57 +00:00
|
|
|
super(player, hand, player.getPosition(), null);
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event is fired on the client side when the player right clicks empty space with an empty hand.
|
|
|
|
* The server is not aware of when the client right clicks empty space with an empty hand, you will need to tell the server yourself.
|
|
|
|
* This event cannot be canceled.
|
|
|
|
*/
|
|
|
|
public static class RightClickEmpty extends PlayerInteractEvent
|
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
public RightClickEmpty(PlayerEntity player, Hand hand)
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
2020-10-29 00:11:57 +00:00
|
|
|
super(player, hand, player.getPosition(), null);
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event is fired when a player left clicks while targeting a block.
|
|
|
|
* This event controls which of {@link net.minecraft.block.Block#onBlockClicked} and/or the item harvesting methods will be called
|
|
|
|
* Canceling the event will cause none of the above noted methods to be called.
|
|
|
|
* There are various results to this event, see the getters below.
|
2016-06-04 01:52:01 +00:00
|
|
|
*
|
2016-04-05 00:58:46 +00:00
|
|
|
* Note that if the event is canceled and the player holds down left mouse, the event will continue to fire.
|
|
|
|
* This is due to how vanilla calls the left click handler methods.
|
2016-06-04 01:52:01 +00:00
|
|
|
*
|
|
|
|
* Also note that creative mode directly breaks the block without running any other logic.
|
|
|
|
* Therefore, in creative mode, {@link #setUseBlock} and {@link #setUseItem} have no effect.
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
2018-09-20 20:11:02 +00:00
|
|
|
@Cancelable
|
2016-04-05 00:58:46 +00:00
|
|
|
public static class LeftClickBlock extends PlayerInteractEvent
|
|
|
|
{
|
|
|
|
private Result useBlock = DEFAULT;
|
|
|
|
private Result useItem = DEFAULT;
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public LeftClickBlock(PlayerEntity player, BlockPos pos, Direction face)
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
super(player, Hand.MAIN_HAND, pos, face);
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-04 01:52:01 +00:00
|
|
|
* @return If {@link net.minecraft.block.Block#onBlockClicked} should be called. Changing this has no effect in creative mode
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
public Result getUseBlock()
|
|
|
|
{
|
|
|
|
return useBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-06-04 01:52:01 +00:00
|
|
|
* @return If the block should be attempted to be mined with the current item. Changing this has no effect in creative mode
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
|
|
|
public Result getUseItem()
|
|
|
|
{
|
|
|
|
return useItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUseBlock(Result triggerBlock)
|
|
|
|
{
|
|
|
|
this.useBlock = triggerBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUseItem(Result triggerItem)
|
|
|
|
{
|
|
|
|
this.useItem = triggerItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setCanceled(boolean canceled)
|
|
|
|
{
|
|
|
|
super.setCanceled(canceled);
|
2016-06-04 01:52:01 +00:00
|
|
|
if (canceled)
|
|
|
|
{
|
|
|
|
useBlock = DENY;
|
|
|
|
useItem = DENY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This event is fired on the client side when the player left clicks empty space with any ItemStack.
|
|
|
|
* The server is not aware of when the client left clicks empty space, you will need to tell the server yourself.
|
|
|
|
* This event cannot be canceled.
|
|
|
|
*/
|
|
|
|
public static class LeftClickEmpty extends PlayerInteractEvent
|
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
public LeftClickEmpty(PlayerEntity player)
|
2016-06-04 01:52:01 +00:00
|
|
|
{
|
2020-10-29 00:11:57 +00:00
|
|
|
super(player, Hand.MAIN_HAND, player.getPosition(), null);
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return The hand involved in this interaction. Will never be null.
|
|
|
|
*/
|
2017-01-11 23:17:08 +00:00
|
|
|
@Nonnull
|
2019-05-23 23:02:15 +00:00
|
|
|
public Hand getHand()
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
|
|
|
return hand;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-01-11 23:17:08 +00:00
|
|
|
* @return The itemstack involved in this interaction, {@code ItemStack.EMPTY} if the hand was empty.
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
2016-11-13 22:09:54 +00:00
|
|
|
@Nonnull
|
2016-04-05 00:58:46 +00:00
|
|
|
public ItemStack getItemStack()
|
|
|
|
{
|
2019-12-17 09:50:13 +00:00
|
|
|
return getPlayer().getHeldItem(hand);
|
2016-04-05 00:58:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the interaction was on an entity, will be a BlockPos centered on the entity.
|
|
|
|
* If the interaction was on a block, will be the position of that block.
|
|
|
|
* Otherwise, will be a BlockPos centered on the player.
|
|
|
|
* Will never be null.
|
|
|
|
* @return The position involved in this interaction.
|
|
|
|
*/
|
2017-01-11 23:17:08 +00:00
|
|
|
@Nonnull
|
2016-04-05 00:58:46 +00:00
|
|
|
public BlockPos getPos()
|
|
|
|
{
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return The face involved in this interaction. For all non-block interactions, this will return null.
|
|
|
|
*/
|
|
|
|
@Nullable
|
2019-05-23 23:02:15 +00:00
|
|
|
public Direction getFace()
|
2016-04-05 00:58:46 +00:00
|
|
|
{
|
|
|
|
return face;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Convenience method to get the world of this interaction.
|
|
|
|
*/
|
|
|
|
public World getWorld()
|
|
|
|
{
|
2019-12-17 09:50:13 +00:00
|
|
|
return getPlayer().getEntityWorld();
|
2012-09-27 04:18:18 +00:00
|
|
|
}
|
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
|
|
|
|
2016-04-05 00:58:46 +00:00
|
|
|
/**
|
2019-03-25 18:41:08 +00:00
|
|
|
* @return The effective, i.e. logical, side of this interaction. This will be {@link LogicalSide#CLIENT} on the client thread, and {@link LogicalSide#SERVER} on the server thread.
|
2016-04-05 00:58:46 +00:00
|
|
|
*/
|
2019-03-25 18:41:08 +00:00
|
|
|
public LogicalSide getSide()
|
2012-09-27 04:18:18 +00:00
|
|
|
{
|
2019-03-25 18:41:08 +00:00
|
|
|
return getWorld().isRemote ? LogicalSide.CLIENT : LogicalSide.SERVER;
|
2012-09-27 04:18:18 +00:00
|
|
|
}
|
2016-03-24 08:44:52 +00:00
|
|
|
|
2017-04-07 23:38:56 +00:00
|
|
|
/**
|
|
|
|
* @return The EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant
|
|
|
|
* method of the event. By default, this is {@link EnumActionResult#PASS}, meaning cancelled events will cause
|
|
|
|
* the client to keep trying more interactions until something works.
|
|
|
|
*/
|
2019-05-23 23:02:15 +00:00
|
|
|
public ActionResultType getCancellationResult()
|
2017-04-07 23:38:56 +00:00
|
|
|
{
|
|
|
|
return cancellationResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant
|
|
|
|
* method of the event.
|
|
|
|
* Note that this only has an effect on {@link RightClickBlock}, {@link RightClickItem}, {@link EntityInteract}, and {@link EntityInteractSpecific}.
|
|
|
|
*/
|
2019-05-23 23:02:15 +00:00
|
|
|
public void setCancellationResult(ActionResultType result)
|
2017-04-07 23:38:56 +00:00
|
|
|
{
|
|
|
|
this.cancellationResult = result;
|
|
|
|
}
|
|
|
|
|
2012-09-27 04:18:18 +00:00
|
|
|
}
|