Jelajahi Sumber

new loom script

mloeschenkohl 2 tahun lalu
induk
melakukan
1adf1413b2
3 mengubah file dengan 129 tambahan dan 0 penghapusan
  1. 1 0
      startscript.txt
  2. 9 0
      system/commands.txt
  3. 119 0
      system/loom.txt

+ 1 - 0
startscript.txt

@@ -31,6 +31,7 @@ script.startNamed("QuestsAdmont", "story/admont/core", "utils/u_general", "utils
 script.startNamed("QuestsSchiffbruch", "story/schiffbruch/core", "utils/u_general", "utils/u_quest");
 script.startNamed("Workberries", "system/workberries");
 script.startNamed("Timber", "system/timber", "utils/u_general");
+script.startNamed("Loom", "system/loom");
 script.startNamed("Gamerules", "system/gamerules");
 script.startNamed("Scheduler", "system/scheduler", "utils/u_general");
 

+ 9 - 0
system/commands.txt

@@ -2963,6 +2963,7 @@ if(size != 1) {
 	msg(sender, " - harvest");
 	msg(sender, " - hawkeye");
 	msg(sender, " - herobrine");
+	msg(sender, " - loom");
 	msg(sender, " - mails");
 	msg(sender, " - perms");
 	msg(sender, " - pumpkin");
@@ -3049,6 +3050,13 @@ elseif(arg0 == "herobrine") {
 	}
 	script.startNamed("Herobrine", "system/herobrine", "utils/u_general");
 }
+elseif(arg0 == "loom") {
+	script = script.get("Loom");
+	if(script != null) {
+		script.term(script);
+	}
+	script.startNamed("Loom", "system/loom");
+}
 elseif(arg0 == "perms") {
 	script.start("system/perms", "utils/u_general");
 }
@@ -8020,6 +8028,7 @@ function setCommandHelps() {
 	command.addHelpChild(help, command.newHelpLiteral("harvest"));
 	command.addHelpChild(help, command.newHelpLiteral("hawkeye"));
 	command.addHelpChild(help, command.newHelpLiteral("herobrine"));
+	command.addHelpChild(help, command.newHelpLiteral("loom"));
 	command.addHelpChild(help, command.newHelpLiteral("games"));
 	command.addHelpChild(help, command.newHelpLiteral("mails"));
 	command.addHelpChild(help, command.newHelpLiteral("perms"));

+ 119 - 0
system/loom.txt

@@ -0,0 +1,119 @@
+event.load("player_toss");
+
+wool_tag = item.getTag("minecraft:wool");
+par = particle.get("minecraft:witch");
+
+counter_map = map.new();
+loom_list = list.new();
+
+msg("dev", "§bLoom §rloaded.");
+@wait
+wait();
+if(event == "player_toss") {
+	target_loc = player.getTarget(player, 5);
+	block_type = block.getType(target_loc);
+	if(block_type == "minecraft:loom") {
+		if(!item.hasTag(wool_tag, item) && item.getType(item) != "km:coarse_cloth") {
+			goto("wait");
+		}
+		cancel = true;
+		spawn_loc = loc.mod(target_loc, 0.5, 1.5, 0.5);
+		loom_loc = loc.mod(target_loc, 0.5, 1, 0.5);
+		item_entity = item.entity.new(spawn_loc, item);
+		item.entity.spawn(item_entity);
+		loom_id = map.getOrDefault(counter_map, loom_loc, 0) + 1;
+		map.add(counter_map, loom_loc, loom_id);
+		a = array.new(3);
+		a[0] = loom_id;
+		a[1] = player.getUuid(player);
+		a[2] = loom_loc;
+		list.add(loom_list, a);
+		sgoto(40, "loom");
+	}
+}
+goto("wait");
+
+@loom
+a = list.getIndex(loom_list, 0);
+list.removeIndex(loom_list, 0);
+loom_id = a[0];
+player_uuid = a[1];
+loom_loc = a[2];
+player = player.get(player_uuid);
+if(player == null) {
+	goto("wait");
+}
+loc_loom_id = map.get(counter_map, loom_loc);
+if(loc_loom_id != loom_id) {
+	goto("wait");
+}
+wool_amount = 0;
+wool_item = null;
+wool_item_entity = null;
+coarse_amount = 0;
+coarse_item = null;
+coarse_item_entity = null;
+list = entity.near(loom_loc, 0.05);
+iter = iterator(list);
+while(hasNext(iter)) {
+	item_entity = next(iter);
+	item = item.entity.get(item_entity);
+	type = item.getType(item);
+	amount = item.getAmount(item);
+	if(item.hasTag(wool_tag, item)) {
+		wool_amount = amount;
+		wool_item = item;
+		wool_item_entity = item_entity;
+		continue;
+	}
+	if(type == "km:coarse_cloth") {
+		coarse_amount = amount;
+		coarse_item = item;
+		coarse_item_entity = item_entity;
+		continue;
+	}
+}
+if(wool_amount == 0) {
+	goto("wait");
+}
+if(coarse_amount == 0) {
+	//only wool to coarse
+	amount = item.getAmount(wool_item);
+	output_item = read.item("km:coarse_cloth");
+	item.setAmount(output_item, amount);
+	item.entity.set(wool_item_entity, output_item);
+	entity.throw(wool_item_entity, 0, 0.3, 0);
+	particle.spawn(loc.mod(loom_loc, 0.5, 1.4, 0.5), par, 20, 0, 0.25, 0.25, 0.25);
+	loomEvent(player, loom_loc, wool_item_entity);
+	goto("wait");
+}
+//wool and coarse to cloth
+if(coarse_amount > wool_amount) {
+	amount = wool_amount;
+	wool_amount = 0;
+	coarse_amount -= amount;
+} else {
+	amount = coarse_amount;
+	coarse_amount = 0;
+	wool_amount -= amount;
+}
+item.setAmount(coarse_item, coarse_amount);
+item.setAmount(wool_item, wool_amount);
+item.entity.set(coarse_item_entity, coarse_item);
+item.entity.set(wool_item_entity, wool_item);
+
+output_item = read.item("km:cloth");
+item.setAmount(output_item, amount);
+output_item_entity = item.entity.new(loom_loc, output_item);
+item.entity.spawn(output_item_entity);
+entity.throw(output_item_entity, 0, 0.2, 0);
+particle.spawn(loc.mod(loom_loc, 0.5, 1.4, 0.5), par, 20, 0, 0.25, 0.25, 0.25);
+loomEvent(player, loom_loc, output_item_entity);
+goto("wait");
+
+function loomEvent(player, loom_loc, entity) {
+	setScriptVar("player", player);
+	setScriptVar("loom_loc", loom_loc);
+	setScriptVar("entity", entity);
+	script.callEvent("player_loom_finish");
+}