Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Name: events.zs
- #reloadable
- import crafttweaker.data.IData;
- import crafttweaker.block.IBlock;
- import crafttweaker.block.IBlockState;
- import crafttweaker.command.ICommandManager;
- import crafttweaker.entity.AttributeInstance;
- import crafttweaker.entity.IEntity;
- import crafttweaker.entity.IEntityDefinition;
- import crafttweaker.entity.IEntityEquipmentSlot;
- import crafttweaker.event.EntityJoinWorldEvent;
- import crafttweaker.event.IEventCancelable;
- import crafttweaker.event.PlayerInteractBlockEvent;
- import crafttweaker.event.PlayerInteractEvent;
- import crafttweaker.events.IEventManager;
- import crafttweaker.formatting.IFormattedText;
- import crafttweaker.item.IItemStack;
- import crafttweaker.world.IBlockPos;
- import crafttweaker.world.IWorld;
- import crafttweaker.player.IPlayer;
- events.onPlayerInteractBlock(function(event as PlayerInteractBlockEvent){
- if(event.world.remote || event.hand == "OFF_HAND") {
- return; // If it is on the client or the OFF_HAND, do not continue. 1.12.2 forge doesn't seem to be able to differentiate which hand is being fired here, but limiting it to 1 makes sure it doesn't fire multiple times.
- }
- if (event.block.definition.id == "minecraft:stone") {
- var mhItem = event.player.mainHandHeldItem;
- var ohItem = event.player.offHandHeldItem;
- var x as float = event.x as float;
- var y as float = event.y as float;
- var z as float = event.z as float;
- if (!isNull(mhItem) && <minecraft:diamond>.matches(mhItem)) {
- event.player.setItemToSlot(IEntityEquipmentSlot.mainHand(), mhItem.amount == 1 ? null : mhItem.withAmount(mhItem.amount - 1));
- y = y + 1;
- /* val customZombieNBT as IData = {
- ForgeCaps:{
- Health:20.0f,
- ArmorItems:[
- {
- id:"minecraft:iron_boots",
- Count:1,
- Damage:0
- },
- {},
- {},
- {
- id:"minecraft:diamond_helmet",
- Count:1,
- Damage:0
- }
- ],
- HandItems:[
- {},
- {}
- ],
- ArmorDropChances:[
- 0.085f,
- 0.085f,
- 0.085f,
- 0.085f
- ],
- HandDropChances:[
- 0.085f,
- 0.085f
- ],
- Leashed:0,
- LeftHanded:0,
- CanBreakDoors:0
- }
- }; */
- var timeToKill = event.world.getWorldTime() +200;
- var zombie as IEntityLivingBase = <entity:minecraft:zombie>.createEntity(event.entityLivingBase.world);
- zombie.setCustomName("tacoZombie");
- zombie.setItemToSlot(crafttweaker.entity.IEntityEquipmentSlot.head(),<minecraft:diamond_helmet>);
- zombie.setNBT({killTime: timeToKill});
- zombie.setPosition(crafttweaker.util.Position3f.create(x, y, z).asBlockPos());
- event.entityLivingBase.world.spawnEntity(zombie);
- /* event.player.sendMessage(zombie.getItemInSlot(0).string); */
- //server.commandManager.executeCommand(server, "summon minecraft:zombie "~x~" "~y~" "~z);
- event.cancel();
- } else {
- if (!isNull(ohItem) && <minecraft:diamond>.matches(ohItem)) {
- event.player.setItemToSlot(IEntityEquipmentSlot.offhand(), ohItem.amount == 1 ? null : ohItem.withAmount(ohItem.amount - 1));
- y = y + 1;
- server.commandManager.executeCommand(server, "summon minecraft:zombie "~x~" "~y~" "~z);
- event.cancel();
- }
- }
- return;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment