diff options
Diffstat (limited to 'src/main/java/los/numeros/HidersAndDiggers/modules/MainModule.java')
-rw-r--r-- | src/main/java/los/numeros/HidersAndDiggers/modules/MainModule.java | 72 |
1 files changed, 52 insertions, 20 deletions
diff --git a/src/main/java/los/numeros/HidersAndDiggers/modules/MainModule.java b/src/main/java/los/numeros/HidersAndDiggers/modules/MainModule.java index 8c1b2b3..f941fdf 100644 --- a/src/main/java/los/numeros/HidersAndDiggers/modules/MainModule.java +++ b/src/main/java/los/numeros/HidersAndDiggers/modules/MainModule.java @@ -4,9 +4,13 @@ import los.numeros.GameEngine.Module; import los.numeros.utils.GiveItem; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantments; +import net.minecraft.entity.attribute.EntityAttribute; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.attribute.EntityAttributes; 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.network.ServerPlayerEntity; import net.minecraft.world.GameMode; @@ -20,43 +24,67 @@ public class MainModule implements Module { } 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) { - GiveItem.setPlayerSlot(p, "diamond_helmet", GiveItem.ARMOR_HEAD); - GiveItem.setPlayerSlot(p, "diamond_leggings", GiveItem.ARMOR_LEGS); - GiveItem.setPlayerSlot(p, "diamond_chestplate", GiveItem.ARMOR_CHEST); - GiveItem.setPlayerSlot(p, "diamond_boots", GiveItem.ARMOR_BOOTS); - GiveItem.setPlayerSlot(p, "iron_sword", 0); - ItemStack pickaxe = GiveItem.givePlayerSpecialItem(p, "diamond_pickaxe"); - pickaxe.addEnchantment(Enchantments.EFFICIENCY, 3); - pickaxe.addEnchantment(Enchantments.UNBREAKING, 255); // TODO: add item attribute unbreakable + // 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[] hidders) { - for (ServerPlayerEntity p : hidders) { - ItemStack pickaxe = GiveItem.givePlayerSpecialItem(p, "diamond_pickaxe"); - pickaxe.addEnchantment(Enchantments.SILK_TOUCH, 1); - pickaxe.addEnchantment(Enchantments.UNBREAKING, 255); // TODO: add item attribute unbreakable + 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); - GiveItem.setPlayerSlot(p, "minecraft:stone", 1); + + // give stone x10 + GiveItem.giveMultipleItem(p, "minecraft:stone", null, 10); } } @Override public int init() { - giveHidersItems(hidders); - giveDiggerItems(diggers); + // 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.REGENERATION, 300, 100, false, false)); // TODO: Rplace with jsut setting health/hunger p.addStatusEffect(new StatusEffectInstance(StatusEffects.SATURATION, 300, 100, false, false)); - // TODO: add haste - // TODO: add beef x64 + p.heal(20); + + // give steak x64 + GiveItem.giveMultipleItem(p, "cooked_beef", 2, 64); + p.setGameMode(GameMode.SURVIVAL); } + giveDiggerItems(diggers); + giveHidersItems(hidders); // TODO: FILL AND TP PLAYERS AND CLEAR ALL ITEMS return 0; } @@ -64,7 +92,11 @@ public class MainModule implements Module { @Override public int end() { - + for (ServerPlayerEntity p : players) { + p.clearStatusEffects(); + p.setGameMode(GameMode.CREATIVE); + p.inventory.clear(); + } return 0; } }
\ No newline at end of file |