Created
February 16, 2020 18:33
-
-
Save supersaiyansubtlety/743355ce8631150ff3b2630089a1c625 to your computer and use it in GitHub Desktop.
Detects when a player interacts with air, regardless of what block they're standing on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crafttweaker.event.PlayerInteractEvent; | |
import crafttweaker.event.PlayerInteractBlockEvent; | |
import crafttweaker.event.PlayerInteractEntityEvent; | |
import crafttweaker.event.EntityLivingUseItemEvent.Start; | |
import crafttweaker.entity.IEntityLiving; | |
import crafttweaker.entity.IEntityEquipmentSlot as slots; | |
import crafttweaker.server.IServer; | |
import crafttweaker.block.IBlock; | |
import crafttweaker.entity.IEntity; | |
import crafttweaker.world.IFacing; | |
/* import crafttweaker.command.ICommand; */ | |
import crafttweaker.command.ICommandSender; | |
import mods.ctutils.utils.Math; | |
import crafttweaker.event.PlayerUseHoeEvent; | |
import crafttweaker.entity.IEntityLivingBase; | |
import crafttweaker.world.IBlockPos; | |
import mods.contenttweaker.BlockState; | |
import scripts.player_interact_statics as stats; | |
events.onPlayerInteract(function(event as PlayerInteractEvent) | |
{ | |
if (event.player.world.isRemote()) { return; } | |
print("player interact"); | |
/* print("Start is PlayerInteractBlockEvent: "~((event instanceof PlayerInteractBlockEvent) as string)); | |
print("Start is PlayerInteractEntityEvent: "~((event instanceof PlayerInteractEntityEvent) as string)); */ | |
/* print("useBlock: "~event.useBlock); | |
print("useItem: "~event.useItem); */ | |
/* print("item: "~event.item.definition.id); */ | |
print("current item: "~event.player.currentItem.definition.id); | |
print("event block: "~event.block.definition.id); | |
print("player blockPos y-1 block: "~event.player.world.getBlock((event.player as IEntity).position.getOffset(IFacing.down(), 1)).definition.id); | |
print("event pos: "~event.x~", "~event.y~", "~event.z); | |
print("player pos: "~(event.player as IEntity).position.x~", "~(event.player as IEntity).position.y~", "~(event.player as IEntity).position.z); | |
/* print("event pos block: "~event.player.world.getBlock(event.position).definition.id); */ | |
/* print("event.block == event.world.getBlock y-1 ?: "~((([event.block] as IBlock []) has event.world.getBlock((event.player as IEntity).position.getOffset(IFacing.down(), 1))) as string)); */ | |
if (event.player.currentItem.definition.id == <minecraft:fire_charge>.definition.id)// && | |
{ | |
print("fire charge used!"); | |
if (event.block.definition.id == <block:minecraft:air>.getBlock().definition.id)// || | |
{ | |
print("fire charge used on air"); | |
server.commandManager.executeCommand(event.player, "summon small_fireball "~(event.player.x as string)~" "~(event.player.y+3 as string)~" "~(event.player.z as string)~" {direction:[0.0,0.0,0.0],power:[0.1,0.0, 0.0]}"); | |
} | |
else | |
{ | |
print("fire charge not used on air"); | |
/* if (([event.position] as IBlockPos []) has (event.player as IEntity).position) */ | |
if((event.x == (event.player as IEntity).position.x) && | |
(event.y == Math.floor(event.player.y)) && | |
(event.z == (event.player as IEntity).position.z)) | |
{ | |
print("fire charge used and pos's match"); | |
server.commandManager.executeCommand(event.player, "summon small_fireball "~(event.player.x as string)~" "~(event.player.y+3 as string)~" "~(event.player.z as string)~" {direction:[0.0,0.0,0.0],power:[0.1,0.0, 0.0]}"); | |
} | |
} | |
} | |
}); | |
/* val direction as | |
eyeHeight | |
heldEquipment | |
rotationYaw | |
rotationPitch | |
lookingDirection */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment