Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import crafttweaker.event.PlayerInteractEvent;
- import crafttweaker.event.PlayerInteractBlockEvent;
- import crafttweaker.event.PlayerInteractEntityEvent;
- import crafttweaker.event.PlayerUseHoeEvent;
- import crafttweaker.entity.IEntityLiving;
- import crafttweaker.entity.IEntityEquipmentSlot as slots;
- import crafttweaker.server.IServer;
- import crafttweaker.block.IBlock;
- import crafttweaker.block.IBlockState;
- import crafttweaker.entity.IEntity;
- import crafttweaker.world.IFacing;
- import crafttweaker.command.ICommandSender;
- import mods.ctutils.utils.Math;
- import crafttweaker.entity.IEntityLivingBase;
- import crafttweaker.world.IBlockPos;
- import mods.contenttweaker.BlockState;
- import crafttweaker.world.IVector3d;
- import mods.contenttweaker.Commands;
- import scripts.player_interact_statics as stats;
- events.onPlayerInteract(function(event as PlayerInteractEvent)
- {
- if (event.player.world.isRemote() || isNull(event.player.currentItem)) { return; }
- print("PlayerInteractEvent fired");
- if (event.player.currentItem.definition.id == <minecraft:fire_charge>.definition.id)// &&
- {
- if (event.block.definition.id == <block:minecraft:air>.getBlock().definition.id || ((event.x == (event.player as IEntity).position.x) &&
- (event.y == Math.floor(event.player.y)) &&
- (event.z == (event.player as IEntity).position.z)))
- {
- val direction as IVector3d = event.player.lookingDirection.normalized.scale(0.061);
- var offset as IVector3d = crafttweaker.world.IVector3d.create(direction.x, 0, direction.z);
- offset = offset.normalized;
- val spawnX = event.player.x + offset.x;
- val spawnY = event.player.y + 1.1;
- val spawnZ = event.player.z + offset.z;
- if(event.player.currentItem.amount > 1)
- {
- event.player.setItemToSlot(slots.mainHand(), event.player.currentItem.withAmount(event.player.currentItem.amount - 1));
- }
- else
- {
- event.player.setItemToSlot(slots.mainHand(), null);
- }
- Commands.call("playsound item.firecharge.use player @s ~ ~ ~ 0.2", event.player, event.player.world, false, true);
- Commands.call("summon small_fireball "~(spawnX as string)~" "~(spawnY as string)~" "~(spawnZ as string)~
- " {direction:["~direction.x~","~direction.y~","~direction.z~"],power:["~direction.x~","~direction.y~","~direction.z~"]}", event.player, event.player.world, false, true);
- }
- }
- });
- events.onPlayerInteractEntity(function(event as PlayerInteractEntityEvent)
- {
- if ((!isNull(event.player.currentItem)) && (event.player.currentItem.definition.id == <minecraft:flint_and_steel>.definition.id) && (event.target instanceof IEntityLiving))
- {
- print("flint and steel PlayerInteractEntityEvent fired");
- event.target.setFire(6);
- if (event.player.world.isRemote()) { return; }
- Commands.call("playsound item.flintandsteel.use player @s ~ ~ ~ 0.2", event.player, event.player.world, false, true);
- stats.damageTool(event);
- }
- });
- events.onPlayerUseHoe(function(event as PlayerUseHoeEvent)
- {
- if (event.world.isRemote() || isNull(event.block.definition)) { return; }
- print("PlayerUseHoeEvent fired");
- if (stats.hoeMatchState has event.block.definition)
- {
- var newState = stats.hoeMatchState[event.block.definition];
- for name in event.blockState.getPropertyNames()
- {
- newState = newState.withProperty(name, event.blockState.getPropertyValue(name));
- }
- Commands.call("playsound item.hoe.till player @s ~ ~ ~ 0.15", event.player, event.player.world, false, true);
- stats.damageTool(event);
- event.world.setBlockState(newState, event.position);
- }
- else if (<minecraft:farmland>.asBlock().definition.id == event.block.definition.id)
- {
- Commands.call("playsound item.hoe.till player @s ~ ~ ~ 0.15", event.player, event.player.world, false, true);
- stats.damageTool(event);
- event.world.setBlockState(<blockstate:minecraft:dirt>, event.position);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment