Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/event/BlockEvent.java
T

312 lines
7.5 KiB
Java
Raw Normal View History

2024-01-21 10:55:40 +03:00
package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Cancelable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import noppes.npcs.api.IBlock;
import noppes.npcs.api.IPos;
import noppes.npcs.api.entity.IEntity;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.event.IBlockEvent;
2024-01-21 22:35:19 +03:00
import noppes.npcs.constants.EnumScriptType;
2024-01-21 10:55:40 +03:00
import noppes.npcs.scripted.NpcAPI;
public class BlockEvent extends CustomNPCsEvent implements IBlockEvent {
public IBlock block;
public BlockEvent(IBlock block){
this.block = block;
}
@Override
public IBlock getBlock() {
return null;
}
/**
* fallenUpon
*/
@Cancelable
public static class EntityFallenUponEvent extends BlockEvent implements IBlockEvent.EntityFallenUponEvent{
public final IEntity entity;
public float distanceFallen;
public EntityFallenUponEvent(IBlock block, Entity entity, float distance){
super(block);
this.distanceFallen = distance;
this.entity = NpcAPI.Instance().getIEntity(entity);
}
@Override
public IEntity getEntity() {
return entity;
}
@Override
public float getDistanceFallen() {
return distanceFallen;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.FALLEN_UPON.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* interact
*/
@Cancelable
public static class InteractEvent extends BlockEvent implements IBlockEvent.InteractEvent{
public final IPlayer player;
public final float hitX, hitY, hitZ;
public final int side;
public InteractEvent(IBlock block, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
super(block);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
this.hitX = hitX;
this.hitY = hitY;
this.hitZ = hitZ;
this.side = side;
}
@Override
public IPlayer getPlayer() {
return player;
}
@Override
public float getHitX() {
return hitX;
}
@Override
public float getHitY() {
return hitY;
}
@Override
public float getHitZ() {
return hitZ;
}
@Override
public int getSide() {
return side;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.INTERACT.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* redstone
*/
public static class RedstoneEvent extends BlockEvent implements IBlockEvent.RedstoneEvent{
public final int prevPower, power;
public RedstoneEvent(IBlock block, int prevPower, int power) {
super(block);
this.power = power;
this.prevPower = prevPower;
}
@Override
public int getPrevPower() {
return prevPower;
}
@Override
public int getPower() {
return power;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.REDSTONE.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* broken
*/
public static class BreakEvent extends BlockEvent implements IBlockEvent.BreakEvent{
public BreakEvent(IBlock block) {
super(block);
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.BROKEN.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* exploded
*/
@Cancelable
public static class ExplodedEvent extends BlockEvent implements IBlockEvent.ExplodedEvent{
public ExplodedEvent(IBlock block) {
super(block);
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.EXPLODED.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* rainFilled
*/
public static class RainFillEvent extends BlockEvent implements IBlockEvent.RainFillEvent{
public RainFillEvent(IBlock block) {
super(block);
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.RAIN_FILLED.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* neighborChanged
*/
public static class NeighborChangedEvent extends BlockEvent implements IBlockEvent.NeighborChangedEvent{
public final IPos changedPos;
public NeighborChangedEvent(IBlock block, IPos changedPos) {
super(block);
this.changedPos = changedPos;
}
@Override
public IPos getChangedPos() {
return changedPos;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.NEIGHBOR_CHANGED.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* init
*/
public static class InitEvent extends BlockEvent implements IBlockEvent.InitEvent{
public InitEvent(IBlock block) {
super(block);
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.INIT.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* tick
*/
public static class UpdateEvent extends BlockEvent implements IBlockEvent.UpdateEvent{
public UpdateEvent(IBlock block) {
super(block);
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.TICK.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* clicked
*/
public static class ClickedEvent extends BlockEvent implements IBlockEvent.ClickedEvent{
public final IPlayer player;
public ClickedEvent(IBlock block, EntityPlayer player) {
super(block);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
}
@Override
public IPlayer getPlayer() {
return player;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.CLICKED.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* harvested
*/
@Cancelable
public static class HarvestedEvent extends BlockEvent implements IBlockEvent.HarvestedEvent{
public final IPlayer player;
public HarvestedEvent(IBlock block, EntityPlayer player) {
super(block);
this.player = (IPlayer) NpcAPI.Instance().getIEntity(player);
}
@Override
public IPlayer getPlayer() {
return player;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.HARVESTED.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* collide
*/
public static class CollidedEvent extends BlockEvent implements IBlockEvent.CollidedEvent{
public final IEntity entity;
public CollidedEvent(IBlock block, Entity entity) {
super(block);
this.entity = NpcAPI.Instance().getIEntity(entity);
}
@Override
public IEntity getEntity() {
return entity;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.COLLIDE.function;
}
2024-01-21 10:55:40 +03:00
}
/**
* timer
*/
public static class TimerEvent extends BlockEvent implements IBlockEvent.TimerEvent{
public final int id;
public TimerEvent(IBlock block, int id) {
super(block);
this.id = id;
}
@Override
public int getId() {
return id;
}
2024-01-21 22:35:19 +03:00
@Override
public String getHookName() {
return EnumScriptType.TIMER.function;
}
2024-01-21 10:55:40 +03:00
}
}