package los.numeros.HidersAndDiggers.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; 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 giveDiggerItems(ServerPlayerEntity[] diggers) { // get pickace with efficiency 3 ItemStack pickaxe = GiveItem.getItem("diamond_pickaxe"); pickaxe.addEnchantment(Enchantments.EFFICIENCY, 3); // put unbreakable attribute into NBT tag NbtCompound pTag = pickaxe.getTag(); pTag.putBoolean("Unbreakable", true); pickaxe.setTag(pTag); 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); GiveItem.givePlayerItem(p, "iron_sword", 0); // equip pick axe and glow diggers p.equip(1, pickaxe); p.addStatusEffect(new StatusEffectInstance(StatusEffects.GLOWING, 200000000, 3, false, false)); } } 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); } } @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); } giveDiggerItems(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.clearStatusEffects(); p.setGameMode(GameMode.CREATIVE); p.inventory.clear(); } return 0; } }