Skip to content

Instantly share code, notes, and snippets.

@kindlich
Created March 25, 2018 19:24
Show Gist options
  • Save kindlich/94591d02bba2e458901ee02165647604 to your computer and use it in GitHub Desktop.
Save kindlich/94591d02bba2e458901ee02165647604 to your computer and use it in GitHub Desktop.
import crafttweaker.event.PlayerDeathDropsEvent;
import crafttweaker.event.PlayerFillBucketEvent;
import crafttweaker.event.PlayerOpenContainerEvent;
import crafttweaker.event.EntityLivingUseItemEvent.Finish;
import crafttweaker.event.EntityLivingFallEvent;
import crafttweaker.world.IBlockPos;
events.onPlayerDeathDrops(function(event as PlayerDeathDropsEvent) {
print("Items:");
for item in event.items {
print("\t\t" ~ item.item.displayName);
}
event.addItem(<minecraft:bedrock> * 64);
});
events.onPlayerFillBucket(function(event as PlayerFillBucketEvent){
val trace = event.rayTraceResult;
if (!isNull(trace)) {
if (trace.isMiss)
print("miss");
else if (trace.isBlock)
print("nope");
else if (trace.isEntity)
print("Success: " ~ trace.entity.displayName);
}
});
events.onPlayerOpenContainer(function(event as PlayerOpenContainerEvent){
print("Items:");
for i, item in event.container {
print("\t\t" ~ (isNull(item) ? "null": item.commandString));
if (!isNull(item) && i != 0)
event.container.setStack(i, item * i);
}
});
events.onEntityLivingUseItemFinish(function(event as Finish) {
val pos = event.player.position;
val test = event.player.lookingDirection.scale(2.0d);
val entity = <entity:minecraft:fireball>.createEntity(event.player.world);
entity.posX = pos.x + test.x;
entity.posY = pos.y + test.y;
entity.posZ = pos.z + test.z;
entity.motionX = test.x;
entity.motionY = test.y;
entity.motionZ = test.z;
event.player.world.spawnEntity(entity);
print("(" ~ test.x ~ " | " ~ test.y ~ " | " ~ test.z ~ ")");
print("Player(" ~ pos.x ~ " | " ~ pos.y ~ " | " ~ pos.z ~ ")");
print("FiBall(" ~ entity.position.x ~ " | " ~ entity.position.y ~ " | " ~ entity.position.z ~ ")");
print(entity.displayName);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment