From 4a4db471dac2435ad40f9fc3c5b6739362bc6eef Mon Sep 17 00:00:00 2001 From: Frog-That-code Date: Sat, 8 Jun 2024 18:45:20 -0400 Subject: begins the code for EPHS --- .../java/los/numeros/EPHS/modules/MainModule.java | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/main/java/los/numeros/EPHS/modules/MainModule.java (limited to 'src/main/java/los/numeros/EPHS/modules/MainModule.java') diff --git a/src/main/java/los/numeros/EPHS/modules/MainModule.java b/src/main/java/los/numeros/EPHS/modules/MainModule.java new file mode 100644 index 0000000..ea7a923 --- /dev/null +++ b/src/main/java/los/numeros/EPHS/modules/MainModule.java @@ -0,0 +1,105 @@ +package los.numeros.EPHS.modules; + +import los.numeros.GameEngine.Module; +import los.numeros.utils.GiveItem; +import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.entity.effect.StatusEffects; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.world.GameMode; +import los.numeros.EPHS.Constants; + +public class MainModule implements Module { + ServerPlayerEntity[] diggers, hidders, players; + ServerCommandSource source; + + public MainModule(ServerPlayerEntity[] diggers, ServerPlayerEntity[] hidders, ServerPlayerEntity[] players, ServerCommandSource source) { + this.diggers = diggers; + this.hidders = hidders; + this.players = players; + this.source = source; + } + + public void giveSeekerItems(ServerPlayerEntity[] diggers) { + for (ServerPlayerEntity p : diggers) { + // give armor + GiveItem.givePlayerItem(p, "diamond_helmet", GiveItem.ARMOR_HEAD); + GiveItem.givePlayerItem(p, "diamond_leggings", GiveItem.ARMOR_LEGS); + GiveItem.givePlayerItem(p, "diamond_chestplate", GiveItem.ARMOR_CHEST); + GiveItem.givePlayerItem(p, "diamond_boots", GiveItem.ARMOR_BOOTS); + + ItemStack sword = GiveItem.getItem("iron_sword"); + sword.addEnchantment(Enchantments.SHARPNESS, 1); + + // make sword unbreakable + NbtCompound sTag = sword.getTag(); + sTag.putBoolean("Unbreakable", true); + sword.setTag(sTag); + p.equip(0, sword); + + // teleport to the seeker box + p.teleport(Constants.seekerSpawnX, Constants.seekerSpawnY, Constants.seekerSpawnZ); + } + } + + public void giveHidersItems(ServerPlayerEntity[] hiders) { + // get pick with silk touch + ItemStack pickaxe = GiveItem.getItem("diamond_pickaxe"); + pickaxe.addEnchantment(Enchantments.SILK_TOUCH, 1); + + // put unbreakable attribute into NBT tag + NbtCompound pTag = pickaxe.getTag(); + pTag.putBoolean("Unbreakable", true); + pickaxe.setTag(pTag); + + for (ServerPlayerEntity p : hiders) { + // equip picaxe on each player + p.equip(0, pickaxe); + // give stone x10 + GiveItem.giveMultipleItem(p, "minecraft:stone", null, 10); + p.teleport(Constants.hidersSpawnX, Constants.hidersSpawnY, Constants.hidersSpawnZ); + } + } + + @Override + public int init() + { + // Give items and status effects to everyone playing game + for (ServerPlayerEntity p : players) { + // Put everyone to full health and hunger and give them night vision on haste until game ends + p.inventory.clear(); + p.addStatusEffect(new StatusEffectInstance(StatusEffects.NIGHT_VISION, 200000000, 3, false, false)); + p.addStatusEffect(new StatusEffectInstance(StatusEffects.HASTE, 200000000, 1, false, false)); + p.addStatusEffect(new StatusEffectInstance(StatusEffects.SATURATION, 300, 100, false, false)); + p.heal(20); + + // give steak x64 + GiveItem.giveMultipleItem(p, "cooked_beef", 2, 64); + + p.setGameMode(GameMode.SURVIVAL); + } + giveSeekerItems(diggers); + giveHidersItems(hidders); + + ServerWorld world = source.getWorld(); + + // TODO: FILL AND TP PLAYERS AND CLEAR ALL ITEMS + return 0; + } + + @Override + public int end() + { + for (ServerPlayerEntity p : players) { + p.teleport(Constants.spawnX, Constants.spawnY, Constants.spawnZ); + p.clearStatusEffects(); + p.setGameMode(GameMode.CREATIVE); + p.inventory.clear(); + } + return 0; + } +} \ No newline at end of file -- cgit v1.2.1