瀏覽代碼

new formatting

Kajetan Johannes Hammerle 5 年之前
父節點
當前提交
053e4f664b
共有 100 個文件被更改,包括 2330 次插入3910 次删除
  1. 8 14
      src/main/java/me/km/ClassLoaderUtils.java
  2. 52 81
      src/main/java/me/km/Client.java
  3. 20 29
      src/main/java/me/km/CommonEvents.java
  4. 16 23
      src/main/java/me/km/KajetansMod.java
  5. 44 70
      src/main/java/me/km/ObjectRegistry.java
  6. 17 38
      src/main/java/me/km/PackageHelper.java
  7. 30 44
      src/main/java/me/km/Server.java
  8. 33 54
      src/main/java/me/km/blockprotections/BlockProtectionBank.java
  9. 36 59
      src/main/java/me/km/blockprotections/BlockProtectionEvents.java
  10. 4 7
      src/main/java/me/km/blockprotections/DummyBlockProtection.java
  11. 3 3
      src/main/java/me/km/blockprotections/IBlockProtection.java
  12. 4 7
      src/main/java/me/km/blocks/BlockBookshelf.java
  13. 17 33
      src/main/java/me/km/blocks/BlockGravelSlab.java
  14. 3 6
      src/main/java/me/km/blocks/BlockHay.java
  15. 4 7
      src/main/java/me/km/blocks/BlockHayBed.java
  16. 14 26
      src/main/java/me/km/blocks/BlockLantern.java
  17. 9 18
      src/main/java/me/km/blocks/BlockModBed.java
  18. 2 4
      src/main/java/me/km/blocks/BlockModSapling.java
  19. 6 10
      src/main/java/me/km/blocks/BlockOre.java
  20. 4 8
      src/main/java/me/km/blocks/BlockResistantTallGrass.java
  21. 10 18
      src/main/java/me/km/blocks/BlockSpikes.java
  22. 64 78
      src/main/java/me/km/blocks/ModBlocks.java
  23. 7 11
      src/main/java/me/km/blocks/ModFlowingFluidBlock.java
  24. 11 14
      src/main/java/me/km/blocks/ModTree.java
  25. 23 48
      src/main/java/me/km/blocks/cookingpot/BlockCookingPot.java
  26. 92 79
      src/main/java/me/km/blocks/cookingpot/CookingPotColorMixer.java
  27. 42 63
      src/main/java/me/km/blocks/cookingpot/TileEntityCookingPot.java
  28. 36 69
      src/main/java/me/km/databank/DataBank.java
  29. 4 7
      src/main/java/me/km/entities/EntityBlackBear.java
  30. 5 8
      src/main/java/me/km/entities/EntityBrownBear.java
  31. 64 112
      src/main/java/me/km/entities/EntityHuman.java
  32. 29 60
      src/main/java/me/km/entities/EntityItemProjectile.java
  33. 14 27
      src/main/java/me/km/entities/EntityNobody.java
  34. 31 59
      src/main/java/me/km/entities/HumanSkinLoader.java
  35. 19 27
      src/main/java/me/km/entities/ModEntities.java
  36. 2 4
      src/main/java/me/km/entities/ModelHuman.java
  37. 5 9
      src/main/java/me/km/entities/RenderBlackBear.java
  38. 5 9
      src/main/java/me/km/entities/RenderBrownBear.java
  39. 33 69
      src/main/java/me/km/entities/RenderHuman.java
  40. 4 7
      src/main/java/me/km/entities/RenderNobody.java
  41. 9 15
      src/main/java/me/km/events/CommandEvent.java
  42. 21 35
      src/main/java/me/km/events/CustomEventCaller.java
  43. 19 30
      src/main/java/me/km/events/PlayerMoveData.java
  44. 65 124
      src/main/java/me/km/inventory/CustomContainer.java
  45. 48 95
      src/main/java/me/km/inventory/InventoryUtils.java
  46. 80 115
      src/main/java/me/km/inventory/ModInventory.java
  47. 9 14
      src/main/java/me/km/inventory/ServerCustomContainer.java
  48. 60 119
      src/main/java/me/km/items/ItemColoredSoup.java
  49. 5 9
      src/main/java/me/km/items/ItemCylinder.java
  50. 5 9
      src/main/java/me/km/items/ItemFood.java
  51. 14 24
      src/main/java/me/km/items/ItemGemStone.java
  52. 5 9
      src/main/java/me/km/items/ItemHat.java
  53. 9 16
      src/main/java/me/km/items/ItemKey.java
  54. 4 7
      src/main/java/me/km/items/ItemNoGlintLingeringPotion.java
  55. 4 7
      src/main/java/me/km/items/ItemNoGlintPotion.java
  56. 4 7
      src/main/java/me/km/items/ItemNoGlintSplashPotion.java
  57. 34 62
      src/main/java/me/km/items/ItemSling.java
  58. 17 27
      src/main/java/me/km/items/ModArmorMaterial.java
  59. 2 4
      src/main/java/me/km/items/ModItemAxe.java
  60. 2 4
      src/main/java/me/km/items/ModItemPickaxe.java
  61. 13 21
      src/main/java/me/km/items/ModItemTier.java
  62. 99 124
      src/main/java/me/km/items/ModItems.java
  63. 12 17
      src/main/java/me/km/items/ModelCylinder.java
  64. 11 16
      src/main/java/me/km/items/ModelHat.java
  65. 16 25
      src/main/java/me/km/networking/CustomInventory.java
  66. 9 22
      src/main/java/me/km/networking/CustomInventoryScreen.java
  67. 12 19
      src/main/java/me/km/networking/FunctionKey.java
  68. 13 35
      src/main/java/me/km/networking/Icon.java
  69. 14 22
      src/main/java/me/km/networking/ItemStackDisplay.java
  70. 47 73
      src/main/java/me/km/networking/ItemStackDisplayGui.java
  71. 12 19
      src/main/java/me/km/networking/KeyManager.java
  72. 39 57
      src/main/java/me/km/networking/ModPacketHandler.java
  73. 15 23
      src/main/java/me/km/networking/PlayerDisplay.java
  74. 51 81
      src/main/java/me/km/networking/PlayerDisplayGui.java
  75. 18 31
      src/main/java/me/km/networking/PlayerHead.java
  76. 10 20
      src/main/java/me/km/networking/PlayerHeadGui.java
  77. 8 13
      src/main/java/me/km/networking/PlayerLeftClickEmpty.java
  78. 18 30
      src/main/java/me/km/networking/StatusDisplay.java
  79. 10 18
      src/main/java/me/km/overrides/ModCapeLayer.java
  80. 37 63
      src/main/java/me/km/overrides/ModEntityPlayerMP.java
  81. 41 84
      src/main/java/me/km/overrides/ModPlayerList.java
  82. 2 4
      src/main/java/me/km/overrides/ModPlayerRenderer.java
  83. 13 28
      src/main/java/me/km/overrides/PlayerCapeLoader.java
  84. 18 35
      src/main/java/me/km/overrides/PlayerScoreboard.java
  85. 8 12
      src/main/java/me/km/permissions/Command.java
  86. 62 105
      src/main/java/me/km/permissions/ModCommandManager.java
  87. 35 63
      src/main/java/me/km/permissions/PermissionManager.java
  88. 10 19
      src/main/java/me/km/playerbank/DummyPlayerBank.java
  89. 6 2
      src/main/java/me/km/playerbank/IPlayerBank.java
  90. 40 82
      src/main/java/me/km/playerbank/PlayerBank.java
  91. 12 22
      src/main/java/me/km/playerbank/PlayerManager.java
  92. 133 232
      src/main/java/me/km/plots/PlotMap.java
  93. 61 106
      src/main/java/me/km/plots/ProtectionEvents.java
  94. 45 73
      src/main/java/me/km/plots/WorldPlotMap.java
  95. 32 59
      src/main/java/me/km/scheduler/AsyncWorker.java
  96. 33 61
      src/main/java/me/km/scheduler/SnuviScheduler.java
  97. 12 20
      src/main/java/me/km/scheduler/SnuviTask.java
  98. 9 17
      src/main/java/me/km/snuviscript/CommandGiveUp.java
  99. 38 78
      src/main/java/me/km/snuviscript/CommandScript.java
  100. 14 28
      src/main/java/me/km/snuviscript/DummyScriptBank.java

+ 8 - 14
src/main/java/me/km/ClassLoaderUtils.java

@@ -6,27 +6,21 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
 
-public class ClassLoaderUtils
-{
-    public static void loadDependencies()
-    {
+public class ClassLoaderUtils {
+    public static void loadDependencies() {
         URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
-        
-        try
-        {
+
+        try {
             Method method = URLClassLoader.class.getDeclaredMethod("addURL", new Class[]{URL.class});
             method.setAccessible(true);
-            method.invoke(sysloader, getURL("mods/libs/SnuviScriptRecoded.jar")); 
+            method.invoke(sysloader, getURL("mods/libs/SnuviScriptRecoded.jar"));
             method.invoke(sysloader, getURL("mods/libs/mysql-connector-java.jar"));
-        }
-        catch(Throwable t)
-        {
+        } catch(Throwable t) {
             t.printStackTrace();
         }
     }
-    
-    private static URL getURL(String s) throws MalformedURLException
-    {
+
+    private static URL getURL(String s) throws MalformedURLException {
         return new File(s).toURI().toURL();
     }
 }

+ 52 - 81
src/main/java/me/km/Client.java

@@ -57,23 +57,20 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
 import net.minecraftforge.eventbus.api.Event;
 
 @OnlyIn(Dist.CLIENT)
-public class Client 
-{   
+public class Client {
     public final static ModelCylinder CYLINDER = new ModelCylinder(1.0f);
     public final static ModelHat STRAW_HAT = new ModelHat(1.0f);
     public static KeyManager keyManager = null;
-    
-    public static void init() 
-    {
+
+    public static void init() {
         MinecraftForge.EVENT_BUS.register(new Client());
         keyManager = new KeyManager();
         MinecraftForge.EVENT_BUS.register(keyManager);
         registerColors();
         ClientReflectionUtils.updatePlayerRenderer();
     }
-    
-    private static void registerColors()
-    {
+
+    private static void registerColors() {
         RenderTypeLookup.setRenderLayer(ModBlocks.lantern, RenderType.getTranslucent());
         RenderTypeLookup.setRenderLayer(ModBlocks.tallGrass, RenderType.getCutout());
         RenderTypeLookup.setRenderLayer(ModBlocks.cherrySapling, RenderType.getCutout());
@@ -84,27 +81,22 @@ public class Client
         RenderTypeLookup.setRenderLayer(ModBlocks.apricotLeaves, RenderType.getCutoutMipped());
         RenderTypeLookup.setRenderLayer(ModBlocks.pearLeaves, RenderType.getCutoutMipped());
         RenderTypeLookup.setRenderLayer(ModBlocks.plumLeaves, RenderType.getCutoutMipped());
-        
+
         BlockColors bColors = Minecraft.getInstance().getBlockColors();
-        bColors.register((state, w, pos, tintIndex) -> 
-        {
-            if(w == null || pos == null)
-            {
+        bColors.register((state, w, pos, tintIndex) -> {
+            if(w == null || pos == null) {
                 return -16777216;
             }
             TileEntityCookingPot tile = (TileEntityCookingPot) w.getTileEntity(pos);
-            if(tile == null) 
-            {
+            if(tile == null) {
                 return -16777216;
             }
             Color c = tile.getColor();
             return -16777216 | c.getRed() << 16 | c.getGreen() << 8 | c.getBlue();
         }, ModBlocks.cookingPotCopper);
 
-        IBlockColor tallGrass = (state, w, pos, tintIndex) ->
-        {
-            if(w != null && pos != null)
-            {
+        IBlockColor tallGrass = (state, w, pos, tintIndex) -> {
+            if(w != null && pos != null) {
                 return BiomeColors.getGrassColor(w, pos);
             }
             return GrassColors.get(0.5D, 1.0D);
@@ -113,69 +105,61 @@ public class Client
 
         ItemColors iColors = Minecraft.getInstance().getItemColors();
         iColors.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ItemColoredSoup.getColor(stack), ModItems.coloredSoup);
-        iColors.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((ItemGemStone) stack.getItem()).getColor(stack), 
+        iColors.register((stack, tintIndex) -> tintIndex > 0 ? -1 : ((ItemGemStone) stack.getItem()).getColor(stack),
                 ModItems.gemStone, ModItems.rawGemStone, ModItems.flawlessGemStone);
-        
+
         iColors.register((stack, tintIndex) -> tallGrass.getColor(
-                ((BlockItem) stack.getItem()).getBlock().getDefaultState(), 
+                ((BlockItem) stack.getItem()).getBlock().getDefaultState(),
                 null, null, tintIndex), ModBlocks.tallGrass);
     }
-    
+
     @SubscribeEvent
-    public void onClientTick(TickEvent.ClientTickEvent e)
-    {
-        if(e.phase == TickEvent.Phase.END)
-        {
+    public void onClientTick(TickEvent.ClientTickEvent e) {
+        if(e.phase == TickEvent.Phase.END) {
             StatusDisplayGui.INSTANCE.tick();
-        }  
+        }
     }
-    
+
     @SubscribeEvent
-    public void onRenderNamePlate(RenderNameplateEvent e)
-    {
+    public void onRenderNamePlate(RenderNameplateEvent e) {
         e.setResult(Event.Result.DENY);
-        
+
         Entity ent = e.getEntity();
         EntityRendererManager erm = Minecraft.getInstance().getRenderManager();
         EntityRenderer renderer = erm.getRenderer(ent);
-        
-        if(ClientReflectionUtils.canRenderName(renderer, ent)) 
-        {
+
+        if(ClientReflectionUtils.canRenderName(renderer, ent)) {
             double d0 = erm.squareDistanceTo(ent);
-            if(!(d0 > 4096.0D))
-            {
+            if(!(d0 > 4096.0D)) {
                 boolean flag = !ent.isDiscrete();
                 MatrixStack mStack = e.getMatrixStack();
                 mStack.push();
                 mStack.translate(0.0, ent.getHeight() + 0.5F, 0.0);
                 mStack.rotate(erm.getCameraOrientation());
                 mStack.scale(-0.025f, -0.025f, 0.025f);
-                
+
                 Matrix4f matrix4f = mStack.getLast().getMatrix();
                 float f1 = Minecraft.getInstance().gameSettings.getTextBackgroundOpacity(0.25F);
                 int j = (int) (f1 * 255.0F) << 24;
-                
+
                 FontRenderer fontrenderer = erm.getFontRenderer();
-                
+
                 ITextComponent text = ent.getCustomName();
-                if(text == null)
-                {
+                if(text == null) {
                     text = ent.getDisplayName();
                 }
                 String s = text.getFormattedText();
                 String[] parts = s.split("\n");
-                
+
                 int packedLight = renderer.getPackedLight(ent, Minecraft.getInstance().getRenderPartialTicks());
-                
+
                 IRenderTypeBuffer buffer = e.getRenderTypeBuffer();
-                
+
                 Vector3f up = new Vector3f(0.0f, 9.0f * 1.15f * 0.025f, 0.0f);
-                for(String line : parts)
-                {
+                for(String line : parts) {
                     float f2 = -0.5f * fontrenderer.getStringWidth(line);
                     fontrenderer.renderString(line, f2, 0.0f, 553648127, false, matrix4f, buffer, flag, j, packedLight);
-                    if(flag)
-                    {
+                    if(flag) {
                         fontrenderer.renderString(line, f2, 0.0f, -1, false, matrix4f, buffer, false, 0, packedLight);
                     }
                     matrix4f.translate(up);
@@ -185,27 +169,22 @@ public class Client
             }
         }
     }
-    
+
     @SubscribeEvent
-    public void onEmptyLeftClick(PlayerInteractEvent.LeftClickEmpty e)
-    {
+    public void onEmptyLeftClick(PlayerInteractEvent.LeftClickEmpty e) {
         ModPacketHandler.sendLeftClickEmpty();
     }
-    
+
     @SubscribeEvent
-    public void onRenderGui(RenderGameOverlayEvent.Pre e)
-    {
-        if(e.getType() == RenderGameOverlayEvent.ElementType.POTION_ICONS)
-        {
+    public void onRenderGui(RenderGameOverlayEvent.Pre e) {
+        if(e.getType() == RenderGameOverlayEvent.ElementType.POTION_ICONS) {
             e.setCanceled(true);
         }
     }
-    
+
     @SubscribeEvent
-    public void onRenderGui(RenderGameOverlayEvent.Post e)
-    {
-        if(e.getType() == RenderGameOverlayEvent.ElementType.EXPERIENCE)
-        {
+    public void onRenderGui(RenderGameOverlayEvent.Post e) {
+        if(e.getType() == RenderGameOverlayEvent.ElementType.EXPERIENCE) {
             PlayerDisplayGui.INSTANCE.paint();
             StatusDisplayGui.INSTANCE.paint();
             PlayerHeadGui.INSTANCE.paint();
@@ -214,12 +193,10 @@ public class Client
     }
 
     @SubscribeEvent
-    public void onRenderGui(GuiScreenEvent.InitGuiEvent e)
-    {
+    public void onRenderGui(GuiScreenEvent.InitGuiEvent e) {
         // workaround until a client side server leave event is back
         Screen gui = e.getGui();
-        if(gui instanceof MainMenuScreen || gui instanceof MultiplayerScreen)
-        {
+        if(gui instanceof MainMenuScreen || gui instanceof MultiplayerScreen) {
             PlayerDisplayGui.INSTANCE.clear();
             StatusDisplayGui.INSTANCE.clear();
             PlayerHeadGui.INSTANCE.clear();
@@ -227,27 +204,21 @@ public class Client
             ItemStackDisplayGui.INSTANCE.setActive(false);
         }
     }
-    
+
     @SubscribeEvent
-    public void showingTooltip(ItemTooltipEvent e) 
-    {
+    public void showingTooltip(ItemTooltipEvent e) {
         ItemStack stack = e.getItemStack();
         Item item = stack.getItem();
-        if(item instanceof ArmorItem)
-        {
+        if(item instanceof ArmorItem) {
             CompoundNBT com = stack.getTag();
-            if(com != null && com.contains("magic"))
-            {
+            if(com != null && com.contains("magic")) {
                 int magic = com.getInt("magic");
-                if(magic != 0)
-                {
+                if(magic != 0) {
                     List<ITextComponent> list = e.getToolTip();
-                    for(int i = 0; i < list.size(); i++)
-                    {
-                        if(list.get(i).getString().contains("+"))
-                        {
+                    for(int i = 0; i < list.size(); i++) {
+                        if(list.get(i).getString().contains("+")) {
                             list.add(i, new StringTextComponent(
-                                    String.format("%s+%d %s", TextFormatting.BLUE, magic, 
+                                    String.format("%s+%d %s", TextFormatting.BLUE, magic,
                                             LanguageMap.getInstance().translateKey("magicarmor"))));
                             break;
                         }
@@ -256,7 +227,7 @@ public class Client
             }
         }
     }
-    
+
     /*@SubscribeEvent
     public void test(net.minecraftforge.client.event.ClientChatEvent e)
     {

+ 20 - 29
src/main/java/me/km/CommonEvents.java

@@ -8,46 +8,37 @@ import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
 import net.minecraftforge.event.world.ExplosionEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 
-public class CommonEvents
-{
+public class CommonEvents {
     @SubscribeEvent
-    public void onExplosionDetonation(ExplosionEvent.Detonate e)
-    {
-        if(!e.isCanceled())
-        {
+    public void onExplosionDetonation(ExplosionEvent.Detonate e) {
+        if(!e.isCanceled()) {
             ExplosionUtils.explosion(e.getExplosion(), e.getWorld());
         }
     }
-    
+
     @SubscribeEvent
-    public void getFuelBurnTime(FurnaceFuelBurnTimeEvent e)
-    {
+    public void getFuelBurnTime(FurnaceFuelBurnTimeEvent e) {
         Item item = e.getItemStack().getItem();
-        if(item == ModItems.sling || item == ModBlocks.bookshelfAcacia.asItem() || 
-                item == ModBlocks.bookshelfBirch.asItem() || 
-                item == ModBlocks.bookshelfDarkOak.asItem() || 
-                item == ModBlocks.bookshelfJungle.asItem() || 
-                item == ModBlocks.bookshelfSpruce.asItem())
-        {
+        if(item == ModItems.sling || item == ModBlocks.bookshelfAcacia.asItem()
+                || item == ModBlocks.bookshelfBirch.asItem()
+                || item == ModBlocks.bookshelfDarkOak.asItem()
+                || item == ModBlocks.bookshelfJungle.asItem()
+                || item == ModBlocks.bookshelfSpruce.asItem()) {
             e.setBurnTime(300);
-        }
-        else if(item == ModItems.woodenBattleAxe || item == ModItems.woodenDagger || 
-                item == ModItems.woodenHammer || item == ModItems.woodenScepter || 
-                item == ModItems.woodenStick)
-        {
+        } else if(item == ModItems.woodenBattleAxe || item == ModItems.woodenDagger
+                || item == ModItems.woodenHammer || item == ModItems.woodenScepter
+                || item == ModItems.woodenStick) {
             e.setBurnTime(200);
-        }
-        else if(item == ModBlocks.crateAcacia.asItem() ||
-                item == ModBlocks.crateBigOak.asItem() ||
-                item == ModBlocks.crateBirch.asItem() ||
-                item == ModBlocks.crateJungle.asItem() ||
-                item == ModBlocks.crateOak.asItem() ||
-                item == ModBlocks.crateSpruce.asItem())
-        {
+        } else if(item == ModBlocks.crateAcacia.asItem()
+                || item == ModBlocks.crateBigOak.asItem()
+                || item == ModBlocks.crateBirch.asItem()
+                || item == ModBlocks.crateJungle.asItem()
+                || item == ModBlocks.crateOak.asItem()
+                || item == ModBlocks.crateSpruce.asItem()) {
             e.setBurnTime(2700);
         }
     }
-    
+
     /*private static final java.util.HashSet<Class> test = new java.util.HashSet<>();
     
     static

+ 16 - 23
src/main/java/me/km/KajetansMod.java

@@ -15,47 +15,40 @@ import net.minecraftforge.fml.event.server.FMLServerStoppedEvent;
 
 @Mod.EventBusSubscriber
 @Mod("km")
-public class KajetansMod
-{    
+public class KajetansMod {
     public static final String MODID = "km";
-    
-    public KajetansMod()
-    {
+
+    public KajetansMod() {
         ClassLoaderUtils.loadDependencies();
-        
+
         IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
         bus.addListener(this::init);
         bus.addListener(this::setupServer);
         bus.addListener(this::clientInit);
         bus.addListener(this::onServerStop);
-        
+
         MinecraftForge.EVENT_BUS.register(this);
     }
-    
-    private void init(FMLCommonSetupEvent e) 
-    {
+
+    private void init(FMLCommonSetupEvent e) {
         DeferredWorkQueue.runLater(() -> ModPacketHandler.init());
         ModWorldGeneration.register();
-        
+
         MinecraftForge.EVENT_BUS.register(new CommonEvents());
     }
-    
-    private void clientInit(FMLClientSetupEvent e)
-    {
+
+    private void clientInit(FMLClientSetupEvent e) {
         Client.init();
     }
-    
-    private void setupServer(FMLDedicatedServerSetupEvent e)
-    {      
+
+    private void setupServer(FMLDedicatedServerSetupEvent e) {
         Server.onStart(e.getServerSupplier().get());
     }
-    
+
     @SubscribeEvent
-    public void onServerStop(FMLServerStoppedEvent e) 
-    {
-        if(e.getServer().isDedicatedServer())
-        {
+    public void onServerStop(FMLServerStoppedEvent e) {
+        if(e.getServer().isDedicatedServer()) {
             Server.onStop();
         }
     }
-}
+}

+ 44 - 70
src/main/java/me/km/ObjectRegistry.java

@@ -25,113 +25,87 @@ import net.minecraftforge.event.RegistryEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 import net.minecraftforge.fml.common.Mod;
 
-@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
-public class ObjectRegistry 
-{
+@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
+public class ObjectRegistry {
     @SubscribeEvent
-    public static void onBlockRegistry(RegistryEvent.Register<Block> e) 
-    {
+    public static void onBlockRegistry(RegistryEvent.Register<Block> e) {
         ModBlocks.initBlocks(e.getRegistry());
     }
-    
+
     @SubscribeEvent
-    public static void onBlockMissing(RegistryEvent.MissingMappings<Block> e) 
-    {
+    public static void onBlockMissing(RegistryEvent.MissingMappings<Block> e) {
         e.getMappings().stream()
-                .forEach((missing) -> 
-                {
+                .forEach((missing) -> {
                     String key = missing.key.toString();
-                    if(key.contains("cauldron"))
-                    {
-                        missing.remap(ModBlocks.cookingPotCopper);   
-                    }
-                    else if(key.contains("campfire"))
-                    {
-                        missing.remap(Blocks.CAMPFIRE);   
-                    }
-                    else if(key.contains("spikes"))
-                    {
-                        missing.remap(ModBlocks.spikesCopper);   
-                    }
-                    else if(key.contains("campfire"))
-                    {
-                        missing.remap(Blocks.CAMPFIRE);   
-                    }
-                    else if(key.contains("barrel"))
-                    {
-                        missing.remap(Blocks.BARREL);   
-                    }
-                    else if(key.contains("poison") || key.contains("honey"))
-                    {
-                        missing.remap(Blocks.WATER);   
-                    }
-                    else
-                    {
-                        missing.remap(Blocks.STONE);   
+                    if(key.contains("cauldron")) {
+                        missing.remap(ModBlocks.cookingPotCopper);
+                    } else if(key.contains("campfire")) {
+                        missing.remap(Blocks.CAMPFIRE);
+                    } else if(key.contains("spikes")) {
+                        missing.remap(ModBlocks.spikesCopper);
+                    } else if(key.contains("campfire")) {
+                        missing.remap(Blocks.CAMPFIRE);
+                    } else if(key.contains("barrel")) {
+                        missing.remap(Blocks.BARREL);
+                    } else if(key.contains("poison") || key.contains("honey")) {
+                        missing.remap(Blocks.WATER);
+                    } else {
+                        missing.remap(Blocks.STONE);
                     }
                 });
     }
-    
+
     @SubscribeEvent
-    public static void onItemMissing(RegistryEvent.MissingMappings<Item> e) 
-    {
+    public static void onItemMissing(RegistryEvent.MissingMappings<Item> e) {
         e.getMappings().stream()
-                .forEach((missing) -> 
-                {
-                    missing.remap(Items.APPLE);   
+                .forEach((missing) -> {
+                    missing.remap(Items.APPLE);
                 });
     }
 
     @SubscribeEvent
-    public static void onItemRegistry(RegistryEvent.Register<Item> e) 
-    {
+    public static void onItemRegistry(RegistryEvent.Register<Item> e) {
         ModItems.init(e.getRegistry());
         ModBlocks.initItemBlocks(e.getRegistry());
     }
-    
+
     @SubscribeEvent
-    public static void onEntityTypeRegistry(RegistryEvent.Register<EntityType<?>> e) 
-    {
+    public static void onEntityTypeRegistry(RegistryEvent.Register<EntityType<?>> e) {
         ModEntities.init(e.getRegistry());
     }
-    
+
     @SubscribeEvent
-    public static void onTileEntityTypeRegistry(RegistryEvent.Register<TileEntityType<?>> e) 
-    {
+    public static void onTileEntityTypeRegistry(RegistryEvent.Register<TileEntityType<?>> e) {
         e.getRegistry().register(TileEntityCookingPot.COOKING_POT);
     }
-    
+
     @SubscribeEvent
-    public static void onModDimensionRegistry(RegistryEvent.Register<ModDimension> e) 
-    {
+    public static void onModDimensionRegistry(RegistryEvent.Register<ModDimension> e) {
         e.getRegistry().register(WorldManager.MOD_DIMENSION);
     }
-    
+
     public static BiomeProviderType<OverworldBiomeProviderSettings, ModBiomeProvider> DESERT_BIOME_PROVIDER;
     public static BiomeProviderType<OverworldBiomeProviderSettings, ModBiomeProvider> SNOW_BIOME_PROVIDER;
-    
-    private static BiomeProviderType createBiomeProviderType(Set<Biome> biomes, String name)
-    {
-        BiomeProviderType provider = ReflectionUtils.newBiomeProviderType((OverworldBiomeProviderSettings settings) -> 
-        {
+
+    private static BiomeProviderType createBiomeProviderType(Set<Biome> biomes, String name) {
+        BiomeProviderType provider = ReflectionUtils.newBiomeProviderType((OverworldBiomeProviderSettings settings) -> {
             return new ModBiomeProvider(biomes, settings);
         }, OverworldBiomeProviderSettings::new);
         provider.setRegistryName(new ResourceLocation("km", name));
         return provider;
     }
-    
+
     @SubscribeEvent
-    public static void onBiomeProviderTypeRegistry(RegistryEvent.Register<BiomeProviderType<?, ?>> e) 
-    {
+    public static void onBiomeProviderTypeRegistry(RegistryEvent.Register<BiomeProviderType<?, ?>> e) {
         DESERT_BIOME_PROVIDER = createBiomeProviderType(ImmutableSet.of(
-                    Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.BADLANDS, Biomes.BADLANDS_PLATEAU, 
-                    Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.MODIFIED_BADLANDS_PLATEAU), "desert_layered");
+                Biomes.DESERT, Biomes.DESERT_HILLS, Biomes.BADLANDS, Biomes.BADLANDS_PLATEAU,
+                Biomes.DESERT_LAKES, Biomes.ERODED_BADLANDS, Biomes.MODIFIED_BADLANDS_PLATEAU), "desert_layered");
         SNOW_BIOME_PROVIDER = createBiomeProviderType(ImmutableSet.of(
-                    Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA, 
-                    Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_BEACH, Biomes.SNOWY_TAIGA, 
-                    Biomes.SNOWY_TAIGA_HILLS, Biomes.DEEP_FROZEN_OCEAN, 
-                    Biomes.ICE_SPIKES, Biomes.SNOWY_TAIGA_MOUNTAINS), "snow_layered");
-        
+                Biomes.FROZEN_OCEAN, Biomes.FROZEN_RIVER, Biomes.SNOWY_TUNDRA,
+                Biomes.SNOWY_MOUNTAINS, Biomes.SNOWY_BEACH, Biomes.SNOWY_TAIGA,
+                Biomes.SNOWY_TAIGA_HILLS, Biomes.DEEP_FROZEN_OCEAN,
+                Biomes.ICE_SPIKES, Biomes.SNOWY_TAIGA_MOUNTAINS), "snow_layered");
+
         e.getRegistry().registerAll(DESERT_BIOME_PROVIDER, SNOW_BIOME_PROVIDER);
     }
 }

+ 17 - 38
src/main/java/me/km/PackageHelper.java

@@ -7,75 +7,54 @@ import java.util.ArrayList;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
-public class PackageHelper
-{
-    public static ArrayList<Class> getClasses(String packageName)
-    {
+public class PackageHelper {
+    public static ArrayList<Class> getClasses(String packageName) {
         URL jar = getPath();
-        if(jar != null)
-        {
-            try
-            {
+        if(jar != null) {
+            try {
                 ZipInputStream zip = new ZipInputStream(jar.openStream());
                 ArrayList<Class> classes = new ArrayList<>();
                 String path = packageName.replace(".", "/");
-                while(true)
-                {
+                while(true) {
                     ZipEntry e = zip.getNextEntry();
-                    if(e == null)
-                    {
+                    if(e == null) {
                         break;
                     }
                     String name = e.getName();
-                    if(name.startsWith(path))
-                    {
+                    if(name.startsWith(path)) {
                         name = name.replace("/", ".").substring(0, e.getName().length() - 6);
-                        try
-                        {
+                        try {
                             classes.add(Class.forName(name));
-                        }
-                        catch(ClassNotFoundException ex)
-                        {
+                        } catch(ClassNotFoundException ex) {
                         }
                     }
                 }
                 return classes;
-            }
-            catch(IOException ex)
-            {
+            } catch(IOException ex) {
             }
         }
         return new ArrayList<>();
     }
 
-    private static URL getPath()
-    {
-        try
-        {
+    private static URL getPath() {
+        try {
             String s;
-            try
-            {
+            try {
                 s = KajetansMod.class.getProtectionDomain().getCodeSource().getLocation().getPath();
                 s = s.substring(5, s.length() - 25);
-            }
-            catch(Exception ex)
-            {
+            } catch(Exception ex) {
                 s = "../build/libs/km-1.0.jar";
             }
 
             File f = new File(s);
-            if(!f.exists())
-            {
-                for(int i = 0; i < 20; i++)
-                {
+            if(!f.exists()) {
+                for(int i = 0; i < 20; i++) {
                     System.out.println(f + " does not exist");
                 }
             }
 
             return new URL("file:" + s);
-        }
-        catch(Exception ex)
-        {
+        } catch(Exception ex) {
             ex.printStackTrace();
         }
         return null;

+ 30 - 44
src/main/java/me/km/Server.java

@@ -36,8 +36,7 @@ import me.km.snuviscript.Scripts;
 import me.km.world.WorldEvents;
 
 @OnlyIn(Dist.DEDICATED_SERVER)
-public class Server
-{
+public class Server {
     private static SnuviLogger logger;
     private static ModCommandManager commands;
     private static DedicatedServer server;
@@ -46,116 +45,103 @@ public class Server
     private static Scripts scripts;
     public static ScriptEvents scriptEvents;
     private static WorldPlotMap plotMap;
-    
-    public static void onStart(DedicatedServer serverIn)
-    {
+
+    public static void onStart(DedicatedServer serverIn) {
         server = serverIn;
         logger = new SnuviLogger();
-        
+
         SnuviConfig conf = new SnuviConfig(logger, "", "config");
-        if(conf.exists())
-        {
+        if(conf.exists()) {
             conf.load();
         }
-        
+
         boolean debug = conf.getBoolean("debug", false);
-        
+
         // permissions
         PermissionManager perms = new PermissionManager(debug);
         logger.setPlayerLoggingData(server, perms);
-        if(debug)
-        {
+        if(debug) {
             logger.print("------------------------------------------------");
             logger.print("Starting server in debug mode");
             logger.print("------------------------------------------------");
         }
-        
+
         // scheduler
         scheduler = new SnuviScheduler(logger);
-        
+
         // mod player list hook
-        Hooks.setPlayerListFunction(ds -> 
-        {
+        Hooks.setPlayerListFunction(ds -> {
             ds.setPlayerList(new ModPlayerList(ds));
         });
-        
+
         // scripts
         scripts = new Scripts(logger, scheduler);
         scriptEvents = new ScriptEvents(scripts, server, perms);
         MinecraftForge.EVENT_BUS.register(scriptEvents);
-        
+
         // command manager
         commands = new ModCommandManager(true, perms, scriptEvents, scripts, scheduler);
         ReflectionUtils.setCommandManager(server, commands);
         commands.registerCommand(new CommandGiveUp(scripts));
-        commands.registerCommand(new CommandScript(scripts, server));  
-        
+        commands.registerCommand(new CommandScript(scripts, server));
+
         // data base connection
         databank = new DataBank(logger, conf.getString("user", "root"), conf.getString("password", ""));
-        if(!databank.openDataBankConnection())
-        {
+        if(!databank.openDataBankConnection()) {
             logger.print("------------------------------------------------");
             logger.print("Starting server with dummy databank");
             logger.print("------------------------------------------------");
         }
         databank.startReconnecting(scheduler);
-        
+
         // protections
         plotMap = new WorldPlotMap();
         scheduler.scheduleTask(() -> plotMap.read(server, logger));
         long time = 20 * 60 * 30; // all 30 minutes
         scheduler.scheduleRepeatingTask(() -> plotMap.save(), time, time);
-                
+
         // block protections / player manager
         IBlockProtection blockProtection;
         IPlayerBank playerBank;
-        if(databank.isDummyDatabank())
-        {
+        if(databank.isDummyDatabank()) {
             blockProtection = new DummyBlockProtection();
             playerBank = new DummyPlayerBank();
-        }
-        else
-        {
+        } else {
             blockProtection = new BlockProtectionBank(databank);
             playerBank = new PlayerBank(databank);
         }
         MinecraftForge.EVENT_BUS.register(new ProtectionEvents(plotMap, perms));
         MinecraftForge.EVENT_BUS.register(new BlockProtectionEvents(blockProtection, perms));
-        
+
         PlayerManager playerManager = new PlayerManager(logger, playerBank);
         MinecraftForge.EVENT_BUS.register(playerManager);
         CustomEventCaller customEventCaller = new CustomEventCaller(server, scheduler);
         scripts.setCustomEventCaller(customEventCaller);
         MinecraftForge.EVENT_BUS.register(customEventCaller);
-        
+
         // scripts
         IScriptBank scriptBank;
-        if(databank.isDummyDatabank())
-        {
+        if(databank.isDummyDatabank()) {
             scriptBank = new DummyScriptBank();
-        }
-        else
-        {
+        } else {
             scriptBank = new ScriptBank(databank, playerManager);
         }
         MinecraftFunctions.registerFunctions(
-                scripts.getScriptManager(), scripts, perms, scheduler, server, playerBank, 
+                scripts.getScriptManager(), scripts, perms, scheduler, server, playerBank,
                 customEventCaller, scriptBank, databank, blockProtection, plotMap, commands);
-        
+
         MinecraftForge.EVENT_BUS.register(new WorldEvents());
         scripts.startScript("startscript");
     }
-    
-    public static void onStop()
-    {
+
+    public static void onStop() {
         scripts.startScript("endscript");
         scheduler.stop();
         scheduler.getWorker().stop();
         databank.closeDataBankConnection();
     }
-    
-    public static ISnuviLogger getLogger()
-    {
+
+    public static ISnuviLogger getLogger() {
         return logger;
     }
 }

+ 33 - 54
src/main/java/me/km/blockprotections/BlockProtectionBank.java

@@ -3,100 +3,79 @@ package me.km.blockprotections;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import me.km.KajetansMod;
 import me.km.databank.DataBank;
 import me.km.overrides.ModEntityPlayerMP;
 import me.km.world.WorldManager;
-import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IWorld;
 
-public class BlockProtectionBank implements IBlockProtection
-{  
+public class BlockProtectionBank implements IBlockProtection {
     private final PreparedStatement hasAccess;
     private final PreparedStatement getId;
-    
-    public BlockProtectionBank(DataBank databank) 
-    {
+
+    public BlockProtectionBank(DataBank databank) {
         databank.execute("CREATE TABLE IF NOT EXISTS block ("
-                    + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, "
-                    + "x int(11) NOT NULL, "
-                    + "y int(11) NOT NULL, "
-                    + "z int(11) NOT NULL, "
-                    + "world_name varchar(20) NOT NULL, "
-                    + "UNIQUE KEY uniq_block_pos (world_name,x,y,z));");
-        
+                + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, "
+                + "x int(11) NOT NULL, "
+                + "y int(11) NOT NULL, "
+                + "z int(11) NOT NULL, "
+                + "world_name varchar(20) NOT NULL, "
+                + "UNIQUE KEY uniq_block_pos (world_name,x,y,z));");
+
         databank.execute("CREATE TABLE IF NOT EXISTS block_grant ("
-                    + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, "
-                    + "block_id int(11) NOT NULL, "
-                    + "player_id int(11) NOT NULL, "
-                    + "INDEX block_id (block_id), "
-                    + "UNIQUE KEY (block_id, player_id), "
-                    + "CONSTRAINT block_grant_ibfk_1 FOREIGN KEY (block_id) REFERENCES block (id) ON DELETE CASCADE);");
-        
+                + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, "
+                + "block_id int(11) NOT NULL, "
+                + "player_id int(11) NOT NULL, "
+                + "INDEX block_id (block_id), "
+                + "UNIQUE KEY (block_id, player_id), "
+                + "CONSTRAINT block_grant_ibfk_1 FOREIGN KEY (block_id) REFERENCES block (id) ON DELETE CASCADE);");
+
         hasAccess = databank.prepareStatement("Select id from block_grant WHERE id = ? AND player_id = ?;");
         getId = databank.prepareStatement("SELECT id FROM block WHERE world_name=? AND x=? AND y=? AND z=?;");
-    }  
+    }
 
     @Override
-    public boolean hasAccess(int x, int y, int z, String worldName, int playerId)
-    {
+    public boolean hasAccess(int x, int y, int z, String worldName, int playerId) {
         int id = getId(x, y, z, worldName);
-        if(id == -1)
-        {
+        if(id == -1) {
             return true;
         }
-        try
-        {
+        try {
             hasAccess.setInt(1, id);
             hasAccess.setInt(2, playerId);
-            try(ResultSet rs = hasAccess.executeQuery())
-            {
+            try(ResultSet rs = hasAccess.executeQuery()) {
                 return rs.next();
-            }
-            catch(SQLException ex)
-            {
+            } catch(SQLException ex) {
                 ex.printStackTrace();
             }
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return false;
     }
-    
+
     @Override
-    public boolean hasAccess(BlockPos pos, IWorld w, ModEntityPlayerMP p)
-    {
+    public boolean hasAccess(BlockPos pos, IWorld w, ModEntityPlayerMP p) {
         return hasAccess(pos.getX(), pos.getY(), pos.getZ(), WorldManager.getName(w), p.getId());
     }
 
-    private int getId(int x, int y, int z, String worldName)
-    {
-        try
-        {
+    private int getId(int x, int y, int z, String worldName) {
+        try {
             getId.setString(1, worldName);
             getId.setInt(2, x);
             getId.setInt(3, y);
             getId.setInt(4, z);
-            try(ResultSet rs = getId.executeQuery())
-            {
-                if(rs.next())
-                {
+            try(ResultSet rs = getId.executeQuery()) {
+                if(rs.next()) {
                     return rs.getInt(1);
                 }
                 return -1;
-            }
-            catch(SQLException ex)
-            {
+            } catch(SQLException ex) {
                 ex.printStackTrace();
             }
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return -1;
     }
-}
+}

+ 36 - 59
src/main/java/me/km/blockprotections/BlockProtectionEvents.java

@@ -18,110 +18,87 @@ import net.minecraftforge.event.world.BlockEvent;
 import net.minecraftforge.eventbus.api.EventPriority;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 
-public class BlockProtectionEvents
-{
+public class BlockProtectionEvents {
     private final static String BLOCK_BYPASS = "block.bypass";
-    
+
     private final IBlockProtection bank;
     private final PermissionManager perms;
-    
-    public BlockProtectionEvents(IBlockProtection bank, PermissionManager perms) 
-    {
+
+    public BlockProtectionEvents(IBlockProtection bank, PermissionManager perms) {
         this.bank = bank;
         this.perms = perms;
     }
-    
-    private BlockPos getSameNearbyBlock(IWorld w, BlockPos pos, Block b)
-    {           
+
+    private BlockPos getSameNearbyBlock(IWorld w, BlockPos pos, Block b) {
         Location l = new Location(w, pos);
-        if(l.getRelativeBlockState(1, 0, 0).getBlock() == b)
-        {
+        if(l.getRelativeBlockState(1, 0, 0).getBlock() == b) {
             return pos.add(1, 0, 0);
-        }
-        else if(l.getRelativeBlockState(-1, 0, 0).getBlock() == b)
-        {
+        } else if(l.getRelativeBlockState(-1, 0, 0).getBlock() == b) {
             return pos.add(-1, 0, 0);
-        }
-        else if(l.getRelativeBlockState(0, 0, 1).getBlock() == b)
-        {
+        } else if(l.getRelativeBlockState(0, 0, 1).getBlock() == b) {
             return pos.add(0, 0, 1);
-        }
-        else if(l.getRelativeBlockState(0, 0, -1).getBlock() == b)
-        {
+        } else if(l.getRelativeBlockState(0, 0, -1).getBlock() == b) {
             return pos.add(0, 0, -1);
         }
         return null;
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onBlockPlace(BlockEvent.EntityPlaceEvent e)
-    {
+    public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
         Block b = e.getPlacedBlock().getBlock();
-        if(!(e.getEntity() instanceof ModEntityPlayerMP))
-        {
+        if(!(e.getEntity() instanceof ModEntityPlayerMP)) {
             return;
         }
         ModEntityPlayerMP p = (ModEntityPlayerMP) e.getEntity();
         IWorld w = e.getWorld();
-        
+
         if(b == Blocks.CHEST || b == Blocks.TRAPPED_CHEST) // Deny placing chests near other protected chests
         {
             BlockPos otherChest = getSameNearbyBlock(w, e.getPos(), b);
-            if(otherChest != null && !bank.hasAccess(otherChest, w, p) && !perms.hasPermission(p, BLOCK_BYPASS))
-            {
+            if(otherChest != null && !bank.hasAccess(otherChest, w, p) && !perms.hasPermission(p, BLOCK_BYPASS)) {
                 e.setCanceled(true);
-            }        
-        } 
-        else if(b == Blocks.HOPPER) // Deny placing of hoppers under blocks
+            }
+        } else if(b == Blocks.HOPPER) // Deny placing of hoppers under blocks
         {
             BlockPos pos = e.getPos().add(0, 1, 0);
-            if(w.getBlockState(pos).getBlock() instanceof ContainerBlock)
-            {
-                if(!bank.hasAccess(pos, w, p) && !perms.hasPermission(p, BLOCK_BYPASS))
-                {
+            if(w.getBlockState(pos).getBlock() instanceof ContainerBlock) {
+                if(!bank.hasAccess(pos, w, p) && !perms.hasPermission(p, BLOCK_BYPASS)) {
                     e.setCanceled(true);
-                }               
-            }            
+                }
+            }
         }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onBlockBreak(BlockEvent.BreakEvent e)
-    {
+    public void onBlockBreak(BlockEvent.BreakEvent e) {
         ModEntityPlayerMP p = (ModEntityPlayerMP) e.getPlayer();
         BlockState state = e.getState();
 
-        BlockPos pos = e.getPos();        
-        if(BlockTags.DOORS.contains(state.getBlock()) && state.get(DoorBlock.HALF) == DoubleBlockHalf.UPPER)
-        {
+        BlockPos pos = e.getPos();
+        if(BlockTags.DOORS.contains(state.getBlock()) && state.get(DoorBlock.HALF) == DoubleBlockHalf.UPPER) {
             pos = pos.add(0, -1, 0);
-        } 
+        }
         IWorld w = e.getWorld();
-        if(bank.hasAccess(pos, w, p) || perms.hasPermission(p, BLOCK_BYPASS))
-        {
+        if(bank.hasAccess(pos, w, p) || perms.hasPermission(p, BLOCK_BYPASS)) {
             // ToDo remove protection
             return;
-        }   
-        e.setCanceled(true);          
+        }
+        e.setCanceled(true);
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onContainerOpen(PlayerInteractEvent.RightClickBlock e)
-    {
-        if(e.getHand() != Hand.MAIN_HAND)
-        {
+    public void onContainerOpen(PlayerInteractEvent.RightClickBlock e) {
+        if(e.getHand() != Hand.MAIN_HAND) {
             return;
         }
         BlockState state = e.getWorld().getBlockState(e.getPos());
         ModEntityPlayerMP p = (ModEntityPlayerMP) e.getPlayer();
         BlockPos pos = e.getPos();
-        if(BlockTags.DOORS.contains(state.getBlock()) && state.get(DoorBlock.HALF) == DoubleBlockHalf.UPPER)
-        {
+        if(BlockTags.DOORS.contains(state.getBlock()) && state.get(DoorBlock.HALF) == DoubleBlockHalf.UPPER) {
             pos = pos.add(0, -1, 0);
         }
-        if(!bank.hasAccess(pos, e.getWorld(), p) && !perms.hasPermission(p, BLOCK_BYPASS))
-        {
-            e.setCanceled(true);   
-        }  
+        if(!bank.hasAccess(pos, e.getWorld(), p) && !perms.hasPermission(p, BLOCK_BYPASS)) {
+            e.setCanceled(true);
+        }
     }
 }

+ 4 - 7
src/main/java/me/km/blockprotections/DummyBlockProtection.java

@@ -4,17 +4,14 @@ import me.km.overrides.ModEntityPlayerMP;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IWorld;
 
-public class DummyBlockProtection implements IBlockProtection
-{
+public class DummyBlockProtection implements IBlockProtection {
     @Override
-    public boolean hasAccess(int x, int y, int z, String worldName, int playerId)
-    {
+    public boolean hasAccess(int x, int y, int z, String worldName, int playerId) {
         return true;
     }
 
     @Override
-    public boolean hasAccess(BlockPos pos, IWorld w, ModEntityPlayerMP p)
-    {
+    public boolean hasAccess(BlockPos pos, IWorld w, ModEntityPlayerMP p) {
         return true;
     }
-}
+}

+ 3 - 3
src/main/java/me/km/blockprotections/IBlockProtection.java

@@ -4,8 +4,8 @@ import me.km.overrides.ModEntityPlayerMP;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IWorld;
 
-public interface IBlockProtection
-{
+public interface IBlockProtection {
     public boolean hasAccess(int x, int y, int z, String worldName, int playerId);
+
     public boolean hasAccess(BlockPos pos, IWorld w, ModEntityPlayerMP p);
-}
+}

+ 4 - 7
src/main/java/me/km/blocks/BlockBookshelf.java

@@ -7,16 +7,13 @@ import net.minecraft.block.material.Material;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IWorldReader;
 
-public class BlockBookshelf extends Block
-{
-    public BlockBookshelf()
-    {
+public class BlockBookshelf extends Block {
+    public BlockBookshelf() {
         super(Block.Properties.create(Material.WOOD).hardnessAndResistance(1.5f).sound(SoundType.WOOD));
     }
 
     @Override
-    public float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos)
-    {
+    public float getEnchantPowerBonus(BlockState state, IWorldReader world, BlockPos pos) {
         return 1;
     }
-}
+}

+ 17 - 33
src/main/java/me/km/blocks/BlockGravelSlab.java

@@ -20,46 +20,36 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 import net.minecraftforge.common.ToolType;
 
-public class BlockGravelSlab extends SlabBlock
-{
-    public BlockGravelSlab(Properties properties)
-    {
+public class BlockGravelSlab extends SlabBlock {
+    public BlockGravelSlab(Properties properties) {
         super(properties);
     }
 
     @Override
-    public ToolType getHarvestTool(BlockState state)
-    {
+    public ToolType getHarvestTool(BlockState state) {
         return ToolType.SHOVEL;
     }
 
     @Override
-    public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving)
-    {
+    public void onBlockAdded(BlockState state, World w, BlockPos pos, BlockState oldState, boolean isMoving) {
         w.getPendingBlockTicks().scheduleTick(pos, this, this.tickRate(w));
     }
-    
+
     @Override
-    public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld w, BlockPos currentPos, BlockPos facingPos)
-    {
+    public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld w, BlockPos currentPos, BlockPos facingPos) {
         w.getPendingBlockTicks().scheduleTick(currentPos, this, this.tickRate(w));
         return super.updatePostPlacement(state, facing, facingState, w, currentPos, facingPos);
     }
 
     @Override
-    public void tick(BlockState state, ServerWorld w, BlockPos pos, Random r)
-    {
-        if(w.isAirBlock(pos.down()) || canFallThrough(w.getBlockState(pos.down())) && pos.getY() >= 0)
-        {
+    public void tick(BlockState state, ServerWorld w, BlockPos pos, Random r) {
+        if(w.isAirBlock(pos.down()) || canFallThrough(w.getBlockState(pos.down())) && pos.getY() >= 0) {
             BlockState fallState;
             double y = pos.getY();
-            if(state == getDefaultState().with(TYPE, SlabType.TOP))    
-            {
+            if(state == getDefaultState().with(TYPE, SlabType.TOP)) {
                 fallState = w.getBlockState(pos).with(TYPE, SlabType.BOTTOM);
                 y += 0.5;
-            }
-            else
-            {
+            } else {
                 fallState = w.getBlockState(pos);
             }
             FallingBlockEntity fallingblockentity = new FallingBlockEntity(w, pos.getX() + 0.5, y, pos.getZ() + 0.5, fallState);
@@ -68,13 +58,11 @@ public class BlockGravelSlab extends SlabBlock
     }
 
     @Override
-    public int tickRate(IWorldReader w)
-    {
+    public int tickRate(IWorldReader w) {
         return 2;
     }
 
-    public static boolean canFallThrough(BlockState state)
-    {
+    public static boolean canFallThrough(BlockState state) {
         Block block = state.getBlock();
         Material material = state.getMaterial();
         return state.isAir() || block == Blocks.FIRE || material.isLiquid() || material.isReplaceable();
@@ -82,13 +70,10 @@ public class BlockGravelSlab extends SlabBlock
 
     @OnlyIn(Dist.CLIENT)
     @Override
-    public void animateTick(BlockState state, World w, BlockPos pos, Random rand)
-    {
-        if(rand.nextInt(16) == 0)
-        {
+    public void animateTick(BlockState state, World w, BlockPos pos, Random rand) {
+        if(rand.nextInt(16) == 0) {
             BlockPos blockpos = pos.down();
-            if(w.isAirBlock(blockpos) || canFallThrough(w.getBlockState(blockpos)))
-            {
+            if(w.isAirBlock(blockpos) || canFallThrough(w.getBlockState(blockpos))) {
                 double x = pos.getX() + rand.nextFloat();
                 double y = pos.getY() - 0.05;
                 double z = pos.getZ() + rand.nextFloat();
@@ -99,8 +84,7 @@ public class BlockGravelSlab extends SlabBlock
     }
 
     @OnlyIn(Dist.CLIENT)
-    public int getDustColor(BlockState state)
-    {
+    public int getDustColor(BlockState state) {
         return -8356741;
     }
-}
+}

+ 3 - 6
src/main/java/me/km/blocks/BlockHay.java

@@ -8,18 +8,15 @@ import net.minecraft.util.Direction;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.World;
 
-public class BlockHay extends RotatedPillarBlock
-{ 
-    public BlockHay(String name) 
-    {
+public class BlockHay extends RotatedPillarBlock {
+    public BlockHay(String name) {
         super(Properties.create(Material.ORGANIC).hardnessAndResistance(0.5f).sound(SoundType.PLANT));
         this.setRegistryName(name);
         this.setDefaultState(this.stateContainer.getBaseState().with(AXIS, Direction.Axis.Y));
     }
 
     @Override
-    public void onFallenUpon(World w, BlockPos pos, Entity ent, float fallDistance)
-    {
+    public void onFallenUpon(World w, BlockPos pos, Entity ent, float fallDistance) {
         ent.onLivingFall(fallDistance, 0.2f);
     }
 }

+ 4 - 7
src/main/java/me/km/blocks/BlockHayBed.java

@@ -9,16 +9,13 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IBlockReader;
 
-public class BlockHayBed extends BlockModBed
-{ 
-    public BlockHayBed(String name) 
-    {
+public class BlockHayBed extends BlockModBed {
+    public BlockHayBed(String name) {
         super(name, Block.Properties.create(Material.ORGANIC).hardnessAndResistance(0.5f).sound(SoundType.PLANT), 2.0);
     }
 
     @Override
-    public ItemStack getItem(IBlockReader w, BlockPos pos, BlockState state)
-    {
+    public ItemStack getItem(IBlockReader w, BlockPos pos, BlockState state) {
         return new ItemStack(ModItems.realHayBed);
     }
-}
+}

+ 14 - 26
src/main/java/me/km/blocks/BlockLantern.java

@@ -21,8 +21,7 @@ import net.minecraft.world.World;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class BlockLantern extends DirectionalBlock
-{
+public class BlockLantern extends DirectionalBlock {
     protected static final VoxelShape HANGING_AABB = Block.makeCuboidShape(3.0, 2.0, 3.0, 13.0, 16.0, 13.0);
     protected static final VoxelShape STANDING_AABB = Block.makeCuboidShape(3.0, 0.0, 3.0, 13.0, 12.0, 13.0);
 
@@ -33,18 +32,15 @@ public class BlockLantern extends DirectionalBlock
 
     protected String name;
 
-    public BlockLantern(String name)
-    {
+    public BlockLantern(String name) {
         super(Properties.create(Material.MISCELLANEOUS).doesNotBlockMovement().hardnessAndResistance(0.0f).lightValue(14).sound(SoundType.METAL));
         this.setRegistryName(name);
         this.setDefaultState(this.stateContainer.getBaseState().with(FACING, Direction.UP));
     }
-    
+
     @Override
-    public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context)
-    {
-        switch(state.get(FACING))
-        {
+    public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) {
+        switch(state.get(FACING)) {
             case UP:
                 return STANDING_AABB;
             case DOWN:
@@ -63,14 +59,12 @@ public class BlockLantern extends DirectionalBlock
 
     @OnlyIn(Dist.CLIENT)
     @Override
-    public void animateTick(BlockState state, World w, BlockPos pos, Random rand)
-    {
+    public void animateTick(BlockState state, World w, BlockPos pos, Random rand) {
         Direction face = state.get(FACING);
         double x = pos.getX() + 0.5;
         double y = pos.getY() + 0.7;
         double z = pos.getZ() + 0.5;
-        switch(face)
-        {
+        switch(face) {
             case EAST:
             case NORTH:
             case WEST:
@@ -90,23 +84,19 @@ public class BlockLantern extends DirectionalBlock
     }
 
     @Override
-    public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos)
-    {
+    public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
         return false;
     }
 
     @Override
-    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
-    {
+    protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
         builder.add(FACING);
     }
 
     @Override
-    public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
-    {
+    public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
         Direction direction = state.get(FACING);
-        if(direction == Direction.UP)
-        {
+        if(direction == Direction.UP) {
             return hasEnoughSolidSide(w, pos.down(), Direction.UP);
         }
         BlockPos blockpos = pos.offset(direction.getOpposite());
@@ -115,14 +105,12 @@ public class BlockLantern extends DirectionalBlock
     }
 
     @Override
-    public BlockState getStateForPlacement(BlockItemUseContext context)
-    {
+    public BlockState getStateForPlacement(BlockItemUseContext context) {
         return this.getDefaultState().with(FACING, context.getFace());
     }
 
     @Override
-    public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld w, BlockPos currentPos, BlockPos facingPos)
-    {
+    public BlockState updatePostPlacement(BlockState state, Direction facing, BlockState facingState, IWorld w, BlockPos currentPos, BlockPos facingPos) {
         return state.get(FACING).getOpposite() == facing && !state.isValidPosition(w, currentPos) ? Blocks.AIR.getDefaultState() : state;
     }
-}
+}

+ 9 - 18
src/main/java/me/km/blocks/BlockModBed.java

@@ -14,12 +14,10 @@ import net.minecraft.util.math.shapes.VoxelShape;
 import net.minecraft.world.IBlockReader;
 import net.minecraft.world.World;
 
-public abstract class BlockModBed extends BedBlock
-{
+public abstract class BlockModBed extends BedBlock {
     private final VoxelShape shape;
 
-    public BlockModBed(String name, Block.Properties builder, double high)
-    {
+    public BlockModBed(String name, Block.Properties builder, double high) {
         super(DyeColor.BLACK, builder);
         super.setRegistryName(name);
         shape = Block.makeCuboidShape(0.0, 0.0, 0.0, 16.0, high, 16.0);
@@ -27,44 +25,37 @@ public abstract class BlockModBed extends BedBlock
     }
 
     @Override
-    public MaterialColor getMaterialColor(BlockState state, IBlockReader w, BlockPos pos) 
-    {
+    public MaterialColor getMaterialColor(BlockState state, IBlockReader w, BlockPos pos) {
         return this.materialColor;
     }
 
     @Override
-    public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving)
-    {
+    public void onReplaced(BlockState state, World worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
         // no tile entity needs to be removed
     }
 
     @Override
-    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
-    {
+    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
         return shape;
     }
 
     @Override
-    public BlockRenderType getRenderType(BlockState state)
-    {
+    public BlockRenderType getRenderType(BlockState state) {
         return BlockRenderType.MODEL;
     }
 
     @Override
-    public TileEntity createNewTileEntity(IBlockReader worldIn)
-    {
+    public TileEntity createNewTileEntity(IBlockReader worldIn) {
         return null;
     }
 
     @Override
-    public boolean hasTileEntity(BlockState state)
-    {
+    public boolean hasTileEntity(BlockState state) {
         return false;
     }
 
     @Override
-    public boolean hasTileEntity()
-    {
+    public boolean hasTileEntity() {
         return false;
     }
 }

+ 2 - 4
src/main/java/me/km/blocks/BlockModSapling.java

@@ -7,10 +7,8 @@ import net.minecraft.block.material.Material;
 import net.minecraft.block.trees.Tree;
 
 // this class just exists because the SaplingBlock constructor is protected
-public class BlockModSapling extends SaplingBlock
-{
-    public BlockModSapling(Tree tree)
-    {
+public class BlockModSapling extends SaplingBlock {
+    public BlockModSapling(Tree tree) {
         super(tree, Block.Properties.create(Material.PLANTS).doesNotBlockMovement()
                 .tickRandomly().hardnessAndResistance(0.0f, 0.0f).sound(SoundType.PLANT));
     }

+ 6 - 10
src/main/java/me/km/blocks/BlockOre.java

@@ -4,25 +4,21 @@ import net.minecraft.block.Block;
 import net.minecraft.block.BlockState;
 import net.minecraftforge.common.ToolType;
 
-public class BlockOre extends Block
-{
+public class BlockOre extends Block {
     private final int harvestLevel;
-    
-    public BlockOre(Properties properties, int harvestLevel)
-    {
+
+    public BlockOre(Properties properties, int harvestLevel) {
         super(properties);
         this.harvestLevel = harvestLevel;
     }
 
     @Override
-    public int getHarvestLevel(BlockState state)
-    {
+    public int getHarvestLevel(BlockState state) {
         return harvestLevel;
     }
 
     @Override
-    public ToolType getHarvestTool(BlockState state)
-    {
+    public ToolType getHarvestTool(BlockState state) {
         return ToolType.PICKAXE;
     }
-}
+}

+ 4 - 8
src/main/java/me/km/blocks/BlockResistantTallGrass.java

@@ -9,24 +9,20 @@ import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IBlockReader;
 import net.minecraft.world.IWorldReader;
 
-public class BlockResistantTallGrass extends TallGrassBlock
-{
-    public BlockResistantTallGrass(String registry)
-    {
+public class BlockResistantTallGrass extends TallGrassBlock {
+    public BlockResistantTallGrass(String registry) {
         super(Block.Properties.create(Material.TALL_PLANTS).doesNotBlockMovement()
                 .hardnessAndResistance(0.0f, 0.0f).sound(SoundType.PLANT));
         super.setRegistryName(registry);
     }
 
     @Override
-    protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos)
-    {
+    protected boolean isValidGround(BlockState state, IBlockReader worldIn, BlockPos pos) {
         return true;
     }
 
     @Override
-    public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
-    {
+    public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
         return true;
     }
 }

+ 10 - 18
src/main/java/me/km/blocks/BlockSpikes.java

@@ -15,47 +15,39 @@ import net.minecraft.world.IWorld;
 import net.minecraft.world.IWorldReader;
 import net.minecraft.world.World;
 
-public class BlockSpikes extends Block
-{
+public class BlockSpikes extends Block {
     private static final VoxelShape SHAPE = Block.makeCuboidShape(0.0, 0.0, 0.0, 16.0, 1.0, 16.0);
 
-    public BlockSpikes(String name, Properties properties)
-    {
+    public BlockSpikes(String name, Properties properties) {
         super(properties.notSolid());
         super.setRegistryName(name);
     }
 
     @Override
-    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
-    {
+    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
         return SHAPE;
     }
 
     @Override
-    public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos)
-    {
+    public boolean isValidPosition(BlockState state, IWorldReader w, BlockPos pos) {
         return hasSolidSideOnTop(w, pos.down()); // from RedstoneDiodeBlock
     }
 
     @Override
-    public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity ent)
-    {
-        if(!ent.isCrouching() && ent instanceof LivingEntity)
-        {
+    public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity ent) {
+        if(!ent.isCrouching() && ent instanceof LivingEntity) {
             ent.attackEntityFrom(DamageSource.CACTUS, 1.0F);
         }
     }
 
     @Override
-    public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos)
-    {
+    public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos) {
         return false;
     }
 
     @Override
-    public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld w, BlockPos currentPos, BlockPos facingPos)
-    {
-        return !stateIn.isValidPosition(w, currentPos) ? Blocks.AIR.getDefaultState() : 
-                super.updatePostPlacement(stateIn, facing, facingState, w, currentPos, facingPos);
+    public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld w, BlockPos currentPos, BlockPos facingPos) {
+        return !stateIn.isValidPosition(w, currentPos) ? Blocks.AIR.getDefaultState()
+                : super.updatePostPlacement(stateIn, facing, facingState, w, currentPos, facingPos);
     }
 }

+ 64 - 78
src/main/java/me/km/blocks/ModBlocks.java

@@ -15,180 +15,170 @@ import net.minecraft.item.BlockItem;
 import net.minecraft.item.ItemGroup;
 import net.minecraftforge.registries.IForgeRegistry;
 
-public class ModBlocks 
-{
+public class ModBlocks {
     // ores + blocks
     public static Block copperOre;
     public static Block copperBlock;
-    
+
     public static Block tinOre;
     public static Block tinBlock;
-    
+
     public static Block bronzeBlock;
-    
+
     public static Block silverOre;
     public static Block silverBlock;
-        
+
     // misc
     public static Block guildblock;
     public static Block artefact;
     public static Block realHayBlock;
     public static Block realHayBed;
-    
+
     public static Block crateAcacia;
     public static Block crateBigOak;
     public static Block crateBirch;
     public static Block crateJungle;
     public static Block crateOak;
     public static Block crateSpruce;
-    
+
     public static Block cookingPotCopper;
-    
+
     public static Block lantern;
-    
+
     public static Block tallGrass;
-    
+
     // traps
     public static Block spikesCopper;
     public static Block spikesBronze;
     public static Block spikesGold;
     public static Block spikesIron;
-    
+
     // slabs
     public static Block gravelSlab;
-    
+
     // leaves
     public static Block cherryLeaves;
     public static Block apricotLeaves;
     public static Block pearLeaves;
     public static Block plumLeaves;
-    
+
     // saplings
     public static Block cherrySapling;
     public static Block apricotSapling;
     public static Block pearSapling;
     public static Block plumSapling;
-    
+
     // bookshelves
     public static Block bookshelfAcacia;
     public static Block bookshelfBirch;
     public static Block bookshelfDarkOak;
     public static Block bookshelfJungle;
     public static Block bookshelfSpruce;
-    
-    private static Block create(String registry, Material m, float hardness, float resistance)
-    {
+
+    private static Block create(String registry, Material m, float hardness, float resistance) {
         Block b = new Block(Properties.create(m).hardnessAndResistance(hardness, resistance));
         b.setRegistryName(registry);
         return b;
     }
-    
-    private static Block createCrate(String registry)
-    {
+
+    private static Block createCrate(String registry) {
         Block b = new Block(Properties.create(Material.WOOD).hardnessAndResistance(2.0f, 5.0f).sound(SoundType.WOOD));
         b.setRegistryName(registry);
         return b;
     }
-    
-    private static Block createOre(String registry, int harvestLevel)
-    {
+
+    private static Block createOre(String registry, int harvestLevel) {
         Block b = new BlockOre(Properties.create(Material.ROCK).hardnessAndResistance(3.0f, 3.0f), harvestLevel);
         b.setRegistryName(registry);
         return b;
     }
-    
-    private static Block createOreBlock(String registry, MaterialColor mc, float hardness, float resistance, int harvestLevel)
-    {
+
+    private static Block createOreBlock(String registry, MaterialColor mc, float hardness, float resistance, int harvestLevel) {
         Block b = new BlockOre(Properties.create(Material.IRON, mc).hardnessAndResistance(hardness, resistance), harvestLevel);
         b.setRegistryName(registry);
         return b;
     }
-    
-    private static Block createLeaves(String registry)
-    {
+
+    private static Block createLeaves(String registry) {
         Block b = new LeavesBlock(Block.Properties.create(Material.LEAVES).hardnessAndResistance(0.2f).tickRandomly().sound(SoundType.PLANT).notSolid());
         b.setRegistryName(registry);
         return b;
     }
-    
-    private static Block createSapling(String registry, BlockState wood, BlockState leaves)
-    {
+
+    private static Block createSapling(String registry, BlockState wood, BlockState leaves) {
         ModTree tree = new ModTree();
         BlockModSapling b = new BlockModSapling(tree);
         tree.setConfig(wood, leaves, b);
         b.setRegistryName(registry);
         return b;
     }
-    
-    private static Block createBookshelf(String registry)
-    {
+
+    private static Block createBookshelf(String registry) {
         Block b = new BlockBookshelf();
         b.setRegistryName(registry);
         return b;
     }
-    
-    public static void initBlocks(IForgeRegistry<Block> r) 
-    {
+
+    public static void initBlocks(IForgeRegistry<Block> r) {
         // ores + blocks
-        copperOre = register(r, createOre("copper_ore", 1));    
-        tinOre = register(r, createOre("tin_ore", 1));   
-        silverOre = register(r, createOre("silver_ore", 2)); 
-        
-        copperBlock = register(r, createOreBlock("copper_block", MaterialColor.BROWN, 3.0f, 6.0f, 1));   
+        copperOre = register(r, createOre("copper_ore", 1));
+        tinOre = register(r, createOre("tin_ore", 1));
+        silverOre = register(r, createOre("silver_ore", 2));
+
+        copperBlock = register(r, createOreBlock("copper_block", MaterialColor.BROWN, 3.0f, 6.0f, 1));
         tinBlock = register(r, createOreBlock("tin_block", MaterialColor.IRON, 3.0f, 6.0f, 1));
         silverBlock = register(r, createOreBlock("silver_block", MaterialColor.IRON, 5.0f, 6.0f, 2));
         bronzeBlock = register(r, createOreBlock("bronze_block", MaterialColor.YELLOW, 5.0f, 6.0f, 2));
-        
+
         // misc
         guildblock = register(r, create("guild_block", Material.IRON, 50.0f, 2000.0f));
         artefact = register(r, create("artefact", Material.IRON, 50.0f, 2000.0f));
         realHayBlock = register(r, new BlockHay("real_hay_block"));
         realHayBed = register(r, new BlockHayBed("real_hay_bed"));
-        
+
         crateAcacia = register(r, createCrate("crate_acacia"));
         crateBigOak = register(r, createCrate("crate_big_oak"));
         crateBirch = register(r, createCrate("crate_birch"));
         crateJungle = register(r, createCrate("crate_jungle"));
         crateOak = register(r, createCrate("crate_oak"));
         crateSpruce = register(r, createCrate("crate_spruce"));
-        
+
         cookingPotCopper = register(r, new BlockCookingPot("cooking_pot_copper"));
-        
+
         lantern = register(r, new BlockLantern("lantern"));
-        
+
         tallGrass = register(r, new BlockResistantTallGrass("rtall_grass"));
-        
+
         // traps
         spikesCopper = register(r, new BlockSpikes("spikes_copper", Properties.create(Material.IRON, MaterialColor.BROWN).hardnessAndResistance(3.0f, 6.0f)));
         spikesBronze = register(r, new BlockSpikes("spikes_bronze", Properties.create(Material.IRON, MaterialColor.YELLOW).hardnessAndResistance(5.0f, 6.0f)));
         spikesGold = register(r, new BlockSpikes("spikes_gold", Properties.create(Material.IRON, MaterialColor.GOLD).hardnessAndResistance(3.0f, 6.0f)));
         spikesIron = register(r, new BlockSpikes("spikes_iron", Properties.create(Material.IRON).hardnessAndResistance(5.0f, 6.0f)));
-        
+
         // slabs
         gravelSlab = register(r, new BlockGravelSlab(Properties.create(Material.SAND, MaterialColor.STONE)
                 .sound(SoundType.GROUND).hardnessAndResistance(0.6f)).setRegistryName("gravel_slab"));
-        
+
         // leaves
         cherryLeaves = register(r, createLeaves("cherry_leaves"));
         apricotLeaves = register(r, createLeaves("apricot_leaves"));
         pearLeaves = register(r, createLeaves("pear_leaves"));
         plumLeaves = register(r, createLeaves("plum_leaves"));
-        
+
         // saplings
         cherrySapling = register(r, createSapling("cherry_sapling", Blocks.OAK_LOG.getDefaultState(), cherryLeaves.getDefaultState()));
         apricotSapling = register(r, createSapling("apricot_sapling", Blocks.OAK_LOG.getDefaultState(), apricotLeaves.getDefaultState()));
         pearSapling = register(r, createSapling("pear_sapling", Blocks.OAK_LOG.getDefaultState(), pearLeaves.getDefaultState()));
         plumSapling = register(r, createSapling("plum_sapling", Blocks.OAK_LOG.getDefaultState(), plumLeaves.getDefaultState()));
-        
+
         // bookshelves
         bookshelfAcacia = register(r, createBookshelf("bookshelf_acacia"));
         bookshelfBirch = register(r, createBookshelf("bookshelf_birch"));
         bookshelfDarkOak = register(r, createBookshelf("bookshelf_dark_oak"));
         bookshelfJungle = register(r, createBookshelf("bookshelf_jungle"));
         bookshelfSpruce = register(r, createBookshelf("bookshelf_spruce"));
-        
-        
-        FireBlock fireblock = (FireBlock)Blocks.FIRE;
+
+        FireBlock fireblock = (FireBlock) Blocks.FIRE;
         fireblock.setFireInfo(bookshelfAcacia, 30, 20);
         fireblock.setFireInfo(bookshelfBirch, 30, 20);
         fireblock.setFireInfo(bookshelfDarkOak, 30, 20);
@@ -205,39 +195,38 @@ public class ModBlocks
         fireblock.setFireInfo(crateOak, 5, 5);
         fireblock.setFireInfo(crateSpruce, 5, 5);
     }
-    
-    public static void initItemBlocks(IForgeRegistry<Item> r) 
-    {
+
+    public static void initItemBlocks(IForgeRegistry<Item> r) {
         // ores + blocks
         register(r, copperOre, getItemBlock(copperOre, ItemGroup.BUILDING_BLOCKS));
         register(r, copperBlock, getItemBlock(copperBlock, ItemGroup.BUILDING_BLOCKS));
-        
+
         register(r, tinOre, getItemBlock(tinOre, ItemGroup.BUILDING_BLOCKS));
         register(r, tinBlock, getItemBlock(tinBlock, ItemGroup.BUILDING_BLOCKS));
-        
+
         register(r, bronzeBlock, getItemBlock(bronzeBlock, ItemGroup.BUILDING_BLOCKS));
-        
+
         register(r, silverOre, getItemBlock(silverOre, ItemGroup.BUILDING_BLOCKS));
         register(r, silverBlock, getItemBlock(silverBlock, ItemGroup.BUILDING_BLOCKS));
 
         // misc
         register(r, guildblock, getItemBlock(guildblock, ItemGroup.BUILDING_BLOCKS));
         register(r, artefact, getItemBlock(artefact, ItemGroup.BUILDING_BLOCKS));
-        
+
         register(r, realHayBlock, getItemBlock(realHayBlock, ItemGroup.BUILDING_BLOCKS));
-        
+
         register(r, crateAcacia, getItemBlock(crateAcacia, ItemGroup.DECORATIONS));
         register(r, crateBigOak, getItemBlock(crateBigOak, ItemGroup.DECORATIONS));
         register(r, crateBirch, getItemBlock(crateBirch, ItemGroup.DECORATIONS));
         register(r, crateJungle, getItemBlock(crateJungle, ItemGroup.DECORATIONS));
         register(r, crateOak, getItemBlock(crateOak, ItemGroup.DECORATIONS));
         register(r, crateSpruce, getItemBlock(crateSpruce, ItemGroup.DECORATIONS));
-        
+
         register(r, cookingPotCopper, getItemBlock(cookingPotCopper, ItemGroup.BREWING));
-        
+
         register(r, lantern, getItemBlock(lantern, ItemGroup.DECORATIONS));
         register(r, tallGrass, getItemBlock(tallGrass, ItemGroup.DECORATIONS));
-        
+
         // traps
         register(r, spikesCopper, getItemBlock(spikesCopper, ItemGroup.DECORATIONS));
         register(r, spikesBronze, getItemBlock(spikesBronze, ItemGroup.DECORATIONS));
@@ -246,19 +235,19 @@ public class ModBlocks
 
         // slabs
         register(r, gravelSlab, getItemBlock(gravelSlab, ItemGroup.BUILDING_BLOCKS));
-        
+
         // leaves
         register(r, cherryLeaves, getItemBlock(cherryLeaves, ItemGroup.BUILDING_BLOCKS));
         register(r, apricotLeaves, getItemBlock(apricotLeaves, ItemGroup.BUILDING_BLOCKS));
         register(r, pearLeaves, getItemBlock(pearLeaves, ItemGroup.BUILDING_BLOCKS));
         register(r, plumLeaves, getItemBlock(plumLeaves, ItemGroup.BUILDING_BLOCKS));
-        
+
         // saplings
         register(r, cherrySapling, getItemBlock(cherrySapling, ItemGroup.BUILDING_BLOCKS));
         register(r, apricotSapling, getItemBlock(apricotSapling, ItemGroup.BUILDING_BLOCKS));
         register(r, pearSapling, getItemBlock(pearSapling, ItemGroup.BUILDING_BLOCKS));
         register(r, plumSapling, getItemBlock(plumSapling, ItemGroup.BUILDING_BLOCKS));
-        
+
         // bookshelves
         register(r, bookshelfAcacia, getItemBlock(bookshelfAcacia, ItemGroup.BUILDING_BLOCKS));
         register(r, bookshelfBirch, getItemBlock(bookshelfBirch, ItemGroup.BUILDING_BLOCKS));
@@ -267,19 +256,16 @@ public class ModBlocks
         register(r, bookshelfSpruce, getItemBlock(bookshelfSpruce, ItemGroup.BUILDING_BLOCKS));
     }
 
-    private static void register(IForgeRegistry<Item> r, Block block, Item itemBlock) 
-    {
+    private static void register(IForgeRegistry<Item> r, Block block, Item itemBlock) {
         r.register(itemBlock);
     }
-    
-    private static Block register(IForgeRegistry<Block> r, Block block) 
-    {
+
+    private static Block register(IForgeRegistry<Block> r, Block block) {
         r.register(block);
         return block;
     }
 
-    private static BlockItem getItemBlock(Block block, ItemGroup group) 
-    {
+    private static BlockItem getItemBlock(Block block, ItemGroup group) {
         BlockItem itemBlock = new BlockItem(block, new Item.Properties().group(group));
         itemBlock.setRegistryName(block.getRegistryName());
         return itemBlock;

+ 7 - 11
src/main/java/me/km/blocks/ModFlowingFluidBlock.java

@@ -11,21 +11,17 @@ import net.minecraft.potion.EffectInstance;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.World;
 
-public class ModFlowingFluidBlock extends FlowingFluidBlock
-{
+public class ModFlowingFluidBlock extends FlowingFluidBlock {
     private final Effect effect;
-    
-    public ModFlowingFluidBlock(FlowingFluid fluid, Effect effect, Block.Properties builder)
-    {
+
+    public ModFlowingFluidBlock(FlowingFluid fluid, Effect effect, Block.Properties builder) {
         super(fluid, builder);
-        this.effect = effect; 
+        this.effect = effect;
     }
-    
+
     @Override
-    public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity ent) 
-    {
-        if(ent instanceof LivingEntity)
-        {
+    public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity ent) {
+        if(ent instanceof LivingEntity) {
             ((LivingEntity) ent).addPotionEffect(new EffectInstance(effect, 60));
         }
     }

+ 11 - 14
src/main/java/me/km/blocks/ModTree.java

@@ -11,25 +11,22 @@ import net.minecraft.world.gen.feature.TreeFeatureConfig;
 import net.minecraft.world.gen.foliageplacer.BlobFoliagePlacer;
 import net.minecraftforge.common.IPlantable;
 
-public class ModTree extends Tree
-{
+public class ModTree extends Tree {
     private TreeFeatureConfig treeConfig = null;
-    
+
     @Nullable
     @Override
-    protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random r, boolean p_225546_2_)
-    {
+    protected ConfiguredFeature<TreeFeatureConfig, ?> getTreeFeature(Random r, boolean p_225546_2_) {
         return Feature.NORMAL_TREE.withConfiguration(treeConfig);
     }
-    
-    public void setConfig(BlockState wood, BlockState leaves, IPlantable sapling)
-    {
+
+    public void setConfig(BlockState wood, BlockState leaves, IPlantable sapling) {
         treeConfig = (new TreeFeatureConfig.Builder(new SimpleBlockStateProvider(wood), new SimpleBlockStateProvider(leaves), new BlobFoliagePlacer(2, 0)))
-                    .baseHeight(5)
-                    .heightRandA(2)
-                    .foliageHeight(3)
-                    .ignoreVines()
-                    .setSapling(sapling)
-                    .build();
+                .baseHeight(5)
+                .heightRandA(2)
+                .foliageHeight(3)
+                .ignoreVines()
+                .setSapling(sapling)
+                .build();
     }
 }

+ 23 - 48
src/main/java/me/km/blocks/cookingpot/BlockCookingPot.java

@@ -20,64 +20,48 @@ import net.minecraft.world.IBlockReader;
 import net.minecraft.world.World;
 import net.minecraft.util.ActionResultType;
 
-public class BlockCookingPot extends CauldronBlock implements ITileEntityProvider
-{
-    public BlockCookingPot(String name)
-    {
+public class BlockCookingPot extends CauldronBlock implements ITileEntityProvider {
+    public BlockCookingPot(String name) {
         super(Block.Properties.create(Material.IRON, MaterialColor.BROWN).hardnessAndResistance(2.0f));
         this.setRegistryName(name);
     }
 
     @Override
-    public TileEntity createNewTileEntity(IBlockReader reader)
-    {
+    public TileEntity createNewTileEntity(IBlockReader reader) {
         return new TileEntityCookingPot();
     }
 
     @Override
-    public boolean hasTileEntity()
-    {
+    public boolean hasTileEntity() {
         return true;
     }
 
     @Override
-    public TileEntity createTileEntity(BlockState state, IBlockReader world)
-    {
+    public TileEntity createTileEntity(BlockState state, IBlockReader world) {
         return new TileEntityCookingPot();
     }
 
     @Override
-    public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit)
-    {
+    public ActionResultType onBlockActivated(BlockState state, World w, BlockPos pos, PlayerEntity p, Hand hand, BlockRayTraceResult hit) {
         TileEntity te = w.getTileEntity(pos);
-        if(te instanceof TileEntityCookingPot)
-        {
+        if(te instanceof TileEntityCookingPot) {
             TileEntityCookingPot cauldron = (TileEntityCookingPot) te;
             ItemStack stack = p.getHeldItem(hand);
-            if(stack.isEmpty())
-            {
+            if(stack.isEmpty()) {
                 return ActionResultType.PASS;
-            }
-            else if(stack.getItem() == Items.BOWL)
-            {
+            } else if(stack.getItem() == Items.BOWL) {
                 int waterLevel = state.get(LEVEL);
-                if(waterLevel > 0 && !w.isRemote)
-                {
+                if(waterLevel > 0 && !w.isRemote) {
                     ItemStack stew = new ItemStack(ModItems.coloredSoup);
                     ItemColoredSoup.addIngredient(stew, cauldron.getIngredients());
                     ItemColoredSoup.setColor(stew, cauldron.getColor().getRGB());
                     ItemColoredSoup.setFoodStats(stew, cauldron.getIngredients());
                     stack.shrink(1);
-                    if(stack.isEmpty())
-                    {
+                    if(stack.isEmpty()) {
                         p.setHeldItem(hand, stew);
-                    }
-                    else if(!p.inventory.addItemStackToInventory(stew))
-                    {
+                    } else if(!p.inventory.addItemStackToInventory(stew)) {
                         p.dropItem(stew, false);
-                    }
-                    else if(p instanceof ServerPlayerEntity)
-                    {
+                    } else if(p instanceof ServerPlayerEntity) {
                         ((ServerPlayerEntity) p).sendContainerToPlayer(p.container);
                     }
                     this.setWaterLevel(w, pos, state, waterLevel - 1);
@@ -85,30 +69,24 @@ public class BlockCookingPot extends CauldronBlock implements ITileEntityProvide
                 return ActionResultType.SUCCESS;
             }
             int ingredients = cauldron.getNumberOfIngredients();
-            if(ingredients < 3 && cauldron.addItemStack(stack, !w.isRemote))
-            {
-                if(!w.isRemote && !p.isCreative())
-                {
+            if(ingredients < 3 && cauldron.addItemStack(stack, !w.isRemote)) {
+                if(!w.isRemote && !p.isCreative()) {
                     stack.shrink(1);
                 }
                 return ActionResultType.SUCCESS;
             }
-            if(ingredients > 0)
-            {
+            if(ingredients > 0) {
                 return ActionResultType.PASS;
             }
         }
         return super.onBlockActivated(state, w, pos, p, hand, hit);
     }
-    
+
     @Override
-    public void setWaterLevel(World w, BlockPos pos, BlockState state, int level)
-    {
-        if(level <= 0 && !w.isRemote)
-        {
+    public void setWaterLevel(World w, BlockPos pos, BlockState state, int level) {
+        if(level <= 0 && !w.isRemote) {
             TileEntity te = w.getTileEntity(pos);
-            if(te instanceof TileEntityCookingPot)
-            {
+            if(te instanceof TileEntityCookingPot) {
                 ((TileEntityCookingPot) te).reset();
             }
         }
@@ -116,13 +94,10 @@ public class BlockCookingPot extends CauldronBlock implements ITileEntityProvide
     }
 
     @Override
-    public void fillWithRain(World w, BlockPos pos)
-    {
-        if(!w.isRemote)
-        {
+    public void fillWithRain(World w, BlockPos pos) {
+        if(!w.isRemote) {
             TileEntity te = w.getTileEntity(pos);
-            if(te instanceof TileEntityCookingPot)
-            {
+            if(te instanceof TileEntityCookingPot) {
                 ((TileEntityCookingPot) te).reset();
             }
         }

+ 92 - 79
src/main/java/me/km/blocks/cookingpot/CookingPotColorMixer.java

@@ -6,12 +6,11 @@ import net.minecraft.item.Items;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 
-public class CookingPotColorMixer 
-{
-    public final static Color DEFAULT = new Color(47, 67, 244); 
-    
-    private final static Color POISON = new Color(0, 128, 43);   
-    
+public class CookingPotColorMixer {
+    public final static Color DEFAULT = new Color(47, 67, 244);
+
+    private final static Color POISON = new Color(0, 128, 43);
+
     private final static Color PUMPKIN = new Color(197, 120, 23, 255);
     private final static Color APPLE = new Color(195, 30, 38);
     private final static Color APPLE_GOLDEN = new Color(164, 149, 56);
@@ -20,115 +19,133 @@ public class CookingPotColorMixer
     private final static Color BEETROOT_SEEDS = new Color(229, 221, 210);
     //private final static Color BLAZE_POWDER = new Color(183, 100, 15); 
     private final static Color CARROT = new Color(144, 121, 29);
-    private final static Color CARROT_GOLDEN = new Color(129, 104, 26);   
-    private final static Color CHICKEN_RAW = new Color(191, 148, 135);   
+    private final static Color CARROT_GOLDEN = new Color(129, 104, 26);
+    private final static Color CHICKEN_RAW = new Color(191, 148, 135);
     private final static Color FISH_CLOWNFISH_RAW = new Color(216, 170, 143, 255);
-    private final static Color FISH_COD_RAW = new Color(163, 180, 180);   
-    private final static Color FISH_SALMON_RAW = new Color(207, 188, 186, 255); 
+    private final static Color FISH_COD_RAW = new Color(163, 180, 180);
+    private final static Color FISH_SALMON_RAW = new Color(207, 188, 186, 255);
     //private final static Color MAGMA_CREAM = new Color(168, 118, 55);    
     private final static Color MELON = new Color(155, 90, 46);
     private final static Color MELON_SPECKLED = new Color(173, 114, 62);
     private final static Color MUTTON_RAW = new Color(175, 60, 53);
     private final static Color NETHER_WART = new Color(115, 27, 34, 255);
     private final static Color PORKCHOP_RAW = new Color(202, 114, 114);
-    private final static Color POTATO = new Color(206, 169, 91);  
-    private final static Color RABBIT_FOOT = new Color(169, 130, 86);  
+    private final static Color POTATO = new Color(206, 169, 91);
+    private final static Color RABBIT_FOOT = new Color(169, 130, 86);
     private final static Color RABBIT_RAW = new Color(213, 170, 155);
     private final static Color SEEDS_MELON = new Color(57, 48, 23);
     private final static Color SEEDS_PUMPKIN = new Color(201, 199, 146);
     private final static Color SEEDS_WHEAT = new Color(61, 134, 27);
     private final static Color SPIDER_EYE_FERMENTED = new Color(117, 44, 54);
-    private final static Color SUGAR = new Color(185, 185, 195); 
+    private final static Color SUGAR = new Color(185, 185, 195);
     //private final static Color WHEAT = new Color(122, 125, 36);    
-    
+
     private final LinkedList<ItemStack> items;
     private final LinkedList<Color> colors;
-    private Color cachedColor; 
+    private Color cachedColor;
 
-    public CookingPotColorMixer()
-    {
+    public CookingPotColorMixer() {
         items = new LinkedList<>();
         colors = new LinkedList<>();
         reset();
     }
-    
-    public final void reset(Color c)
-    {
+
+    public final void reset(Color c) {
         cachedColor = c;
         colors.clear();
         items.clear();
     }
-    
-    public final void reset()
-    {
+
+    public final void reset() {
         reset(DEFAULT);
     }
-    
-    public LinkedList<ItemStack> getItems()
-    {
+
+    public LinkedList<ItemStack> getItems() {
         return items;
     }
-    
-    public Color getItemColor(ItemStack stack)
-    {
+
+    public Color getItemColor(ItemStack stack) {
         Item item = stack.getItem();
-        if(item == Items.PUMPKIN) { return PUMPKIN; }
-        else if(item == Items.APPLE) { return APPLE; }
-        else if(item == Items.GOLDEN_APPLE) { return APPLE_GOLDEN; }
-        else if(item == Items.BEETROOT_SEEDS) { return BEETROOT_SEEDS; }
-        else if(item == Items.MELON_SEEDS) { return SEEDS_MELON; }
-        else if(item == Items.PUMPKIN_SEEDS) { return SEEDS_PUMPKIN; }
-        else if(item == Items.WHEAT_SEEDS) { return SEEDS_WHEAT; }
-        else if(item == Items.PORKCHOP) { return PORKCHOP_RAW; }
-        else if(item == Items.BEEF) { return BEEF_RAW; }
-        else if(item == Items.TROPICAL_FISH) { return FISH_CLOWNFISH_RAW; }
-        else if(item == Items.COD) { return FISH_COD_RAW; }
-        else if(item == Items.PUFFERFISH) { return POISON; }
-        else if(item == Items.SALMON) { return FISH_SALMON_RAW; }
-        else if(item == Items.SUGAR) { return SUGAR; }
-        else if(item == Items.MELON_SLICE) { return MELON; }
-        else if(item == Items.GLISTERING_MELON_SLICE) { return MELON_SPECKLED; }
-        else if(item == Items.CHICKEN) { return CHICKEN_RAW; }
-        else if(item == Items.SPIDER_EYE) { return POISON; }
-        else if(item == Items.POISONOUS_POTATO) { return POISON; }
-        else if(item == Items.RABBIT_FOOT) { return RABBIT_FOOT; }
-        else if(item == Items.NETHER_WART) { return NETHER_WART; }
-        else if(item == Items.FERMENTED_SPIDER_EYE) { return SPIDER_EYE_FERMENTED; }
-        else if(item == Items.GOLDEN_CARROT) { return CARROT_GOLDEN; }
-        else if(item == Items.CARROT) { return CARROT; }
-        else if(item == Items.RABBIT) { return RABBIT_RAW; }
-        else if(item == Items.POTATO) { return POTATO; }
-        else if(item == Items.MUTTON) { return MUTTON_RAW; }
-        else if(item == Items.BEETROOT) { return BEETROOT; }
+        if(item == Items.PUMPKIN) {
+            return PUMPKIN;
+        } else if(item == Items.APPLE) {
+            return APPLE;
+        } else if(item == Items.GOLDEN_APPLE) {
+            return APPLE_GOLDEN;
+        } else if(item == Items.BEETROOT_SEEDS) {
+            return BEETROOT_SEEDS;
+        } else if(item == Items.MELON_SEEDS) {
+            return SEEDS_MELON;
+        } else if(item == Items.PUMPKIN_SEEDS) {
+            return SEEDS_PUMPKIN;
+        } else if(item == Items.WHEAT_SEEDS) {
+            return SEEDS_WHEAT;
+        } else if(item == Items.PORKCHOP) {
+            return PORKCHOP_RAW;
+        } else if(item == Items.BEEF) {
+            return BEEF_RAW;
+        } else if(item == Items.TROPICAL_FISH) {
+            return FISH_CLOWNFISH_RAW;
+        } else if(item == Items.COD) {
+            return FISH_COD_RAW;
+        } else if(item == Items.PUFFERFISH) {
+            return POISON;
+        } else if(item == Items.SALMON) {
+            return FISH_SALMON_RAW;
+        } else if(item == Items.SUGAR) {
+            return SUGAR;
+        } else if(item == Items.MELON_SLICE) {
+            return MELON;
+        } else if(item == Items.GLISTERING_MELON_SLICE) {
+            return MELON_SPECKLED;
+        } else if(item == Items.CHICKEN) {
+            return CHICKEN_RAW;
+        } else if(item == Items.SPIDER_EYE) {
+            return POISON;
+        } else if(item == Items.POISONOUS_POTATO) {
+            return POISON;
+        } else if(item == Items.RABBIT_FOOT) {
+            return RABBIT_FOOT;
+        } else if(item == Items.NETHER_WART) {
+            return NETHER_WART;
+        } else if(item == Items.FERMENTED_SPIDER_EYE) {
+            return SPIDER_EYE_FERMENTED;
+        } else if(item == Items.GOLDEN_CARROT) {
+            return CARROT_GOLDEN;
+        } else if(item == Items.CARROT) {
+            return CARROT;
+        } else if(item == Items.RABBIT) {
+            return RABBIT_RAW;
+        } else if(item == Items.POTATO) {
+            return POTATO;
+        } else if(item == Items.MUTTON) {
+            return MUTTON_RAW;
+        } else if(item == Items.BEETROOT) {
+            return BEETROOT;
+        }
         return null;
     }
 
-    public void addColor(ItemStack stack, Color c)
-    {
+    public void addColor(ItemStack stack, Color c) {
         colors.add(c);
         ItemStack copy = stack.copy();
         copy.setCount(1);
         items.add(copy);
         cachedColor = mixColors();
     }
-    
-    public void cache()
-    {
-        if(items.isEmpty())
-        {
+
+    public void cache() {
+        if(items.isEmpty()) {
             colors.clear();
             cachedColor = DEFAULT;
             return;
         }
-        if(colors.size() != items.size())
-        {
+        if(colors.size() != items.size()) {
             colors.clear();
             Color c;
-            for(ItemStack stack : items)
-            {
+            for(ItemStack stack : items) {
                 c = getItemColor(stack);
-                if(c != null)
-                {
+                if(c != null) {
                     colors.add(c);
                 }
             }
@@ -136,26 +153,22 @@ public class CookingPotColorMixer
         cachedColor = mixColors();
     }
 
-    public Color getMixedColor()
-    {
+    public Color getMixedColor() {
         return cachedColor;
     }
-    
-    private Color mixColors()
-    {
+
+    private Color mixColors() {
         int alpha = 0;
         int red = 0;
         int green = 0;
         int blue = 0;
-        for(Color c : colors)
-        {
+        for(Color c : colors) {
             alpha += c.getAlpha();
             red += c.getRed();
             green += c.getGreen();
             blue += c.getBlue();
         }
-        if(!colors.isEmpty())
-        {
+        if(!colors.isEmpty()) {
             int size = colors.size();
             alpha /= size;
             red /= size;

+ 42 - 63
src/main/java/me/km/blocks/cookingpot/TileEntityCookingPot.java

@@ -13,96 +13,80 @@ import net.minecraft.network.play.server.SUpdateTileEntityPacket;
 import net.minecraft.tileentity.TileEntity;
 import net.minecraft.tileentity.TileEntityType;
 
-public class TileEntityCookingPot extends TileEntity
-{
-    public static final TileEntityType<TileEntityCookingPot> COOKING_POT = 
-            (TileEntityType<TileEntityCookingPot>) TileEntityType.Builder
-            .create(TileEntityCookingPot::new).build(null)
-            .setRegistryName(KajetansMod.MODID, "cooking_pot");
-    
+public class TileEntityCookingPot extends TileEntity {
+    public static final TileEntityType<TileEntityCookingPot> COOKING_POT
+            = (TileEntityType<TileEntityCookingPot>) TileEntityType.Builder
+                    .create(TileEntityCookingPot::new).build(null)
+                    .setRegistryName(KajetansMod.MODID, "cooking_pot");
+
     private final CookingPotColorMixer mixer;
-    
-    public TileEntityCookingPot()
-    {
+
+    public TileEntityCookingPot() {
         super(COOKING_POT);
         mixer = new CookingPotColorMixer();
     }
-    
+
     @Override
-    public CompoundNBT write(CompoundNBT com)
-    {
+    public CompoundNBT write(CompoundNBT com) {
         super.write(com);
-        
+
         ListNBT list = new ListNBT();
         LinkedList<ItemStack> items = mixer.getItems();
-        items.stream().forEach(stack -> 
-        {
+        items.stream().forEach(stack -> {
             CompoundNBT nbttagcompound = new CompoundNBT();
             stack.write(nbttagcompound);
             list.add(nbttagcompound);
         });
-        
+
         com.put("items", list);
         return com;
     }
-    
+
     @Override
-    public void read(CompoundNBT com)
-    {
+    public void read(CompoundNBT com) {
         super.read(com);
         readItems(com);
     }
-    
-    private void readItems(CompoundNBT com)
-    {
-        if(com.contains("items"))
-        {
+
+    private void readItems(CompoundNBT com) {
+        if(com.contains("items")) {
             mixer.reset();
             ListNBT list = com.getList("items", 10);
             LinkedList<ItemStack> items = mixer.getItems();
-            for(INBT base : list)
-            {
+            for(INBT base : list) {
                 items.add(ItemStack.read((CompoundNBT) base));
             }
-            
+
             mixer.cache();
         }
     }
 
-    public boolean hasDefaultColor()
-    {
+    public boolean hasDefaultColor() {
         return mixer.getItems().isEmpty();
     }
-    
-    public int getNumberOfIngredients()
-    {
+
+    public int getNumberOfIngredients() {
         return mixer.getItems().size();
     }
-    
-    public LinkedList<ItemStack> getIngredients()
-    {
+
+    public LinkedList<ItemStack> getIngredients() {
         return mixer.getItems();
     }
-    
-    public Color getColor() 
-    {
+
+    public Color getColor() {
         return mixer.getMixedColor();
     }
-    
-    public void reset()
-    {
+
+    public void reset() {
         mixer.reset();
     }
-    
-    public boolean addItemStack(ItemStack stack, boolean server)
-    {
+
+    public boolean addItemStack(ItemStack stack, boolean server) {
         Color c = mixer.getItemColor(stack);
-        if(c == null)
-        {
+        if(c == null) {
             return false;
         }
-        if(server)
-        {
+        if(server) {
             mixer.addColor(stack, c);
             notifyBlockUpdate();
             markDirty();
@@ -110,35 +94,30 @@ public class TileEntityCookingPot extends TileEntity
         return true;
     }
 
-    public void setColor(int red, int green, int blue)
-    {
+    public void setColor(int red, int green, int blue) {
         mixer.reset(new Color(red, green, blue));
         notifyBlockUpdate();
         markDirty();
     }
-    
-    private void notifyBlockUpdate()
-    {
+
+    private void notifyBlockUpdate() {
         BlockState state = world.getBlockState(pos);
         this.world.notifyBlockUpdate(pos, state, state, 3);
     }
-    
+
     @Override
-    public SUpdateTileEntityPacket getUpdatePacket()
-    {
+    public SUpdateTileEntityPacket getUpdatePacket() {
         return new SUpdateTileEntityPacket(this.pos, -1, this.getUpdateTag());
     }
-    
+
     @Override
-    public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) 
-    {
+    public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket pkt) {
         readItems(pkt.getNbtCompound());
         notifyBlockUpdate();
     }
 
     @Override
-    public CompoundNBT getUpdateTag()
-    {
+    public CompoundNBT getUpdateTag() {
         return write(new CompoundNBT());
     }
-}
+}

+ 36 - 69
src/main/java/me/km/databank/DataBank.java

@@ -8,127 +8,94 @@ import java.util.HashMap;
 import me.hammerle.snuviscript.code.ISnuviLogger;
 import me.km.scheduler.SnuviScheduler;
 
-public class DataBank
-{
+public class DataBank {
     private final ISnuviLogger logger;
     private Connection c = null;
     private final String user;
     private final String password;
-    
+
     private final HashMap<String, PreparedStatement> statements = new HashMap<>();
-    
-    public DataBank(ISnuviLogger logger, String user, String password) 
-    {
+
+    public DataBank(ISnuviLogger logger, String user, String password) {
         this.logger = logger;
         this.user = user;
         this.password = password;
     }
-    
-    public boolean openDataBankConnection()
-    {
-        try 
-        {
+
+    public boolean openDataBankConnection() {
+        try {
             // The newInstance() call is a work around for some broken Java implementations
             Class.forName("com.mysql.jdbc.Driver").newInstance();
             c = DriverManager.getConnection("jdbc:mysql://localhost/minecraft?useSSL=false", user, password);
             logger.print("connection to datebank etablished");
             return true;
-        } 
-        catch(ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException ex) 
-        {
+        } catch(ClassNotFoundException | IllegalAccessException | InstantiationException | SQLException ex) {
             logger.print(ex);
             return false;
         }
     }
-    
-    public void closeDataBankConnection()
-    {
-        try 
-        {
-            if(c != null)
-            {
+
+    public void closeDataBankConnection() {
+        try {
+            if(c != null) {
                 c.close();
-                statements.values().forEach(stmt -> 
-                {
-                    try
-                    {
+                statements.values().forEach(stmt -> {
+                    try {
                         stmt.close();
-                    }
-                    catch(SQLException ex)
-                    {
+                    } catch(SQLException ex) {
                     }
                 });
             }
             logger.print("connection to databank was closed");
-        } 
-        catch (SQLException ex) 
-        {
+        } catch(SQLException ex) {
             logger.print(ex);
         }
     }
-    
-    public boolean isDummyDatabank()
-    {
+
+    public boolean isDummyDatabank() {
         return c == null;
     }
-    
-    public PreparedStatement prepareStatement(String query)
-    {
-        try
-        {
+
+    public PreparedStatement prepareStatement(String query) {
+        try {
             PreparedStatement ps = c.prepareStatement(query);
             PreparedStatement old = statements.put(query, ps);
-            if(old != null)
-            {
+            if(old != null) {
                 old.close();
             }
             return ps;
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return null;
     }
-    
-    public PreparedStatement prepareUnsafeStatement(String query) throws SQLException
-    {
+
+    public PreparedStatement prepareUnsafeStatement(String query) throws SQLException {
         return c.prepareStatement(query);
     }
-    
-    public boolean execute(String query)
-    {
-        if(c == null)
-        {
+
+    public boolean execute(String query) {
+        if(c == null) {
             return false;
         }
-        try(java.sql.Statement stmt = c.createStatement())
-        {
+        try(java.sql.Statement stmt = c.createStatement()) {
             stmt.executeUpdate(query);
             return true;
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
             return false;
         }
     }
-    
-    public void startReconnecting(SnuviScheduler scheduler)
-    {
-        if(c == null)
-        {
+
+    public void startReconnecting(SnuviScheduler scheduler) {
+        if(c == null) {
             return;
         }
-        scheduler.scheduleRepeatingTask(() -> 
-        {
-            try(java.sql.Statement stmt = c.createStatement()) 
-            {
+        scheduler.scheduleRepeatingTask(() -> {
+            try(java.sql.Statement stmt = c.createStatement()) {
                 // pointless query just for reconnecting
                 stmt.executeUpdate("SHOW TABLES IN minecraft");
-            }
-            catch(SQLException ex) 
-            {
+            } catch(SQLException ex) {
                 logger.print("reconnect was done");
             }
         }, 100, 12000); // doing this every 10 minutes

+ 4 - 7
src/main/java/me/km/entities/EntityBlackBear.java

@@ -4,16 +4,13 @@ import net.minecraft.entity.EntityType;
 import net.minecraft.entity.passive.PolarBearEntity;
 import net.minecraft.world.World;
 
-public class EntityBlackBear extends PolarBearEntity
-{
-    public EntityBlackBear(EntityType<EntityBlackBear> type, World w) 
-    {
+public class EntityBlackBear extends PolarBearEntity {
+    public EntityBlackBear(EntityType<EntityBlackBear> type, World w) {
         super(ModEntities.BLACK_BEAR, w);
     }
 
     @Override
-    public EntityType<?> getType()
-    {
+    public EntityType<?> getType() {
         return ModEntities.BLACK_BEAR;
-    }   
+    }
 }

+ 5 - 8
src/main/java/me/km/entities/EntityBrownBear.java

@@ -4,16 +4,13 @@ import net.minecraft.entity.EntityType;
 import net.minecraft.entity.passive.PolarBearEntity;
 import net.minecraft.world.World;
 
-public class EntityBrownBear extends PolarBearEntity
-{
-    public EntityBrownBear(EntityType<EntityBrownBear> type, World w) 
-    {
+public class EntityBrownBear extends PolarBearEntity {
+    public EntityBrownBear(EntityType<EntityBrownBear> type, World w) {
         super(ModEntities.BROWN_BEAR, w);
     }
-    
+
     @Override
-    public EntityType<?> getType()
-    {
+    public EntityType<?> getType() {
         return ModEntities.BROWN_BEAR;
-    }   
+    }
 }

+ 64 - 112
src/main/java/me/km/entities/EntityHuman.java

@@ -26,28 +26,25 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 import net.minecraft.util.SoundEvents;
 
-public class EntityHuman extends CreatureEntity
-{
+public class EntityHuman extends CreatureEntity {
     private static final DataParameter<String> SKIN_NAME = EntityDataManager.createKey(EntityHuman.class, DataSerializers.STRING);
     private static final DataParameter<Float> SCALE = EntityDataManager.createKey(EntityHuman.class, DataSerializers.FLOAT);
     private static final DataParameter<Boolean> SLIM = EntityDataManager.createKey(EntityHuman.class, DataSerializers.BOOLEAN);
-    
+
     private float lastScale = 1.0f;
     private final float originalWidth;
     private final float originalHeight;
     private EntitySize size;
-    
-    public EntityHuman(EntityType<EntityHuman> type, World w)
-    {
-        super(type, w);  
+
+    public EntityHuman(EntityType<EntityHuman> type, World w) {
+        super(type, w);
         this.originalWidth = getWidth();
         this.originalHeight = getHeight();
         size = ModEntities.HUMAN.getSize();
     }
-    
+
     @Override
-    protected void registerData() 
-    {
+    protected void registerData() {
         super.registerData();
         this.getDataManager().register(SKIN_NAME, "Steve");
         this.getDataManager().register(SCALE, 1.0f);
@@ -57,74 +54,59 @@ public class EntityHuman extends CreatureEntity
     // -------------------------------------------------------------------------
     // size modifier
     // -------------------------------------------------------------------------
-
-    public boolean isSlim()
-    {
+    public boolean isSlim() {
         return this.getDataManager().get(SLIM);
     }
-    
-    public void setSlim(boolean slim)
-    {
+
+    public void setSlim(boolean slim) {
         this.getDataManager().set(SLIM, slim);
     }
-    
-    public final float getScale()
-    {
+
+    public final float getScale() {
         return this.getDataManager().get(SCALE);
     }
-    
-    public final void setScale(float scale)
-    {
+
+    public final void setScale(float scale) {
         this.getDataManager().set(SCALE, scale);
         updateSize(scale);
     }
-    
-    private void updateSize(float scale)
-    {
+
+    private void updateSize(float scale) {
         this.setSize(originalWidth * scale, originalHeight * scale);
     }
-    
-    public void setSkinName(String name)
-    {
+
+    public void setSkinName(String name) {
         this.getDataManager().set(SKIN_NAME, name);
-    }   
-    
-    public String getSkinName()
-    {
+    }
+
+    public String getSkinName() {
         return this.getDataManager().get(SKIN_NAME);
     }
-    
+
     // -------------------------------------------------------------------------
     // texture stuff
     // -------------------------------------------------------------------------
-    
     @OnlyIn(Dist.CLIENT)
-    public ResourceLocation getTexture()
-    {
+    public ResourceLocation getTexture() {
         return HumanSkinLoader.INSTANCE.getTexture(getSkinName());
     }
-    
+
     @Override
-    public void readAdditional(CompoundNBT com)
-    {
+    public void readAdditional(CompoundNBT com) {
         super.readAdditional(com);
-        if(com.contains("HumanName"))
-        {
+        if(com.contains("HumanName")) {
             setSkinName(com.getString("HumanName"));
         }
-        if(com.contains("Scale"))
-        {
+        if(com.contains("Scale")) {
             setScale(com.getFloat("Scale"));
         }
-        if(com.contains("Slim"))
-        {
+        if(com.contains("Slim")) {
             setSlim(com.getBoolean("Slim"));
         }
     }
 
     @Override
-    public void writeAdditional(CompoundNBT com)
-    {
+    public void writeAdditional(CompoundNBT com) {
         super.writeAdditional(com);
         com.putString("HumanName", getSkinName());
         com.putFloat("Scale", getScale());
@@ -132,50 +114,41 @@ public class EntityHuman extends CreatureEntity
     }
 
     @Override
-    public void addVelocity(double x, double y, double z)
-    {
+    public void addVelocity(double x, double y, double z) {
     }
-    
+
     @Override
-    public void knockBack(Entity entityIn, float strength, double xRatio, double zRatio)
-    {
+    public void knockBack(Entity entityIn, float strength, double xRatio, double zRatio) {
     }
-    
+
     @Override
-    public void applyEntityCollision(Entity entityIn) 
-    {
+    public void applyEntityCollision(Entity entityIn) {
     }
 
     @Override
-    public boolean attackEntityFrom(DamageSource source, float amount) 
-    {
-        if(source == DamageSource.OUT_OF_WORLD)
-        {
+    public boolean attackEntityFrom(DamageSource source, float amount) {
+        if(source == DamageSource.OUT_OF_WORLD) {
             this.remove();
             return false;
         }
-        if(!world.isRemote)
-        {
+        if(!world.isRemote) {
             Entity ent = source.getTrueSource();
-            if(ent instanceof ModEntityPlayerMP)
-            {
+            if(ent instanceof ModEntityPlayerMP) {
                 Server.scriptEvents.onHumanHurt((ModEntityPlayerMP) ent, this);
             }
         }
         return false;
     }
-    
+
     @Override
-    protected void registerGoals() 
-    {
+    protected void registerGoals() {
         this.goalSelector.addGoal(0, new SwimGoal(this));
         this.goalSelector.addGoal(1, new LookAtGoal(this, PlayerEntity.class, 6.0F));
         this.goalSelector.addGoal(2, new LookRandomlyGoal(this));
-   }
-    
+    }
+
     @Override
-    protected void registerAttributes()
-    {
+    protected void registerAttributes() {
         super.registerAttributes();
         this.getAttributes().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(1);
         this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.1d);
@@ -183,114 +156,93 @@ public class EntityHuman extends CreatureEntity
     }
 
     @Override
-    protected SoundEvent getSwimSound()
-    {
+    protected SoundEvent getSwimSound() {
         return SoundEvents.ENTITY_PLAYER_SWIM;
     }
 
     @Override
-    protected SoundEvent getSplashSound()
-    {
+    protected SoundEvent getSplashSound() {
         return SoundEvents.ENTITY_PLAYER_SPLASH;
     }
 
     @Override
-    public SoundCategory getSoundCategory()
-    {
+    public SoundCategory getSoundCategory() {
         return SoundCategory.NEUTRAL;
     }
 
     @Override
-    protected SoundEvent getHurtSound(DamageSource ds)
-    {
-        if (ds == DamageSource.ON_FIRE)
-        {
+    protected SoundEvent getHurtSound(DamageSource ds) {
+        if(ds == DamageSource.ON_FIRE) {
             return SoundEvents.ENTITY_PLAYER_HURT_ON_FIRE;
-        }
-        else
-        {
+        } else {
             return ds == DamageSource.DROWN ? SoundEvents.ENTITY_PLAYER_HURT_DROWN : SoundEvents.ENTITY_PLAYER_HURT;
         }
     }
 
     @Override
-    protected SoundEvent getDeathSound()
-    {
+    protected SoundEvent getDeathSound() {
         return SoundEvents.ENTITY_PLAYER_DEATH;
     }
 
     @Override
-    public double getYOffset()
-    {
+    public double getYOffset() {
         return -0.35D;
     }
 
     @Override
-    public float getAIMoveSpeed()
-    {
+    public float getAIMoveSpeed() {
         return (float) this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getValue();
     }
 
     @Override
-    protected SoundEvent getFallSound(int heightIn)
-    {
+    protected SoundEvent getFallSound(int heightIn) {
         return heightIn > 4 ? SoundEvents.ENTITY_PLAYER_BIG_FALL : SoundEvents.ENTITY_PLAYER_SMALL_FALL;
     }
 
     @OnlyIn(Dist.CLIENT)
     @Override
-    public boolean getAlwaysRenderNameTagForRender()
-    {
+    public boolean getAlwaysRenderNameTagForRender() {
         return true;
     }
 
     @Override
-    public ITextComponent getDisplayName()
-    {
+    public ITextComponent getDisplayName() {
         return getName();
     }
 
     @Override
-    public float getEyeHeight(Pose p_213307_1_)
-    {
+    public float getEyeHeight(Pose p_213307_1_) {
         float f = getDefaultEyeHeight();
-        if(getHeight() == 1.65F)
-        {
+        if(getHeight() == 1.65F) {
             f -= 0.08F;
         }
         f *= getScale();
         return f;
     }
 
-    public float getDefaultEyeHeight()
-    {
+    public float getDefaultEyeHeight() {
         return 1.62F;
     }
 
     @Override
-    public boolean canDespawn(double distanceToClosestPlayer)
-    {
+    public boolean canDespawn(double distanceToClosestPlayer) {
         return false;
     }
 
     @Override
-    public EntitySize getSize(Pose poseIn)
-    {
+    public EntitySize getSize(Pose poseIn) {
         return size;
     }
-    
-    private void setSize(float w, float h)
-    {
+
+    private void setSize(float w, float h) {
         size = EntitySize.flexible(w, h);
         recalculateSize();
     }
 
     @Override
-    public void notifyDataManagerChange(DataParameter<?> key)
-    {
+    public void notifyDataManagerChange(DataParameter<?> key) {
         super.notifyDataManagerChange(key);
-        if(SCALE.equals(key))
-        {
+        if(SCALE.equals(key)) {
             updateSize(getScale());
         }
     }

+ 29 - 60
src/main/java/me/km/entities/EntityItemProjectile.java

@@ -19,34 +19,29 @@ import net.minecraft.util.math.RayTraceContext;
 import net.minecraft.util.math.RayTraceResult;
 import net.minecraft.util.math.Vec3d;
 
-public class EntityItemProjectile extends ItemEntity implements IProjectile
-{
+public class EntityItemProjectile extends ItemEntity implements IProjectile {
     private LivingEntity owner;
     private boolean hit = false;
     private final float damage;
     private Entity ignoreEntity = null;
     private int ignoreTime = 0;
 
-    public EntityItemProjectile(LivingEntity thrower, ItemStack stack, float damage)
-    {
+    public EntityItemProjectile(LivingEntity thrower, ItemStack stack, float damage) {
         super(thrower.world, thrower.getPosX(), thrower.getPosY() + thrower.getEyeHeight() - 0.1d, thrower.getPosZ(), stack);
         this.owner = thrower;
         super.setInfinitePickupDelay();
         this.damage = damage;
     }
 
-    public EntityItemProjectile(LivingEntity thrower, ItemStack stack)
-    {
+    public EntityItemProjectile(LivingEntity thrower, ItemStack stack) {
         this(thrower, stack, -1);
     }
 
-    public LivingEntity getItemThrower()
-    {
+    public LivingEntity getItemThrower() {
         return owner;
     }
 
-    public void setHeadingFromThrower(Entity thrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy)
-    {
+    public void setHeadingFromThrower(Entity thrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy) {
         float f = -MathHelper.sin(rotationYawIn * ((float) Math.PI / 180.0f)) * MathHelper.cos(rotationPitchIn * ((float) Math.PI / 180.0f));
         float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * ((float) Math.PI / 180.0f));
         float f2 = MathHelper.cos(rotationYawIn * ((float) Math.PI / 180.0f)) * MathHelper.cos(rotationPitchIn * ((float) Math.PI / 180.0f));
@@ -56,8 +51,7 @@ public class EntityItemProjectile extends ItemEntity implements IProjectile
     }
 
     @Override
-    public void shoot(double x, double y, double z, float velocity, float inaccuracy)
-    {
+    public void shoot(double x, double y, double z, float velocity, float inaccuracy) {
         Vec3d vec3d = new Vec3d(x, y, z)
                 .normalize()
                 .add(rand.nextGaussian() * 0.0075 * inaccuracy, rand.nextGaussian() * 0.0075 * inaccuracy, rand.nextGaussian() * 0.0075 * inaccuracy)
@@ -70,17 +64,13 @@ public class EntityItemProjectile extends ItemEntity implements IProjectile
         this.prevRotationPitch = this.rotationPitch;
     }
 
-    private void onImpact(RayTraceResult ray)
-    {
-        if(damage == -1)
-        {
-            if(!(owner instanceof ModEntityPlayerMP))
-            {
+    private void onImpact(RayTraceResult ray) {
+        if(damage == -1) {
+            if(!(owner instanceof ModEntityPlayerMP)) {
                 return;
             }
             ModEntityPlayerMP p = (ModEntityPlayerMP) owner;
-            switch(ray.getType())
-            {
+            switch(ray.getType()) {
                 case ENTITY:
                     Server.scriptEvents.onEntityItemProjectileHit(this, p, this.getItem(), ((EntityRayTraceResult) ray).getEntity(), null);
                     break;
@@ -88,55 +78,43 @@ public class EntityItemProjectile extends ItemEntity implements IProjectile
                     Server.scriptEvents.onEntityItemProjectileHit(this, p, this.getItem(), null, ((BlockRayTraceResult) ray).getPos());
                     break;
             }
-        }
-        else if(ray.getType() == RayTraceResult.Type.ENTITY)
-        {
+        } else if(ray.getType() == RayTraceResult.Type.ENTITY) {
             ((EntityRayTraceResult) ray).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, owner), damage);
         }
     }
 
     @Override
-    public void tick()
-    {
+    public void tick() {
         super.tick();
-        if(hit)
-        {
+        if(hit) {
             return;
         }
 
         AxisAlignedBB axisalignedbb = this.getBoundingBox().expand(this.getMotion()).grow(2.0D);
 
-        for(Entity entity : this.world.getEntitiesInAABBexcluding(this, axisalignedbb, (p) -> !p.isSpectator() && p.canBeCollidedWith()))
-        {
-            if(entity == this.ignoreEntity)
-            {
+        for(Entity entity : this.world.getEntitiesInAABBexcluding(this, axisalignedbb, (p) -> !p.isSpectator() && p.canBeCollidedWith())) {
+            if(entity == this.ignoreEntity) {
                 this.ignoreTime++;
                 break;
             }
 
-            if(this.owner != null && this.ticksExisted < 2 && this.ignoreEntity == null)
-            {
+            if(this.owner != null && this.ticksExisted < 2 && this.ignoreEntity == null) {
                 this.ignoreEntity = entity;
                 this.ignoreTime = 3;
                 break;
             }
         }
 
-        RayTraceResult ray = ProjectileHelper.rayTrace(this, axisalignedbb, 
+        RayTraceResult ray = ProjectileHelper.rayTrace(this, axisalignedbb,
                 (p) -> !p.isSpectator() && p.canBeCollidedWith() && p != this.ignoreEntity, RayTraceContext.BlockMode.OUTLINE, true);
-        if(this.ignoreEntity != null && this.ignoreTime-- <= 0)
-        {
+        if(this.ignoreEntity != null && this.ignoreTime-- <= 0) {
             this.ignoreEntity = null;
         }
 
-        if(ray.getType() != RayTraceResult.Type.MISS)
-        {
-            if(ray.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult) ray).getPos()).getBlock() == Blocks.NETHER_PORTAL)
-            {
+        if(ray.getType() != RayTraceResult.Type.MISS) {
+            if(ray.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult) ray).getPos()).getBlock() == Blocks.NETHER_PORTAL) {
                 this.setPortal(((BlockRayTraceResult) ray).getPos());
-            }
-            else
-            {
+            } else {
                 this.onImpact(ray);
                 hit = true;
                 this.setDefaultPickupDelay();
@@ -148,44 +126,35 @@ public class EntityItemProjectile extends ItemEntity implements IProjectile
         float f = MathHelper.sqrt(horizontalMag(vec3d));
         this.rotationYaw = (float) (MathHelper.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI));
 
-        for(this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, (double) f) * (double) (180F / (float) Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F)
-        {
+        for(this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, (double) f) * (double) (180F / (float) Math.PI)); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {
         }
 
-        while(this.rotationPitch - this.prevRotationPitch >= 180.0F)
-        {
+        while(this.rotationPitch - this.prevRotationPitch >= 180.0F) {
             this.prevRotationPitch += 360.0F;
         }
 
-        while(this.rotationYaw - this.prevRotationYaw < -180.0F)
-        {
+        while(this.rotationYaw - this.prevRotationYaw < -180.0F) {
             this.prevRotationYaw -= 360.0F;
         }
 
-        while(this.rotationYaw - this.prevRotationYaw >= 180.0F)
-        {
+        while(this.rotationYaw - this.prevRotationYaw >= 180.0F) {
             this.prevRotationYaw += 360.0F;
         }
 
         this.rotationPitch = MathHelper.lerp(0.2F, this.prevRotationPitch, this.rotationPitch);
         this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw);
         float f1;
-        if(this.isInWater())
-        {
-            for(int i = 0; i < 4; ++i)
-            {
+        if(this.isInWater()) {
+            for(int i = 0; i < 4; ++i) {
                 this.world.addParticle(ParticleTypes.BUBBLE, getPosX() - vec3d.x * 0.25D, getPosY() - vec3d.y * 0.25D, getPosZ() - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
             }
             f1 = 0.8F;
-        }
-        else
-        {
+        } else {
             f1 = 0.99F;
         }
 
         this.setMotion(vec3d.scale((double) f1));
-        if(!this.hasNoGravity())
-        {
+        if(!this.hasNoGravity()) {
             Vec3d vec3d1 = this.getMotion();
             this.setMotion(vec3d1.x, vec3d1.y - 0.03, vec3d1.z);
         }

+ 14 - 27
src/main/java/me/km/entities/EntityNobody.java

@@ -10,71 +10,58 @@ import net.minecraft.util.DamageSource;
 import net.minecraft.util.HandSide;
 import net.minecraft.world.World;
 
-public class EntityNobody extends LivingEntity
-{
-    public EntityNobody(EntityType<EntityNobody> type, World p_i48577_2_)
-    {
+public class EntityNobody extends LivingEntity {
+    public EntityNobody(EntityType<EntityNobody> type, World p_i48577_2_) {
         super(type, p_i48577_2_);
     }
 
     @Override
-    public boolean attackEntityFrom(DamageSource source, float amount)
-    {
+    public boolean attackEntityFrom(DamageSource source, float amount) {
         return false;
     }
 
     @Override
-    public void knockBack(Entity entityIn, float strength, double xRatio, double zRatio)
-    {
+    public void knockBack(Entity entityIn, float strength, double xRatio, double zRatio) {
     }
 
     @Override
-    public void applyEntityCollision(Entity entityIn)
-    {
+    public void applyEntityCollision(Entity entityIn) {
     }
 
     @Override
-    public void addVelocity(double x, double y, double z)
-    {
+    public void addVelocity(double x, double y, double z) {
     }
-    
+
     @Override
-    public Iterable<ItemStack> getArmorInventoryList()
-    {
+    public Iterable<ItemStack> getArmorInventoryList() {
         return Collections.EMPTY_LIST;
     }
 
     @Override
-    public ItemStack getItemStackFromSlot(EquipmentSlotType est)
-    {
+    public ItemStack getItemStackFromSlot(EquipmentSlotType est) {
         return ItemStack.EMPTY;
     }
 
     @Override
-    public void setItemStackToSlot(EquipmentSlotType est, ItemStack is)
-    {
+    public void setItemStackToSlot(EquipmentSlotType est, ItemStack is) {
     }
 
     @Override
-    public HandSide getPrimaryHand()
-    {
+    public HandSide getPrimaryHand() {
         return HandSide.LEFT;
     }
 
     @Override
-    public boolean canBeCollidedWith()
-    {
+    public boolean canBeCollidedWith() {
         return false;
     }
 
     @Override
-    protected void collideWithEntity(Entity entityIn)
-    {
+    protected void collideWithEntity(Entity entityIn) {
     }
 
     @Override
-    public boolean isCustomNameVisible()
-    {
+    public boolean isCustomNameVisible() {
         return true;
     }
 }

+ 31 - 59
src/main/java/me/km/entities/HumanSkinLoader.java

@@ -15,8 +15,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
 import org.apache.logging.log4j.LogManager;
 
 @OnlyIn(Dist.CLIENT)
-public class HumanSkinLoader
-{
+public class HumanSkinLoader {
     public final static HumanSkinLoader INSTANCE = new HumanSkinLoader();
 
     private static final ResourceLocation TEXTURE_STEVE = new ResourceLocation("textures/entity/steve.png");
@@ -26,21 +25,16 @@ public class HumanSkinLoader
 
     private final TextureManager manager = Minecraft.getInstance().getRenderManager().textureManager;
 
-    private HumanSkinLoader()
-    {
+    private HumanSkinLoader() {
     }
 
-    public ResourceLocation getTexture(String name)
-    {
+    public ResourceLocation getTexture(String name) {
         ResourceLocation loc = skins.get(name);
-        if(loc != null)
-        {
+        if(loc != null) {
             return loc;
         }
-        if(loading.add(name))
-        {
-            downloadSkin(name, image ->
-            {
+        if(loading.add(name)) {
+            downloadSkin(name, image -> {
                 ResourceLocation rloc = manager.getDynamicTextureLocation("skin_" + name.toLowerCase(), new DynamicTexture(image));
                 skins.put(name, rloc);
                 loading.remove(name);
@@ -49,32 +43,27 @@ public class HumanSkinLoader
         return TEXTURE_STEVE;
     }
 
-    private void downloadSkin(String name, Consumer<NativeImage> delayed)
-    {
-        new Thread(() ->
-        {
+    private void downloadSkin(String name, Consumer<NativeImage> delayed) {
+        new Thread(() -> {
             HttpURLConnection httpurlconnection = null;
-            try
-            {
+            try {
                 URL url = new URL("http://skins.hammerle.me/skins/" + name + ".png");
                 httpurlconnection = (HttpURLConnection) url.openConnection(Minecraft.getInstance().getProxy());
                 httpurlconnection.setDoInput(true);
                 httpurlconnection.setDoOutput(false);
                 httpurlconnection.connect();
-                
-                int code = httpurlconnection.getResponseCode();               
-                if(code != 200)
-                {
+
+                int code = httpurlconnection.getResponseCode();
+                if(code != 200) {
                     // Failed own server, trying crafatar
                     httpurlconnection.disconnect();
-                    httpurlconnection = (HttpURLConnection) (new URL("https://crafatar.com/skins/" + name + ".png")) 
+                    httpurlconnection = (HttpURLConnection) (new URL("https://crafatar.com/skins/" + name + ".png"))
                             .openConnection(Minecraft.getInstance().getProxy());
                     httpurlconnection.setDoInput(true);
                     httpurlconnection.setDoOutput(false);
                     httpurlconnection.connect();
                     code = httpurlconnection.getResponseCode();
-                    if(code != 200)
-                    {
+                    if(code != 200) {
                         LogManager.getLogger().warn("Server response code did return " + code + ", skin servers might be down.");
                         return;
                     }
@@ -82,26 +71,19 @@ public class HumanSkinLoader
 
                 NativeImage image = convert(NativeImage.read(httpurlconnection.getInputStream()));
                 Minecraft.getInstance().enqueue(() -> delayed.accept(image));
-            }
-            catch(Exception ex)
-            {
+            } catch(Exception ex) {
                 LogManager.getLogger().warn("Error occurred when downloading skin, however, skin servers seem to be up.");
-            }
-            finally
-            {
-                if(httpurlconnection != null)
-                {
+            } finally {
+                if(httpurlconnection != null) {
                     httpurlconnection.disconnect();
                 }
             }
         }).start();
     }
-    
-    private NativeImage convert(NativeImage old)
-    {
+
+    private NativeImage convert(NativeImage old) {
         boolean flag = old.getHeight() == 32;
-        if (flag) 
-        {
+        if(flag) {
             NativeImage nativeimage = new NativeImage(64, 64, true);
             nativeimage.copyImageData(old);
             old.close();
@@ -122,8 +104,7 @@ public class HumanSkinLoader
         }
 
         setAreaOpaque(old, 0, 0, 32, 16);
-        if (flag) 
-        {
+        if(flag) {
             setAreaTransparent(old, 32, 0, 64, 32);
         }
 
@@ -131,37 +112,28 @@ public class HumanSkinLoader
         setAreaOpaque(old, 16, 48, 48, 64);
         return old;
     }
-    
-    private static void setAreaTransparent(NativeImage image, int x, int y, int width, int height)
-    {
-        for(int i = x; i < width; ++i)
-        {
-            for(int j = y; j < height; ++j)
-            {
+
+    private static void setAreaTransparent(NativeImage image, int x, int y, int width, int height) {
+        for(int i = x; i < width; ++i) {
+            for(int j = y; j < height; ++j) {
                 int k = image.getPixelRGBA(i, j);
-                if((k >> 24 & 255) < 128)
-                {
+                if((k >> 24 & 255) < 128) {
                     return;
                 }
             }
         }
 
-        for(int l = x; l < width; ++l)
-        {
-            for(int i1 = y; i1 < height; ++i1)
-            {
+        for(int l = x; l < width; ++l) {
+            for(int i1 = y; i1 < height; ++i1) {
                 image.setPixelRGBA(l, i1, image.getPixelRGBA(l, i1) & 16777215);
             }
         }
 
     }
 
-    private static void setAreaOpaque(NativeImage image, int x, int y, int width, int height)
-    {
-        for(int i = x; i < width; ++i)
-        {
-            for(int j = y; j < height; ++j)
-            {
+    private static void setAreaOpaque(NativeImage image, int x, int y, int width, int height) {
+        for(int i = x; i < width; ++i) {
+            for(int j = y; j < height; ++j) {
                 image.setPixelRGBA(i, j, image.getPixelRGBA(i, j) | -16777216);
             }
         }

+ 19 - 27
src/main/java/me/km/entities/ModEntities.java

@@ -9,58 +9,50 @@ import net.minecraftforge.fml.client.registry.RenderingRegistry;
 import net.minecraftforge.fml.loading.FMLEnvironment;
 import net.minecraftforge.registries.IForgeRegistry;
 
-public class ModEntities 
-{
-    public static final EntityType<EntityHuman> HUMAN = 
-            (EntityType<EntityHuman>) EntityType.Builder.create(EntityHuman::new, EntityClassification.CREATURE)
+public class ModEntities {
+    public static final EntityType<EntityHuman> HUMAN
+            = (EntityType<EntityHuman>) EntityType.Builder.create(EntityHuman::new, EntityClassification.CREATURE)
                     .size(0.6f, 1.8f)
                     .build(String.format("%s:human", KajetansMod.MODID))
                     .setRegistryName(KajetansMod.MODID, "human");
-    public static final EntityType<EntityNobody> NOBODY = 
-            (EntityType<EntityNobody>) EntityType.Builder.create(EntityNobody::new, EntityClassification.MISC)
+    public static final EntityType<EntityNobody> NOBODY
+            = (EntityType<EntityNobody>) EntityType.Builder.create(EntityNobody::new, EntityClassification.MISC)
                     .size(0.5f, 0.5f)
                     .build(String.format("%s:nobody", KajetansMod.MODID))
                     .setRegistryName(KajetansMod.MODID, "nobody");
-    public static final EntityType<EntityBrownBear> BROWN_BEAR = 
-            (EntityType<EntityBrownBear>) EntityType.Builder.create(EntityBrownBear::new, EntityClassification.CREATURE)
+    public static final EntityType<EntityBrownBear> BROWN_BEAR
+            = (EntityType<EntityBrownBear>) EntityType.Builder.create(EntityBrownBear::new, EntityClassification.CREATURE)
                     .size(1.4f, 1.4f)
                     .build(String.format("%s:bear/brownbear", KajetansMod.MODID))
                     .setRegistryName(KajetansMod.MODID, "bear/brownbear");
-    public static final EntityType<EntityBlackBear> BLACK_BEAR = 
-            (EntityType<EntityBlackBear>) EntityType.Builder.create(EntityBlackBear::new, EntityClassification.CREATURE)
+    public static final EntityType<EntityBlackBear> BLACK_BEAR
+            = (EntityType<EntityBlackBear>) EntityType.Builder.create(EntityBlackBear::new, EntityClassification.CREATURE)
                     .size(1.4f, 1.4f)
                     .build(String.format("%s:bear/blackbear", KajetansMod.MODID))
                     .setRegistryName(KajetansMod.MODID, "bear/blackbear");
-    
-    public static void init(IForgeRegistry<EntityType<?>> r)
-    {
-        if(FMLEnvironment.dist == Dist.CLIENT)
-        {
+
+    public static void init(IForgeRegistry<EntityType<?>> r) {
+        if(FMLEnvironment.dist == Dist.CLIENT) {
             initClient();
         }
         r.register(HUMAN);
         r.register(NOBODY);
         r.register(BROWN_BEAR);
-        r.register(BLACK_BEAR); 
+        r.register(BLACK_BEAR);
     }
-    
+
     @OnlyIn(Dist.CLIENT)
-    private static void initClient() 
-    {
-        RenderingRegistry.registerEntityRenderingHandler(BROWN_BEAR, (rm) -> 
-        {
+    private static void initClient() {
+        RenderingRegistry.registerEntityRenderingHandler(BROWN_BEAR, (rm) -> {
             return new RenderBrownBear(rm);
         });
-        RenderingRegistry.registerEntityRenderingHandler(BLACK_BEAR, (rm) -> 
-        {
+        RenderingRegistry.registerEntityRenderingHandler(BLACK_BEAR, (rm) -> {
             return new RenderBlackBear(rm);
         });
-        RenderingRegistry.registerEntityRenderingHandler(HUMAN, (rm) -> 
-        {
+        RenderingRegistry.registerEntityRenderingHandler(HUMAN, (rm) -> {
             return new RenderHuman(rm);
         });
-        RenderingRegistry.registerEntityRenderingHandler(NOBODY, (rm) -> 
-        {
+        RenderingRegistry.registerEntityRenderingHandler(NOBODY, (rm) -> {
             return new RenderNobody(rm);
         });
     }

+ 2 - 4
src/main/java/me/km/entities/ModelHuman.java

@@ -2,10 +2,8 @@ package me.km.entities;
 
 import net.minecraft.client.renderer.entity.model.PlayerModel;
 
-public class ModelHuman extends PlayerModel<EntityHuman>
-{
-    public ModelHuman(float modelSize, boolean smallArmsIn) 
-    {
+public class ModelHuman extends PlayerModel<EntityHuman> {
+    public ModelHuman(float modelSize, boolean smallArmsIn) {
         super(modelSize, smallArmsIn);
     }
 }

+ 5 - 9
src/main/java/me/km/entities/RenderBlackBear.java

@@ -10,25 +10,21 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class RenderBlackBear extends MobRenderer<EntityBlackBear, PolarBearModel<EntityBlackBear>>
-{
+public class RenderBlackBear extends MobRenderer<EntityBlackBear, PolarBearModel<EntityBlackBear>> {
     private static final ResourceLocation BLACK_BEAR_TEXTURE = new ResourceLocation(KajetansMod.MODID, "textures/entity/bear/blackbear.png");
 
-    public RenderBlackBear(EntityRendererManager erm)
-    {
+    public RenderBlackBear(EntityRendererManager erm) {
         super(erm, new PolarBearModel<>(), 0.9F);
     }
 
     @Override
-    public ResourceLocation getEntityTexture(EntityBlackBear entity)
-    {
+    public ResourceLocation getEntityTexture(EntityBlackBear entity) {
         return BLACK_BEAR_TEXTURE;
     }
 
     @Override
-    protected void preRenderCallback(EntityBlackBear ent, MatrixStack mStack, float partialTickTime) 
-    {
+    protected void preRenderCallback(EntityBlackBear ent, MatrixStack mStack, float partialTickTime) {
         mStack.scale(1.2F, 1.2F, 1.2F);
         super.preRenderCallback(ent, mStack, partialTickTime);
     }
-}
+}

+ 5 - 9
src/main/java/me/km/entities/RenderBrownBear.java

@@ -10,25 +10,21 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class RenderBrownBear extends MobRenderer<EntityBrownBear, PolarBearModel<EntityBrownBear>>
-{
+public class RenderBrownBear extends MobRenderer<EntityBrownBear, PolarBearModel<EntityBrownBear>> {
     private static final ResourceLocation BLACK_BEAR_TEXTURE = new ResourceLocation(KajetansMod.MODID, "textures/entity/bear/brownbear.png");
 
-    public RenderBrownBear(EntityRendererManager erm)
-    {
+    public RenderBrownBear(EntityRendererManager erm) {
         super(erm, new PolarBearModel<>(), 0.9F);
     }
 
     @Override
-    public ResourceLocation getEntityTexture(EntityBrownBear entity)
-    {
+    public ResourceLocation getEntityTexture(EntityBrownBear entity) {
         return BLACK_BEAR_TEXTURE;
     }
 
     @Override
-    protected void preRenderCallback(EntityBrownBear ent, MatrixStack mStack, float partialTickTime) 
-    {
+    protected void preRenderCallback(EntityBrownBear ent, MatrixStack mStack, float partialTickTime) {
         mStack.scale(1.2F, 1.2F, 1.2F);
         super.preRenderCallback(ent, mStack, partialTickTime);
     }
-}
+}

+ 33 - 69
src/main/java/me/km/entities/RenderHuman.java

@@ -27,13 +27,11 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman>
-{
+public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman> {
     private final ModelHuman steve;
     private final ModelHuman alex;
-    
-    public RenderHuman(EntityRendererManager renderManager)
-    {
+
+    public RenderHuman(EntityRendererManager renderManager) {
         super(renderManager, new ModelHuman(0.0f, false), 0.5F);
         this.addLayer(new BipedArmorLayer<>(this, new BipedModel(0.5F), new BipedModel(1.0F)));
         this.addLayer(new HeldItemLayer<>(this));
@@ -41,35 +39,29 @@ public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman>
         this.addLayer(new HeadLayer<>(this));
         this.addLayer(new ElytraLayer<>(this));
         this.addLayer(new BeeStingerLayer<>(this));
-        
+
         this.steve = this.getEntityModel();
         this.alex = new ModelHuman(0, true);
     }
 
     @Override
-    public void render(EntityHuman ent, float entityYaw, float partialRenderTick, MatrixStack mStack, IRenderTypeBuffer buffer, int light)
-    {
+    public void render(EntityHuman ent, float entityYaw, float partialRenderTick, MatrixStack mStack, IRenderTypeBuffer buffer, int light) {
         this.setModelVisibilities(ent);
-        if(ent.isSlim())
-        {
+        if(ent.isSlim()) {
             this.entityModel = alex;
             super.render(ent, entityYaw, partialRenderTick, mStack, buffer, light);
             this.entityModel = steve;
-        }
-        else
-        {
+        } else {
             super.render(ent, entityYaw, partialRenderTick, mStack, buffer, light);
         }
     }
 
     @Override
-    public Vec3d getRenderOffset(EntityHuman ent, float p_225627_2_)
-    {
+    public Vec3d getRenderOffset(EntityHuman ent, float p_225627_2_) {
         return ent.isCrouching() ? new Vec3d(0.0D, -0.125D, 0.0D) : super.getRenderOffset(ent, p_225627_2_);
     }
 
-    private void setModelVisibilities(EntityHuman ent)
-    {
+    private void setModelVisibilities(EntityHuman ent) {
         PlayerModel<EntityHuman> m = this.getEntityModel();
         ItemStack mainStack = ent.getHeldItemMainhand();
         ItemStack offStack = ent.getHeldItemOffhand();
@@ -83,58 +75,41 @@ public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman>
         m.isSneak = ent.isCrouching();
         BipedModel.ArmPose mainHand = getArmPose(ent, mainStack, offStack, Hand.MAIN_HAND);
         BipedModel.ArmPose offHand = getArmPose(ent, mainStack, offStack, Hand.OFF_HAND);
-        if(ent.getPrimaryHand() == HandSide.RIGHT)
-        {
+        if(ent.getPrimaryHand() == HandSide.RIGHT) {
             m.rightArmPose = mainHand;
             m.leftArmPose = offHand;
-        }
-        else
-        {
+        } else {
             m.rightArmPose = offHand;
             m.leftArmPose = mainHand;
         }
     }
 
-    private BipedModel.ArmPose getArmPose(EntityHuman ent, ItemStack mainStack, ItemStack offStack, Hand hand)
-    {
+    private BipedModel.ArmPose getArmPose(EntityHuman ent, ItemStack mainStack, ItemStack offStack, Hand hand) {
         BipedModel.ArmPose pose = BipedModel.ArmPose.EMPTY;
         ItemStack itemstack = hand == Hand.MAIN_HAND ? mainStack : offStack;
-        if(!itemstack.isEmpty())
-        {
+        if(!itemstack.isEmpty()) {
             pose = BipedModel.ArmPose.ITEM;
-            if(ent.getItemInUseCount() > 0)
-            {
+            if(ent.getItemInUseCount() > 0) {
                 UseAction useaction = itemstack.getUseAction();
-                if(useaction == UseAction.BLOCK)
-                {
+                if(useaction == UseAction.BLOCK) {
                     pose = BipedModel.ArmPose.BLOCK;
-                }
-                else if(useaction == UseAction.BOW)
-                {
+                } else if(useaction == UseAction.BOW) {
                     pose = BipedModel.ArmPose.BOW_AND_ARROW;
-                }
-                else if(useaction == UseAction.SPEAR)
-                {
+                } else if(useaction == UseAction.SPEAR) {
                     pose = BipedModel.ArmPose.THROW_SPEAR;
-                }
-                else if(useaction == UseAction.CROSSBOW && hand == ent.getActiveHand())
-                {
+                } else if(useaction == UseAction.CROSSBOW && hand == ent.getActiveHand()) {
                     pose = BipedModel.ArmPose.CROSSBOW_CHARGE;
                 }
-            }
-            else
-            {
+            } else {
                 boolean flag3 = mainStack.getItem() == Items.CROSSBOW;
                 boolean flag = CrossbowItem.isCharged(mainStack);
                 boolean flag1 = offStack.getItem() == Items.CROSSBOW;
                 boolean flag2 = CrossbowItem.isCharged(offStack);
-                if(flag3 && flag)
-                {
+                if(flag3 && flag) {
                     pose = BipedModel.ArmPose.CROSSBOW_HOLD;
                 }
 
-                if(flag1 && flag2 && mainStack.getItem().getUseAction(mainStack) == UseAction.NONE)
-                {
+                if(flag1 && flag2 && mainStack.getItem().getUseAction(mainStack) == UseAction.NONE) {
                     pose = BipedModel.ArmPose.CROSSBOW_HOLD;
                 }
             }
@@ -144,30 +119,25 @@ public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman>
     }
 
     @Override
-    public ResourceLocation getEntityTexture(EntityHuman ent)
-    {
+    public ResourceLocation getEntityTexture(EntityHuman ent) {
         return ent.getTexture();
     }
-    
+
     @Override
-    protected void preRenderCallback(EntityHuman ent, MatrixStack mStack, float partialTickTime)
-    {
+    protected void preRenderCallback(EntityHuman ent, MatrixStack mStack, float partialTickTime) {
         mStack.scale(0.9375F, 0.9375F, 0.9375F);
         float factor = ent.getScale();
         mStack.scale(factor, factor, factor);
     }
-    
+
     @Override
-    protected void applyRotations(EntityHuman ent, MatrixStack mStack, float ageInTicks, float rotationYaw, float partialTicks)
-    {
+    protected void applyRotations(EntityHuman ent, MatrixStack mStack, float ageInTicks, float rotationYaw, float partialTicks) {
         float f = ent.getSwimAnimation(partialTicks);
-        if(ent.isElytraFlying())
-        {
+        if(ent.isElytraFlying()) {
             super.applyRotations(ent, mStack, ageInTicks, rotationYaw, partialTicks);
             float f1 = ent.getTicksElytraFlying() + partialTicks;
             float f2 = MathHelper.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
-            if(!ent.isSpinAttacking())
-            {
+            if(!ent.isSpinAttacking()) {
                 mStack.rotate(Vector3f.XP.rotationDegrees(f2 * (-90.0F - ent.rotationPitch)));
             }
 
@@ -175,27 +145,21 @@ public class RenderHuman extends LivingRenderer<EntityHuman, ModelHuman>
             Vec3d vec3d1 = ent.getMotion();
             double d0 = Entity.horizontalMag(vec3d1);
             double d1 = Entity.horizontalMag(vec3d);
-            if(d0 > 0.0D && d1 > 0.0D)
-            {
+            if(d0 > 0.0D && d1 > 0.0D) {
                 double d2 = (vec3d1.x * vec3d.x + vec3d1.z * vec3d.z) / (Math.sqrt(d0) * Math.sqrt(d1));
                 double d3 = vec3d1.x * vec3d.z - vec3d1.z * vec3d.x;
                 mStack.rotate(Vector3f.YP.rotation((float) (Math.signum(d3) * Math.acos(d2))));
             }
-        }
-        else if(f > 0.0F)
-        {
+        } else if(f > 0.0F) {
             super.applyRotations(ent, mStack, ageInTicks, rotationYaw, partialTicks);
             float f3 = ent.isInWater() ? -90.0F - ent.rotationPitch : -90.0F;
             float f4 = MathHelper.lerp(f, 0.0F, f3);
             mStack.rotate(Vector3f.XP.rotationDegrees(f4));
-            if(ent.isActualySwimming())
-            {
+            if(ent.isActualySwimming()) {
                 mStack.translate(0.0D, -1.0D, (double) 0.3F);
             }
-        }
-        else
-        {
+        } else {
             super.applyRotations(ent, mStack, ageInTicks, rotationYaw, partialTicks);
         }
     }
-}
+}

+ 4 - 7
src/main/java/me/km/entities/RenderNobody.java

@@ -7,16 +7,13 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class RenderNobody extends EntityRenderer<EntityNobody>
-{
-    public RenderNobody(EntityRendererManager erm)
-    {
+public class RenderNobody extends EntityRenderer<EntityNobody> {
+    public RenderNobody(EntityRendererManager erm) {
         super(erm);
     }
 
     @Override
-    public ResourceLocation getEntityTexture(EntityNobody entity)
-    {
+    public ResourceLocation getEntityTexture(EntityNobody entity) {
         return null;
     }
-}
+}

+ 9 - 15
src/main/java/me/km/events/CommandEvent.java

@@ -2,35 +2,29 @@ package me.km.events;
 
 import net.minecraft.entity.player.PlayerEntity;
 
-public class CommandEvent
-{
+public class CommandEvent {
     private final PlayerEntity p;
     private final String command;
     private boolean cancel = false;
-    
-    public CommandEvent(PlayerEntity p, String command)
-    {
+
+    public CommandEvent(PlayerEntity p, String command) {
         this.p = p;
         this.command = command;
     }
 
-    public PlayerEntity getPlayer()
-    {
+    public PlayerEntity getPlayer() {
         return p;
     }
-    
-    public String getName()
-    {
+
+    public String getName() {
         return command;
     }
-    
-    public void setCanceled(boolean b)
-    {
+
+    public void setCanceled(boolean b) {
         cancel = b;
     }
 
-    public boolean isCanceled()
-    {
+    public boolean isCanceled() {
         return cancel;
     }
 }

+ 21 - 35
src/main/java/me/km/events/CustomEventCaller.java

@@ -8,72 +8,58 @@ import net.minecraft.server.MinecraftServer;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 import net.minecraftforge.event.TickEvent;
 
-public class CustomEventCaller 
-{
+public class CustomEventCaller {
     private final HashMap<Integer, PlayerMoveData> moveData = new HashMap<>();
-    
+
     private final LinkedList<Integer> removeQueue = new LinkedList<>();
     private final LinkedList<PlayerMoveData> addQueue = new LinkedList<>();
-    
+
     private final MinecraftServer server;
     private final SnuviScheduler scheduler;
-    
-    public CustomEventCaller(MinecraftServer server, SnuviScheduler scheduler)
-    {
+
+    public CustomEventCaller(MinecraftServer server, SnuviScheduler scheduler) {
         this.server = server;
         this.scheduler = scheduler;
     }
 
-    public int registerMoveData(PlayerMoveData data)
-    {
+    public int registerMoveData(PlayerMoveData data) {
         addQueue.add(data);
         return data.getId();
     }
-    
-    public void removeScriptData(Script sc)
-    {
-        moveData.entrySet().forEach(e -> 
-        {
-            if(e.getValue().isSameScript(sc))
-            {
+
+    public void removeScriptData(Script sc) {
+        moveData.entrySet().forEach(e -> {
+            if(e.getValue().isSameScript(sc)) {
                 removeQueue.add(e.getValue().getId());
             }
         });
     }
-    
-    public void removeMoveData(int id)
-    {
+
+    public void removeMoveData(int id) {
         removeQueue.add(id);
     }
-    
+
     @SubscribeEvent
-    public void onServerTick(TickEvent.ServerTickEvent e)
-    {      
-        if(e.phase == TickEvent.Phase.END)
-        {
+    public void onServerTick(TickEvent.ServerTickEvent e) {
+        if(e.phase == TickEvent.Phase.END) {
             scheduler.tick();
-            if(!addQueue.isEmpty())
-            {
+            if(!addQueue.isEmpty()) {
                 addQueue.forEach(data -> moveData.put(data.getId(), data));
                 addQueue.clear();
             }
-            moveData.values().removeIf(data -> 
-            {
-                if(data.tickLiving())
-                {
+            moveData.values().removeIf(data -> {
+                if(data.tickLiving()) {
                     return true;
                 }
-                if(data.tick())
-                {
+                if(data.tick()) {
                     return false;
                 }
                 return server.getPlayerList().getPlayers().stream().anyMatch(p -> data.check(p));
             });
-            if(!removeQueue.isEmpty())
-            {
+            if(!removeQueue.isEmpty()) {
                 removeQueue.forEach(i -> moveData.remove(i));
                 removeQueue.clear();
             }
         }
-    } 
+    }
 }

+ 19 - 30
src/main/java/me/km/events/PlayerMoveData.java

@@ -7,15 +7,14 @@ import me.km.utils.Location;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.world.IWorld;
 
-public class PlayerMoveData 
-{
+public class PlayerMoveData {
     private static int idCounter = 0;
-    
+
     private final Script sc;
     private final int coolDown;
     private int ticks;
     private int livingTime;
-    
+
     private final IWorld w;
     private final double minX;
     private final double minY;
@@ -23,12 +22,11 @@ public class PlayerMoveData
     private final double maxX;
     private final double maxY;
     private final double maxZ;
-    
+
     private final int id = idCounter++;
     private final UUID uuid;
-    
-    public PlayerMoveData(Script sc, Location l1, Location l2, int cooldown, int livingTime, UUID uuid)
-    {
+
+    public PlayerMoveData(Script sc, Location l1, Location l2, int cooldown, int livingTime, UUID uuid) {
         this.sc = sc;
         this.coolDown = cooldown;
         this.ticks = cooldown;
@@ -43,49 +41,40 @@ public class PlayerMoveData
         this.uuid = uuid;
     }
 
-    public int getId() 
-    {
+    public int getId() {
         return id;
     }
-    
-    public boolean isSameScript(Script sc)
-    {
+
+    public boolean isSameScript(Script sc) {
         return this.sc == sc;
     }
-    
-    public boolean tickLiving()
-    {
-        if(livingTime == -1)
-        {
+
+    public boolean tickLiving() {
+        if(livingTime == -1) {
             return false;
         }
         livingTime--;
         return livingTime < 0;
     }
-    
-    public boolean tick()    
-    {
+
+    public boolean tick() {
         ticks--;
-        if(ticks > 0)
-        {
+        if(ticks > 0) {
             return true;
         }
         ticks = coolDown;
         return false;
     }
-    
-    public boolean check(ServerPlayerEntity p)    
-    {
+
+    public boolean check(ServerPlayerEntity p) {
         double posX = p.getPosX();
         double posY = p.getPosY();
         double posZ = p.getPosZ();
-        if(p.world != w || posX < minX || posX > maxX || posZ < minZ || posZ > maxZ || posY < minY || posY > maxY)
-        {
+        if(p.world != w || posX < minX || posX > maxX || posZ < minZ || posZ > maxZ || posY < minY || posY > maxY) {
             return false;
         }
         boolean b = (uuid == null || p.getUniqueID().equals(uuid));
-        if(sc != null && b)
-        {
+        if(sc != null && b) {
             Server.scriptEvents.onPlayerMove(p, id);
         }
         return coolDown == -1 && b;

+ 65 - 124
src/main/java/me/km/inventory/CustomContainer.java

@@ -12,28 +12,23 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.util.text.TextFormatting;
 import net.minecraft.util.text.TranslationTextComponent;
 
-public class CustomContainer extends Container
-{
+public class CustomContainer extends Container {
     private final ModInventory inv;
     private final int numRows;
 
-    public CustomContainer(int id, PlayerInventory pInv, ModInventory inv)
-    {
+    public CustomContainer(int id, PlayerInventory pInv, ModInventory inv) {
         super(null, id);
         // basic stuff
         this.inv = inv;
         this.numRows = inv.getRows();
         inv.openInventory(pInv.player);
         int i = (this.numRows - 4) * 18;
-        
+
         // inventory slots
         int counter = 0;
-        for(int y = 0; y < this.numRows; y++)
-        {
-            for(int x = 0; x < 9; x++)
-            {
-                if(inv.isSlotValid(x, y))
-                {
+        for(int y = 0; y < this.numRows; y++) {
+            for(int x = 0; x < 9; x++) {
+                if(inv.isSlotValid(x, y)) {
                     addSlot(new Slot(inv, counter, 8 + x * 18, 18 + y * 18));
                     counter++;
                 }
@@ -41,40 +36,32 @@ public class CustomContainer extends Container
         }
 
         // plaver inventory slots
-        for(int y = 0; y < 3; y++)
-        {
-            for(int x = 0; x < 9; x++)
-            {
+        for(int y = 0; y < 3; y++) {
+            for(int x = 0; x < 9; x++) {
                 addSlot(new Slot(pInv, x + y * 9 + 9, 8 + x * 18, 103 + y * 18 + i));
             }
         }
 
-        for(int x = 0; x < 9; x++)
-        {
+        for(int x = 0; x < 9; x++) {
             addSlot(new Slot(pInv, x, 8 + x * 18, 161 + i));
         }
     }
 
-    public ModInventory getInventoryBase() 
-    {
+    public ModInventory getInventoryBase() {
         return inv;
     }
-    
-    public boolean onButtonClick(int slot, int dragType, ClickType click, PlayerEntity p)
-    {
+
+    public boolean onButtonClick(int slot, int dragType, ClickType click, PlayerEntity p) {
         return false;
     }
-    
-    public static void openForPlayer(ServerPlayerEntity p, ModInventory inv, String title, Script sc)
-    {
+
+    public static void openForPlayer(ServerPlayerEntity p, ModInventory inv, String title, Script sc) {
         // taken from ServerPlayerEntity.openContainer
-        if(p.isSpectator())
-        {
+        if(p.isSpectator()) {
             p.sendStatusMessage((new TranslationTextComponent("container.spectatorCantOpen")).applyTextStyle(TextFormatting.RED), true);
             return;
         }
-        if(p.openContainer != p.container)
-        {
+        if(p.openContainer != p.container) {
             p.closeScreen();
         }
 
@@ -86,101 +73,76 @@ public class CustomContainer extends Container
     }
 
     @Override
-    public boolean canInteractWith(PlayerEntity p)
-    {
+    public boolean canInteractWith(PlayerEntity p) {
         return this.inv.isUsableByPlayer(p);
     }
 
     @Override
-    public ItemStack transferStackInSlot(PlayerEntity p, int index)
-    {
+    public ItemStack transferStackInSlot(PlayerEntity p, int index) {
         // taken from ChestContainer, changed size
         ItemStack stack = ItemStack.EMPTY;
         Slot slot = this.inventorySlots.get(index);
         int size = inv.getSizeInventory();
-        if(slot != null && slot.getHasStack())
-        {
+        if(slot != null && slot.getHasStack()) {
             ItemStack slotStack = slot.getStack();
             stack = slotStack.copy();
-            if(index < size)
-            {
-                if(!this.mergeItemStack(slotStack, size, this.inventorySlots.size(), true))
-                {
+            if(index < size) {
+                if(!this.mergeItemStack(slotStack, size, this.inventorySlots.size(), true)) {
                     return ItemStack.EMPTY;
                 }
-            }
-            else if(!this.mergeItemStack(slotStack, 0, size, false))
-            {
+            } else if(!this.mergeItemStack(slotStack, 0, size, false)) {
                 return ItemStack.EMPTY;
             }
 
-            if(slotStack.isEmpty())
-            {
+            if(slotStack.isEmpty()) {
                 slot.putStack(ItemStack.EMPTY);
-            }
-            else
-            {
+            } else {
                 slot.onSlotChanged();
             }
         }
         return stack;
     }
-    
+
     @Override
-    public boolean canMergeSlot(ItemStack stack, Slot slot)
-    {
+    public boolean canMergeSlot(ItemStack stack, Slot slot) {
         return inv.getSlotStatus(slot.slotNumber) == 1;
     }
-    
+
     @Override
-    public boolean canDragIntoSlot(Slot slot)
-    {
+    public boolean canDragIntoSlot(Slot slot) {
         return inv.getSlotStatus(slot.slotNumber) == 1;
     }
-    
+
     @Override
-    protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection)
-    {
+    protected boolean mergeItemStack(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) {
         boolean flag = false;
         int i = startIndex;
-        if(reverseDirection)
-        {
+        if(reverseDirection) {
             i = endIndex - 1;
         }
 
-        if(stack.isStackable())
-        {
-            while(!stack.isEmpty())
-            {
-                if(reverseDirection)
-                {
-                    if(i < startIndex)
-                    {
+        if(stack.isStackable()) {
+            while(!stack.isEmpty()) {
+                if(reverseDirection) {
+                    if(i < startIndex) {
                         break;
                     }
-                }
-                else if(i >= endIndex)
-                {
+                } else if(i >= endIndex) {
                     break;
                 }
 
-                if(inv.getSlotStatus(i) == 1)
-                {
+                if(inv.getSlotStatus(i) == 1) {
                     Slot slot = this.inventorySlots.get(i);
                     ItemStack itemstack = slot.getStack();
-                    if(!itemstack.isEmpty() && areItemsAndTagsEqual(stack, itemstack))
-                    {
+                    if(!itemstack.isEmpty() && areItemsAndTagsEqual(stack, itemstack)) {
                         int j = itemstack.getCount() + stack.getCount();
                         int maxSize = Math.min(slot.getSlotStackLimit(), stack.getMaxStackSize());
-                        if(j <= maxSize)
-                        {
+                        if(j <= maxSize) {
                             stack.setCount(0);
                             itemstack.setCount(j);
                             slot.onSlotChanged();
                             flag = true;
-                        }
-                        else if(itemstack.getCount() < maxSize)
-                        {
+                        } else if(itemstack.getCount() < maxSize) {
                             stack.shrink(maxSize - itemstack.getCount());
                             itemstack.setCount(maxSize);
                             slot.onSlotChanged();
@@ -189,54 +151,37 @@ public class CustomContainer extends Container
                     }
                 }
 
-                if(reverseDirection)
-                {
+                if(reverseDirection) {
                     --i;
-                }
-                else
-                {
+                } else {
                     ++i;
                 }
             }
         }
 
-        if(!stack.isEmpty())
-        {
-            if(reverseDirection)
-            {
+        if(!stack.isEmpty()) {
+            if(reverseDirection) {
                 i = endIndex - 1;
-            }
-            else
-            {
+            } else {
                 i = startIndex;
             }
 
-            while(true)
-            {
-                if(reverseDirection)
-                {
-                    if(i < startIndex)
-                    {
+            while(true) {
+                if(reverseDirection) {
+                    if(i < startIndex) {
                         break;
                     }
-                }
-                else if(i >= endIndex)
-                {
+                } else if(i >= endIndex) {
                     break;
                 }
 
-                if(inv.getSlotStatus(i) == 1)
-                {
+                if(inv.getSlotStatus(i) == 1) {
                     Slot slot1 = this.inventorySlots.get(i);
                     ItemStack itemstack1 = slot1.getStack();
-                    if(itemstack1.isEmpty() && slot1.isItemValid(stack))
-                    {
-                        if(stack.getCount() > slot1.getSlotStackLimit())
-                        {
+                    if(itemstack1.isEmpty() && slot1.isItemValid(stack)) {
+                        if(stack.getCount() > slot1.getSlotStackLimit()) {
                             slot1.putStack(stack.split(slot1.getSlotStackLimit()));
-                        }
-                        else
-                        {
+                        } else {
                             slot1.putStack(stack.split(stack.getCount()));
                         }
 
@@ -246,12 +191,9 @@ public class CustomContainer extends Container
                     }
                 }
 
-                if(reverseDirection)
-                {
+                if(reverseDirection) {
                     --i;
-                }
-                else
-                {
+                } else {
                     ++i;
                 }
             }
@@ -259,23 +201,22 @@ public class CustomContainer extends Container
 
         return flag;
     }
-    
+
     @Override
-    public final ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity p) 
-    {
-        if(slotId < 0 || slotId >= inv.getSizeInventory())
-        {
+    public final ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity p) {
+        if(slotId < 0 || slotId >= inv.getSizeInventory()) {
             return super.slotClick(slotId, dragType, clickTypeIn, p);
         }
-        switch(inv.getSlotStatus(slotId))
-        {
-            case 0: return ItemStack.EMPTY;
-            case 1: return super.slotClick(slotId, dragType, clickTypeIn, p);
-            case 2: 
+        switch(inv.getSlotStatus(slotId)) {
+            case 0:
+                return ItemStack.EMPTY;
+            case 1:
+                return super.slotClick(slotId, dragType, clickTypeIn, p);
+            case 2:
             case 3:
                 onButtonClick(slotId, dragType, clickTypeIn, p);
                 return ItemStack.EMPTY;
         }
         return ItemStack.EMPTY;
     }
-}
+}

+ 48 - 95
src/main/java/me/km/inventory/InventoryUtils.java

@@ -4,72 +4,53 @@ import net.minecraft.inventory.IInventory;
 import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 
-public class InventoryUtils
-{       
-    public static int searchInventoryFor(IInventory inv, ItemStack searchfor, boolean useData)
-    {
-        if(searchfor.isEmpty())
-        {
+public class InventoryUtils {
+    public static int searchInventoryFor(IInventory inv, ItemStack searchfor, boolean useData) {
+        if(searchfor.isEmpty()) {
             return 0;
         }
         int counter = 0;
-        if(useData)
-        {
+        if(useData) {
             int size = inv.getSizeInventory();
             ItemStack stack;
-            for(int i = 0; i < size; i++)
-            {
+            for(int i = 0; i < size; i++) {
                 stack = inv.getStackInSlot(i);
-                if(stackEqualExact(stack, searchfor))
-                {
+                if(stackEqualExact(stack, searchfor)) {
                     counter += stack.getCount();
                 }
             }
-        }
-        else
-        {
+        } else {
             int size = inv.getSizeInventory();
             Item item = searchfor.getItem();
             ItemStack stack;
-            for(int i = 0; i < size; i++)
-            {
+            for(int i = 0; i < size; i++) {
                 stack = inv.getStackInSlot(i);
-                if(stack.getItem() == item)
-                {
+                if(stack.getItem() == item) {
                     counter += stack.getCount();
                 }
             }
         }
         return counter;
     }
-    
-    public static int removeFromInventory(IInventory inv, ItemStack remove)
-    {
-        if(remove.isEmpty())
-        {
+
+    public static int removeFromInventory(IInventory inv, ItemStack remove) {
+        if(remove.isEmpty()) {
             return 0;
         }
         ItemStack stack;
         int sub;
         int amount = remove.getCount();
-        for(int i = 0; i < inv.getSizeInventory(); i++)
-        {
+        for(int i = 0; i < inv.getSizeInventory(); i++) {
             stack = inv.getStackInSlot(i);
-            if(stackEqualExact(stack, remove))
-            {
+            if(stackEqualExact(stack, remove)) {
                 sub = stack.getCount();
-                if(amount > sub)
-                {
+                if(amount > sub) {
                     amount -= sub;
                     inv.setInventorySlotContents(i, ItemStack.EMPTY);
-                }
-                else if(amount == sub)
-                {
+                } else if(amount == sub) {
                     inv.setInventorySlotContents(i, ItemStack.EMPTY);
                     return 0;
-                }
-                else
-                {
+                } else {
                     stack.setCount(sub - amount);
                     return 0;
                 }
@@ -77,36 +58,26 @@ public class InventoryUtils
         }
         return amount;
     }
-    
-    public static int addToInventory(IInventory inv, ItemStack add)
-    {    
-        if(add.isEmpty())
-        {
+
+    public static int addToInventory(IInventory inv, ItemStack add) {
+        if(add.isEmpty()) {
             return 0;
-        }
-        else
-        {
-            if(add.isDamaged())
-            {
+        } else {
+            if(add.isDamaged()) {
                 int j = getFirstEmptyStack(inv);
-                if(j >= 0)
-                {
+                if(j >= 0) {
                     inv.setInventorySlotContents(j, add.copy());
                     inv.getStackInSlot(j).setAnimationsToGo(5);
                     return 0;
                 }
                 return add.getCount();
-            }
-            else
-            {
+            } else {
                 ItemStack copy = add.copy();
                 int i;
-                while(true)
-                {
+                while(true) {
                     i = copy.getCount();
                     copy.setCount(storePartialItemStack(inv, copy));
-                    if(copy.isEmpty() || copy.getCount() >= i)
-                    {
+                    if(copy.isEmpty() || copy.getCount() >= i) {
                         break;
                     }
                 }
@@ -114,82 +85,64 @@ public class InventoryUtils
             }
         }
     }
-    
-    private static int storePartialItemStack(IInventory inv, ItemStack add)
-    {
+
+    private static int storePartialItemStack(IInventory inv, ItemStack add) {
         int i = add.getCount();
         int j = storeItemStack(inv, add);
-        if(j == -1)
-        {
+        if(j == -1) {
             j = getFirstEmptyStack(inv);
         }
-        if (j == -1)
-        {
+        if(j == -1) {
             return i;
         }
         ItemStack stack = inv.getStackInSlot(j);
-        if(stack.isEmpty())
-        {
+        if(stack.isEmpty()) {
             stack = add.copy();
             stack.setCount(0);
-            if(add.hasTag())
-            {
+            if(add.hasTag()) {
                 stack.setTag(add.getTag().copy());
             }
             inv.setInventorySlotContents(j, stack);
         }
 
         int k = i;
-        if(i > stack.getMaxStackSize() - stack.getCount())
-        {
+        if(i > stack.getMaxStackSize() - stack.getCount()) {
             k = stack.getMaxStackSize() - stack.getCount();
         }
-        if(k > inv.getInventoryStackLimit() - stack.getCount())
-        {
+        if(k > inv.getInventoryStackLimit() - stack.getCount()) {
             k = inv.getInventoryStackLimit() - stack.getCount();
         }
 
-        if(k == 0)
-        {
+        if(k == 0) {
             return i;
-        }
-        else
-        {
+        } else {
             i -= k;
             stack.grow(k);
             stack.setAnimationsToGo(5);
             return i;
         }
     }
-    
-    private static int storeItemStack(IInventory inv, ItemStack add)
-    {
-        for (int i = 0; i < inv.getSizeInventory(); i++)
-        {
-            if(canMergeStacks(inv, inv.getStackInSlot(i), add))
-            {
+
+    private static int storeItemStack(IInventory inv, ItemStack add) {
+        for(int i = 0; i < inv.getSizeInventory(); i++) {
+            if(canMergeStacks(inv, inv.getStackInSlot(i), add)) {
                 return i;
             }
         }
         return -1;
     }
-    
-    private static boolean canMergeStacks(IInventory inv, ItemStack first, ItemStack sec)
-    {
+
+    private static boolean canMergeStacks(IInventory inv, ItemStack first, ItemStack sec) {
         return !first.isEmpty() && stackEqualExact(first, sec) && first.isStackable() && first.getCount() < first.getMaxStackSize() && first.getCount() < inv.getInventoryStackLimit();
     }
-    
-    public static boolean stackEqualExact(ItemStack first, ItemStack sec)
-    {
+
+    public static boolean stackEqualExact(ItemStack first, ItemStack sec) {
         return first.getItem() == sec.getItem() && ItemStack.areItemStackTagsEqual(first, sec);
     }
-    
-    public static int getFirstEmptyStack(IInventory inv)
-    {
-        for(int i = 0; i < inv.getSizeInventory(); i++)
-        {
-            if(inv.getStackInSlot(i).isEmpty())
-            {
+
+    public static int getFirstEmptyStack(IInventory inv) {
+        for(int i = 0; i < inv.getSizeInventory(); i++) {
+            if(inv.getStackInSlot(i).isEmpty()) {
                 return i;
             }
         }

+ 80 - 115
src/main/java/me/km/inventory/ModInventory.java

@@ -4,17 +4,15 @@ import java.util.Arrays;
 import net.minecraft.inventory.Inventory;
 import net.minecraft.item.ItemStack;
 
-public class ModInventory extends Inventory
-{
+public class ModInventory extends Inventory {
     private static int modIds = 0;
     private final int modId;
     private final int allSlots;
     private final int rows;
     private final byte[] data;
     private final byte[] smallData;
-    
-    public ModInventory(byte[] data, int slots, int allSlots) 
-    {
+
+    public ModInventory(byte[] data, int slots, int allSlots) {
         super(slots);
         this.modId = modIds++;
         this.allSlots = allSlots;
@@ -22,47 +20,38 @@ public class ModInventory extends Inventory
         this.data = data;
         this.smallData = deleteZeros(data);
     }
-    
-    private static int countZeros(String slots)
-    {
+
+    private static int countZeros(String slots) {
         int i = 0;
-        for(char c : slots.toCharArray())
-        {
-            if(c == '0')
-            {
+        for(char c : slots.toCharArray()) {
+            if(c == '0') {
                 i++;
             }
         }
         return i;
     }
-    
-    private static byte[] deleteZeros(byte[] bytes)
-    {
+
+    private static byte[] deleteZeros(byte[] bytes) {
         int size = 0;
-        for(byte b : bytes)
-        {
+        for(byte b : bytes) {
             size += (b & 3) != 0 ? 1 : 0;
             size += (b & 12) != 0 ? 1 : 0;
             size += (b & 48) != 0 ? 1 : 0;
             size += (b & 192) != 0 ? 1 : 0;
         }
         size = (size >> 2) + ((size & 3) != 0 ? 1 : 0);
-        
+
         byte[] b = new byte[size];
         byte current;
         int index = 0;
         int pos = 0;
-        for(int i = 0; i < bytes.length; i++)
-        {
-            for(int j = 0; j < 8; j += 2)
-            {
+        for(int i = 0; i < bytes.length; i++) {
+            for(int j = 0; j < 8; j += 2) {
                 current = (byte) ((bytes[i] >> j) & 3);
-                if(current != 0)
-                {
+                if(current != 0) {
                     b[index] |= current << pos;
                     pos += 2;
-                    if(pos == 8)
-                    {
+                    if(pos == 8) {
                         pos = 0;
                         index++;
                     }
@@ -71,27 +60,23 @@ public class ModInventory extends Inventory
         }
         return b;
     }
-    
-    public ModInventory(String slots) 
-    {
+
+    public ModInventory(String slots) {
         super(Math.min(54, slots.length() - countZeros(slots)));
-        
+
         this.modId = modIds++;
         allSlots = Math.min(54, slots.length());
         this.rows = allSlots / 9 + (allSlots % 9 == 0 ? 0 : 1);
 
         this.data = new byte[14];
-        
+
         int id;
-        for(int i = 0; i < allSlots; i++)
-        {
+        for(int i = 0; i < allSlots; i++) {
             id = Character.getNumericValue(slots.charAt(i));
-            if(id > 3 || id < 0)
-            {
+            if(id > 3 || id < 0) {
                 id = 0;
             }
-            switch(i % 4)
-            {
+            switch(i % 4) {
                 case 0:
                     data[i / 4] += id;
                     break;
@@ -106,12 +91,11 @@ public class ModInventory extends Inventory
                     break;
             }
         }
-        
+
         this.smallData = deleteZeros(data);
     }
-    
-    public ModInventory(int slots) 
-    {
+
+    public ModInventory(int slots) {
         super(Math.max(9, Math.min(54, ((slots / 9) + ((slots % 9) == 0 ? 0 : 1)) * 9)));
         this.modId = modIds++;
         this.allSlots = super.getSizeInventory();
@@ -122,139 +106,120 @@ public class ModInventory extends Inventory
         this.smallData = data;
     }
 
-    public byte[] getData() 
-    {
+    public byte[] getData() {
         return data;
     }
-    
-    public int getRows()
-    {
+
+    public int getRows() {
         return rows;
     }
-    
-    public int getSlotStatus(int slot)
-    {
-        if(slot < 0 || slot >= this.getSizeInventory())
-        {
+
+    public int getSlotStatus(int slot) {
+        if(slot < 0 || slot >= this.getSizeInventory()) {
             return 1;
         }
         int index = Math.max(0, Math.min(smallData.length, slot / 4));
-        switch(slot % 4)
-        {
-            case 0: return smallData[index] & 3;
-            case 1: return (smallData[index] >> 2) & 3;
-            case 2: return (smallData[index] >> 4) & 3;
-            case 3: return (smallData[index] >> 6) & 3;
+        switch(slot % 4) {
+            case 0:
+                return smallData[index] & 3;
+            case 1:
+                return (smallData[index] >> 2) & 3;
+            case 2:
+                return (smallData[index] >> 4) & 3;
+            case 3:
+                return (smallData[index] >> 6) & 3;
         }
         return 0;
     }
-    
-    public int getSlotStatus(int x, int y)
-    {
+
+    public int getSlotStatus(int x, int y) {
         int slot = y * 9 + x;
         int index = Math.max(0, Math.min(13, slot / 4));
-        switch(slot % 4)
-        {
-            case 0: return data[index] & 3;
-            case 1: return (data[index] >> 2) & 3;
-            case 2: return (data[index] >> 4) & 3;
-            case 3: return (data[index] >> 6) & 3;
+        switch(slot % 4) {
+            case 0:
+                return data[index] & 3;
+            case 1:
+                return (data[index] >> 2) & 3;
+            case 2:
+                return (data[index] >> 4) & 3;
+            case 3:
+                return (data[index] >> 6) & 3;
         }
         return 0;
     }
-    
-    public boolean isSlotValid(int x, int y)
-    {
+
+    public boolean isSlotValid(int x, int y) {
         return getSlotStatus(x, y) != 0;
     }
-    
-    public boolean shouldRenderOverlay(int x, int y)
-    {
+
+    public boolean shouldRenderOverlay(int x, int y) {
         int status = getSlotStatus(x, y);
-        return  status == 0 || status == 2; 
+        return status == 0 || status == 2;
     }
-    
-    public boolean shouldRenderDarker(int x, int y)
-    {
-        return  getSlotStatus(x, y) == 3; 
+
+    public boolean shouldRenderDarker(int x, int y) {
+        return getSlotStatus(x, y) == 3;
     }
 
-    public int getModId()
-    {
+    public int getModId() {
         return modId;
     }
-    
+
     @Override
-    public ItemStack addItem(ItemStack stack)
-    {
+    public ItemStack addItem(ItemStack stack) {
         stack = stack.copy();
         this.moveToEqualItemStack(stack);
-        if(stack.isEmpty())
-        {
+        if(stack.isEmpty()) {
             return ItemStack.EMPTY;
-        }
-        else
-        {
+        } else {
             this.moveToEmptySlot(stack);
             return stack.isEmpty() ? ItemStack.EMPTY : stack;
         }
     }
-    
-    private void moveToEqualItemStack(ItemStack stack)
-    {
-        for(int i = 0; i < getSizeInventory(); i++)
-        {
+
+    private void moveToEqualItemStack(ItemStack stack) {
+        for(int i = 0; i < getSizeInventory(); i++) {
             // ignore special fields
-            if(getSlotStatus(i) != 1)
-            {
+            if(getSlotStatus(i) != 1) {
                 continue;
             }
             ItemStack slotStack = getStackInSlot(i);
-            if(ItemStack.areItemsEqual(slotStack, stack))
-            {
+            if(ItemStack.areItemsEqual(slotStack, stack)) {
                 this.mergeItemStacks(stack, slotStack);
-                if(stack.isEmpty())
-                {
+                if(stack.isEmpty()) {
                     return;
                 }
             }
         }
 
     }
-    
-    private void mergeItemStacks(ItemStack stack, ItemStack slotStack)
-    {
+
+    private void mergeItemStacks(ItemStack stack, ItemStack slotStack) {
         int maxSize = Math.min(getInventoryStackLimit(), slotStack.getMaxStackSize());
         int maxMoveable = Math.min(stack.getCount(), maxSize - slotStack.getCount());
-        if(maxMoveable > 0)
-        {
+        if(maxMoveable > 0) {
             slotStack.grow(maxMoveable);
             stack.shrink(maxMoveable);
             markDirty();
         }
     }
-    
-    private void moveToEmptySlot(ItemStack stack)
-    {
-        for(int i = 0; i < getSizeInventory(); i++)
-        {
+
+    private void moveToEmptySlot(ItemStack stack) {
+        for(int i = 0; i < getSizeInventory(); i++) {
             // ignore special fields
-            if(getSlotStatus(i) != 1)
-            {
+            if(getSlotStatus(i) != 1) {
                 continue;
             }
             ItemStack slotStack = getStackInSlot(i);
-            if(slotStack.isEmpty())
-            {
+            if(slotStack.isEmpty()) {
                 setInventorySlotContents(i, stack.copy());
                 stack.setCount(0);
                 return;
             }
         }
     }
-    
-    public int getAllSlots()
-    {
+
+    public int getAllSlots() {
         return allSlots;
     }
 }

+ 9 - 14
src/main/java/me/km/inventory/ServerCustomContainer.java

@@ -8,33 +8,28 @@ import net.minecraft.inventory.container.ClickType;
 import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.StringTextComponent;
 
-public class ServerCustomContainer extends CustomContainer
-{
+public class ServerCustomContainer extends CustomContainer {
     private final Script script;
     private final ITextComponent name;
-    
-    public ServerCustomContainer(int id, PlayerInventory pInv, ModInventory inv, String name, Script sc)
-    {
+
+    public ServerCustomContainer(int id, PlayerInventory pInv, ModInventory inv, String name, Script sc) {
         super(id, pInv, inv);
         this.script = sc;
         this.name = new StringTextComponent(name);
     }
-    
+
     @Override
-    public void onContainerClosed(PlayerEntity p) 
-    {
+    public void onContainerClosed(PlayerEntity p) {
         Server.scriptEvents.onInventoryClose(script, name, getInventoryBase(), p);
         super.onContainerClosed(p);
     }
-    
+
     @Override
-    public boolean onButtonClick(int slot, int dragType, ClickType click, PlayerEntity p)
-    {
+    public boolean onButtonClick(int slot, int dragType, ClickType click, PlayerEntity p) {
         return Server.scriptEvents.onInventoryClick(script, name, getInventoryBase(), slot, click, p);
     }
-    
-    public ITextComponent getName()
-    {
+
+    public ITextComponent getName() {
         return name;
     }
 }

+ 60 - 119
src/main/java/me/km/items/ItemColoredSoup.java

@@ -26,98 +26,81 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemColoredSoup extends ItemFood
-{
-    public ItemColoredSoup() 
-    {
+public class ItemColoredSoup extends ItemFood {
+    public ItemColoredSoup() {
         super(new Properties().group(ItemGroup.FOOD).food(new Food.Builder().build()).maxStackSize(1));
     }
 
     @Override
-    public ItemStack onItemUseFinish(ItemStack stack, World w, LivingEntity liv)
-    {
+    public ItemStack onItemUseFinish(ItemStack stack, World w, LivingEntity liv) {
         super.onItemUseFinish(stack, w, liv);
         return new ItemStack(Items.BOWL);
     }
 
     @Override
-    public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) 
-    {
+    public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
         getTagCompound(stack);
         return null;
-    }  
-    
+    }
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public void addInformation(ItemStack stack, World w, List<ITextComponent> lore, ITooltipFlag flag) 
-    {
+    public void addInformation(ItemStack stack, World w, List<ITextComponent> lore, ITooltipFlag flag) {
         String text = getLocalizedIngredientList(stack);
-        if(!text.isEmpty())
-        {
+        if(!text.isEmpty()) {
             lore.add(new StringTextComponent(text));
         }
     }
-    
-    private static CompoundNBT getTagCompound(ItemStack stack)
-    {
+
+    private static CompoundNBT getTagCompound(ItemStack stack) {
         CompoundNBT com = stack.getTag();
-        if(com == null)
-        {
+        if(com == null) {
             com = new CompoundNBT();
             com.putInt("color", CookingPotColorMixer.DEFAULT.getRGB());
             com.put("ingredients", new ListNBT());
             com.putFloat("saturation", 0.0f);
             com.putInt("food", 0);
             stack.setTag(com);
-        }
-        else
-        {
-            if(!com.contains("color"))
-            {
-                com.putInt("color", CookingPotColorMixer.DEFAULT.getRGB());   
+        } else {
+            if(!com.contains("color")) {
+                com.putInt("color", CookingPotColorMixer.DEFAULT.getRGB());
             }
-            if(!com.contains("ingredients"))
-            {
-                com.put("ingredients", new ListNBT());   
+            if(!com.contains("ingredients")) {
+                com.put("ingredients", new ListNBT());
             }
-            if(!com.contains("saturation"))
-            {
-                com.putFloat("saturation", 0);   
+            if(!com.contains("saturation")) {
+                com.putFloat("saturation", 0);
             }
-            if(!com.contains("food"))
-            {
-                com.putInt("food", 0);   
+            if(!com.contains("food")) {
+                com.putInt("food", 0);
             }
         }
         return com;
     }
-    
+
     @SuppressWarnings(value = "")
-    public static void addIngredient(ItemStack stew, Iterable<ItemStack> stacks)     
-    {
+    public static void addIngredient(ItemStack stew, Iterable<ItemStack> stacks) {
         CompoundNBT com = stew.getTag();
         ListNBT list = com.getList("ingredients", 8);
-        for(ItemStack stack : stacks)
-        {
+        for(ItemStack stack : stacks) {
             list.add(StringNBT.valueOf(stack.getTranslationKey()));
         }
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @SuppressWarnings(value = "")
-    private String getLocalizedIngredientList(ItemStack stack)
-    {
+    private String getLocalizedIngredientList(ItemStack stack) {
         CompoundNBT com = stack.getTag();
         ListNBT list = com.getList("ingredients", 8);
-        switch(list.size())
-        {
-            case 0: return "";
-            case 1: return TextFormatting.GRAY + LanguageMap.getInstance().translateKey(list.getString(0));
+        switch(list.size()) {
+            case 0:
+                return "";
+            case 1:
+                return TextFormatting.GRAY + LanguageMap.getInstance().translateKey(list.getString(0));
             default:
                 StringBuilder sb = new StringBuilder(TextFormatting.GRAY.toString());
                 sb.append(LanguageMap.getInstance().translateKey(list.getString(0)));
-                for(int i = 1; i < list.size(); i++)
-                {
+                for(int i = 1; i < list.size(); i++) {
                     sb.append(", ");
                     sb.append(LanguageMap.getInstance().translateKey(list.getString(i)));
                 }
@@ -125,132 +108,90 @@ public class ItemColoredSoup extends ItemFood
         }
     }
 
-    public static void setColor(ItemStack stack, int color)
-    {
+    public static void setColor(ItemStack stack, int color) {
         getTagCompound(stack).putInt("color", color);
     }
-    
-    public static int getColor(ItemStack stack)
-    {
+
+    public static int getColor(ItemStack stack) {
         return getTagCompound(stack).getInt("color");
     }
-    
-    public static void setFoodStats(ItemStack soup, LinkedList<ItemStack> ingredients)
-    {
+
+    public static void setFoodStats(ItemStack soup, LinkedList<ItemStack> ingredients) {
         float saturation = 0.0f;
         int food = 0;
-        
-        for(ItemStack stack : ingredients)
-        {
+
+        for(ItemStack stack : ingredients) {
             Item item = stack.getItem();
-            if(item == Item.getItemFromBlock(Blocks.PUMPKIN))
-            {
+            if(item == Item.getItemFromBlock(Blocks.PUMPKIN)) {
                 food += 6;
                 saturation += 0.3F;
-            }
-            else if(item == Items.APPLE)
-            {
+            } else if(item == Items.APPLE) {
                 food += 4;
                 saturation += 0.3F;
-            }
-            else if(item == Items.GOLDEN_APPLE)
-            {
+            } else if(item == Items.GOLDEN_APPLE) {
                 food += 4;
                 saturation += 1.2F;
-            }
-            else if(item == Items.BEETROOT_SEEDS || item == Items.MELON_SEEDS || item == Items.PUMPKIN_SEEDS || item == Items.WHEAT_SEEDS)
-            {
+            } else if(item == Items.BEETROOT_SEEDS || item == Items.MELON_SEEDS || item == Items.PUMPKIN_SEEDS || item == Items.WHEAT_SEEDS) {
                 food += 1;
                 saturation += 0.1F;
-            }
-            else if(item == Items.BEEF || item == Items.PORKCHOP)
-            {
+            } else if(item == Items.BEEF || item == Items.PORKCHOP) {
                 food += 8;
                 saturation += 0.8F;
-            }          
-            else if(item == Items.TROPICAL_FISH)
-            {
+            } else if(item == Items.TROPICAL_FISH) {
                 food += 1;
                 saturation += 0.1F;
-            }
-            else if(item == Items.COD)
-            {
+            } else if(item == Items.COD) {
                 food += 5;
                 saturation += 0.6F;
-            }
-            else if(item == Items.PUFFERFISH)
-            {
+            } else if(item == Items.PUFFERFISH) {
                 food -= 75;
                 saturation -= 0.8F;
-            }
-            else if(item == Items.SALMON)
-            {
+            } else if(item == Items.SALMON) {
                 food += 6;
                 saturation += 0.8F;
-            }
-            else if(item == Items.SUGAR)
-            {
+            } else if(item == Items.SUGAR) {
                 food += 1;
                 saturation += 0.1F;
-            }
-            else if(item == Items.MELON_SLICE || item == Items.GLISTERING_MELON_SLICE)
-            {
+            } else if(item == Items.MELON_SLICE || item == Items.GLISTERING_MELON_SLICE) {
                 food += 2;
                 saturation += 0.3F;
-            }
-            else if(item == Items.CHICKEN)
-            {
+            } else if(item == Items.CHICKEN) {
                 food += 6;
                 saturation += 0.6F;
-            }
-            else if(item == Items.POISONOUS_POTATO || item == Items.SPIDER_EYE)
-            {
+            } else if(item == Items.POISONOUS_POTATO || item == Items.SPIDER_EYE) {
                 food += -25;
                 saturation -= 0.2F;
-            }
-            else if(item == Items.RABBIT_FOOT || item == Items.NETHER_WART || item == Items.FERMENTED_SPIDER_EYE)
-            {
+            } else if(item == Items.RABBIT_FOOT || item == Items.NETHER_WART || item == Items.FERMENTED_SPIDER_EYE) {
                 food += 1;
                 saturation += 0.1F;
-            }
-            else if(item == Items.GOLDEN_CARROT || item == Items.CARROT)
-            {
+            } else if(item == Items.GOLDEN_CARROT || item == Items.CARROT) {
                 food += 3;
                 saturation += 0.6F;
-            }
-            else if(item == Items.RABBIT || item == Items.POTATO)
-            {
+            } else if(item == Items.RABBIT || item == Items.POTATO) {
                 food += 5;
                 saturation += 0.6F;
-            }
-            else if(item == Items.MUTTON)
-            {
+            } else if(item == Items.MUTTON) {
                 food += 6;
                 saturation += 0.8F;
-            }
-            else if(item == Items.BEETROOT)
-            {
+            } else if(item == Items.BEETROOT) {
                 food += 1;
                 saturation += 0.6F;
             }
         }
-        
+
         getTagCompound(soup).putFloat("saturation", saturation);
         getTagCompound(soup).putInt("food", food);
     }
 
     @Override
-    public void onFoodEaten(ItemStack stack, World w, LivingEntity liv)
-    {
+    public void onFoodEaten(ItemStack stack, World w, LivingEntity liv) {
         int food = getTagCompound(stack).getInt("food");
-        if(food < 0 && !w.isRemote)
-        {
+        if(food < 0 && !w.isRemote) {
             liv.addPotionEffect(new EffectInstance(Effects.POISON, 100, -food / 25));
             food = 0;
         }
         float saturation = getTagCompound(stack).getFloat("saturation");
-        if(liv instanceof PlayerEntity && !w.isRemote)
-        {
+        if(liv instanceof PlayerEntity && !w.isRemote) {
             ((PlayerEntity) liv).getFoodStats().addStats(food, saturation);
         }
     }

+ 5 - 9
src/main/java/me/km/items/ItemCylinder.java

@@ -12,19 +12,15 @@ import net.minecraft.item.ItemStack;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemCylinder extends ArmorItem
-{
-    public ItemCylinder(IArmorMaterial am, Item.Properties builder) 
-    {
+public class ItemCylinder extends ArmorItem {
+    public ItemCylinder(IArmorMaterial am, Item.Properties builder) {
         super(am, EquipmentSlotType.HEAD, builder.group(ItemGroup.COMBAT));
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel normal)
-    {
-        if(slot != EquipmentSlotType.HEAD)
-        {
+    public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel normal) {
+        if(slot != EquipmentSlotType.HEAD) {
             return normal;
         }
         return Client.CYLINDER;

+ 5 - 9
src/main/java/me/km/items/ItemFood.java

@@ -5,23 +5,19 @@ import net.minecraft.item.Item;
 import net.minecraft.item.ItemStack;
 import net.minecraft.world.World;
 
-public abstract class ItemFood extends Item
-{
-    public ItemFood(Properties properties)
-    {
+public abstract class ItemFood extends Item {
+    public ItemFood(Properties properties) {
         super(properties);
     }
 
     @Override
-    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity liv)
-    {
-        if(this.isFood())
-        {
+    public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity liv) {
+        if(this.isFood()) {
             onFoodEaten(stack, worldIn, liv);
             return liv.onFoodEaten(worldIn, stack);
         }
         return stack;
     }
-    
+
     public abstract void onFoodEaten(ItemStack stack, World worldIn, LivingEntity liv);
 }

+ 14 - 24
src/main/java/me/km/items/ItemGemStone.java

@@ -6,46 +6,36 @@ import net.minecraft.item.ItemStack;
 import net.minecraft.nbt.CompoundNBT;
 import net.minecraftforge.common.capabilities.ICapabilityProvider;
 
-public class ItemGemStone extends Item
-{
-    public ItemGemStone() 
-    {
+public class ItemGemStone extends Item {
+    public ItemGemStone() {
         super(new Properties().group(ItemGroup.MATERIALS));
     }
 
     @Override
-    public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) 
-    {
+    public ICapabilityProvider initCapabilities(ItemStack stack, CompoundNBT nbt) {
         getTagCompound(stack);
         return null;
-    }  
-    
-    private CompoundNBT getTagCompound(ItemStack stack)
-    {
+    }
+
+    private CompoundNBT getTagCompound(ItemStack stack) {
         CompoundNBT com = stack.getTag();
-        if(com == null)
-        {
+        if(com == null) {
             com = new CompoundNBT();
             com.putInt("color", 0xFFFFFF);
             stack.setTag(com);
-        }
-        else
-        {
-            if(!com.contains("color"))
-            {
-                com.putInt("color", 0xFFFFFF);   
+        } else {
+            if(!com.contains("color")) {
+                com.putInt("color", 0xFFFFFF);
             }
         }
         return com;
     }
-    
-    public void setColor(ItemStack stack, int color)
-    {
+
+    public void setColor(ItemStack stack, int color) {
         getTagCompound(stack).putInt("color", color);
     }
-    
-    public int getColor(ItemStack stack)
-    {
+
+    public int getColor(ItemStack stack) {
         return getTagCompound(stack).getInt("color");
     }
 }

+ 5 - 9
src/main/java/me/km/items/ItemHat.java

@@ -12,19 +12,15 @@ import net.minecraft.item.ItemStack;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemHat extends ArmorItem
-{
-    public ItemHat(IArmorMaterial am, Item.Properties builder) 
-    {
+public class ItemHat extends ArmorItem {
+    public ItemHat(IArmorMaterial am, Item.Properties builder) {
         super(am, EquipmentSlotType.HEAD, builder.group(ItemGroup.COMBAT));
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel normal)
-    {
-        if(slot != EquipmentSlotType.HEAD)
-        {
+    public BipedModel getArmorModel(LivingEntity entityLiving, ItemStack itemStack, EquipmentSlotType armorSlot, BipedModel normal) {
+        if(slot != EquipmentSlotType.HEAD) {
             return normal;
         }
         return Client.STRAW_HAT;

+ 9 - 16
src/main/java/me/km/items/ItemKey.java

@@ -12,31 +12,24 @@ import net.minecraft.world.World;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemKey extends Item
-{
+public class ItemKey extends Item {
     private final IItemTier it;
-    
-    public ItemKey(IItemTier it)
-    {
+
+    public ItemKey(IItemTier it) {
         super(new Item.Properties().group(ItemGroup.MISC).maxStackSize(1));
         this.it = it;
     }
-    
-    public int getLockPickResistance()
-    {
+
+    public int getLockPickResistance() {
         return it.getHarvestLevel() + 1;
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public void addInformation(ItemStack stack, World w, List<ITextComponent> lore, ITooltipFlag flag)
-    {
-        if(stack.hasDisplayName())
-        {
+    public void addInformation(ItemStack stack, World w, List<ITextComponent> lore, ITooltipFlag flag) {
+        if(stack.hasDisplayName()) {
             lore.get(0).applyTextStyle(TextFormatting.GREEN);
-        }
-        else
-        {
+        } else {
             lore.get(0).applyTextStyle(TextFormatting.RED);
         }
     }

+ 4 - 7
src/main/java/me/km/items/ItemNoGlintLingeringPotion.java

@@ -7,17 +7,14 @@ import net.minecraft.item.ItemStack;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemNoGlintLingeringPotion extends LingeringPotionItem
-{
-    public ItemNoGlintLingeringPotion()
-    {
+public class ItemNoGlintLingeringPotion extends LingeringPotionItem {
+    public ItemNoGlintLingeringPotion() {
         super(new Item.Properties().maxStackSize(16).group(ItemGroup.BREWING));
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public boolean hasEffect(ItemStack stack)
-    {
+    public boolean hasEffect(ItemStack stack) {
         return stack.isEnchanted();
     }
 }

+ 4 - 7
src/main/java/me/km/items/ItemNoGlintPotion.java

@@ -7,17 +7,14 @@ import net.minecraft.item.ItemStack;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemNoGlintPotion extends PotionItem
-{
-    public ItemNoGlintPotion()
-    {
+public class ItemNoGlintPotion extends PotionItem {
+    public ItemNoGlintPotion() {
         super(new Item.Properties().maxStackSize(16).group(ItemGroup.BREWING));
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public boolean hasEffect(ItemStack stack)
-    {
+    public boolean hasEffect(ItemStack stack) {
         return stack.isEnchanted();
     }
 }

+ 4 - 7
src/main/java/me/km/items/ItemNoGlintSplashPotion.java

@@ -7,17 +7,14 @@ import net.minecraft.item.ItemStack;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public class ItemNoGlintSplashPotion extends SplashPotionItem
-{
-    public ItemNoGlintSplashPotion()
-    {
+public class ItemNoGlintSplashPotion extends SplashPotionItem {
+    public ItemNoGlintSplashPotion() {
         super(new Item.Properties().maxStackSize(16).group(ItemGroup.BREWING));
     }
-    
+
     @OnlyIn(Dist.CLIENT)
     @Override
-    public boolean hasEffect(ItemStack stack)
-    {
+    public boolean hasEffect(ItemStack stack) {
         return stack.isEnchanted();
     }
 }

+ 34 - 62
src/main/java/me/km/items/ItemSling.java

@@ -18,95 +18,72 @@ import net.minecraft.util.SoundCategory;
 import net.minecraft.util.SoundEvents;
 import net.minecraft.world.World;
 
-public class ItemSling extends Item
-{
-    public ItemSling(int maxDamage) 
-    {
+public class ItemSling extends Item {
+    public ItemSling(int maxDamage) {
         super(new Properties().defaultMaxDamage(maxDamage).group(ItemGroup.COMBAT));
-        
-        this.addPropertyOverride(new ResourceLocation("pull"), (stack, w, ent) -> 
-        {
-            if(ent == null)
-            {
+
+        this.addPropertyOverride(new ResourceLocation("pull"), (stack, w, ent) -> {
+            if(ent == null) {
                 return 0.0f;
-            }
-            else
-            {
+            } else {
                 return ent.getActiveItemStack().getItem() != ModItems.sling ? 0.0f : (stack.getUseDuration() - ent.getItemInUseCount()) / 20.0F;
             }
         });
         this.addPropertyOverride(new ResourceLocation("pulling"), (stack, w, ent) -> ent != null && ent.isHandActive() && ent.getActiveItemStack() == stack ? 1.0f : 0.0f);
     }
-    
-    private ItemStack findAmmo(PlayerEntity p)
-    {
-        if(this.isAmmo(p.getHeldItem(Hand.OFF_HAND)))
-        {
+
+    private ItemStack findAmmo(PlayerEntity p) {
+        if(this.isAmmo(p.getHeldItem(Hand.OFF_HAND))) {
             return p.getHeldItem(Hand.OFF_HAND);
-        }
-        else if(this.isAmmo(p.getHeldItem(Hand.MAIN_HAND)))
-        {
+        } else if(this.isAmmo(p.getHeldItem(Hand.MAIN_HAND))) {
             return p.getHeldItem(Hand.MAIN_HAND);
-        }
-        else
-        {
-            for(int i = 0; i < p.inventory.getSizeInventory(); i++)
-            {
+        } else {
+            for(int i = 0; i < p.inventory.getSizeInventory(); i++) {
                 ItemStack stack = p.inventory.getStackInSlot(i);
-                if(this.isAmmo(stack))
-                {
+                if(this.isAmmo(stack)) {
                     return stack;
                 }
             }
             return ItemStack.EMPTY;
         }
     }
-    
-    private boolean isAmmo(ItemStack stack)
-    {
+
+    private boolean isAmmo(ItemStack stack) {
         return stack.getItem() == Item.getItemFromBlock(Blocks.COBBLESTONE);
     }
 
     @Override
-    public void onPlayerStoppedUsing(ItemStack stack, World w, LivingEntity liv, int timeLeft) 
-    {
-        if(liv instanceof PlayerEntity)
-        {
+    public void onPlayerStoppedUsing(ItemStack stack, World w, LivingEntity liv, int timeLeft) {
+        if(liv instanceof PlayerEntity) {
             int i = this.getUseDuration(stack) - timeLeft;
-            if(i < 0)
-            {
+            if(i < 0) {
                 return;
             }
-            
+
             PlayerEntity p = (PlayerEntity) liv;
             ItemStack ammo = this.findAmmo(p);
 
-            if(!ammo.isEmpty() || p.abilities.isCreativeMode)
-            {
-                if(ammo.isEmpty())
-                {
+            if(!ammo.isEmpty() || p.abilities.isCreativeMode) {
+                if(ammo.isEmpty()) {
                     ammo = new ItemStack(Blocks.COBBLESTONE);
                 }
 
                 float f = BowItem.getArrowVelocity(i);
-                if(f >= 0.1)
-                {
-                    if(!w.isRemote)
-                    {
+                if(f >= 0.1) {
+                    if(!w.isRemote) {
                         ItemStack ammoCopy = ammo.copy();
                         ammoCopy.setCount(1);
                         EntityItemProjectile proj = new EntityItemProjectile(p, ammoCopy, 2.0f);
                         proj.setHeadingFromThrower(p, p.rotationPitch, p.rotationYaw, 0.0f, f, 1.0f);
-                        stack.damageItem(1, p, (c) -> {});
+                        stack.damageItem(1, p, (c) -> {
+                        });
                         w.addEntity(proj);
                     }
 
                     w.playSound(null, p.getPosX(), p.getPosY(), p.getPosZ(), SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.PLAYERS, 1.0f, 1.0f / (random.nextFloat() * 0.4f + 1.2f) + f * 0.5f);
-                    if(!p.abilities.isCreativeMode)
-                    {
+                    if(!p.abilities.isCreativeMode) {
                         ammo.shrink(1);
-                        if(ammo.isEmpty())
-                        {
+                        if(ammo.isEmpty()) {
                             p.inventory.deleteStack(ammo);
                         }
                     }
@@ -118,32 +95,27 @@ public class ItemSling extends Item
     }
 
     @Override
-    public int getUseDuration(ItemStack stack)
-    {
+    public int getUseDuration(ItemStack stack) {
         return 72000;
     }
 
     @Override
-    public UseAction getUseAction(ItemStack stack)
-    {
+    public UseAction getUseAction(ItemStack stack) {
         return UseAction.BOW;
     }
 
     @Override
-    public ActionResult<ItemStack> onItemRightClick(World w, PlayerEntity p, Hand hand)
-    {
+    public ActionResult<ItemStack> onItemRightClick(World w, PlayerEntity p, Hand hand) {
         ItemStack ammo = p.getHeldItem(hand);
-        if(!p.abilities.isCreativeMode && this.findAmmo(p).isEmpty())
-        {
+        if(!p.abilities.isCreativeMode && this.findAmmo(p).isEmpty()) {
             return new ActionResult<>(ActionResultType.FAIL, ammo);
         }
         p.setActiveHand(hand);
         return new ActionResult<>(ActionResultType.SUCCESS, ammo);
-    } 
+    }
 
     @Override
-    public int getItemEnchantability()
-    {
+    public int getItemEnchantability() {
         return 1;
     }
-}
+}

+ 17 - 27
src/main/java/me/km/items/ModArmorMaterial.java

@@ -11,19 +11,17 @@ import net.minecraft.util.SoundEvents;
 import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
-public enum ModArmorMaterial implements IArmorMaterial
-{
-    COPPER("km:copper", 9, new int[] {1, 4, 5, 1}, 20, SoundEvents.ITEM_ARMOR_EQUIP_CHAIN, 0.0f, () -> Ingredient.fromItems(ModItems.copperIngot)),
-    BRONZE("km:bronze", 13, new int[] {2, 5, 6, 2}, 3, SoundEvents.ITEM_ARMOR_EQUIP_CHAIN, 0.0f, () -> Ingredient.fromItems(ModItems.bronzeIngot)),
-    STRAW("km:straw", 3, new int[] {1, 1, 1, 1}, 3, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0f, () -> Ingredient.fromItems(Items.WHEAT)),
-    CYLINDER("km:cylinder", 3, new int[] {1, 1, 1, 1}, 3, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0f, () -> Ingredient.fromItems(Items.STRING)),
-    SILK("km:silk", 3, new int[] {1, 1, 1, 1}, 3, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0f, () -> Ingredient.fromItems(Items.STRING));
+public enum ModArmorMaterial implements IArmorMaterial {
+    COPPER("km:copper", 9, new int[]{1, 4, 5, 1}, 20, SoundEvents.ITEM_ARMOR_EQUIP_CHAIN, 0.0f, () -> Ingredient.fromItems(ModItems.copperIngot)),
+    BRONZE("km:bronze", 13, new int[]{2, 5, 6, 2}, 3, SoundEvents.ITEM_ARMOR_EQUIP_CHAIN, 0.0f, () -> Ingredient.fromItems(ModItems.bronzeIngot)),
+    STRAW("km:straw", 3, new int[]{1, 1, 1, 1}, 3, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0f, () -> Ingredient.fromItems(Items.WHEAT)),
+    CYLINDER("km:cylinder", 3, new int[]{1, 1, 1, 1}, 3, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0f, () -> Ingredient.fromItems(Items.STRING)),
+    SILK("km:silk", 3, new int[]{1, 1, 1, 1}, 3, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, 0.0f, () -> Ingredient.fromItems(Items.STRING));
 
-    private static final int[] MAX_DAMAGE_ARRAY = new int[]
-    {
+    private static final int[] MAX_DAMAGE_ARRAY = new int[]{
         13, 15, 16, 11
     };
-    
+
     private final String name;
     private final int maxDamageFactor;
     private final int[] damageReductionAmountArray;
@@ -32,8 +30,7 @@ public enum ModArmorMaterial implements IArmorMaterial
     private final float toughness;
     private final LazyValue<Ingredient> repairMaterial;
 
-    private ModArmorMaterial(String name, int maxDamageFactor, int[] damageReduction, int enchantability, SoundEvent se, float toughness, Supplier<Ingredient> repairMaterial)
-    {
+    private ModArmorMaterial(String name, int maxDamageFactor, int[] damageReduction, int enchantability, SoundEvent se, float toughness, Supplier<Ingredient> repairMaterial) {
         this.name = name;
         this.maxDamageFactor = maxDamageFactor;
         this.damageReductionAmountArray = damageReduction;
@@ -44,45 +41,38 @@ public enum ModArmorMaterial implements IArmorMaterial
     }
 
     @Override
-    public int getDurability(EquipmentSlotType slotIn)
-    {
+    public int getDurability(EquipmentSlotType slotIn) {
         return MAX_DAMAGE_ARRAY[slotIn.getIndex()] * this.maxDamageFactor;
     }
 
     @Override
-    public int getDamageReductionAmount(EquipmentSlotType slotIn)
-    {
+    public int getDamageReductionAmount(EquipmentSlotType slotIn) {
         return this.damageReductionAmountArray[slotIn.getIndex()];
     }
 
     @Override
-    public int getEnchantability()
-    {
+    public int getEnchantability() {
         return this.enchantability;
     }
 
     @Override
-    public SoundEvent getSoundEvent()
-    {
+    public SoundEvent getSoundEvent() {
         return this.soundEvent;
     }
 
     @Override
-    public Ingredient getRepairMaterial()
-    {
+    public Ingredient getRepairMaterial() {
         return this.repairMaterial.getValue();
     }
 
     @OnlyIn(Dist.CLIENT)
     @Override
-    public String getName()
-    {
+    public String getName() {
         return this.name;
     }
 
     @Override
-    public float getToughness()
-    {
+    public float getToughness() {
         return this.toughness;
     }
-}
+}

+ 2 - 4
src/main/java/me/km/items/ModItemAxe.java

@@ -5,10 +5,8 @@ import net.minecraft.item.Item;
 import net.minecraft.item.AxeItem;
 
 // this class just exists because the AxeItem constructor is protected
-public class ModItemAxe extends AxeItem
-{
-    public ModItemAxe(IItemTier tier, int attackDamageIn, float attackSpeedIn, Item.Properties builder)
-    {
+public class ModItemAxe extends AxeItem {
+    public ModItemAxe(IItemTier tier, int attackDamageIn, float attackSpeedIn, Item.Properties builder) {
         super(tier, attackDamageIn, attackSpeedIn, builder);
     }
 }

+ 2 - 4
src/main/java/me/km/items/ModItemPickaxe.java

@@ -4,10 +4,8 @@ import net.minecraft.item.IItemTier;
 import net.minecraft.item.PickaxeItem;
 
 // this class just exists because the PickaxeItem constructor is protected
-public class ModItemPickaxe extends PickaxeItem
-{
-    public ModItemPickaxe(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder)
-    {
+public class ModItemPickaxe extends PickaxeItem {
+    public ModItemPickaxe(IItemTier tier, int attackDamageIn, float attackSpeedIn, Properties builder) {
         super(tier, attackDamageIn, attackSpeedIn, builder);
     }
 }

+ 13 - 21
src/main/java/me/km/items/ModItemTier.java

@@ -6,13 +6,12 @@ import net.minecraft.item.IItemTier;
 import net.minecraft.item.crafting.Ingredient;
 import net.minecraft.util.LazyValue;
 
-public enum ModItemTier implements IItemTier
-{
-    COPPER(1, 161, 6.0f, 1.0f, 18, () -> Ingredient.fromItems(ModItems.copperIngot)), 
-    BRONZE(2, 208, 7.0f, 1.5f, 15, () -> Ingredient.fromItems(ModItems.bronzeIngot)), 
-    REDSTONE(0, 59, 1.0f, 0.0f, 22, () -> Ingredient.fromItems(Items.REDSTONE)), 
-    SILVER(2, 250, 5.0f, 2.0f, 20, () -> Ingredient.fromItems(ModItems.silverIngot)), 
-    EMERALD(0, 1248, 7.0f, 2.5f, 10, () -> Ingredient.fromItems(Items.EMERALD)), 
+public enum ModItemTier implements IItemTier {
+    COPPER(1, 161, 6.0f, 1.0f, 18, () -> Ingredient.fromItems(ModItems.copperIngot)),
+    BRONZE(2, 208, 7.0f, 1.5f, 15, () -> Ingredient.fromItems(ModItems.bronzeIngot)),
+    REDSTONE(0, 59, 1.0f, 0.0f, 22, () -> Ingredient.fromItems(Items.REDSTONE)),
+    SILVER(2, 250, 5.0f, 2.0f, 20, () -> Ingredient.fromItems(ModItems.silverIngot)),
+    EMERALD(0, 1248, 7.0f, 2.5f, 10, () -> Ingredient.fromItems(Items.EMERALD)),
     LAPIS(0, 131, 4.0f, 1.0f, 15, () -> Ingredient.fromItems(Items.LAPIS_LAZULI));
 
     private final int harvestLevel;
@@ -22,8 +21,7 @@ public enum ModItemTier implements IItemTier
     private final int enchantability;
     private final LazyValue<Ingredient> repairMaterial;
 
-    private ModItemTier(int harvestLevelIn, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier<Ingredient> repairMaterialIn)
-    {
+    private ModItemTier(int harvestLevelIn, int maxUsesIn, float efficiencyIn, float attackDamageIn, int enchantabilityIn, Supplier<Ingredient> repairMaterialIn) {
         this.harvestLevel = harvestLevelIn;
         this.maxUses = maxUsesIn;
         this.efficiency = efficiencyIn;
@@ -33,38 +31,32 @@ public enum ModItemTier implements IItemTier
     }
 
     @Override
-    public int getMaxUses()
-    {
+    public int getMaxUses() {
         return this.maxUses;
     }
 
     @Override
-    public float getEfficiency()
-    {
+    public float getEfficiency() {
         return this.efficiency;
     }
 
     @Override
-    public float getAttackDamage()
-    {
+    public float getAttackDamage() {
         return this.attackDamage;
     }
 
     @Override
-    public int getHarvestLevel()
-    {
+    public int getHarvestLevel() {
         return this.harvestLevel;
     }
 
     @Override
-    public int getEnchantability()
-    {
+    public int getEnchantability() {
         return this.enchantability;
     }
 
     @Override
-    public Ingredient getRepairMaterial()
-    {
+    public Ingredient getRepairMaterial() {
         return this.repairMaterial.getValue();
     }
 }

+ 99 - 124
src/main/java/me/km/items/ModItems.java

@@ -1,7 +1,6 @@
 package me.km.items;
 
 import me.km.blocks.ModBlocks;
-import net.minecraft.fluid.FlowingFluid;
 import net.minecraft.item.Items;
 import net.minecraft.inventory.EquipmentSlotType;
 import net.minecraft.item.IArmorMaterial;
@@ -10,7 +9,6 @@ import net.minecraft.item.Item;
 import net.minecraft.item.Item.Properties;
 import net.minecraft.item.ArmorItem;
 import net.minecraft.item.BedItem;
-import net.minecraft.item.BucketItem;
 import net.minecraft.item.Food;
 import net.minecraft.item.ItemGroup;
 import net.minecraft.item.HoeItem;
@@ -23,54 +21,53 @@ import net.minecraft.potion.EffectInstance;
 import net.minecraft.potion.Effects;
 import net.minecraftforge.registries.IForgeRegistry;
 
-public class ModItems 
-{
+public class ModItems {
     // nuggets and ingots
     public static Item copperIngot;
     public static Item copperNugget;
-    
+
     public static Item tinIngot;
     public static Item tinNugget;
-    
+
     public static Item bronzeIngot;
     public static Item bronzeNugget;
-    
+
     public static Item silverIngot;
     public static Item silverNugget;
-    
+
     // tools and swords
     public static Item copperSword;
     public static Item copperShovel;
     public static Item copperPickaxe;
     public static Item copperAxe;
     public static Item copperHoe;
-    
+
     public static Item bronzeSword;
     public static Item bronzeShovel;
     public static Item bronzePickaxe;
     public static Item bronzeAxe;
     public static Item bronzeHoe;
-    
+
     public static Item sling;
-    
+
     // armor
     public static Item copperHelmet;
     public static Item copperChestplate;
     public static Item copperLeggings;
     public static Item copperBoots;
-    
+
     public static Item bronzeHelmet;
     public static Item bronzeChestplate;
     public static Item bronzeLeggings;
     public static Item bronzeBoots;
-    
+
     public static Item cylinder;
     public static Item suitChestplate;
     public static Item suitLeggings;
     public static Item suitBoots;
-    
+
     public static Item strawHat;
-    
+
     // sticks
     public static Item woodenStick;
     public static Item stoneStick;
@@ -79,7 +76,7 @@ public class ModItems
     public static Item ironStick;
     public static Item goldStick;
     public static Item diamondStick;
-    
+
     // scepters
     public static Item woodenScepter;
     public static Item stoneScepter;
@@ -88,7 +85,7 @@ public class ModItems
     public static Item ironScepter;
     public static Item goldScepter;
     public static Item diamondScepter;
-    
+
     // dagger
     public static Item woodenDagger;
     public static Item stoneDagger;
@@ -97,7 +94,7 @@ public class ModItems
     public static Item ironDagger;
     public static Item goldDagger;
     public static Item diamondDagger;
-    
+
     // hammer
     public static Item woodenHammer;
     public static Item stoneHammer;
@@ -105,8 +102,8 @@ public class ModItems
     public static Item bronzeHammer;
     public static Item ironHammer;
     public static Item goldHammer;
-    public static Item diamondHammer;   
-    
+    public static Item diamondHammer;
+
     // battle axe
     public static Item woodenBattleAxe;
     public static Item stoneBattleAxe;
@@ -115,27 +112,27 @@ public class ModItems
     public static Item ironBattleAxe;
     public static Item goldBattleAxe;
     public static Item diamondBattleAxe;
-    
+
     // key
     public static Item silverKey;
     public static Item copperKey;
     public static Item bronzeKey;
     public static Item ironKey;
     public static Item goldKey;
-    
+
     // coins
     public static Item copperCoin;
     public static Item silverCoin;
     public static Item goldCoin;
-    
+
     // misc
-    public static Item realHayBed; 
-    public static Item hayBundle; 
-    public static Item batWing; 
-    public static Item wolfFur; 
-    public static Item bearBrownFur; 
-    public static Item bearBlackFur; 
-    public static Item bearPolarFur; 
+    public static Item realHayBed;
+    public static Item hayBundle;
+    public static Item batWing;
+    public static Item wolfFur;
+    public static Item bearBrownFur;
+    public static Item bearBlackFur;
+    public static Item bearPolarFur;
     public static Item cloth;
     public static Item coarseCloth;
     public static Item gemStone;
@@ -144,7 +141,7 @@ public class ModItems
     public static Item scroll;
     public static Item soulStone;
     public static Item piercingStone;
-    
+
     // food
     public static Item coloredSoup;
     public static Item apricot;
@@ -153,7 +150,7 @@ public class ModItems
     public static Item mushroomStickCooked;
     public static Item pear;
     public static Item plum;
-    
+
     // icons
     public static Item arrowDown;
     public static Item arrowLeft;
@@ -170,7 +167,7 @@ public class ModItems
     public static Item returnGreen;
     public static Item returnRed;
     public static Item gear;
-    
+
     // herbs
     public static Item herbStrong;
     public static Item herbShadow;
@@ -179,135 +176,119 @@ public class ModItems
     public static Item herbGold;
     public static Item herbBreathing;
     public static Item herbFire;
-    
-    private static Item newSword(IItemTier tier)
-    {
+
+    private static Item newSword(IItemTier tier) {
         return new SwordItem(tier, 3, -2.4f, (new Item.Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newShovel(IItemTier tier)
-    {
+
+    private static Item newShovel(IItemTier tier) {
         return new ShovelItem(tier, 1.5f, -3.0f, (new Item.Properties()).group(ItemGroup.TOOLS));
     }
-    
-    private static Item newPickaxe(IItemTier tier)
-    {
+
+    private static Item newPickaxe(IItemTier tier) {
         return new ModItemPickaxe(tier, 1, -2.8f, (new Item.Properties()).group(ItemGroup.TOOLS));
     }
-    
-    private static Item newAxe(IItemTier tier, int attackDamageIn, float attackSpeedIn)
-    {
+
+    private static Item newAxe(IItemTier tier, int attackDamageIn, float attackSpeedIn) {
         return new ModItemAxe(tier, attackDamageIn, attackSpeedIn, (new Item.Properties()).group(ItemGroup.TOOLS));
     }
-    
-    private static Item newHoe(IItemTier tier, float speed)
-    {
+
+    private static Item newHoe(IItemTier tier, float speed) {
         return new HoeItem(tier, speed, (new Item.Properties()).group(ItemGroup.TOOLS));
     }
-    
-    private static Item newStick(IItemTier tier)
-    {
+
+    private static Item newStick(IItemTier tier) {
         return new SwordItem(tier, 0, -2.3f, (new Item.Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newScepter(IItemTier tier)
-    {
+
+    private static Item newScepter(IItemTier tier) {
         return new SwordItem(tier, 1, -2.6f, (new Item.Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newHammer(IItemTier tier)
-    {
+
+    private static Item newHammer(IItemTier tier) {
         return new SwordItem(tier, 4, -3.0f, (new Item.Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newDagger(IItemTier tier)
-    {
+
+    private static Item newDagger(IItemTier tier) {
         return new SwordItem(tier, 1, -2.2f, (new Item.Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newBattleAxe(IItemTier tier)
-    {
+
+    private static Item newBattleAxe(IItemTier tier) {
         return new SwordItem(tier, 5, -3.0f, (new Item.Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newArmor(IArmorMaterial am, EquipmentSlotType slot)
-    {
+
+    private static Item newArmor(IArmorMaterial am, EquipmentSlotType slot) {
         return new ArmorItem(am, slot, (new Properties()).group(ItemGroup.COMBAT));
     }
-    
-    private static Item newItem(ItemGroup group)
-    {
+
+    private static Item newItem(ItemGroup group) {
         return new Item(new Properties().group(group));
     }
-    
-    private static Item newHerb()
-    {
+
+    private static Item newHerb() {
         return new Item(new Properties().group(ItemGroup.FOOD).food(
                 new Food.Builder().setAlwaysEdible().fastToEat().build()));
     }
-    
-    private static Item newEffectHerb(Effect effect, int duration, int amplifier)
-    {
+
+    private static Item newEffectHerb(Effect effect, int duration, int amplifier) {
         return new Item(new Properties().group(ItemGroup.FOOD).food(
                 new Food.Builder().setAlwaysEdible().fastToEat()
                         .effect(new EffectInstance(effect, duration, amplifier), 1.0f)
                         .build()));
     }
-    
-    private static Item newFood(int food, float saturation)
-    {
+
+    private static Item newFood(int food, float saturation) {
         return new Item(new Properties().group(ItemGroup.FOOD).food(
                 new Food.Builder().hunger(food).saturation(saturation).build()));
     }
-    
-    public static void init(IForgeRegistry<Item> r) 
-    {
+
+    public static void init(IForgeRegistry<Item> r) {
         // nuggets and ingots
-	copperIngot = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "copper_ingot");
+        copperIngot = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "copper_ingot");
         copperNugget = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "copper_nugget");
-        
+
         tinIngot = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "tin_ingot");
         tinNugget = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "tin_nugget");
-        
-        bronzeIngot = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)),"bronze_ingot");
+
+        bronzeIngot = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "bronze_ingot");
         bronzeNugget = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "bronze_nugget");
-        
+
         silverIngot = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "silver_ingot");
         silverNugget = register(r, new Item(new Properties().group(ItemGroup.MATERIALS)), "silver_nugget");
-        
+
         // tools and swords
-        copperSword =  register(r, newSword(ModItemTier.COPPER), "copper_sword");
+        copperSword = register(r, newSword(ModItemTier.COPPER), "copper_sword");
         copperShovel = register(r, newShovel(ModItemTier.COPPER), "copper_shovel");
         copperPickaxe = register(r, newPickaxe(ModItemTier.COPPER), "copper_pickaxe");
         copperAxe = register(r, newAxe(ModItemTier.COPPER, 7, -3.1f), "copper_axe");
         copperHoe = register(r, newHoe(ModItemTier.COPPER, -2.0f), "copper_hoe");
-        
-        bronzeSword =  register(r, newSword(ModItemTier.BRONZE), "bronze_sword");
+
+        bronzeSword = register(r, newSword(ModItemTier.BRONZE), "bronze_sword");
         bronzeShovel = register(r, newShovel(ModItemTier.BRONZE), "bronze_shovel");
         bronzePickaxe = register(r, newPickaxe(ModItemTier.BRONZE), "bronze_pickaxe");
         bronzeAxe = register(r, newAxe(ModItemTier.BRONZE, 8, -3.0f), "bronze_axe");
         bronzeHoe = register(r, newHoe(ModItemTier.BRONZE, -1.0f), "bronze_hoe");
-        
+
         sling = register(r, new ItemSling(192), "sling");
-               
+
         // armor
         copperHelmet = register(r, newArmor(ModArmorMaterial.COPPER, EquipmentSlotType.HEAD), "copper_helmet");
         copperChestplate = register(r, newArmor(ModArmorMaterial.COPPER, EquipmentSlotType.CHEST), "copper_chestplate");
         copperLeggings = register(r, newArmor(ModArmorMaterial.COPPER, EquipmentSlotType.LEGS), "copper_leggings");
         copperBoots = register(r, newArmor(ModArmorMaterial.COPPER, EquipmentSlotType.FEET), "copper_boots");
-        
+
         bronzeHelmet = register(r, newArmor(ModArmorMaterial.BRONZE, EquipmentSlotType.HEAD), "bronze_helmet");
         bronzeChestplate = register(r, newArmor(ModArmorMaterial.BRONZE, EquipmentSlotType.CHEST), "bronze_chestplate");
         bronzeLeggings = register(r, newArmor(ModArmorMaterial.BRONZE, EquipmentSlotType.LEGS), "bronze_leggings");
         bronzeBoots = register(r, newArmor(ModArmorMaterial.BRONZE, EquipmentSlotType.FEET), "bronze_boots");
-        
+
         cylinder = register(r, new ItemCylinder(ModArmorMaterial.CYLINDER, new Properties()), "cylinder");
         suitChestplate = register(r, newArmor(ModArmorMaterial.SILK, EquipmentSlotType.CHEST), "suit_chestplate");
         suitLeggings = register(r, newArmor(ModArmorMaterial.SILK, EquipmentSlotType.LEGS), "suit_leggings");
         suitBoots = register(r, newArmor(ModArmorMaterial.SILK, EquipmentSlotType.FEET), "suit_boots");
-        
-        strawHat = register(r, new ItemHat(ModArmorMaterial.STRAW, new Properties()), "straw_hat");        
-        
+
+        strawHat = register(r, new ItemHat(ModArmorMaterial.STRAW, new Properties()), "straw_hat");
+
         // sticks
         woodenStick = register(r, newStick(ItemTier.WOOD), "wooden_stick");
         stoneStick = register(r, newStick(ItemTier.STONE), "stone_stick");
@@ -316,7 +297,7 @@ public class ModItems
         ironStick = register(r, newStick(ItemTier.IRON), "iron_stick");
         goldStick = register(r, newStick(ItemTier.GOLD), "golden_stick");
         diamondStick = register(r, newStick(ItemTier.DIAMOND), "diamond_stick");
-        
+
         // scepter
         woodenScepter = register(r, newScepter(ItemTier.WOOD), "wooden_scepter");
         stoneScepter = register(r, newScepter(ItemTier.STONE), "stone_scepter");
@@ -325,7 +306,7 @@ public class ModItems
         ironScepter = register(r, newScepter(ItemTier.IRON), "iron_scepter");
         goldScepter = register(r, newScepter(ItemTier.GOLD), "golden_scepter");
         diamondScepter = register(r, newScepter(ItemTier.DIAMOND), "diamond_scepter");
-        
+
         // dagger
         woodenDagger = register(r, newDagger(ItemTier.WOOD), "wooden_dagger");
         stoneDagger = register(r, newDagger(ItemTier.STONE), "stone_dagger");
@@ -334,7 +315,7 @@ public class ModItems
         ironDagger = register(r, newDagger(ItemTier.IRON), "iron_dagger");
         goldDagger = register(r, newDagger(ItemTier.GOLD), "golden_dagger");
         diamondDagger = register(r, newDagger(ItemTier.DIAMOND), "diamond_dagger");
-        
+
         // hammer
         woodenHammer = register(r, newHammer(ItemTier.WOOD), "wooden_hammer");
         stoneHammer = register(r, newHammer(ItemTier.STONE), "stone_hammer");
@@ -343,7 +324,7 @@ public class ModItems
         ironHammer = register(r, newHammer(ItemTier.IRON), "iron_hammer");
         goldHammer = register(r, newHammer(ItemTier.GOLD), "golden_hammer");
         diamondHammer = register(r, newHammer(ItemTier.DIAMOND), "diamond_hammer");
-        
+
         // battle axe
         woodenBattleAxe = register(r, newBattleAxe(ItemTier.WOOD), "wooden_battleaxe");
         stoneBattleAxe = register(r, newBattleAxe(ItemTier.STONE), "stone_battleaxe");
@@ -352,19 +333,19 @@ public class ModItems
         ironBattleAxe = register(r, newBattleAxe(ItemTier.IRON), "iron_battleaxe");
         goldBattleAxe = register(r, newBattleAxe(ItemTier.GOLD), "golden_battleaxe");
         diamondBattleAxe = register(r, newBattleAxe(ItemTier.DIAMOND), "diamond_battleaxe");
-              
+
         // key
         silverKey = register(r, new ItemKey(ModItemTier.SILVER), "silver_key");
         copperKey = register(r, new ItemKey(ModItemTier.COPPER), "copper_key");
         bronzeKey = register(r, new ItemKey(ModItemTier.BRONZE), "bronze_key");
         ironKey = register(r, new ItemKey(ItemTier.IRON), "iron_key");
         goldKey = register(r, new ItemKey(ItemTier.GOLD), "golden_key");
-        
+
         // coins
         copperCoin = register(r, newItem(ItemGroup.MISC), "coin_copper");
         silverCoin = register(r, newItem(ItemGroup.MISC), "coin_silver");
         goldCoin = register(r, newItem(ItemGroup.MISC), "coin_gold");
-        
+
         // misc
         realHayBed = register(r, new BedItem(ModBlocks.realHayBed, (new Item.Properties()).maxStackSize(1).group(ItemGroup.DECORATIONS)), "real_hay_bed");
         hayBundle = register(r, newItem(ItemGroup.MATERIALS), "hay_bundle");
@@ -381,7 +362,7 @@ public class ModItems
         scroll = register(r, newItem(ItemGroup.MISC), "scroll");
         soulStone = register(r, newItem(ItemGroup.MATERIALS), "soul_stone");
         piercingStone = register(r, newItem(ItemGroup.MATERIALS), "piercing_stone");
-        
+
         // food
         coloredSoup = register(r, new ItemColoredSoup(), "colored_soup");
         friedEgg = register(r, newFood(2, 0.3f), "fried_egg");
@@ -390,7 +371,7 @@ public class ModItems
         apricot = register(r, newFood(4, 0.3f), "apricot");
         pear = register(r, newFood(4, 0.3f), "pear");
         plum = register(r, newFood(4, 0.3f), "plum");
-        
+
         // icons
         arrowDown = register(r, newItem(ItemGroup.MISC), "arrow_down");
         arrowLeft = register(r, newItem(ItemGroup.MISC), "arrow_left");
@@ -407,7 +388,7 @@ public class ModItems
         returnGreen = register(r, newItem(ItemGroup.MISC), "return_green");
         returnRed = register(r, newItem(ItemGroup.MISC), "return_red");
         gear = register(r, newItem(ItemGroup.MISC), "gear");
-        
+
         // herbs
         herbStrong = register(r, newEffectHerb(Effects.SPEED, 6000, 1), "herb_strong");
         herbShadow = register(r, newEffectHerb(Effects.NIGHT_VISION, 3600, 0), "herb_shadow");
@@ -416,40 +397,34 @@ public class ModItems
         herbGold = register(r, newHerb(), "herb_gold");
         herbBreathing = register(r, newEffectHerb(Effects.WATER_BREATHING, 2400, 0), "herb_breathing");
         herbFire = register(r, newEffectHerb(Effects.FIRE_RESISTANCE, 2400, 0), "herb_fire");
-        
+
         // skill icons
-        for(int i = 1; i <= 57; i++)
-        {
+        for(int i = 1; i <= 57; i++) {
             register(r, newItem(ItemGroup.MISC), "skill" + i);
         }
-        
+
         // block overrides
-        try
-        {
+        try {
             PotionItem potion = new ItemNoGlintPotion();
             register(r, Items.POTION, potion);
-             
+
             PotionItem splashPotion = new ItemNoGlintSplashPotion();
             register(r, Items.SPLASH_POTION, splashPotion);
-            
+
             PotionItem lingeringPotion = new ItemNoGlintLingeringPotion();
             register(r, Items.LINGERING_POTION, lingeringPotion);
-        }
-        catch(Exception ex)
-        {
+        } catch(Exception ex) {
             ex.printStackTrace();
         }
     }
-	
-    private static Item register(IForgeRegistry<Item> r, Item item, String registry) 
-    {
+
+    private static Item register(IForgeRegistry<Item> r, Item item, String registry) {
         item.setRegistryName(registry);
         r.register(item);
         return item;
     }
-    
-    private static void register(IForgeRegistry<Item> r, Item old, Item newItem) 
-    {
+
+    private static void register(IForgeRegistry<Item> r, Item old, Item newItem) {
         newItem.setRegistryName(old.getRegistryName());
         r.register(newItem);
     }

+ 12 - 17
src/main/java/me/km/items/ModelCylinder.java

@@ -8,40 +8,36 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class ModelCylinder extends BipedModel
-{
+public class ModelCylinder extends BipedModel {
     private final static float FACTOR = ((float) Math.PI / 180.0f);
-    
+
     private final ModelRenderer firstHeadPart;
     private final ModelRenderer secHeadPart;
 
-    public ModelCylinder(float scale)
-    {
+    public ModelCylinder(float scale) {
         super(scale, 0, 64, 64);
-    
+
         firstHeadPart = new ModelRenderer(this, 0, 32);
         firstHeadPart.addBox(-5, -8.6f, -5, 10, 1, 10);
         firstHeadPart.setRotationPoint(0.0f, 0.0f, 0.0f);
         firstHeadPart.setTextureSize(64, 64);
         firstHeadPart.mirror = true;
         setRotation(firstHeadPart, 0.0f, 0.0f, 0.0f);
-        
+
         secHeadPart = new ModelRenderer(this, 0, 43);
         secHeadPart.addBox(-3, -15.6f, -3, 6, 7, 6);
         secHeadPart.setRotationPoint(0.0f, 0.0f, 0.0f);
         secHeadPart.setTextureSize(64, 64);
         secHeadPart.mirror = true;
         setRotation(secHeadPart, 0.0f, 0.0f, 0.0f);
-         
+
         bipedHead.addChild(firstHeadPart);
         bipedHead.addChild(secHeadPart);
     }
-    
+
     @Override
-    public void setRotationAngles(LivingEntity ent, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) 
-    {
-        if(ent instanceof ArmorStandEntity)
-        {
+    public void setRotationAngles(LivingEntity ent, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
+        if(ent instanceof ArmorStandEntity) {
             ArmorStandEntity ase = (ArmorStandEntity) ent;
             this.bipedHead.rotateAngleX = FACTOR * ase.getHeadRotation().getX();
             this.bipedHead.rotateAngleY = FACTOR * ase.getHeadRotation().getY();
@@ -68,11 +64,10 @@ public class ModelCylinder extends BipedModel
         }
         super.setRotationAngles(ent, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
     }
-    
-    private void setRotation(ModelRenderer model, float x, float y, float z)
-    {
+
+    private void setRotation(ModelRenderer model, float x, float y, float z) {
         model.rotateAngleX = x;
         model.rotateAngleY = y;
         model.rotateAngleZ = z;
     }
-}
+}

+ 11 - 16
src/main/java/me/km/items/ModelHat.java

@@ -8,40 +8,36 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class ModelHat extends BipedModel
-{
+public class ModelHat extends BipedModel {
     private final static float FACTOR = ((float) Math.PI / 180.0f);
-    
+
     private final ModelRenderer firstHeadPart;
     private final ModelRenderer secHeadPart;
 
-    public ModelHat(float scale)
-    {
+    public ModelHat(float scale) {
         super(scale, 0, 64, 64);
-    
+
         firstHeadPart = new ModelRenderer(this, 0, 32);
         firstHeadPart.addBox(-5, -8.6f, -5, 10, 1, 10);
         firstHeadPart.setRotationPoint(0.0f, 0.0f, 0.0f);
         firstHeadPart.setTextureSize(64, 64);
         firstHeadPart.mirror = true;
         setRotation(firstHeadPart, 0.0f, 0.0f, 0.0f);
-        
+
         secHeadPart = new ModelRenderer(this, 0, 43);
         secHeadPart.addBox(-3, -11.6f, -3, 6, 3, 6);
         secHeadPart.setRotationPoint(0.0f, 0.0f, 0.0f);
         secHeadPart.setTextureSize(64, 64);
         secHeadPart.mirror = true;
         setRotation(secHeadPart, 0.0f, 0.0f, 0.0f);
-         
+
         bipedHead.addChild(firstHeadPart);
         bipedHead.addChild(secHeadPart);
     }
-    
+
     @Override
-    public void setRotationAngles(LivingEntity ent, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) 
-    {
-        if(ent instanceof ArmorStandEntity)
-        {
+    public void setRotationAngles(LivingEntity ent, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
+        if(ent instanceof ArmorStandEntity) {
             ArmorStandEntity ase = (ArmorStandEntity) ent;
             this.bipedHead.rotateAngleX = FACTOR * ase.getHeadRotation().getX();
             this.bipedHead.rotateAngleY = FACTOR * ase.getHeadRotation().getY();
@@ -68,9 +64,8 @@ public class ModelHat extends BipedModel
         }
         super.setRotationAngles(ent, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
     }
-    
-    private void setRotation(ModelRenderer model, float x, float y, float z)
-    {
+
+    private void setRotation(ModelRenderer model, float x, float y, float z) {
         model.rotateAngleX = x;
         model.rotateAngleY = y;
         model.rotateAngleZ = z;

+ 16 - 25
src/main/java/me/km/networking/CustomInventory.java

@@ -11,34 +11,30 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class CustomInventory
-{
+public class CustomInventory {
     private int windowId;
     private String windowTitle;
     private byte slotCount;
     private byte allSlots;
     private final byte[] data;
-    
-    public CustomInventory() 
-    {
+
+    public CustomInventory() {
         windowId = -1;
         windowTitle = "";
         slotCount = 9;
         allSlots = 9;
         data = new byte[14];
     }
-    
-    public CustomInventory(int id, String title, ModInventory inv) 
-    {
+
+    public CustomInventory(int id, String title, ModInventory inv) {
         windowId = id;
         windowTitle = title;
         slotCount = (byte) inv.getSizeInventory();
         allSlots = (byte) inv.getAllSlots();
         data = inv.getData();
     }
-    
-    public static void writeBytes(CustomInventory ci, PacketBuffer buf)
-    {
+
+    public static void writeBytes(CustomInventory ci, PacketBuffer buf) {
         buf.writeInt(ci.windowId);
         byte[] b = ci.windowTitle.getBytes(StandardCharsets.UTF_8);
         buf.writeInt(b.length);
@@ -47,37 +43,32 @@ public class CustomInventory
         buf.writeByte(ci.allSlots);
         buf.writeBytes(ci.data);
     }
-    
-    public static CustomInventory fromBytes(PacketBuffer buf)
-    {
+
+    public static CustomInventory fromBytes(PacketBuffer buf) {
         CustomInventory ci = new CustomInventory();
         ci.windowId = buf.readInt();
         int length = buf.readInt();
         ci.windowTitle = buf.readBytes(length).toString(StandardCharsets.UTF_8);
         ci.slotCount = buf.readByte();
         ci.allSlots = buf.readByte();
-        for(int i = 0; i < 14; i++)
-        {
+        for(int i = 0; i < 14; i++) {
             ci.data[i] = buf.readByte();
         }
         return ci;
     }
-    
-    public static void handle(CustomInventory ci, Supplier<NetworkEvent.Context> context)
-    {
+
+    public static void handle(CustomInventory ci, Supplier<NetworkEvent.Context> context) {
         // prevent error on loading the class on the server
         handleIntern(ci, context);
     }
-    
+
     @OnlyIn(Dist.CLIENT)
-    private static void handleIntern(CustomInventory ci, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
+    private static void handleIntern(CustomInventory ci, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
             Minecraft mc = Minecraft.getInstance();
             CustomContainer cc = new CustomContainer(ci.windowId, mc.player.inventory, new ModInventory(ci.data, ci.slotCount, ci.allSlots));
             mc.player.openContainer = cc;
-            mc.displayGuiScreen(new CustomInventoryScreen(cc, mc.player.inventory, new StringTextComponent(ci.windowTitle))); 
+            mc.displayGuiScreen(new CustomInventoryScreen(cc, mc.player.inventory, new StringTextComponent(ci.windowTitle)));
         });
         context.get().setPacketHandled(true);
     }

+ 9 - 22
src/main/java/me/km/networking/CustomInventoryScreen.java

@@ -13,18 +13,13 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class CustomInventoryScreen extends ContainerScreen<CustomContainer> implements IHasContainer<CustomContainer>
-{
-    /**
-     * The ResourceLocation containing the chest GUI texture.
-     */
+public class CustomInventoryScreen extends ContainerScreen<CustomContainer> implements IHasContainer<CustomContainer> {
     private static final ResourceLocation CHEST_GUI_TEXTURE = new ResourceLocation("textures/gui/container/generic_54.png");
     private static final ResourceLocation EMPTY_TILE = new ResourceLocation(KajetansMod.MODID, "textures/gui/container/empty_tile.png");
 
     private final int inventoryRows;
 
-    public CustomInventoryScreen(CustomContainer cc, PlayerInventory pInv, ITextComponent title)
-    {
+    public CustomInventoryScreen(CustomContainer cc, PlayerInventory pInv, ITextComponent title) {
         super(cc, pInv, title);
         passEvents = false;
         inventoryRows = cc.getInventoryBase().getRows();
@@ -32,23 +27,20 @@ public class CustomInventoryScreen extends ContainerScreen<CustomContainer> impl
     }
 
     @Override
-    public void render(int mouseX, int mouseY, float partialTicks)
-    {
+    public void render(int mouseX, int mouseY, float partialTicks) {
         this.renderBackground();
         super.render(mouseX, mouseY, partialTicks);
         this.renderHoveredToolTip(mouseX, mouseY);
     }
 
     @Override
-    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
-    {
+    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
         this.font.drawString(title.getFormattedText(), 8.0f, 6.0f, 4210752);
         this.font.drawString(playerInventory.getDisplayName().getFormattedText(), 8.0f, ySize - 94, 4210752);
     }
 
     @Override
-    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
-    {
+    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         minecraft.getTextureManager().bindTexture(CHEST_GUI_TEXTURE);
         int i = (width - xSize) / 2;
@@ -60,16 +52,11 @@ public class CustomInventoryScreen extends ContainerScreen<CustomContainer> impl
         j += 17;
         minecraft.getTextureManager().bindTexture(EMPTY_TILE);
         ModInventory base = this.getContainer().getInventoryBase();
-        for(int x = 0; x < 9; x++)
-        {
-            for(int y = 0; y < inventoryRows; y++)
-            {
-                if(base.shouldRenderOverlay(x, y))
-                {
+        for(int x = 0; x < 9; x++) {
+            for(int y = 0; y < inventoryRows; y++) {
+                if(base.shouldRenderOverlay(x, y)) {
                     blit(i + 18 * x, j + 18 * y, 0, 0, 18, 18, 64, 64);
-                }
-                else if(base.shouldRenderDarker(x, y))
-                {
+                } else if(base.shouldRenderDarker(x, y)) {
                     blit(i + 18 * x, j + 18 * y, 18, 0, 18, 18, 64, 64);
                 }
             }

+ 12 - 19
src/main/java/me/km/networking/FunctionKey.java

@@ -5,34 +5,27 @@ import me.km.Server;
 import net.minecraft.network.PacketBuffer;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class FunctionKey
-{
+public class FunctionKey {
     private final byte key;
-    
-    public FunctionKey() 
-    {
+
+    public FunctionKey() {
         key = -1;
     }
-    
-    public FunctionKey(int key) 
-    {
+
+    public FunctionKey(int key) {
         this.key = (byte) key;
     }
-    
-    public static void writeBytes(FunctionKey fk, PacketBuffer buf)
-    {
+
+    public static void writeBytes(FunctionKey fk, PacketBuffer buf) {
         buf.writeByte(fk.key);
     }
-    
-    public static FunctionKey fromBytes(PacketBuffer buf)
-    {
+
+    public static FunctionKey fromBytes(PacketBuffer buf) {
         return new FunctionKey(buf.readByte());
     }
-    
-    public static void handle(FunctionKey fk, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
+
+    public static void handle(FunctionKey fk, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
             Server.scriptEvents.onFunctionKey(context.get().getSender(), fk.key);
         });
         context.get().setPacketHandled(true);

+ 13 - 35
src/main/java/me/km/networking/Icon.java

@@ -1,7 +1,6 @@
 package me.km.networking;
 
-public enum Icon 
-{
+public enum Icon {
     NULL(0, 0, 9, 9),
     FULL_HEART(9, 0, 9, 9),
     HALF_HEART(18, 0, 9, 9),
@@ -25,11 +24,9 @@ public enum Icon
     FULL_ENERGY(9, 36, 9, 9),
     HALF_ENERGY(18, 36, 9, 9),
     EMPTY_ENERGY(27, 36, 9, 9),
-    
     GOLD_COIN(99, 9, 9, 9),
     SILVER_COIN(108, 9, 9, 9),
     COPPER_COIN(117, 9, 9, 9),
-    
     XP_BOTTLE(99, 0, 9, 9),
     BLUE_BOTTLE(108, 0, 9, 9),
     RED_BOTTLE(117, 0, 9, 9),
@@ -37,10 +34,8 @@ public enum Icon
     LIME_BOTTLE(135, 0, 9, 9),
     GREEN_BOTTLE(144, 0, 9, 9),
     VIOLET_BOTTLE(153, 0, 9, 9),
-    YELLOW_BOTTLE(162, 0, 9, 9), 
-    
+    YELLOW_BOTTLE(162, 0, 9, 9),
     BOW(27, 45, 9, 9),
-    
     DIAMOND_SHOVEL(36, 9, 9, 9),
     GOLD_SHOVEL(45, 9, 9, 9),
     IRON_SHOVEL(54, 9, 9, 9),
@@ -48,7 +43,6 @@ public enum Icon
     COPPER_SHOVEL(72, 9, 9, 9),
     STONE_SHOVEL(81, 9, 9, 9),
     WOOD_SHOVEL(90, 9, 9, 9),
-    
     DIAMOND_PICKAXE(36, 18, 9, 9),
     GOLD_PICKAXE(45, 18, 9, 9),
     IRON_PICKAXE(54, 18, 9, 9),
@@ -56,7 +50,6 @@ public enum Icon
     COPPER_PICKAXE(72, 18, 9, 9),
     STONE_PICKAXE(81, 18, 9, 9),
     WOOD_PICKAXE(90, 18, 9, 9),
-    
     DIAMOND_HOE(36, 27, 9, 9),
     GOLD_HOE(45, 27, 9, 9),
     IRON_HOE(54, 27, 9, 9),
@@ -64,7 +57,6 @@ public enum Icon
     COPPER_HOE(72, 27, 9, 9),
     STONE_HOE(81, 27, 9, 9),
     WOOD_HOE(90, 27, 9, 9),
-    
     DIAMOND_AXE(36, 36, 9, 9),
     GOLD_AXE(45, 36, 9, 9),
     IRON_AXE(54, 36, 9, 9),
@@ -72,7 +64,6 @@ public enum Icon
     COPPER_AXE(72, 36, 9, 9),
     STONE_AXE(81, 36, 9, 9),
     WOOD_AXE(90, 36, 9, 9),
-    
     DIAMOND_SWORD(36, 45, 9, 9),
     GOLD_SWORD(45, 45, 9, 9),
     IRON_SWORD(54, 45, 9, 9),
@@ -80,7 +71,6 @@ public enum Icon
     COPPER_SWORD(72, 45, 9, 9),
     STONE_SWORD(81, 45, 9, 9),
     WOOD_SWORD(90, 45, 9, 9),
-    
     DIAMOND_DAGGER(36, 54, 9, 9),
     GOLD_DAGGER(45, 54, 9, 9),
     IRON_DAGGER(54, 54, 9, 9),
@@ -88,7 +78,6 @@ public enum Icon
     COPPER_DAGGER(72, 54, 9, 9),
     STONE_DAGGER(81, 54, 9, 9),
     WOOD_DAGGER(90, 54, 9, 9),
-    
     DIAMOND_STICK(36, 63, 9, 9),
     GOLD_STICK(45, 63, 9, 9),
     IRON_STICK(54, 63, 9, 9),
@@ -96,7 +85,6 @@ public enum Icon
     COPPER_STICK(72, 63, 9, 9),
     STONE_STICK(81, 63, 9, 9),
     WOOD_STICK(90, 63, 9, 9),
-    
     DIAMOND_BATTLE_AXE(36, 72, 9, 9),
     GOLD_BATTLE_AXE(45, 72, 9, 9),
     IRON_BATTLE_AXE(54, 72, 9, 9),
@@ -104,7 +92,6 @@ public enum Icon
     COPPER_BATTLE_AXE(72, 72, 9, 9),
     STONE_BATTLE_AXE(81, 72, 9, 9),
     WOOD_BATTLE_AXE(90, 72, 9, 9),
-    
     DIAMOND_SCEPTER(36, 81, 9, 9),
     GOLD_SCEPTER(45, 81, 9, 9),
     IRON_SCEPTER(54, 81, 9, 9),
@@ -112,7 +99,6 @@ public enum Icon
     COPPER_SCEPTER(72, 81, 9, 9),
     STONE_SCEPTER(81, 81, 9, 9),
     WOOD_SCEPTER(90, 81, 9, 9),
-    
     DIAMOND_HAMMER(36, 90, 9, 9),
     GOLD_HAMMER(45, 90, 9, 9),
     IRON_HAMMER(54, 90, 9, 9),
@@ -120,50 +106,42 @@ public enum Icon
     COPPER_HAMMER(72, 90, 9, 9),
     STONE_HAMMER(81, 90, 9, 9),
     WOOD_HAMMER(90, 90, 9, 9),
-    
     FISHING_ROD(18, 45, 9, 9),
     SLING(9, 45, 9, 9),
     CROSS_BOW(0, 45, 9, 9);
-        
+
     private static final Icon[] icons = Icon.values();
-            
+
     private final int offsetX;
     private final int offsetY;
     private final int width;
     private final int height;
-        
-    Icon(int offsetX, int offsetY, int width, int height)
-    {
+
+    Icon(int offsetX, int offsetY, int width, int height) {
         this.offsetX = offsetX;
         this.offsetY = offsetY;
         this.width = width;
         this.height = height;
     }
 
-    public int getOffsetX() 
-    {
+    public int getOffsetX() {
         return offsetX;
     }
 
-    public int getOffsetY() 
-    {
+    public int getOffsetY() {
         return offsetY;
     }
 
-    public int getHeight() 
-    {
+    public int getHeight() {
         return height;
     }
 
-    public int getWidth() 
-    {
+    public int getWidth() {
         return width;
     }
-    
-    public static Icon getIcon(int i)
-    {
-        if(i < 0 || i >= icons.length)
-        {
+
+    public static Icon getIcon(int i) {
+        if(i < 0 || i >= icons.length) {
             return NULL;
         }
         return icons[i];

+ 14 - 22
src/main/java/me/km/networking/ItemStackDisplay.java

@@ -4,48 +4,40 @@ import java.util.function.Supplier;
 import net.minecraft.network.PacketBuffer;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class ItemStackDisplay
-{
+public class ItemStackDisplay {
     private byte index;
     private int iconIndex;
     private int count;
-    
-    public ItemStackDisplay() 
-    {
+
+    public ItemStackDisplay() {
         index = -1;
         iconIndex = -1;
         count = -1;
     }
-    
-    public ItemStackDisplay(byte index, int iconIndex, int count) 
-    {
+
+    public ItemStackDisplay(byte index, int iconIndex, int count) {
         this.index = index;
         this.iconIndex = iconIndex;
         this.count = count;
     }
-    
-    public static void writeBytes(ItemStackDisplay isd, PacketBuffer buf)
-    {
+
+    public static void writeBytes(ItemStackDisplay isd, PacketBuffer buf) {
         buf.writeByte(isd.index);
         buf.writeInt(isd.iconIndex);
         buf.writeInt(isd.count);
     }
-    
-    public static ItemStackDisplay fromBytes(PacketBuffer buf)
-    {
+
+    public static ItemStackDisplay fromBytes(PacketBuffer buf) {
         ItemStackDisplay isd = new ItemStackDisplay();
         isd.index = buf.readByte();
         isd.iconIndex = buf.readInt();
         isd.count = buf.readInt();
         return isd;
     }
-    
-    public static void handle(ItemStackDisplay isd, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
-            switch(isd.index)
-            {
+
+    public static void handle(ItemStackDisplay isd, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
+            switch(isd.index) {
                 case -1:
                     ItemStackDisplayGui.INSTANCE.setActive(true);
                     break;
@@ -55,7 +47,7 @@ public class ItemStackDisplay
                 case -3:
                     ItemStackDisplayGui.INSTANCE.clear();
                     break;
-                default: 
+                default:
                     ItemStackDisplayGui.INSTANCE.setIcon(isd.index, isd.iconIndex, isd.count);
                     break;
             }

+ 47 - 73
src/main/java/me/km/networking/ItemStackDisplayGui.java

@@ -11,36 +11,28 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class ItemStackDisplayGui extends AbstractGui
-{
+public class ItemStackDisplayGui extends AbstractGui {
     private static final ResourceLocation CUSTOM_ICONS = new ResourceLocation(KajetansMod.MODID, "textures/gui/itemstacks.png");
-    
+
     public final static ItemStackDisplayGui INSTANCE = new ItemStackDisplayGui(Minecraft.getInstance());
-    
-    private static class Stack
-    {
+
+    private static class Stack {
         private int x = -1;
         private int y = 0;
         private int width = 0;
         private int height = 0;
         private String text = "";
-        
-        public void setIcon(int index, int c)
-        {
-            if(index < 0)
-            {
+
+        public void setIcon(int index, int c) {
+            if(index < 0) {
                 clear();
-            }
-            else if(index >= 0 && index < 104)
-            {
+            } else if(index >= 0 && index < 104) {
                 x = (index % 52) * 16 + 192;
                 y = (index / 52) * 16;
                 width = 16;
                 height = 16;
                 text = (c == 0) ? "" : String.valueOf(c);
-            }
-            else
-            {
+            } else {
                 index -= 104;
                 x = (index % 16) * 64;
                 y = (index / 16) * 64 + 32;
@@ -49,100 +41,82 @@ public class ItemStackDisplayGui extends AbstractGui
                 text = null;
             }
         }
-        
-        public void clear()
-        {
+
+        public void clear() {
             x = -1;
         }
     }
-    
+
     private final Minecraft mc;
-    
+
     private final Stack[] icons = new Stack[9];
     private boolean inactive = true;
-    
-    public ItemStackDisplayGui(Minecraft mc)
-    {
+
+    public ItemStackDisplayGui(Minecraft mc) {
         this.mc = mc;
-        
-        for(int i = 0; i < icons.length; i++)
-        {
+
+        for(int i = 0; i < icons.length; i++) {
             icons[i] = new Stack();
         }
-    }  
-    
-    public void setActive(boolean active)
-    {
+    }
+
+    public void setActive(boolean active) {
         this.inactive = !active;
     }
-    
-    public void setIcon(int index, int i, int count)
-    {
-        if(index >= 0 && index < 9)
-        {
+
+    public void setIcon(int index, int i, int count) {
+        if(index >= 0 && index < 9) {
             icons[index].setIcon(i, count);
         }
     }
-    
-    public final void clear()
-    {
-        for(Stack stack : icons)
-        {
+
+    public final void clear() {
+        for(Stack stack : icons) {
             stack.clear();
         }
     }
-    
-    public void paint(KeyManager km)
-    {
-        if(inactive)
-        {
+
+    public void paint(KeyManager km) {
+        if(inactive) {
             return;
         }
-        
+
         RenderSystem.enableBlend();
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
-        
+
         mc.getTextureManager().bindTexture(CUSTOM_ICONS);
-        
+
         int screenWidth = (mc.getMainWindow().getScaledWidth() >> 1) - 91;
         int y = 3;
-        
-        if(ClientReflectionUtils.isRenderingBossBar())
-        {
+
+        if(ClientReflectionUtils.isRenderingBossBar()) {
             y += 20;
         }
-        
+
         blit(screenWidth, y - 3, 0, 0, 182, 22, 1024, 1024);
-        
+
         int i = 0;
-        for(int x = 3; x < 164; x += 20)
-        {
+        for(int x = 3; x < 164; x += 20) {
             Stack s = icons[i];
-            if(s.x != -1)
-            {
+            if(s.x != -1) {
                 blit(screenWidth + x, y, 16, 16, s.x, s.y, s.width, s.height, 1024, 1024);
             }
             i++;
         }
-        
+
         RenderSystem.disableBlend();
-        
+
         FontRenderer fr = mc.fontRenderer;
         i = 0;
-        for(int x = 20; x < 181; x += 20)
-        {
-            if(icons[i].x != -1)
-            {
-                if(icons[i].text == null)
-                {
+        for(int x = 20; x < 181; x += 20) {
+            if(icons[i].x != -1) {
+                if(icons[i].text == null) {
                     String s = km.getKeyDescription(i);
-                    fr.drawStringWithShadow(s, (float)(screenWidth + x - fr.getStringWidth(s)), y + 9, 16777215);
-                }
-                else if(!icons[i].text.isEmpty())
-                {
-                    fr.drawStringWithShadow(icons[i].text, (float)(screenWidth + x - fr.getStringWidth(icons[i].text)), y + 9, 16777215);
+                    fr.drawStringWithShadow(s, (float) (screenWidth + x - fr.getStringWidth(s)), y + 9, 16777215);
+                } else if(!icons[i].text.isEmpty()) {
+                    fr.drawStringWithShadow(icons[i].text, (float) (screenWidth + x - fr.getStringWidth(icons[i].text)), y + 9, 16777215);
                 }
-            }             
+            }
             i++;
         }
     }

+ 12 - 19
src/main/java/me/km/networking/KeyManager.java

@@ -9,12 +9,10 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
 import org.lwjgl.glfw.GLFW;
 
 @OnlyIn(Dist.CLIENT)
-public class KeyManager 
-{
+public class KeyManager {
     private final KeyBinding[] functionKeys;
-    
-    public KeyManager()
-    {
+
+    public KeyManager() {
         functionKeys = new KeyBinding[9];
         functionKeys[0] = register(1, GLFW.GLFW_KEY_G);
         functionKeys[1] = register(2, GLFW.GLFW_KEY_H);
@@ -26,26 +24,21 @@ public class KeyManager
         functionKeys[7] = register(8, GLFW.GLFW_KEY_M);
         functionKeys[8] = register(9, GLFW.GLFW_KEY_COMMA);
     }
-    
-    public String getKeyDescription(int index)
-    {
+
+    public String getKeyDescription(int index) {
         return functionKeys[index].getLocalizedName();
     }
-    
-    private KeyBinding register(int id, int key)
-    {
-        KeyBinding keyBind =  new KeyBinding("key.function." + id, key, "key.km.function");
+
+    private KeyBinding register(int id, int key) {
+        KeyBinding keyBind = new KeyBinding("key.function." + id, key, "key.km.function");
         ClientRegistry.registerKeyBinding(keyBind);
         return keyBind;
     }
-    
+
     @SubscribeEvent
-    public void onRenderGui(TickEvent.ClientTickEvent e)
-    {
-        for(int i = 0; i < functionKeys.length; i++)
-        {
-            if(functionKeys[i].isPressed())
-            {
+    public void onRenderGui(TickEvent.ClientTickEvent e) {
+        for(int i = 0; i < functionKeys.length; i++) {
+            if(functionKeys[i].isPressed()) {
                 ModPacketHandler.sendFunctionKey(i + 1);
             }
         }

+ 39 - 57
src/main/java/me/km/networking/ModPacketHandler.java

@@ -8,19 +8,17 @@ import net.minecraftforge.fml.network.NetworkRegistry;
 import net.minecraftforge.fml.network.PacketDistributor;
 import net.minecraftforge.fml.network.simple.SimpleChannel;
 
-public class ModPacketHandler 
-{
+public class ModPacketHandler {
     private static final String PROTOCOL_VERSION = "1";
-    
+
     private static final SimpleChannel INSTANCE = NetworkRegistry.ChannelBuilder
-			.named(new ResourceLocation(KajetansMod.MODID, "main"))
-			.clientAcceptedVersions(PROTOCOL_VERSION::equals)
-			.serverAcceptedVersions(PROTOCOL_VERSION::equals)
-			.networkProtocolVersion(() -> PROTOCOL_VERSION)
-			.simpleChannel();
-    
-    public static void init()
-    {
+            .named(new ResourceLocation(KajetansMod.MODID, "main"))
+            .clientAcceptedVersions(PROTOCOL_VERSION::equals)
+            .serverAcceptedVersions(PROTOCOL_VERSION::equals)
+            .networkProtocolVersion(() -> PROTOCOL_VERSION)
+            .simpleChannel();
+
+    public static void init() {
         int id = 0;
         INSTANCE.registerMessage(id++, PlayerDisplay.class, PlayerDisplay::writeBytes, PlayerDisplay::fromBytes, PlayerDisplay::handle);
         INSTANCE.registerMessage(id++, FunctionKey.class, FunctionKey::writeBytes, FunctionKey::fromBytes, FunctionKey::handle);
@@ -30,83 +28,67 @@ public class ModPacketHandler
         INSTANCE.registerMessage(id++, ItemStackDisplay.class, ItemStackDisplay::writeBytes, ItemStackDisplay::fromBytes, ItemStackDisplay::handle);
         INSTANCE.registerMessage(id++, PlayerLeftClickEmpty.class, PlayerLeftClickEmpty::writeBytes, PlayerLeftClickEmpty::fromBytes, PlayerLeftClickEmpty::handle);
     }
-    
-    private static void sendToPlayer(ServerPlayerEntity p, Object msg)
-    {
+
+    private static void sendToPlayer(ServerPlayerEntity p, Object msg) {
         INSTANCE.send(PacketDistributor.PLAYER.with(() -> p), msg);
     }
-    
-    private static void sendToPlayers(Object msg)
-    {
+
+    private static void sendToPlayers(Object msg) {
         INSTANCE.send(PacketDistributor.ALL.noArg(), msg);
     }
-    
-    private static void sendToServer(Object msg)
-    {
+
+    private static void sendToServer(Object msg) {
         INSTANCE.sendToServer(msg);
     }
-    
-    public static void sendToDisplay(ServerPlayerEntity p, byte action, byte index, String text)
-    {
+
+    public static void sendToDisplay(ServerPlayerEntity p, byte action, byte index, String text) {
         sendToPlayer(p, new PlayerDisplay(action, index, text));
     }
-    
-    public static void sendFunctionKey(int key)
-    {
+
+    public static void sendFunctionKey(int key) {
         sendToServer(new FunctionKey(key));
     }
-    
-    public static void sendCustomInventory(ServerPlayerEntity p, int id, String title, ModInventory inv)
-    {
+
+    public static void sendCustomInventory(ServerPlayerEntity p, int id, String title, ModInventory inv) {
         sendToPlayer(p, new CustomInventory(id, title, inv));
     }
 
-    public static void addStatus(ServerPlayerEntity p, byte index, String text)
-    {
+    public static void addStatus(ServerPlayerEntity p, byte index, String text) {
         sendToPlayer(p, new StatusDisplay((byte) 1, index, text));
     }
-    
-    public static void addTimedStatus(ServerPlayerEntity p, byte index, String text, int time)
-    {
+
+    public static void addTimedStatus(ServerPlayerEntity p, byte index, String text, int time) {
         sendToPlayer(p, new StatusDisplay((byte) 1, index, time, text));
     }
-    
-    public static void removeStatus(ServerPlayerEntity p, byte index)
-    {
+
+    public static void removeStatus(ServerPlayerEntity p, byte index) {
         sendToPlayer(p, new StatusDisplay((byte) 2, index, ""));
     }
-    
-    public static void clearStatus(ServerPlayerEntity p)
-    {
+
+    public static void clearStatus(ServerPlayerEntity p) {
         sendToPlayer(p, new StatusDisplay((byte) 3, (byte) 0, ""));
     }
-    
-    public static void sendToHead(ServerPlayerEntity p, byte action, byte index, String name, int x, int y, byte scale)
-    {
+
+    public static void sendToHead(ServerPlayerEntity p, byte action, byte index, String name, int x, int y, byte scale) {
         sendToPlayer(p, new PlayerHead(action, index, name, x, y, scale));
     }
-    
-    public static void sendLeftClickEmpty()
-    {
+
+    public static void sendLeftClickEmpty() {
         sendToServer(new PlayerLeftClickEmpty());
     }
-    
+
     //--------------------------------------------------------------------------
     // item stack display
     //--------------------------------------------------------------------------
-    
-    public static void setItemStackIndex(ServerPlayerEntity p, byte index, int iconIndex, int count)
-    {
+    public static void setItemStackIndex(ServerPlayerEntity p, byte index, int iconIndex, int count) {
         sendToPlayer(p, new ItemStackDisplay(index, iconIndex, count));
     }
-    
-    public static void setItemStackActive(ServerPlayerEntity p, boolean active)
-    {
+
+    public static void setItemStackActive(ServerPlayerEntity p, boolean active) {
         sendToPlayer(p, new ItemStackDisplay(active ? (byte) -1 : (byte) -2, -1, -1));
     }
-    
-    public static void clearItemStacks(ServerPlayerEntity p)
-    {
+
+    public static void clearItemStacks(ServerPlayerEntity p) {
         sendToPlayer(p, new ItemStackDisplay((byte) -3, -1, -1));
     }
-}
+}

+ 15 - 23
src/main/java/me/km/networking/PlayerDisplay.java

@@ -5,40 +5,35 @@ import java.util.function.Supplier;
 import net.minecraft.network.PacketBuffer;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class PlayerDisplay
-{
+public class PlayerDisplay {
     // 1 - add - index, text
     // 2 - remove - index
     // 3 - clear
     private byte action;
     private byte index;
     private String text;
-    
-    public PlayerDisplay() 
-    {
+
+    public PlayerDisplay() {
         action = -1;
         index = -1;
         text = "";
     }
-    
-    public PlayerDisplay(byte action, byte index, String text) 
-    {
+
+    public PlayerDisplay(byte action, byte index, String text) {
         this.action = action;
         this.index = index;
         this.text = text;
     }
-    
-    public static void writeBytes(PlayerDisplay pd, PacketBuffer buf)
-    {
+
+    public static void writeBytes(PlayerDisplay pd, PacketBuffer buf) {
         buf.writeByte(pd.action);
         buf.writeByte(pd.index);
         byte[] b = pd.text.getBytes(StandardCharsets.UTF_8);
         buf.writeInt(b.length);
         buf.writeBytes(b);
     }
-    
-    public static PlayerDisplay fromBytes(PacketBuffer buf)
-    {
+
+    public static PlayerDisplay fromBytes(PacketBuffer buf) {
         PlayerDisplay pd = new PlayerDisplay();
         pd.action = buf.readByte();
         pd.index = buf.readByte();
@@ -46,23 +41,20 @@ public class PlayerDisplay
         pd.text = buf.readBytes(length).toString(StandardCharsets.UTF_8);
         return pd;
     }
-    
-    public static void handle(PlayerDisplay pd, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
-            switch(pd.action)
-            {
+
+    public static void handle(PlayerDisplay pd, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
+            switch(pd.action) {
                 case 1:
                     PlayerDisplayGui.INSTANCE.add(pd.index, pd.text);
                     break;
                 case 2:
                     PlayerDisplayGui.INSTANCE.remove(pd.index);
                     break;
-                case 3: 
+                case 3:
                     PlayerDisplayGui.INSTANCE.clear();
                     break;
-            }  
+            }
         });
         context.get().setPacketHandled(true);
     }

+ 51 - 81
src/main/java/me/km/networking/PlayerDisplayGui.java

@@ -11,158 +11,129 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class PlayerDisplayGui extends AbstractGui
-{
+public class PlayerDisplayGui extends AbstractGui {
     private static final ResourceLocation CUSTOM_ICONS = new ResourceLocation(KajetansMod.MODID, "textures/gui/icons.png");
-    
+
     public final static PlayerDisplayGui INSTANCE = new PlayerDisplayGui(Minecraft.getInstance());
-    
-    private class IconStorage
-    {
+
+    private class IconStorage {
         private final Icon icon;
         private final int count;
-        
-        public IconStorage(int id, int count)
-        {
+
+        public IconStorage(int id, int count) {
             this.icon = Icon.getIcon(id);
             this.count = count;
         }
-        
-        public int getWidth()
-        {
+
+        public int getWidth() {
             return count * icon.getWidth() - count + 1;
         }
-        
-        public int getHeight()
-        {
+
+        public int getHeight() {
             return icon.getHeight();
         }
     }
-    
-    private class LineData
-    {
+
+    private class LineData {
         private ArrayList<String> list;
         private ArrayList<IconStorage> icons;
-        
-        public LineData(String s)
-        {
+
+        public LineData(String s) {
             this.list = new ArrayList<>();
             this.icons = new ArrayList<>();
-            
+
             int pos;
             int old = 0;
-            while(true)
-            {
+            while(true) {
                 // icon format #X-Y- where X and Y are numbers
                 pos = s.indexOf("#", old);
-                if(pos == -1)
-                {
+                if(pos == -1) {
                     list.add(s.substring(old));
                     break;
                 }
                 list.add(s.substring(old, pos));
-                try
-                {
+                try {
                     int first = s.indexOf("-", pos);
                     int second = s.indexOf("-", first + 1);
                     icons.add(new IconStorage(Integer.parseInt(s.substring(pos + 1, first)), Integer.parseInt(s.substring(first + 1, second))));
                     old = second + 1;
-                }
-                catch(Exception ex)
-                {
+                } catch(Exception ex) {
                     list.add("ERROR");
                     break;
                 }
             }
         }
-        
-        public int getWidth()
-        {
+
+        public int getWidth() {
             return list.stream().mapToInt(s -> mc.fontRenderer.getStringWidth(s)).sum() + icons.stream().mapToInt(i -> i.getWidth()).sum();
         }
-        
-        public int getHeight()
-        {
+
+        public int getHeight() {
             return Math.max(mc.fontRenderer.FONT_HEIGHT, icons.stream().mapToInt(i -> i.getHeight()).max().orElse(0) + 1);
         }
     }
-    
+
     private final TreeMap<Integer, LineData> strings;
     private final Minecraft mc;
-    
-    public PlayerDisplayGui(Minecraft mc)
-    {
+
+    public PlayerDisplayGui(Minecraft mc) {
         this.mc = mc;
-        this.strings = new TreeMap<>(); 
+        this.strings = new TreeMap<>();
     }
-    
-    public void add(int i, String s)
-    {
+
+    public void add(int i, String s) {
         strings.put(i, new LineData(s));
     }
-    
-    public void remove(int i)
-    {
+
+    public void remove(int i) {
         strings.remove(i);
     }
-    
-    public void clear()
-    {
+
+    public void clear() {
         strings.clear();
     }
-    
-    public void paint()
-    {
-        if(strings.isEmpty())
-        {
+
+    public void paint() {
+        if(strings.isEmpty()) {
             return;
         }
         int x;
         int y = 2;
-        
+
         int width = 0;
         int height = 4;
-        
-        for(LineData data : strings.values())
-        {
+
+        for(LineData data : strings.values()) {
             height += data.getHeight();
             width = Math.max(data.getWidth(), width);
         }
-        
+
         fill(0, 0, width + 4, height, 1342177280);
-        
+
         String s;
-        for(LineData data : strings.values())
-        {
+        for(LineData data : strings.values()) {
             x = 2;
-            for(int i = 0; i < data.list.size(); i++)
-            {
+            for(int i = 0; i < data.list.size(); i++) {
                 s = data.list.get(i);
                 mc.fontRenderer.drawString(s, x, y + 1, 0xFFFFFF);
-                if(!s.isEmpty())
-                {
+                if(!s.isEmpty()) {
                     x += mc.fontRenderer.getStringWidth(s);
-                }
-                else
-                {
+                } else {
                     x--;
                 }
-                if(i < data.icons.size())
-                {
+                if(i < data.icons.size()) {
                     x += paintIcons(data.icons.get(i), x, y);
                 }
             }
             y += data.getHeight();
         }
     }
-    
-    private void bind(ResourceLocation res)
-    {
+
+    private void bind(ResourceLocation res) {
         mc.getTextureManager().bindTexture(res);
     }
-    
-    private int paintIcons(IconStorage is, int x, int y)
-    {
+
+    private int paintIcons(IconStorage is, int x, int y) {
         RenderSystem.enableBlend();
         RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
         bind(CUSTOM_ICONS);
@@ -171,8 +142,7 @@ public class PlayerDisplayGui extends AbstractGui
         int height = icon.getHeight();
         int offX = icon.getOffsetX();
         int offY = icon.getOffsetY();
-        for(int i = 0; i < is.count; i++)
-        {
+        for(int i = 0; i < is.count; i++) {
             blit(x + width * i - i, y, offX, offY, width, height);
         }
         RenderSystem.disableBlend();

+ 18 - 31
src/main/java/me/km/networking/PlayerHead.java

@@ -5,8 +5,7 @@ import java.util.function.Supplier;
 import net.minecraft.network.PacketBuffer;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class PlayerHead
-{
+public class PlayerHead {
     // 1 - add - index, name, x, y, scale
     // 2 - remove - index
     // 3 - clear
@@ -16,9 +15,8 @@ public class PlayerHead
     private int x;
     private int y;
     private byte scale;
-    
-    public PlayerHead() 
-    {
+
+    public PlayerHead() {
         action = -1;
         index = -1;
         name = "";
@@ -26,29 +24,23 @@ public class PlayerHead
         y = -1;
         scale = -1;
     }
-    
-    public PlayerHead(byte action, byte index, String name, int x, int y, byte scale) 
-    {
+
+    public PlayerHead(byte action, byte index, String name, int x, int y, byte scale) {
         this.action = action;
         this.index = index;
-        if(name.length() > 16)
-        {
+        if(name.length() > 16) {
             this.name = name.substring(0, 16);
-        }
-        else
-        {
+        } else {
             this.name = name;
         }
         this.x = x;
         this.y = y;
         this.scale = scale;
     }
-    
-    public static void writeBytes(PlayerHead ph, PacketBuffer buf)
-    {
+
+    public static void writeBytes(PlayerHead ph, PacketBuffer buf) {
         buf.writeByte(ph.action);
-        switch(ph.action)
-        {
+        switch(ph.action) {
             case 1:
                 buf.writeInt(ph.x);
                 buf.writeInt(ph.y);
@@ -63,13 +55,11 @@ public class PlayerHead
                 break;
         }
     }
-    
-    public static PlayerHead fromBytes(PacketBuffer buf)
-    {
+
+    public static PlayerHead fromBytes(PacketBuffer buf) {
         PlayerHead ph = new PlayerHead();
         ph.action = buf.readByte();
-        switch(ph.action)
-        {
+        switch(ph.action) {
             case 1:
                 ph.x = buf.readInt();
                 ph.y = buf.readInt();
@@ -84,20 +74,17 @@ public class PlayerHead
         }
         return ph;
     }
-    
-    public static void handle(PlayerHead ph, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
-            switch(ph.action)
-            {
+
+    public static void handle(PlayerHead ph, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
+            switch(ph.action) {
                 case 1:
                     PlayerHeadGui.INSTANCE.add(ph.index, ph.x, ph.y, ph.scale, ph.name);
                     break;
                 case 2:
                     PlayerHeadGui.INSTANCE.remove(ph.index);
                     break;
-                case 3: 
+                case 3:
                     PlayerHeadGui.INSTANCE.clear();
                     break;
             }

+ 10 - 20
src/main/java/me/km/networking/PlayerHeadGui.java

@@ -10,27 +10,23 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class PlayerHeadGui extends AbstractGui
-{
+public class PlayerHeadGui extends AbstractGui {
     public final static PlayerHeadGui INSTANCE = new PlayerHeadGui(Minecraft.getInstance());
 
-    private class HeadData
-    {
+    private class HeadData {
         private final int x;
         private final int y;
         private final int scale;
         private final ResourceLocation rl;
 
-        public HeadData(int x, int y, int scale, ResourceLocation rl)
-        {
+        public HeadData(int x, int y, int scale, ResourceLocation rl) {
             this.x = x;
             this.y = y;
             this.scale = scale;
             this.rl = rl;
         }
 
-        public void paint(Minecraft mc)
-        {
+        public void paint(Minecraft mc) {
             RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
             mc.getTextureManager().bindTexture(rl);
             AbstractGui.blit(x, y, 8 * scale, 8 * scale, 8.0f, 8.0f, 8, 8, 64, 64);
@@ -41,33 +37,27 @@ public class PlayerHeadGui extends AbstractGui
     private final TreeMap<Integer, HeadData> data;
     private final Minecraft mc;
 
-    public PlayerHeadGui(Minecraft mc)
-    {
+    public PlayerHeadGui(Minecraft mc) {
         this.mc = mc;
         this.data = new TreeMap<>();
     }
 
-    public void add(int i, int x, int y, int scale, String name)
-    {
+    public void add(int i, int x, int y, int scale, String name) {
         NetworkPlayerInfo info = this.mc.player.connection.getPlayerInfo(name);
-        if(info != null)
-        {
+        if(info != null) {
             data.put(i, new HeadData(x, y, scale, info.getLocationSkin()));
         }
     }
 
-    public void remove(int i)
-    {
+    public void remove(int i) {
         data.remove(i);
     }
 
-    public void clear()
-    {
+    public void clear() {
         data.clear();
     }
 
-    public void paint()
-    {
+    public void paint() {
         data.values().forEach(head -> head.paint(mc));
     }
 }

+ 8 - 13
src/main/java/me/km/networking/PlayerLeftClickEmpty.java

@@ -5,23 +5,18 @@ import me.km.Server;
 import net.minecraft.network.PacketBuffer;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class PlayerLeftClickEmpty
-{
-    public static void writeBytes(PlayerLeftClickEmpty pd, PacketBuffer buf)
-    {
+public class PlayerLeftClickEmpty {
+    public static void writeBytes(PlayerLeftClickEmpty pd, PacketBuffer buf) {
     }
-    
-    public static PlayerLeftClickEmpty fromBytes(PacketBuffer buf)
-    {
+
+    public static PlayerLeftClickEmpty fromBytes(PacketBuffer buf) {
         return new PlayerLeftClickEmpty();
     }
-    
-    public static void handle(PlayerLeftClickEmpty pd, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
+
+    public static void handle(PlayerLeftClickEmpty pd, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
             Server.scriptEvents.onEmptyLeftClick(context.get().getSender());
         });
         context.get().setPacketHandled(true);
     }
-}
+}

+ 18 - 30
src/main/java/me/km/networking/StatusDisplay.java

@@ -5,8 +5,7 @@ import java.util.function.Supplier;
 import net.minecraft.network.PacketBuffer;
 import net.minecraftforge.fml.network.NetworkEvent;
 
-public class StatusDisplay
-{
+public class StatusDisplay {
     // 1 - add - index, text
     // 2 - remove - index
     // 3 - clear
@@ -14,36 +13,29 @@ public class StatusDisplay
     private byte index;
     private int time;
     private String text;
-    
-    public StatusDisplay() 
-    {
+
+    public StatusDisplay() {
         action = -1;
         index = -1;
         text = "";
     }
-    
-    public StatusDisplay(byte action, byte index, int time, String text) 
-    {
+
+    public StatusDisplay(byte action, byte index, int time, String text) {
         this.action = action;
         this.index = index;
         this.time = time;
-        if(text.length() > 32)
-        {
+        if(text.length() > 32) {
             this.text = text.substring(0, 32);
-        }
-        else
-        {
+        } else {
             this.text = text;
         }
     }
-    
-    public StatusDisplay(byte action, byte index, String text) 
-    {
+
+    public StatusDisplay(byte action, byte index, String text) {
         this(action, index, Integer.MAX_VALUE, text);
     }
-    
-    public static void writeBytes(StatusDisplay sd, PacketBuffer buf)
-    {
+
+    public static void writeBytes(StatusDisplay sd, PacketBuffer buf) {
         buf.writeByte(sd.action);
         buf.writeByte(sd.index);
         buf.writeInt(sd.time);
@@ -51,9 +43,8 @@ public class StatusDisplay
         buf.writeInt(b.length);
         buf.writeBytes(b);
     }
-    
-    public static StatusDisplay fromBytes(PacketBuffer buf)
-    {
+
+    public static StatusDisplay fromBytes(PacketBuffer buf) {
         StatusDisplay sd = new StatusDisplay();
         sd.action = buf.readByte();
         sd.index = buf.readByte();
@@ -62,20 +53,17 @@ public class StatusDisplay
         sd.text = buf.readBytes(length).toString(StandardCharsets.UTF_8);
         return sd;
     }
-    
-    public static void handle(StatusDisplay sd, Supplier<NetworkEvent.Context> context)
-    {
-        context.get().enqueueWork(() -> 
-        {
-            switch(sd.action)
-            {
+
+    public static void handle(StatusDisplay sd, Supplier<NetworkEvent.Context> context) {
+        context.get().enqueueWork(() -> {
+            switch(sd.action) {
                 case 1:
                     StatusDisplayGui.INSTANCE.add(sd.index, sd.time, sd.text);
                     break;
                 case 2:
                     StatusDisplayGui.INSTANCE.remove(sd.index);
                     break;
-                case 3: 
+                case 3:
                     StatusDisplayGui.INSTANCE.clear();
                     break;
             }

+ 10 - 18
src/main/java/me/km/overrides/ModCapeLayer.java

@@ -21,27 +21,21 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class ModCapeLayer extends CapeLayer
-{
-    public ModCapeLayer(IEntityRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> pRenderer)
-    {
+public class ModCapeLayer extends CapeLayer {
+    public ModCapeLayer(IEntityRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>> pRenderer) {
         super(pRenderer);
     }
 
     @Override
-    public void render(MatrixStack mStack, IRenderTypeBuffer buffer, int packedLightIn, AbstractClientPlayerEntity p, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch)
-    {
-        if(p.hasPlayerInfo() && !p.isInvisible() && p.isWearing(PlayerModelPart.CAPE))
-        {
+    public void render(MatrixStack mStack, IRenderTypeBuffer buffer, int packedLightIn, AbstractClientPlayerEntity p, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
+        if(p.hasPlayerInfo() && !p.isInvisible() && p.isWearing(PlayerModelPart.CAPE)) {
             ItemStack chestStack = p.getItemStackFromSlot(EquipmentSlotType.CHEST);
-            if(chestStack.getItem() != Items.ELYTRA)
-            {
+            if(chestStack.getItem() != Items.ELYTRA) {
                 ResourceLocation rl = PlayerCapeLoader.INSTANCE.getTexture(p.getUniqueID());
-                if(rl == null)
-                {
+                if(rl == null) {
                     return;
                 }
-                
+
                 mStack.push();
                 mStack.translate(0.0, 0.0, 0.125);
                 double d0 = MathHelper.lerp(partialTicks, p.prevChasingPosX, p.chasingPosX) - MathHelper.lerp(partialTicks, p.prevPosX, p.getPosX());
@@ -56,15 +50,13 @@ public class ModCapeLayer extends CapeLayer
                 f2 = MathHelper.clamp(f2, 0.0f, 150.0f);
                 float f3 = (float) (d0 * d4 - d2 * d3) * 100.0f;
                 f3 = MathHelper.clamp(f3, -20.0f, 20.0f);
-                if(f2 < 0.0f)
-                {
+                if(f2 < 0.0f) {
                     f2 = 0.0f;
                 }
 
                 float f4 = MathHelper.lerp(partialTicks, p.prevCameraYaw, p.cameraYaw);
                 f1 = f1 + MathHelper.sin(MathHelper.lerp(partialTicks, p.prevDistanceWalkedModified, p.distanceWalkedModified) * 6.0f) * 32.0f * f4;
-                if(p.isCrouching())
-                {
+                if(p.isCrouching()) {
                     f1 += 25.0f;
                 }
 
@@ -77,4 +69,4 @@ public class ModCapeLayer extends CapeLayer
             }
         }
     }
-}
+}

+ 37 - 63
src/main/java/me/km/overrides/ModEntityPlayerMP.java

@@ -12,31 +12,27 @@ import net.minecraft.util.text.ITextComponent;
 import net.minecraft.util.text.StringTextComponent;
 import net.minecraft.world.server.ServerWorld;
 
-public class ModEntityPlayerMP extends ServerPlayerEntity
-{
+public class ModEntityPlayerMP extends ServerPlayerEntity {
     private final PlayerScoreboard board;
     private int id = -1;
     private final HashMap<String, Integer> timedData;
     private final HashMap<String, Object> data;
     private StringTextComponent tabDisplayName = null;
-    
+
     private boolean isIterating = false;
-    
-    public ModEntityPlayerMP(MinecraftServer ms, ServerWorld w, GameProfile gp, PlayerInteractionManager pim)
-    {
+
+    public ModEntityPlayerMP(MinecraftServer ms, ServerWorld w, GameProfile gp, PlayerInteractionManager pim) {
         super(ms, w, gp, pim);
         this.board = new PlayerScoreboard();
         this.timedData = new HashMap();
         this.data = new HashMap();
     }
 
-    public PlayerScoreboard getScoreboard()
-    {
+    public PlayerScoreboard getScoreboard() {
         return board;
     }
-    
-    public ModEntityPlayerMP(MinecraftServer ms, ServerWorld w, GameProfile gp, PlayerInteractionManager pim, ModEntityPlayerMP old)
-    {
+
+    public ModEntityPlayerMP(MinecraftServer ms, ServerWorld w, GameProfile gp, PlayerInteractionManager pim, ModEntityPlayerMP old) {
         super(ms, w, gp, pim);
         this.board = old.board;
         this.timedData = old.timedData;
@@ -45,49 +41,39 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
     }
 
     @Override
-    public void tick()
-    {
+    public void tick() {
         super.tick();
         board.update(this);
         tickData();
     }
-    
-    public void setTabListDisplayName(String name, ISnuviScheduler scheduler)
-    {
+
+    public void setTabListDisplayName(String name, ISnuviScheduler scheduler) {
         tabDisplayName = new StringTextComponent(name);
-        scheduler.scheduleTask(() -> 
-        {
+        scheduler.scheduleTask(() -> {
             server.getPlayerList().sendPacketToAllPlayers(
-                new SPlayerListItemPacket(SPlayerListItemPacket.Action.UPDATE_DISPLAY_NAME, this));
+                    new SPlayerListItemPacket(SPlayerListItemPacket.Action.UPDATE_DISPLAY_NAME, this));
         });
     }
 
     @Override
-    public ITextComponent getTabListDisplayName()
-    {
+    public ITextComponent getTabListDisplayName() {
         return tabDisplayName;
     }
-    
-    public void setId(int id)
-    {
+
+    public void setId(int id) {
         this.id = id;
     }
-    
-    public int getId()
-    {
+
+    public int getId() {
         return id;
     }
-    
-    private void tickData()
-    {
+
+    private void tickData() {
         isIterating = true;
-        timedData.entrySet().removeIf(entry -> 
-        {
+        timedData.entrySet().removeIf(entry -> {
             int time = entry.getValue() - 1;
-            if(time <= 0)
-            {
-                if(time == 0)
-                {
+            if(time <= 0) {
+                if(time == 0) {
                     Server.scriptEvents.onPlayerDataTick(this, entry.getKey());
                 }
                 return true;
@@ -97,50 +83,38 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
         });
         isIterating = false;
     }
-    
-    public void setVar(String varname, Object value)
-    {
+
+    public void setVar(String varname, Object value) {
         data.put(varname, value);
     }
-    
-    public Object getVar(String varname)
-    {
+
+    public Object getVar(String varname) {
         return data.get(varname);
     }
-    
-    public void setTimer(String varname, int time, ISnuviScheduler scheduler)
-    {
-        if(isIterating)
-        {
+
+    public void setTimer(String varname, int time, ISnuviScheduler scheduler) {
+        if(isIterating) {
             scheduler.scheduleTask(() -> timedData.put(varname, time));
-        }
-        else
-        {
+        } else {
             timedData.put(varname, time);
         }
     }
-    
-    public int getTimer(String varname)
-    {
+
+    public int getTimer(String varname) {
         return timedData.getOrDefault(varname, -1);
     }
-    
-    public void clearData(ISnuviScheduler scheduler)
-    {
-        if(isIterating)
-        {
+
+    public void clearData(ISnuviScheduler scheduler) {
+        if(isIterating) {
             scheduler.scheduleTask(() -> timedData.clear());
-        }
-        else
-        {
+        } else {
             timedData.clear();
         }
         data.clear();
     }
 
     @Override
-    protected int getPermissionLevel()
-    {
+    protected int getPermissionLevel() {
         return 999;
     }
 }

+ 41 - 84
src/main/java/me/km/overrides/ModPlayerList.java

@@ -48,14 +48,12 @@ import net.minecraft.world.dimension.DimensionType;
 import net.minecraft.world.storage.WorldInfo;
 import org.apache.logging.log4j.LogManager;
 
-public final class ModPlayerList extends DedicatedPlayerList
-{
+public final class ModPlayerList extends DedicatedPlayerList {
     private final DedicatedServer server;
     private final List<ServerPlayerEntity> players;
     private final Map<UUID, ServerPlayerEntity> uuidToPlayerMap;
 
-    public ModPlayerList(DedicatedServer server)
-    {
+    public ModPlayerList(DedicatedServer server) {
         super(server);
         this.server = server;
         this.players = getPlayers();
@@ -63,16 +61,14 @@ public final class ModPlayerList extends DedicatedPlayerList
     }
 
     @Override
-    public void initializeConnectionToPlayer(NetworkManager netManager, ServerPlayerEntity p)
-    {
+    public void initializeConnectionToPlayer(NetworkManager netManager, ServerPlayerEntity p) {
         GameProfile profile = p.getGameProfile();
         PlayerProfileCache cache = this.server.getPlayerProfileCache();
         cache.addEntry(profile);
         CompoundNBT compoundnbt = this.readPlayerDataFromFile(p);
-        
+
         ServerWorld sw = this.server.getWorld(p.dimension);
-        if (sw == null) 
-        {
+        if(sw == null) {
             p.dimension = DimensionType.OVERWORLD;
             sw = this.server.getWorld(p.dimension);
             p.setPosition(sw.getWorldInfo().getSpawnX(), sw.getWorldInfo().getSpawnY(), sw.getWorldInfo().getSpawnZ());
@@ -80,8 +76,7 @@ public final class ModPlayerList extends DedicatedPlayerList
         p.setWorld(sw);
         p.interactionManager.setWorld((ServerWorld) p.world);
         String s1 = "local";
-        if(netManager.getRemoteAddress() != null)
-        {
+        if(netManager.getRemoteAddress() != null) {
             s1 = netManager.getRemoteAddress().toString();
         }
 
@@ -110,58 +105,45 @@ public final class ModPlayerList extends DedicatedPlayerList
         this.uuidToPlayerMap.put(p.getUniqueID(), p);
         this.sendPacketToAllPlayers(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, p));
 
-        for(int i = 0; i < this.players.size(); i++)
-        {
+        for(int i = 0; i < this.players.size(); i++) {
             p.connection.sendPacket(new SPlayerListItemPacket(SPlayerListItemPacket.Action.ADD_PLAYER, players.get(i)));
         }
 
         sw.addNewPlayer(p);
         server.getCustomBossEvents().onPlayerLogin(p);
         sendWorldInfo(p, sw);
-        if(!this.server.getResourcePackUrl().isEmpty())
-        {
+        if(!this.server.getResourcePackUrl().isEmpty()) {
             p.loadResourcePack(server.getResourcePackUrl(), server.getResourcePackHash());
         }
 
-        for(EffectInstance effectinstance : p.getActivePotionEffects())
-        {
+        for(EffectInstance effectinstance : p.getActivePotionEffects()) {
             spnh.sendPacket(new SPlayEntityEffectPacket(p.getEntityId(), effectinstance));
         }
 
-        if(compoundnbt != null && compoundnbt.contains("RootVehicle", 10))
-        {
+        if(compoundnbt != null && compoundnbt.contains("RootVehicle", 10)) {
             CompoundNBT compoundnbt1 = compoundnbt.getCompound("RootVehicle");
             final ServerWorld worldf = sw;
-            Entity entity1 = EntityType.func_220335_a(compoundnbt1.getCompound("Entity"), sw, (p_217885_1_) ->
-            {
+            Entity entity1 = EntityType.func_220335_a(compoundnbt1.getCompound("Entity"), sw, (p_217885_1_) -> {
                 return !worldf.summonEntity(p_217885_1_) ? null : p_217885_1_;
             });
-            if(entity1 != null)
-            {
+            if(entity1 != null) {
                 UUID uuid = compoundnbt1.getUniqueId("Attach");
-                if(entity1.getUniqueID().equals(uuid))
-                {
+                if(entity1.getUniqueID().equals(uuid)) {
                     p.startRiding(entity1, true);
-                }
-                else
-                {
-                    for(Entity entity : entity1.getRecursivePassengers())
-                    {
-                        if(entity.getUniqueID().equals(uuid))
-                        {
+                } else {
+                    for(Entity entity : entity1.getRecursivePassengers()) {
+                        if(entity.getUniqueID().equals(uuid)) {
                             p.startRiding(entity, true);
                             break;
                         }
                     }
                 }
 
-                if(!p.isPassenger())
-                {
+                if(!p.isPassenger()) {
                     LogManager.getLogger().warn("Couldn't reattach entity to player");
                     p.removeEntity(entity1);
 
-                    for(Entity entity2 : entity1.getRecursivePassengers())
-                    {
+                    for(Entity entity2 : entity1.getRecursivePassengers()) {
                         sw.removeEntity(entity2);
                     }
                 }
@@ -173,74 +155,58 @@ public final class ModPlayerList extends DedicatedPlayerList
     }
 
     @Override
-    public ServerPlayerEntity createPlayerForUser(GameProfile profile)
-    {
+    public ServerPlayerEntity createPlayerForUser(GameProfile profile) {
         UUID uuid = PlayerEntity.getUUID(profile);
         List<ServerPlayerEntity> list = Lists.newArrayList();
 
-        for(int i = 0; i < this.players.size(); i++)
-        {
+        for(int i = 0; i < this.players.size(); i++) {
             ServerPlayerEntity p = this.players.get(i);
-            if(p.getUniqueID().equals(uuid))
-            {
+            if(p.getUniqueID().equals(uuid)) {
                 list.add(p);
             }
         }
 
         ServerPlayerEntity p2 = this.uuidToPlayerMap.get(profile.getId());
-        if(p2 != null && !list.contains(p2))
-        {
+        if(p2 != null && !list.contains(p2)) {
             list.add(p2);
         }
 
-        for(ServerPlayerEntity p : list)
-        {
+        for(ServerPlayerEntity p : list) {
             p.connection.disconnect(new TranslationTextComponent("multiplayer.disconnect.duplicate_login"));
         }
 
         PlayerInteractionManager playerinteractionmanager;
-        if(server.isDemo())
-        {
+        if(server.isDemo()) {
             playerinteractionmanager = new DemoPlayerInteractionManager(server.getWorld(DimensionType.OVERWORLD));
-        }
-        else
-        {
+        } else {
             playerinteractionmanager = new PlayerInteractionManager(server.getWorld(DimensionType.OVERWORLD));
         }
 
         return new ModEntityPlayerMP(this.server, this.server.getWorld(DimensionType.OVERWORLD), profile, playerinteractionmanager);
     }
-        
+
     @Override
-    public ServerPlayerEntity recreatePlayerEntity(ServerPlayerEntity pIn, DimensionType dim, boolean conqueredEnd)
-    {
+    public ServerPlayerEntity recreatePlayerEntity(ServerPlayerEntity pIn, DimensionType dim, boolean conqueredEnd) {
         Server.scriptEvents.onPlayerPreRespawn(pIn);
         ServerWorld world = server.getWorld(dim);
-        if(world == null)
-        {
+        if(world == null) {
             dim = pIn.getSpawnDimension();
-        }
-        else if(!world.getDimension().canRespawnHere())
-        {
+        } else if(!world.getDimension().canRespawnHere()) {
             dim = world.getDimension().getRespawnDimension(pIn);
         }
-        if(server.getWorld(dim) == null)
-        {
+        if(server.getWorld(dim) == null) {
             dim = DimensionType.OVERWORLD;
         }
-        
+
         this.removePlayer(pIn);
         pIn.getServerWorld().removePlayer(pIn, true); // Forge: keep data until copyFrom called
         BlockPos blockpos = pIn.getBedLocation(dim);
         boolean flag = pIn.isSpawnForced(dim);
         pIn.dimension = dim;
         PlayerInteractionManager playerinteractionmanager;
-        if(this.server.isDemo())
-        {
+        if(this.server.isDemo()) {
             playerinteractionmanager = new DemoPlayerInteractionManager(this.server.getWorld(pIn.dimension));
-        }
-        else
-        {
+        } else {
             playerinteractionmanager = new PlayerInteractionManager(this.server.getWorld(pIn.dimension));
         }
 
@@ -252,30 +218,24 @@ public final class ModPlayerList extends DedicatedPlayerList
         p.setEntityId(pIn.getEntityId());
         p.setPrimaryHand(pIn.getPrimaryHand());
 
-        for(String s : pIn.getTags())
-        {
+        for(String s : pIn.getTags()) {
             p.addTag(s);
         }
 
         ServerWorld sw = this.server.getWorld(pIn.dimension);
         setPlayerGameTypeBasedOnOther(p, pIn, sw);
-        if(blockpos != null)
-        {
+        if(blockpos != null) {
             Optional<Vec3d> optional = PlayerEntity.func_213822_a(server.getWorld(pIn.dimension), blockpos, flag);
-            if(optional.isPresent())
-            {
+            if(optional.isPresent()) {
                 Vec3d vec3d = optional.get();
                 p.setLocationAndAngles(vec3d.x, vec3d.y, vec3d.z, 0.0f, 0.0f);
                 p.setSpawnPoint(blockpos, flag, false, dim);
-            }
-            else
-            {
+            } else {
                 p.connection.sendPacket(new SChangeGameStatePacket(0, 0.0f));
             }
         }
 
-        while(!sw.func_226669_j_(p) && p.getPosY() < 256.0D) 
-        {
+        while(!sw.func_226669_j_(p) && p.getPosY() < 256.0D) {
             p.setPosition(p.getPosX(), p.getPosY() + 1.0, p.getPosZ());
         }
 
@@ -298,17 +258,14 @@ public final class ModPlayerList extends DedicatedPlayerList
         return p;
     }
 
-    private void setPlayerGameTypeBasedOnOther(ServerPlayerEntity target, ServerPlayerEntity source, IWorld w) 
-    {
+    private void setPlayerGameTypeBasedOnOther(ServerPlayerEntity target, ServerPlayerEntity source, IWorld w) {
         ReflectionUtils.setPlayerGameTypeBasedOnOther(this, target, source, w);
     }
 
     @Override
-    public void sendMessage(ITextComponent component)
-    {
+    public void sendMessage(ITextComponent component) {
         // filter multiplayer leave text
-        if(component instanceof TranslationTextComponent && ((TranslationTextComponent) component).getKey().equals("multiplayer.player.left"))
-        {
+        if(component instanceof TranslationTextComponent && ((TranslationTextComponent) component).getKey().equals("multiplayer.player.left")) {
             return;
         }
         super.sendMessage(component);

+ 2 - 4
src/main/java/me/km/overrides/ModPlayerRenderer.java

@@ -6,10 +6,8 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.CLIENT)
-public class ModPlayerRenderer extends PlayerRenderer
-{
-    public ModPlayerRenderer(EntityRendererManager renderManager, boolean useSmallArms)
-    {
+public class ModPlayerRenderer extends PlayerRenderer {
+    public ModPlayerRenderer(EntityRendererManager renderManager, boolean useSmallArms) {
         super(renderManager, useSmallArms);
         this.addLayer(new ModCapeLayer(this));
     }

+ 13 - 28
src/main/java/me/km/overrides/PlayerCapeLoader.java

@@ -15,10 +15,8 @@ import net.minecraftforge.api.distmarker.OnlyIn;
 import org.apache.logging.log4j.LogManager;
 
 @OnlyIn(Dist.CLIENT)
-public class PlayerCapeLoader
-{
-    private static class Data
-    {
+public class PlayerCapeLoader {
+    private static class Data {
         private ResourceLocation cape;
     }
 
@@ -28,33 +26,26 @@ public class PlayerCapeLoader
 
     private final TextureManager manager = Minecraft.getInstance().getRenderManager().textureManager;
 
-    private PlayerCapeLoader()
-    {
+    private PlayerCapeLoader() {
     }
 
-    public ResourceLocation getTexture(UUID uuid)
-    {
+    public ResourceLocation getTexture(UUID uuid) {
         Data oldData = skins.get(uuid);
-        if(oldData != null)
-        {
+        if(oldData != null) {
             return oldData.cape;
         }
         Data newData = new Data();
         skins.put(uuid, newData);
-        downloadCape(uuid, image ->
-        {
+        downloadCape(uuid, image -> {
             newData.cape = manager.getDynamicTextureLocation("cape_" + uuid, new DynamicTexture(image));
         });
         return null;
     }
 
-    private void downloadCape(UUID uuid, Consumer<NativeImage> delayed)
-    {
-        new Thread(() ->
-        {
+    private void downloadCape(UUID uuid, Consumer<NativeImage> delayed) {
+        new Thread(() -> {
             HttpURLConnection httpurlconnection = null;
-            try
-            {
+            try {
                 httpurlconnection = (HttpURLConnection) (new URL(String.format("http://skins.hammerle.me/cape_%s.png", uuid)))
                         .openConnection(Minecraft.getInstance().getProxy());
                 httpurlconnection.setDoInput(true);
@@ -62,22 +53,16 @@ public class PlayerCapeLoader
                 httpurlconnection.connect();
 
                 int code = httpurlconnection.getResponseCode();
-                if(code != 200)
-                {
+                if(code != 200) {
                     return;
                 }
 
                 NativeImage image = NativeImage.read(httpurlconnection.getInputStream());
                 Minecraft.getInstance().enqueue(() -> delayed.accept(image));
-            }
-            catch(Exception ex)
-            {
+            } catch(Exception ex) {
                 LogManager.getLogger().warn("Error occurred when downloading skin, however, skin servers seem to be up.");
-            }
-            finally
-            {
-                if(httpurlconnection != null)
-                {
+            } finally {
+                if(httpurlconnection != null) {
                     httpurlconnection.disconnect();
                 }
             }

+ 18 - 35
src/main/java/me/km/overrides/PlayerScoreboard.java

@@ -13,8 +13,7 @@ import net.minecraft.scoreboard.Scoreboard;
 import net.minecraft.scoreboard.ServerScoreboard.Action;
 import net.minecraft.util.text.StringTextComponent;
 
-public class PlayerScoreboard 
-{
+public class PlayerScoreboard {
     private final HashMap<Integer, String> elements = new HashMap<>();
     private final HashSet<Integer> toRemove = new HashSet<>();
     private final HashMap<Integer, String> toAdd = new HashMap<>();
@@ -22,78 +21,62 @@ public class PlayerScoreboard
     private final Scoreboard board = new Scoreboard();
     private final ScoreObjective o;
     private boolean changeNeeded = true;
-    
+
     private boolean init = true;
 
-    public PlayerScoreboard()
-    {
+    public PlayerScoreboard() {
         o = new ScoreObjective(board, "ScoreBoardAPI", ScoreCriteria.DUMMY, new StringTextComponent("§6---------------"), RenderType.INTEGER);
     }
 
-    public void addText(int id, String text)
-    { 
+    public void addText(int id, String text) {
         String s = elements.get(id);
-        if(s != null && !s.equals(text))
-        {
+        if(s != null && !s.equals(text)) {
             toRemove.add(id);
             toAdd.put(id, text);
             changeNeeded = true;
-        }
-        else if(s == null)
-        {
+        } else if(s == null) {
             toAdd.put(id, text);
             changeNeeded = true;
         }
     }
 
-    public void removeText(int id)
-    { 
-        if(elements.containsKey(id))
-        {
+    public void removeText(int id) {
+        if(elements.containsKey(id)) {
             toRemove.add(id);
             changeNeeded = true;
         }
     }
 
-    public void clear(ServerPlayerEntity p)
-    {
+    public void clear(ServerPlayerEntity p) {
         elements.keySet().forEach(i -> toRemove.add(i));
         changeNeeded = true;
         update(p);
     }
 
-    public boolean update(ServerPlayerEntity p)
-    {         
-        if(!changeNeeded)
-        {
+    public boolean update(ServerPlayerEntity p) {
+        if(!changeNeeded) {
             return false;
         }
-        if(init)
-        {
+        if(init) {
             init = false;
             p.connection.sendPacket(new SScoreboardObjectivePacket(o, 0));
         }
 
-        if(!toRemove.isEmpty())
-        {
-            toRemove.forEach(i -> 
-            {
+        if(!toRemove.isEmpty()) {
+            toRemove.forEach(i -> {
                 String s = elements.remove(i);
-                if(s != null)
-                {
+                if(s != null) {
                     p.connection.sendPacket(new SUpdateScorePacket(Action.REMOVE, o.getName(), s, -1));
                 }
             });
             toRemove.clear();
         }
 
-        if(!toAdd.isEmpty())
-        {
-            toAdd.entrySet().stream().forEach((e) -> 
-            {
+        if(!toAdd.isEmpty()) {
+            toAdd.entrySet().stream().forEach((e) -> {
                 elements.put(e.getKey(), e.getValue());
                 p.connection.sendPacket(new SUpdateScorePacket(Action.CHANGE, o.getName(), e.getValue(), e.getKey()));
-            });      
+            });
             toAdd.clear();
         }
 

+ 8 - 12
src/main/java/me/km/permissions/Command.java

@@ -4,24 +4,20 @@ import java.util.Collections;
 import net.minecraft.command.ICommandSource;
 import net.minecraft.util.text.StringTextComponent;
 
-public abstract class Command
-{
+public abstract class Command {
     public abstract String getName();
-    
-    public Iterable<String> getAliases()
-    {
+
+    public Iterable<String> getAliases() {
         return Collections.EMPTY_LIST;
     }
-    
+
     public abstract void execute(ICommandSource cs, String[] arg);
-    
-    public void sendMessage(ICommandSource cs, String message)
-    {
+
+    public void sendMessage(ICommandSource cs, String message) {
         cs.sendMessage(new StringTextComponent(String.format("[§dScript§r] %s", message)));
     }
-    
-    public void sendMessage(ICommandSource cs, String message1, String message2)
-    {
+
+    public void sendMessage(ICommandSource cs, String message1, String message2) {
         cs.sendMessage(new StringTextComponent(String.format("§d - %s§r %s", message1, message2)));
     }
 }

+ 62 - 105
src/main/java/me/km/permissions/ModCommandManager.java

@@ -23,98 +23,79 @@ import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.network.play.server.SCommandListPacket;
 
-public class ModCommandManager extends Commands
-{
+public class ModCommandManager extends Commands {
     private final HashSet<String> otherCommands = new HashSet<>();
-    
+
     private final HashMap<String, Command> commands = new HashMap<>();
     private final PermissionManager perms;
     private final ScriptEvents events;
     private final Scripts scripts;
-    
+
     private final ArrayList<CommandNode> customNodes = new ArrayList<>();
 
-    public ModCommandManager(boolean isDedicatedServer, PermissionManager perms, ScriptEvents events, Scripts scripts, ISnuviScheduler scheduler)
-    {
+    public ModCommandManager(boolean isDedicatedServer, PermissionManager perms, ScriptEvents events, Scripts scripts, ISnuviScheduler scheduler) {
         super(isDedicatedServer);
-        getDispatcher().getRoot().getChildren().forEach(c -> 
-        {
+        getDispatcher().getRoot().getChildren().forEach(c -> {
             otherCommands.add(c.getName());
         });
-        scheduler.scheduleTask(() -> 
-        {
-            getDispatcher().getRoot().getChildren().forEach(c -> 
-            {
-                if(otherCommands.add(c.getName()))
-                {
+        scheduler.scheduleTask(() -> {
+            getDispatcher().getRoot().getChildren().forEach(c -> {
+                if(otherCommands.add(c.getName())) {
                     perms.addOtherGroupPermission(c.getName());
                 }
-            }); 
+            });
         });
         this.perms = perms;
         this.events = events;
         this.scripts = scripts;
     }
-    
-    public void clearCustomNodes()
-    {
+
+    public void clearCustomNodes() {
         customNodes.clear();
     }
-    
-    public void addCustomNodes(CommandNode node)
-    {
+
+    public void addCustomNodes(CommandNode node) {
         customNodes.add(node);
     }
-    
-    public void registerCommand(Command command)
-    {
+
+    public void registerCommand(Command command) {
         commands.put(command.getName(), command);
-        for(String alias : command.getAliases())
-        {
+        for(String alias : command.getAliases()) {
             commands.put(alias, command);
         }
     }
 
-    private String getCommandName(String rawCommand)
-    {
-        if(rawCommand.isEmpty())
-        {
+    private String getCommandName(String rawCommand) {
+        if(rawCommand.isEmpty()) {
             return "";
         }
         int index = rawCommand.indexOf(' ');
         return rawCommand.substring(rawCommand.charAt(0) == '/' ? 1 : 0, index == -1 ? rawCommand.length() : index);
     }
-    
-    private static String[] getArguments(String rawCommand)
-    {
+
+    private static String[] getArguments(String rawCommand) {
         int old = rawCommand.indexOf(' ') + 1;
-        if(old == 0)
-        {
+        if(old == 0) {
             return new String[0];
         }
         int pos = old;
         ArrayList<String> list = new ArrayList<>();
-        while(pos < rawCommand.length())
-        {
+        while(pos < rawCommand.length()) {
             char c = rawCommand.charAt(pos);
-            switch(c)
-            {
+            switch(c) {
                 case ' ':
-                    if(pos - old > 0)
-                    {
+                    if(pos - old > 0) {
                         list.add(rawCommand.substring(old, pos));
                     }
                     old = pos + 1;
                     break;
                 case '"':
-                    if(pos - old > 0)
-                    {
+                    if(pos - old > 0) {
                         list.add(rawCommand.substring(old, pos));
                     }
                     old = pos + 1;
                     pos = old;
-                    while(pos < rawCommand.length() && rawCommand.charAt(pos) != '"')
-                    {
+                    while(pos < rawCommand.length() && rawCommand.charAt(pos) != '"') {
                         pos++;
                     }
                     list.add(rawCommand.substring(old, pos));
@@ -123,73 +104,59 @@ public class ModCommandManager extends Commands
             }
             pos++;
         }
-        if(pos - old > 0)
-        {
+        if(pos - old > 0) {
             list.add(rawCommand.substring(old, pos));
         }
         return list.toArray(new String[list.size()]);
     }
 
-    private ICommandSource getSource(CommandSource cs)
-    {
-        if(cs.getEntity() != null)
-        {
+    private ICommandSource getSource(CommandSource cs) {
+        if(cs.getEntity() != null) {
             return cs.getEntity();
         }
         return cs.getServer();
     }
-    
-    private String lowerRawCommand(String raw)
-    {
+
+    private String lowerRawCommand(String raw) {
         int index = raw.indexOf(" ");
-        if(index == -1)
-        {
+        if(index == -1) {
             return raw.toLowerCase();
         }
         return raw.substring(0, index).toLowerCase() + raw.substring(index);
     }
-    
+
     @Override
-    public int handleCommand(CommandSource cs, String rawCommand)
-    { 
+    public int handleCommand(CommandSource cs, String rawCommand) {
         rawCommand = lowerRawCommand(rawCommand);
         String commandName = getCommandName(rawCommand);
-        
+
         Command command = commands.get(commandName);
-        if(command != null)
-        {
-            if(perms.hasPermission(cs, command.getName()))
-            {
+        if(command != null) {
+            if(perms.hasPermission(cs, command.getName())) {
                 command.execute(getSource(cs), getArguments(rawCommand));
                 return 1;
             }
             events.onMissingPermission(getSource(cs), command.getName());
             return 0;
         }
-        
-        if(scripts.isRegisteredScriptCommand(commandName))
-        {
+
+        if(scripts.isRegisteredScriptCommand(commandName)) {
             Entity ent = cs.getEntity();
-            if(ent != null && ent instanceof PlayerEntity)
-            {
+            if(ent != null && ent instanceof PlayerEntity) {
                 events.onCustomCommand((PlayerEntity) ent, commandName, getArguments(rawCommand));
                 return 1;
             }
             events.onCustomCommand(null, commandName, getArguments(rawCommand));
             return 0;
         }
-        
-        if(otherCommands.contains(commandName))
-        {
-            if(perms.hasPermission(cs, commandName))
-            {
+
+        if(otherCommands.contains(commandName)) {
+            if(perms.hasPermission(cs, commandName)) {
                 Entity ent = cs.getEntity();
-                if(ent != null && ent instanceof PlayerEntity)
-                {
+                if(ent != null && ent instanceof PlayerEntity) {
                     CommandEvent e = new CommandEvent((PlayerEntity) ent, commandName);
                     events.onCommand(e);
-                    if(e.isCanceled())
-                    {
+                    if(e.isCanceled()) {
                         return 0;
                     }
                 }
@@ -198,63 +165,53 @@ public class ModCommandManager extends Commands
             events.onMissingPermission(getSource(cs), commandName);
             return 0;
         }
-        
+
         events.onMissingCommand(getSource(cs), commandName);
         return 0;
     }
 
     @Override
-    public void send(ServerPlayerEntity player)
-    {
+    public void send(ServerPlayerEntity player) {
         Map<CommandNode<CommandSource>, CommandNode<ISuggestionProvider>> map = Maps.newHashMap();
         RootCommandNode<ISuggestionProvider> rootcommandnode = new RootCommandNode<>();
         map.put(getDispatcher().getRoot(), rootcommandnode);
         this.commandSourceNodesToSuggestionNodes(true, getDispatcher().getRoot(), rootcommandnode, player.getCommandSource(), map);
-        
-        for(CommandNode node : customNodes)
-        {
+
+        for(CommandNode node : customNodes) {
             rootcommandnode.addChild(node);
         }
-        
+
         player.connection.sendPacket(new SCommandListPacket(rootcommandnode));
     }
 
-    private void commandSourceNodesToSuggestionNodes(boolean first, 
-            CommandNode<CommandSource> node, 
-            CommandNode<ISuggestionProvider> suggestion, 
-            CommandSource source, 
-            Map<CommandNode<CommandSource>, CommandNode<ISuggestionProvider>> map)
-    {
-        for(CommandNode<CommandSource> commandnode : node.getChildren())
-        {
-            if((first && perms.hasPermission(source, commandnode.getName()) || (!first && commandnode.canUse(source))))
-            {
+    private void commandSourceNodesToSuggestionNodes(boolean first,
+            CommandNode<CommandSource> node,
+            CommandNode<ISuggestionProvider> suggestion,
+            CommandSource source,
+            Map<CommandNode<CommandSource>, CommandNode<ISuggestionProvider>> map) {
+        for(CommandNode<CommandSource> commandnode : node.getChildren()) {
+            if((first && perms.hasPermission(source, commandnode.getName()) || (!first && commandnode.canUse(source)))) {
                 ArgumentBuilder<ISuggestionProvider, ?> argumentbuilder = (ArgumentBuilder) commandnode.createBuilder();
                 argumentbuilder.requires(a -> true);
-                if(argumentbuilder.getCommand() != null)
-                {
+                if(argumentbuilder.getCommand() != null) {
                     argumentbuilder.executes(a -> 0);
                 }
 
-                if(argumentbuilder instanceof RequiredArgumentBuilder)
-                {
+                if(argumentbuilder instanceof RequiredArgumentBuilder) {
                     RequiredArgumentBuilder<ISuggestionProvider, ?> requiredargumentbuilder = (RequiredArgumentBuilder) argumentbuilder;
-                    if(requiredargumentbuilder.getSuggestionsProvider() != null)
-                    {
+                    if(requiredargumentbuilder.getSuggestionsProvider() != null) {
                         requiredargumentbuilder.suggests(SuggestionProviders.ensureKnown(requiredargumentbuilder.getSuggestionsProvider()));
                     }
                 }
 
-                if(argumentbuilder.getRedirect() != null)
-                {
+                if(argumentbuilder.getRedirect() != null) {
                     argumentbuilder.redirect(map.get(argumentbuilder.getRedirect()));
                 }
 
                 CommandNode<ISuggestionProvider> commandNode = argumentbuilder.build();
                 map.put(commandnode, commandNode);
                 suggestion.addChild(commandNode);
-                if(!commandnode.getChildren().isEmpty())
-                {
+                if(!commandnode.getChildren().isEmpty()) {
                     this.commandSourceNodesToSuggestionNodes(false, commandnode, commandNode, source, map);
                 }
             }

+ 35 - 63
src/main/java/me/km/permissions/PermissionManager.java

@@ -10,82 +10,65 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.DEDICATED_SERVER)
-public class PermissionManager
-{
+public class PermissionManager {
     private final HashMap<UUID, ArrayList<Integer>> playerGroups = new HashMap<>();
     private final ArrayList<HashSet<String>> stringGroupPerms = new ArrayList<>();
     private final HashSet<String> otherGroup = new HashSet<>();
     private final boolean debug;
-    
-    public PermissionManager(boolean debug) 
-    {
+
+    public PermissionManager(boolean debug) {
         this.debug = debug;
         addGroups();
     }
 
-    public void clear()
-    {
+    public void clear() {
         playerGroups.clear();
         stringGroupPerms.clear();
         addGroups();
     }
-    
-    private void addGroups()
-    {
+
+    private void addGroups() {
         stringGroupPerms.add(new HashSet<>());
         stringGroupPerms.add(otherGroup);
     }
-    
-    public void addOtherGroupPermission(String perm)
-    {
+
+    public void addOtherGroupPermission(String perm) {
         otherGroup.add(perm);
     }
-    
+
     // -------------------------------------------------------------------------
     // Permission-Check
     // -------------------------------------------------------------------------
-    
     private final static UUID MARVINIUS = UUID.fromString("e41b5335-3c74-46e9-a6c5-dafc6334a477");
     private final static UUID KAJETANJOHANNES = UUID.fromString("51e240f9-ab10-4ea6-8a5d-779319f51257");
-    
-    public boolean hasPermission(Entity ent, String perm) 
-    {
+
+    public boolean hasPermission(Entity ent, String perm) {
         return hasPermission(ent.getUniqueID(), perm);
     }
-    
-    public boolean hasPermission(UUID uuid, String perm) 
-    {
-        if(debug)
-        {
+
+    public boolean hasPermission(UUID uuid, String perm) {
+        if(debug) {
             return true;
         }
-        if(perm.equals("script"))
-        {
-            if(uuid.equals(MARVINIUS) || uuid.equals(KAJETANJOHANNES))
-            {
+        if(perm.equals("script")) {
+            if(uuid.equals(MARVINIUS) || uuid.equals(KAJETANJOHANNES)) {
                 return true;
             }
         }
         ArrayList<Integer> groups = playerGroups.get(uuid);
-        if(groups == null)
-        {
-            if(!stringGroupPerms.isEmpty())
-            {
+        if(groups == null) {
+            if(!stringGroupPerms.isEmpty()) {
                 return stringGroupPerms.get(0).contains(perm);
-            }
-            else
-            {
+            } else {
                 return false;
             }
         }
         return groups.stream().anyMatch(i -> stringGroupPerms.get(i).contains(perm));
     }
-    
-    public boolean hasPermission(CommandSource cs, String perm) 
-    {
+
+    public boolean hasPermission(CommandSource cs, String perm) {
         Entity ent = cs.getEntity();
-        if(ent != null)
-        {
+        if(ent != null) {
             return hasPermission(ent.getUniqueID(), perm);
         }
         return true;
@@ -94,16 +77,12 @@ public class PermissionManager
     // -------------------------------------------------------------------------
     // Permission-Registry
     // -------------------------------------------------------------------------
-    
-    public void registerPlayerGroup(UUID uuid, int id)
-    {
-        if(id < 0 || id >= stringGroupPerms.size())
-        {
+    public void registerPlayerGroup(UUID uuid, int id) {
+        if(id < 0 || id >= stringGroupPerms.size()) {
             throw new IllegalArgumentException(String.format("%d' is no valid group id", id));
         }
         ArrayList<Integer> groups = playerGroups.get(uuid);
-        if(groups == null)
-        {
+        if(groups == null) {
             groups = new ArrayList<>();
             // adding default group
             groups.add(0);
@@ -111,33 +90,26 @@ public class PermissionManager
         }
         groups.add(id);
     }
-    
-    public boolean unregisterPlayer(UUID uuid, int id)
-    {
-        if(id < 0 || id >= stringGroupPerms.size())
-        {
+
+    public boolean unregisterPlayer(UUID uuid, int id) {
+        if(id < 0 || id >= stringGroupPerms.size()) {
             throw new IllegalArgumentException(String.format("%d' is no valid group id", id));
         }
         ArrayList<Integer> groups = playerGroups.get(uuid);
-        if(groups == null)
-        {
+        if(groups == null) {
             return false;
         }
         return groups.remove((Integer) id);
     }
-    
-    public void registerGroupPermission(int id, String perm)
-    {
-        if(perm.isEmpty())
-        {
+
+    public void registerGroupPermission(int id, String perm) {
+        if(perm.isEmpty()) {
             throw new IllegalArgumentException("empty permission string");
         }
-        if(id == 1)
-        {
+        if(id == 1) {
             throw new IllegalArgumentException("id 1 is reserved for worldedit");
         }
-        if(id >= stringGroupPerms.size())
-        {
+        if(id >= stringGroupPerms.size()) {
             HashSet<String> set = new HashSet<>();
             set.add(perm);
             stringGroupPerms.add(set);
@@ -145,4 +117,4 @@ public class PermissionManager
         }
         stringGroupPerms.get(id).add(perm);
     }
-}
+}

+ 10 - 19
src/main/java/me/km/playerbank/DummyPlayerBank.java

@@ -3,18 +3,15 @@ package me.km.playerbank;
 import java.util.HashMap;
 import java.util.UUID;
 
-public class DummyPlayerBank implements IPlayerBank
-{
+public class DummyPlayerBank implements IPlayerBank {
     private final HashMap<UUID, String> uuidToName = new HashMap<>();
     private final HashMap<UUID, Integer> uuidToId = new HashMap<>();
     private final HashMap<Integer, UUID> idToUuid = new HashMap<>();
     private int id = 0;
-    
+
     @Override
-    public boolean add(UUID uuid, String name)
-    {
-        if(uuidToName.put(uuid, name) == null)
-        {
+    public boolean add(UUID uuid, String name) {
+        if(uuidToName.put(uuid, name) == null) {
             int c = id++;
             uuidToId.put(uuid, c);
             idToUuid.put(c, uuid);
@@ -23,37 +20,31 @@ public class DummyPlayerBank implements IPlayerBank
     }
 
     @Override
-    public void changeName(UUID uuid, String name)
-    {
+    public void changeName(UUID uuid, String name) {
         uuidToName.put(uuid, name);
     }
 
     @Override
-    public int getId(UUID uuid)
-    {
+    public int getId(UUID uuid) {
         return uuidToId.getOrDefault(uuid, -1);
     }
 
     @Override
-    public UUID getUUIDfromID(int id)
-    {
+    public UUID getUUIDfromID(int id) {
         return idToUuid.getOrDefault(id, null);
     }
 
     @Override
-    public String getNamefromID(int id)
-    {
+    public String getNamefromID(int id) {
         UUID uuid = idToUuid.get(id);
-        if(uuid == null)
-        {
+        if(uuid == null) {
             return null;
         }
         return uuidToName.getOrDefault(uuid, "");
     }
 
     @Override
-    public UUID getUUID(String name)
-    {
+    public UUID getUUID(String name) {
         return uuidToName.entrySet().stream().filter(e -> name.equals(e.getValue())).map(e -> e.getKey()).findFirst().orElse(null);
     }
 }

+ 6 - 2
src/main/java/me/km/playerbank/IPlayerBank.java

@@ -2,12 +2,16 @@ package me.km.playerbank;
 
 import java.util.UUID;
 
-public interface IPlayerBank
-{
+public interface IPlayerBank {
     public boolean add(UUID uuid, String name);
+
     public void changeName(UUID uuid, String name);
+
     public int getId(UUID uuid);
+
     public UUID getUUIDfromID(int id);
+
     public String getNamefromID(int id);
+
     public UUID getUUID(String name);
 }

+ 40 - 82
src/main/java/me/km/playerbank/PlayerBank.java

@@ -6,24 +6,22 @@ import java.sql.SQLException;
 import java.util.UUID;
 import me.km.databank.DataBank;
 
-public class PlayerBank implements IPlayerBank
-{  
+public class PlayerBank implements IPlayerBank {
     private final PreparedStatement add;
     private final PreparedStatement changeName;
     private final PreparedStatement getId;
     private final PreparedStatement getUUIDfromID;
     private final PreparedStatement getNamefromID;
     private final PreparedStatement getUUID;
-    
-    public PlayerBank(DataBank databank) 
-    {
+
+    public PlayerBank(DataBank databank) {
         databank.execute("CREATE TABLE IF NOT EXISTS players ("
                 + "id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, "
                 + "uuid_1 BIGINT NOT NULL, "
                 + "uuid_2 BIGINT NOT NULL, "
                 + "name VARCHAR(20) NOT NULL, "
                 + "UNIQUE INDEX (uuid_1, uuid_2));");
-        
+
         add = databank.prepareStatement("INSERT INTO players (uuid_1,uuid_2,name) VALUES (?,?,?);");
         changeName = databank.prepareStatement("UPDATE players SET name=? WHERE uuid_1=? AND uuid_2=?;");
         getId = databank.prepareStatement("SELECT id FROM players WHERE uuid_1=? AND uuid_2=?;");
@@ -31,138 +29,98 @@ public class PlayerBank implements IPlayerBank
         getNamefromID = databank.prepareStatement("SELECT name FROM players WHERE id=?;");
         getUUID = databank.prepareStatement("SELECT uuid_1,uuid_2 FROM players WHERE name=?;");
     }
-    
+
     @Override
-    public boolean add(UUID uuid, String name)
-    {
-        try
-        {
+    public boolean add(UUID uuid, String name) {
+        try {
             add.setLong(1, uuid.getLeastSignificantBits());
             add.setLong(2, uuid.getMostSignificantBits());
             add.setString(3, name);
             add.executeUpdate();
             return true;
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
             return false;
         }
     }
-    
+
     @Override
-    public void changeName(UUID uuid, String name)
-    {
-        try
-        {
+    public void changeName(UUID uuid, String name) {
+        try {
             changeName.setString(1, name);
             changeName.setLong(2, uuid.getLeastSignificantBits());
             changeName.setLong(3, uuid.getMostSignificantBits());
             changeName.executeUpdate();
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
     }
-    
+
     @Override
-    public int getId(UUID uuid)
-    {
-        try
-        {
+    public int getId(UUID uuid) {
+        try {
             getId.setLong(1, uuid.getLeastSignificantBits());
             getId.setLong(2, uuid.getMostSignificantBits());
-            try(ResultSet rs = getId.executeQuery())
-            {
-                if(rs.next())
-                {
+            try(ResultSet rs = getId.executeQuery()) {
+                if(rs.next()) {
                     return rs.getInt(1);
                 }
                 return -1;
-            }
-            catch(SQLException ex)
-            {
+            } catch(SQLException ex) {
                 ex.printStackTrace();
             }
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return -1;
     }
-    
+
     @Override
-    public UUID getUUIDfromID(int id)
-    {
-        try
-        {
+    public UUID getUUIDfromID(int id) {
+        try {
             getUUIDfromID.setInt(1, id);
-            try(ResultSet rs = getUUIDfromID.executeQuery())
-            {
-                if(rs.next())
-                {
+            try(ResultSet rs = getUUIDfromID.executeQuery()) {
+                if(rs.next()) {
                     return new UUID(rs.getLong(2), rs.getLong(1));
                 }
-            }
-            catch(SQLException ex)
-            {
+            } catch(SQLException ex) {
                 ex.printStackTrace();
             }
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return null;
     }
-    
+
     @Override
-    public String getNamefromID(int id)
-    {
-        try
-        {
+    public String getNamefromID(int id) {
+        try {
             getNamefromID.setInt(1, id);
-            try(ResultSet rs = getNamefromID.executeQuery())
-            {
-                if(rs.next())
-                {
+            try(ResultSet rs = getNamefromID.executeQuery()) {
+                if(rs.next()) {
                     return rs.getString(1);
                 }
-            }
-            catch(SQLException ex)
-            {
+            } catch(SQLException ex) {
                 ex.printStackTrace();
             }
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return "";
     }
-    
+
     @Override
-    public UUID getUUID(String name)
-    {
-        try
-        {
+    public UUID getUUID(String name) {
+        try {
             getUUID.setString(1, name);
-            try(ResultSet rs = getUUID.executeQuery())
-            {
-                if(rs.next())
-                {
+            try(ResultSet rs = getUUID.executeQuery()) {
+                if(rs.next()) {
                     return new UUID(rs.getLong(2), rs.getLong(1));
                 }
-            }
-            catch(Exception ex)
-            {
+            } catch(Exception ex) {
                 ex.printStackTrace();
             }
-        }
-        catch(SQLException ex)
-        {
+        } catch(SQLException ex) {
             ex.printStackTrace();
         }
         return null;

+ 12 - 22
src/main/java/me/km/playerbank/PlayerManager.java

@@ -6,45 +6,35 @@ import net.minecraftforge.eventbus.api.EventPriority;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 import net.minecraftforge.event.entity.player.PlayerEvent;
 
-public class PlayerManager
-{
+public class PlayerManager {
     private final ISnuviLogger logger;
     private final IPlayerBank bank;
-    
-    public PlayerManager(ISnuviLogger logger, IPlayerBank bank) 
-    {
+
+    public PlayerManager(ISnuviLogger logger, IPlayerBank bank) {
         this.logger = logger;
         this.bank = bank;
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGH)
-    public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent e)
-    {
+    public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent e) {
         ModEntityPlayerMP p = (ModEntityPlayerMP) e.getPlayer();
-        if(p == null)
-        {
+        if(p == null) {
             return;
         }
-        
+
         int id = bank.getId(p.getUniqueID());
-        if(id == -1)
-        {
+        if(id == -1) {
             bank.add(p.getUniqueID(), p.getName().getUnformattedComponentText());
             logger.print(String.format("'%s' was added", p.getName().getString()));
-            
+
             id = bank.getId(p.getUniqueID());
-            if(id == -1)
-            {
+            if(id == -1) {
                 // this should never happen
                 logger.print(String.format("'%s' has no id", p.getName().getString()));
-            }
-            else
-            {
+            } else {
                 p.setId(id);
             }
-        }
-        else
-        {
+        } else {
             p.setId(id);
             bank.changeName(p.getUniqueID(), p.getName().getString());
         }

+ 133 - 232
src/main/java/me/km/plots/PlotMap.java

@@ -14,13 +14,11 @@ import java.util.UUID;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
-public class PlotMap
-{
-    public static class Plot
-    {
+public class PlotMap {
+    public static class Plot {
         private Plot previous = null;
         private Plot next = null;
-        
+
         private final int id;
         private final int minX;
         private final int minY;
@@ -28,267 +26,215 @@ public class PlotMap
         private final int maxX;
         private final int maxY;
         private final int maxZ;
-        
+
         private final ArrayList<UUID> owners = new ArrayList<>(1);
         private int flags = 0;
-        
+
         private String name = "";
 
-        public Plot(int id, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
-        {
+        public Plot(int id, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
             minX = Math.min(16000, Math.max(-16000, minX));
             minY = Math.min(16000, Math.max(-16000, minY));
             minZ = Math.min(16000, Math.max(-16000, minZ));
             maxX = Math.min(16000, Math.max(-16000, maxX));
             maxY = Math.min(16000, Math.max(-16000, maxY));
             maxZ = Math.min(16000, Math.max(-16000, maxZ));
-            
+
             this.id = id;
-            if(minX < maxX)
-            {
+            if(minX < maxX) {
                 this.minX = minX;
                 this.maxX = maxX;
-            }
-            else
-            {
+            } else {
                 this.minX = maxX;
                 this.maxX = minX;
             }
 
-            if(minY < maxY)
-            {
+            if(minY < maxY) {
                 this.minY = minY;
                 this.maxY = maxY;
-            }
-            else
-            {
+            } else {
                 this.minY = maxY;
                 this.maxY = minY;
             }
 
-            if(minZ < maxZ)
-            {
+            if(minZ < maxZ) {
                 this.minZ = minZ;
                 this.maxZ = maxZ;
-            }
-            else
-            {
+            } else {
                 this.minZ = maxZ;
                 this.maxZ = minZ;
             }
         }
 
-        private boolean isInside(int x, int y, int z)
-        {
+        private boolean isInside(int x, int y, int z) {
             return minX <= x && x <= maxX && minY <= y && y <= maxY && minZ <= z && z <= maxZ;
         }
 
-        public int getMinX()
-        {
+        public int getMinX() {
             return minX;
         }
 
-        public int getMinY()
-        {
+        public int getMinY() {
             return minY;
         }
 
-        public int getMinZ()
-        {
+        public int getMinZ() {
             return minZ;
         }
 
-        public int getMaxX()
-        {
+        public int getMaxX() {
             return maxX;
         }
 
-        public int getMaxY()
-        {
+        public int getMaxY() {
             return maxY;
         }
 
-        public int getMaxZ()
-        {
+        public int getMaxZ() {
             return maxZ;
         }
-        
-        public int getFlags()
-        {
+
+        public int getFlags() {
             return flags;
         }
-        
-        public boolean hasFlags(int flags)
-        {
+
+        public boolean hasFlags(int flags) {
             return (flags & this.flags) == flags;
         }
-        
-        public void setFlag(int flags, boolean b)
-        {
-            if(b)
-            {
+
+        public void setFlag(int flags, boolean b) {
+            if(b) {
                 this.flags |= flags;
-            }
-            else
-            {
+            } else {
                 this.flags &= ~flags;
             }
         }
-        
-        public ArrayList<UUID> getOwners()
-        {
+
+        public ArrayList<UUID> getOwners() {
             return owners;
         }
-        
-        public void setName(String s)
-        {
+
+        public void setName(String s) {
             name = s;
         }
 
-        public String getName()
-        {
+        public String getName() {
             return name;
         }
 
-        public int getId()
-        {
+        public int getId() {
             return id;
         }
 
         @Override
-        public String toString()
-        {
+        public String toString() {
             return String.format("Plot(%d, %d, %d, %d, %d, %d)", minX, minY, minZ, maxX, maxY, maxZ);
         }
     }
-    
+
     private static int idCounter = 0;
 
     private static final int SIZE_FACTOR = 64;
-    private final static int[] PRIMES = 
-    {
-        17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911, 43853, 87719, 
-        175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
-        44917381, 89834777, 179669557, 359339171, 718678369
-    };
-    
+    private final static int[] PRIMES
+            = {
+                17, 37, 79, 163, 331, 673, 1361, 2729, 5471, 10949, 21911, 43853, 87719,
+                175447, 350899, 701819, 1403641, 2807303, 5614657, 11229331, 22458671,
+                44917381, 89834777, 179669557, 359339171, 718678369
+            };
+
     private int primeIndex = 0;
     private int size = 0;
     private ArrayList<Plot>[] plots = new ArrayList[PRIMES[primeIndex]];
     private Plot last = null;
-    
-    public PlotMap()
-    {
+
+    public PlotMap() {
     }
-    
-    private int hash(int x, int z, int arrayLength)
-    {
+
+    private int hash(int x, int z, int arrayLength) {
         int h = (x + z * 12195263) % arrayLength;
-        if(h < 0)
-        {
+        if(h < 0) {
             return h + arrayLength;
         }
         return h;
     }
-    
-    private void rehash()
-    {
+
+    private void rehash() {
         // load factor 0.75
-        if(size < (plots.length * 3 / 4) || primeIndex + 1 >= PRIMES.length)
-        {
+        if(size < (plots.length * 3 / 4) || primeIndex + 1 >= PRIMES.length) {
             return;
         }
         primeIndex++;
         ArrayList<Plot>[] newPlots = new ArrayList[PRIMES[primeIndex]];
         Plot p = last;
-        while(p != null)
-        {
+        while(p != null) {
             addIntern(newPlots, p, newPlots.length);
             p = p.previous;
         }
         plots = newPlots;
     }
-    
-    private void addIntern(ArrayList<Plot>[] data, Plot p, int arrayLength)
-    {
+
+    private void addIntern(ArrayList<Plot>[] data, Plot p, int arrayLength) {
         int startX = Math.floorDiv(p.minX, SIZE_FACTOR);
         int startZ = Math.floorDiv(p.minZ, SIZE_FACTOR);
         int endX = Math.floorDiv(p.maxX, SIZE_FACTOR);
         int endZ = Math.floorDiv(p.maxZ, SIZE_FACTOR);
 
-        for(int x = startX; x <= endX; x++)
-        {
-            for(int z = startZ; z <= endZ; z++)
-            {
+        for(int x = startX; x <= endX; x++) {
+            for(int z = startZ; z <= endZ; z++) {
                 int hash = hash(x, z, arrayLength);
-                if(data[hash] == null)
-                {
+                if(data[hash] == null) {
                     data[hash] = new ArrayList<>();
                 }
-                if(!data[hash].contains(p))
-                {
+                if(!data[hash].contains(p)) {
                     data[hash].add(p);
                 }
             }
         }
     }
-    
-    public Plot add(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int id)
-    {
-        if(id >= idCounter)
-        {
+
+    public Plot add(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int id) {
+        if(id >= idCounter) {
             idCounter = id + 1;
         }
-        
+
         Plot p = new Plot(id, minX, minY, minZ, maxX, maxY, maxZ);
-        
-        if(last == null)
-        {
+
+        if(last == null) {
             last = p;
-        }
-        else
-        {
+        } else {
             last.next = p;
             p.previous = last;
             last = p;
         }
-        
+
         size++;
         rehash();
-        
+
         addIntern(plots, p, plots.length);
         return p;
     }
-    
-    public Plot add(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
-    {
+
+    public Plot add(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
         return add(minX, minY, minZ, maxX, maxY, maxZ, idCounter);
     }
-    
-    public List<Plot> getPlotAt(int x, int y, int z)
-    {
+
+    public List<Plot> getPlotAt(int x, int y, int z) {
         ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
-        if(list == null)
-        {
+        if(list == null) {
             return new ArrayList<>();
         }
         return list.stream().filter(p -> p.isInside(x, y, z)).collect(Collectors.toList());
     }
-    
-    public boolean anyPlotMatches(int x, int y, int z, boolean empty, Predicate<Plot> pred)
-    {
+
+    public boolean anyPlotMatches(int x, int y, int z, boolean empty, Predicate<Plot> pred) {
         ArrayList<Plot> list = plots[hash(Math.floorDiv(x, SIZE_FACTOR), Math.floorDiv(z, SIZE_FACTOR), plots.length)];
-        if(list == null)
-        {
+        if(list == null) {
             return empty;
         }
         boolean r = empty;
-        for(Plot p : list)
-        {
-            if(p.isInside(x, y, z))
-            {
-                if(pred.test(p))
-                {
+        for(Plot p : list) {
+            if(p.isInside(x, y, z)) {
+                if(pred.test(p)) {
                     return true;
                 }
                 r = false;
@@ -296,108 +242,84 @@ public class PlotMap
         }
         return r;
     }
-    
-    public void remove(Plot p)
-    {
-        if(last == p)
-        {
+
+    public void remove(Plot p) {
+        if(last == p) {
             last = last.previous;
-            if(last != null)
-            {
+            if(last != null) {
                 last.next = null;
             }
-        }
-        else
-        {
-            if(p.previous != null)
-            {
+        } else {
+            if(p.previous != null) {
                 p.previous.next = p.next;
             }
-            if(p.next != null)
-            {
+            if(p.next != null) {
                 p.next.previous = p.previous;
             }
         }
-        
+
         int startX = Math.floorDiv(p.minX, SIZE_FACTOR);
         int startZ = Math.floorDiv(p.minZ, SIZE_FACTOR);
         int endX = Math.floorDiv(p.maxX, SIZE_FACTOR);
         int endZ = Math.floorDiv(p.maxZ, SIZE_FACTOR);
 
-        for(int x = startX; x <= endX; x++)
-        {
-            for(int z = startZ; z <= endZ; z++)
-            {
+        for(int x = startX; x <= endX; x++) {
+            for(int z = startZ; z <= endZ; z++) {
                 int hash = hash(x, z, plots.length);
-                if(plots[hash] == null)
-                {
+                if(plots[hash] == null) {
                     throw new NullPointerException("plot without list at location");
                 }
                 plots[hash].remove(p);
             }
         }
     }
-    
-    public Iterator<Plot> getIterator()
-    {
-        return new Iterator<PlotMap.Plot>()
-        {
+
+    public Iterator<Plot> getIterator() {
+        return new Iterator<PlotMap.Plot>() {
             private Plot current = last;
-            
+
             @Override
-            public boolean hasNext()
-            {
+            public boolean hasNext() {
                 return current != null;
             }
 
             @Override
-            public Plot next()
-            {
+            public Plot next() {
                 Plot p = current;
                 current = current.previous;
                 return p;
             }
         };
     }
-    
-    public Iterator<Plot> getIterator(UUID uuid)
-    {
-        return new Iterator<PlotMap.Plot>()
-        {
+
+    public Iterator<Plot> getIterator(UUID uuid) {
+        return new Iterator<PlotMap.Plot>() {
             private Plot current = last;
-            
-            private boolean gotoNext()
-            {
-                if(current == null)
-                {
+
+            private boolean gotoNext() {
+                if(current == null) {
                     return false;
                 }
-                if(current.getOwners().contains(uuid))
-                {
+                if(current.getOwners().contains(uuid)) {
                     return true;
                 }
-                while(current.previous != null)
-                {
+                while(current.previous != null) {
                     current = current.previous;
-                    if(current.getOwners().contains(uuid))
-                    {
+                    if(current.getOwners().contains(uuid)) {
                         return true;
                     }
                 }
                 return false;
             }
-            
+
             @Override
-            public boolean hasNext()
-            {
+            public boolean hasNext() {
                 return gotoNext();
             }
 
             @Override
-            public Plot next()
-            {
-                if(!gotoNext())
-                {
+            public Plot next() {
+                if(!gotoNext()) {
                     throw new IllegalStateException("next without a next element");
                 }
                 Plot p = current;
@@ -406,17 +328,14 @@ public class PlotMap
             }
         };
     }
-    
-    public void save(String path)
-    {
+
+    public void save(String path) {
         File f = new File(path);
-        try(DataOutputStream out = new DataOutputStream(new FileOutputStream(f)))
-        {
+        try(DataOutputStream out = new DataOutputStream(new FileOutputStream(f))) {
             Iterator<Plot> iter = getIterator();
-            while(iter.hasNext())
-            {
+            while(iter.hasNext()) {
                 Plot p = iter.next();
-                
+
                 out.writeInt(p.id);
                 out.writeShort(p.minX);
                 out.writeShort(p.minY);
@@ -426,31 +345,24 @@ public class PlotMap
                 out.writeShort(p.maxZ);
                 int owners = Math.min(127, p.owners.size());
                 out.writeByte(owners);
-                for(int i = 0; i < owners; i++)
-                {
+                for(int i = 0; i < owners; i++) {
                     out.writeLong(p.owners.get(i).getLeastSignificantBits());
                     out.writeLong(p.owners.get(i).getMostSignificantBits());
                 }
                 out.writeInt(p.flags);
                 out.writeUTF(p.name);
             }
-        }
-        catch(IOException ex)
-        {
+        } catch(IOException ex) {
             ex.printStackTrace();
         }
     }
-    
-    public void read(File f)
-    {
-        if(!f.exists())
-        {
+
+    public void read(File f) {
+        if(!f.exists()) {
             return;
         }
-        try(DataInputStream in = new DataInputStream(new FileInputStream(f)))
-        {
-            while(true)
-            {
+        try(DataInputStream in = new DataInputStream(new FileInputStream(f))) {
+            while(true) {
                 int id = in.readInt();
                 int minX = in.readShort();
                 int minY = in.readShort();
@@ -461,8 +373,7 @@ public class PlotMap
 
                 Plot p = add(minX, minY, minZ, maxX, maxY, maxZ, id);
                 int owners = in.readByte();
-                for(int i = 0; i < owners; i++)
-                {
+                for(int i = 0; i < owners; i++) {
                     long lsb = in.readLong();
                     long msb = in.readLong();
                     p.owners.add(new UUID(msb, lsb));
@@ -470,51 +381,41 @@ public class PlotMap
                 p.flags = in.readInt();
                 p.name = in.readUTF();
             }
-        }
-        catch(EOFException ex)
-        {
-        }
-        catch(IOException ex)
-        {
+        } catch(EOFException ex) {
+        } catch(IOException ex) {
             ex.printStackTrace();
         }
     }
-    
-    public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
-    {
-        if(minX > maxX)
-        {
+
+    public ArrayList<Plot> getIntersectingPlots(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
+        if(minX > maxX) {
             int tmp = minX;
             minX = maxX;
             maxX = tmp;
         }
 
-        if(minY > maxY)
-        {
+        if(minY > maxY) {
             int tmp = minY;
             minY = maxY;
             maxY = tmp;
         }
 
-        if(minZ > maxZ)
-        {
+        if(minZ > maxZ) {
             int tmp = minZ;
             minZ = maxZ;
             maxZ = tmp;
         }
-            
+
         ArrayList<Plot> list = new ArrayList<>();
-        
+
         Plot p = last;
-        while(p != null)
-        {
-            if(maxX > p.minX && p.maxX > minX && maxY > p.minY && p.maxY > minY && maxZ > p.minZ && p.maxZ > minZ)
-            {
+        while(p != null) {
+            if(maxX > p.minX && p.maxX > minX && maxY > p.minY && p.maxY > minY && maxZ > p.minZ && p.maxZ > minZ) {
                 list.add(p);
             }
             p = p.previous;
         }
-        
+
         return list;
     }
 }

+ 61 - 106
src/main/java/me/km/plots/ProtectionEvents.java

@@ -22,195 +22,150 @@ import net.minecraftforge.event.world.BlockEvent;
 import net.minecraftforge.eventbus.api.EventPriority;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
 
-public class ProtectionEvents
-{
+public class ProtectionEvents {
     private final WorldPlotMap plots;
     private final PermissionManager perms;
-    
-    public ProtectionEvents(WorldPlotMap plotMap, PermissionManager perms)
-    {
+
+    public ProtectionEvents(WorldPlotMap plotMap, PermissionManager perms) {
         this.plots = plotMap;
         this.perms = perms;
     }
-    
-    private boolean canBypass(PlayerEntity p)
-    {
+
+    private boolean canBypass(PlayerEntity p) {
         return perms.hasPermission(p, "plot.bypass");
     }
-    
-    private boolean shouldBeProtected(Entity ent)
-    {
+
+    private boolean shouldBeProtected(Entity ent) {
         EntityType type = ent.getType();
         return type == EntityType.ITEM_FRAME || type == EntityType.PAINTING || type == EntityType.ARMOR_STAND;
     }
-    
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onBlockPlace(BlockEvent.EntityPlaceEvent e)
-    {
-        if(e.getEntity() instanceof PlayerEntity)
-        {
+    public void onBlockPlace(BlockEvent.EntityPlaceEvent e) {
+        if(e.getEntity() instanceof PlayerEntity) {
             PlayerEntity p = (PlayerEntity) e.getEntity();
-            if(!canBypass(p) && !plots.canPlaceBlock(e.getWorld(), e.getPos(), p))
-            {
+            if(!canBypass(p) && !plots.canPlaceBlock(e.getWorld(), e.getPos(), p)) {
                 e.setCanceled(true);
-            }  
-        }   
+            }
+        }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onBlockBreak(BlockEvent.BreakEvent e)
-    {
+    public void onBlockBreak(BlockEvent.BreakEvent e) {
         PlayerEntity p = e.getPlayer();
-        if(!canBypass(p) && !plots.canBreakBlock(e.getWorld(), e.getPos(), p))
-        {
+        if(!canBypass(p) && !plots.canBreakBlock(e.getWorld(), e.getPos(), p)) {
             e.setCanceled(true);
-        }  
+        }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onBossSpawn(EntityJoinWorldEvent e)
-    {
+    public void onBossSpawn(EntityJoinWorldEvent e) {
         EntityType type = e.getEntity().getType();
-        if(type == EntityType.WITHER && e.getWorld().getDimension().getType() != DimensionType.THE_NETHER)
-        {
+        if(type == EntityType.WITHER && e.getWorld().getDimension().getType() != DimensionType.THE_NETHER) {
             e.setCanceled(true);
-        }  
-        else if(type == EntityType.ENDER_DRAGON && e.getWorld().getDimension().getType() != DimensionType.THE_END)
-        {
+        } else if(type == EntityType.ENDER_DRAGON && e.getWorld().getDimension().getType() != DimensionType.THE_END) {
             e.setCanceled(true);
-        } 
+        }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onBucketFill(FillBucketEvent e)
-    {
+    public void onBucketFill(FillBucketEvent e) {
         RayTraceResult ray = e.getTarget();
-        if(ray == null || ray.getType() != RayTraceResult.Type.BLOCK || canBypass(e.getPlayer()))
-        {
+        if(ray == null || ray.getType() != RayTraceResult.Type.BLOCK || canBypass(e.getPlayer())) {
             return;
         }
-        if(!plots.canUseBucket(e.getWorld(), ((BlockRayTraceResult) ray).getPos(), e.getPlayer()))
-        {
+        if(!plots.canUseBucket(e.getWorld(), ((BlockRayTraceResult) ray).getPos(), e.getPlayer())) {
             e.setCanceled(true);
         }
     }
 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onEntityHit(AttackEntityEvent e)
-    {
-        if(shouldBeProtected(e.getTarget()))
-        {
+    public void onEntityHit(AttackEntityEvent e) {
+        if(shouldBeProtected(e.getTarget())) {
             PlayerEntity p = e.getPlayer();
-            if(!canBypass(p) && !plots.canHitAmbientEntity(p.world, e.getTarget().getPosition(), p))
-            {
+            if(!canBypass(p) && !plots.canHitAmbientEntity(p.world, e.getTarget().getPosition(), p)) {
                 e.setCanceled(true);
             }
         }
     }
 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onThrowableImpact(ProjectileImpactEvent.Throwable e)
-    {
-        if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY)
-        {
+    public void onThrowableImpact(ProjectileImpactEvent.Throwable e) {
+        if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY) {
             EntityRayTraceResult result = (EntityRayTraceResult) e.getRayTraceResult();
-            if(shouldBeProtected(result.getEntity()))
-            {
+            if(shouldBeProtected(result.getEntity())) {
                 Entity thrower = e.getThrowable().getThrower();
-                if(thrower != null && (thrower instanceof PlayerEntity))
-                {
+                if(thrower != null && (thrower instanceof PlayerEntity)) {
                     PlayerEntity p = (PlayerEntity) thrower;
-                    if(!canBypass(p) && !plots.canHitAmbientEntity(p.world, e.getThrowable().getPosition(), p))
-                    {
+                    if(!canBypass(p) && !plots.canHitAmbientEntity(p.world, e.getThrowable().getPosition(), p)) {
                         e.setCanceled(true);
                     }
-                }
-                else
-                {
+                } else {
                     e.setCanceled(true);
                 }
             }
         }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onThrowableImpact(ProjectileImpactEvent.Arrow e)
-    {
-        if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY)
-        {
+    public void onThrowableImpact(ProjectileImpactEvent.Arrow e) {
+        if(e.getRayTraceResult().getType() == RayTraceResult.Type.ENTITY) {
             EntityRayTraceResult result = (EntityRayTraceResult) e.getRayTraceResult();
-            if(shouldBeProtected(result.getEntity()))
-            {
+            if(shouldBeProtected(result.getEntity())) {
                 Entity shooter = e.getArrow().getShooter();
-                if(shooter != null && (shooter instanceof ModEntityPlayerMP))
-                {
+                if(shooter != null && (shooter instanceof ModEntityPlayerMP)) {
                     PlayerEntity p = (PlayerEntity) shooter;
-                    if(!canBypass(p) && !plots.canHitAmbientEntity(p.world, e.getArrow().getPosition(), p))
-                    {
+                    if(!canBypass(p) && !plots.canHitAmbientEntity(p.world, e.getArrow().getPosition(), p)) {
                         e.setCanceled(true);
                     }
-                }
-                else
-                {
+                } else {
                     e.setCanceled(true);
                 }
             }
         }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void EntityProtectionPotion(EntityStruckByLightningEvent e)
-    {
+    public void EntityProtectionPotion(EntityStruckByLightningEvent e) {
         e.setCanceled(true);
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onPlayerInteract(PlayerInteractEvent.LeftClickBlock e) 
-    {
+    public void onPlayerInteract(PlayerInteractEvent.LeftClickBlock e) {
         PlayerEntity p = e.getPlayer();
-        if(canBypass(p))
-        {
+        if(canBypass(p)) {
             return;
-        }  
+        }
         Block b = e.getWorld().getBlockState(e.getPos()).getBlock();
-        if(b == Blocks.FIRE && !plots.canBreakBlock(e.getWorld(), e.getPos(), p)) 
-        {
+        if(b == Blocks.FIRE && !plots.canBreakBlock(e.getWorld(), e.getPos(), p)) {
             e.setCanceled(true);
         }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onPlayerInteract(PlayerInteractEvent.RightClickBlock e) 
-    {
+    public void onPlayerInteract(PlayerInteractEvent.RightClickBlock e) {
         PlayerEntity p = e.getPlayer();
-        if(!canBypass(p) && !plots.canInteractWithBlock(e.getWorld(), e.getPos(), p))
-        {
+        if(!canBypass(p) && !plots.canInteractWithBlock(e.getWorld(), e.getPos(), p)) {
             e.setCanceled(true);
-        }    
+        }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onPlayerEntityInteract(PlayerInteractEvent.EntityInteract e)
-    {      
+    public void onPlayerEntityInteract(PlayerInteractEvent.EntityInteract e) {
         PlayerEntity p = e.getPlayer();
-        if(!canBypass(p) && !plots.canInteractWithEntity(e.getWorld(), e.getTarget().getPosition(), p))
-        {
+        if(!canBypass(p) && !plots.canInteractWithEntity(e.getWorld(), e.getTarget().getPosition(), p)) {
             e.setCanceled(true);
         }
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onFarmlandTrample(BlockEvent.FarmlandTrampleEvent e)
-    {      
+    public void onFarmlandTrample(BlockEvent.FarmlandTrampleEvent e) {
         e.setCanceled(true);
     }
-    
+
     @SubscribeEvent(priority = EventPriority.HIGHEST)
-    public void onAttackVillager(LivingAttackEvent e)
-    { 
-        if(e.getEntityLiving().getType() == EntityType.VILLAGER && !e.getSource().isCreativePlayer())
-        {
+    public void onAttackVillager(LivingAttackEvent e) {
+        if(e.getEntityLiving().getType() == EntityType.VILLAGER && !e.getSource().isCreativePlayer()) {
             e.setCanceled(true);
         }
     }

+ 45 - 73
src/main/java/me/km/plots/WorldPlotMap.java

@@ -15,147 +15,119 @@ import net.minecraft.server.MinecraftServer;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.world.IWorld;
 
-public class WorldPlotMap
-{
+public class WorldPlotMap {
     private final HashMap<IWorld, PlotMap> maps = new HashMap<>();
-    
+
     private final static int PLACE_FLAG = (1 << 0);
     private final static int BREAK_FLAG = (1 << 1);
     private final static int BUCKET_FLAG = (1 << 2);
     private final static int HIT_AMBIENT_FLAG = (1 << 3);
     private final static int BLOCK_INTERACT_FLAG = (1 << 4);
     private final static int ENTITY_INTERACT_FLAG = (1 << 5);
-    
-    public boolean canDoSomething(IWorld w, BlockPos pos, PlayerEntity p, int flag, boolean empty)
-    {
+
+    public boolean canDoSomething(IWorld w, BlockPos pos, PlayerEntity p, int flag, boolean empty) {
         PlotMap map = maps.get(w);
-        if(map == null)
-        {
+        if(map == null) {
             return empty;
         }
-        if(p == null)
-        {
+        if(p == null) {
             return map.anyPlotMatches(pos.getX(), pos.getY(), pos.getZ(), empty, plot -> plot.hasFlags(flag));
         }
         UUID uuid = p.getUniqueID();
-        return map.anyPlotMatches(pos.getX(), pos.getY(), pos.getZ(), empty, 
+        return map.anyPlotMatches(pos.getX(), pos.getY(), pos.getZ(), empty,
                 plot -> plot.hasFlags(flag) || plot.getOwners().contains(uuid));
     }
-    
-    public boolean canPlaceBlock(IWorld w, BlockPos pos, PlayerEntity p)
-    {
+
+    public boolean canPlaceBlock(IWorld w, BlockPos pos, PlayerEntity p) {
         return canDoSomething(w, pos, p, PLACE_FLAG, true);
     }
-    
-    public boolean canBreakBlock(IWorld w, BlockPos pos, PlayerEntity p)
-    {
+
+    public boolean canBreakBlock(IWorld w, BlockPos pos, PlayerEntity p) {
         return canDoSomething(w, pos, p, BREAK_FLAG, true);
     }
-    
-    public boolean canUseBucket(IWorld w, BlockPos pos, PlayerEntity p)
-    {
+
+    public boolean canUseBucket(IWorld w, BlockPos pos, PlayerEntity p) {
         return canDoSomething(w, pos, p, BUCKET_FLAG, true);
     }
-    
-    public boolean canHitAmbientEntity(IWorld w, BlockPos pos, PlayerEntity p)
-    {
+
+    public boolean canHitAmbientEntity(IWorld w, BlockPos pos, PlayerEntity p) {
         return canDoSomething(w, pos, p, HIT_AMBIENT_FLAG, true);
     }
-    
-    public boolean canInteractWithBlock(IWorld w, BlockPos pos, PlayerEntity p)
-    {
+
+    public boolean canInteractWithBlock(IWorld w, BlockPos pos, PlayerEntity p) {
         return canDoSomething(w, pos, p, BLOCK_INTERACT_FLAG, true);
     }
-    
-    public boolean canInteractWithEntity(IWorld w, BlockPos pos, PlayerEntity p)
-    {
+
+    public boolean canInteractWithEntity(IWorld w, BlockPos pos, PlayerEntity p) {
         return canDoSomething(w, pos, p, ENTITY_INTERACT_FLAG, true);
     }
-    
-    public List<PlotMap.Plot> getPlots(IWorld w, BlockPos pos)
-    {
+
+    public List<PlotMap.Plot> getPlots(IWorld w, BlockPos pos) {
         PlotMap map = maps.get(w);
-        if(map == null)
-        {
+        if(map == null) {
             return new ArrayList<>();
         }
         return map.getPlotAt(pos.getX(), pos.getY(), pos.getZ());
     }
-    
-    public PlotMap.Plot add(IWorld w, BlockPos pos1, BlockPos pos2)
-    {
+
+    public PlotMap.Plot add(IWorld w, BlockPos pos1, BlockPos pos2) {
         PlotMap map = maps.get(w);
-        if(map == null)
-        {
+        if(map == null) {
             map = new PlotMap();
             maps.put(w, map);
         }
         return map.add(pos1.getX(), pos1.getY(), pos1.getZ(), pos2.getX(), pos2.getY(), pos2.getZ());
     }
-    
-    public void remove(IWorld w, Plot p)
-    {
+
+    public void remove(IWorld w, Plot p) {
         PlotMap map = maps.get(w);
-        if(map != null)
-        {
+        if(map != null) {
             map.remove(p);
         }
     }
-    
-    public Iterator<PlotMap.Plot> getIterator(IWorld w)
-    {
+
+    public Iterator<PlotMap.Plot> getIterator(IWorld w) {
         PlotMap map = maps.get(w);
-        if(map != null)
-        {
+        if(map != null) {
             return map.getIterator();
         }
         return Collections.EMPTY_LIST.iterator();
     }
-    
-    public Iterator<PlotMap.Plot> getIterator(IWorld w, UUID uuid)
-    {
+
+    public Iterator<PlotMap.Plot> getIterator(IWorld w, UUID uuid) {
         PlotMap map = maps.get(w);
-        if(map != null)
-        {
+        if(map != null) {
             return map.getIterator(uuid);
         }
         return Collections.EMPTY_LIST.iterator();
     }
-    
-    public List<Plot> getIntersectingPlots(IWorld w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
-    {
+
+    public List<Plot> getIntersectingPlots(IWorld w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
         PlotMap map = maps.get(w);
-        if(map != null)
-        {
+        if(map != null) {
             return map.getIntersectingPlots(minX, minY, minZ, maxX, maxY, maxZ);
         }
         return Collections.EMPTY_LIST;
     }
-    
-    public void save()
-    {
+
+    public void save() {
         File f = new File("plot_storage");
         f.mkdir();
-        maps.entrySet().forEach((entry) ->
-        {
+        maps.entrySet().forEach((entry) -> {
             String name = WorldManager.getName(entry.getKey());
             entry.getValue().save("plot_storage/" + name);
         });
     }
-    
-    public void read(MinecraftServer ms, ISnuviLogger logger)
-    {
+
+    public void read(MinecraftServer ms, ISnuviLogger logger) {
         File dir = new File("plot_storage");
-        if(!dir.exists())
-        {
+        if(!dir.exists()) {
             return;
         }
-        for(File f : dir.listFiles())
-        {
+        for(File f : dir.listFiles()) {
             String name = f.getName();
             IWorld sw = WorldManager.get(ms, f.getName());
-            if(sw == null)
-            {
+            if(sw == null) {
                 logger.print(String.format("invalid world storage '%s'", name));
                 continue;
             }

+ 32 - 59
src/main/java/me/km/scheduler/AsyncWorker.java

@@ -2,99 +2,72 @@ package me.km.scheduler;
 
 import java.util.LinkedList;
 
-public class AsyncWorker
-{
+public class AsyncWorker {
     private final LinkedList<Runnable> tasks = new LinkedList<>();
     private final Thread worker;
-    
-    public AsyncWorker()
-    {
+
+    public AsyncWorker() {
         worker = new Thread(() -> run());
     }
-    
-    public void start()
-    {
+
+    public void start() {
         worker.start();
     }
-    
-    public void stop()
-    {
-        while(worker.isAlive())
-        {
-            synchronized(worker)
-            {
+
+    public void stop() {
+        while(worker.isAlive()) {
+            synchronized(worker) {
                 worker.interrupt();
             }
-            try
-            {
+            try {
                 worker.join(100);
-            }
-            catch(InterruptedException ex)
-            {   
+            } catch(InterruptedException ex) {
             }
         }
     }
-    
-    private void run()
-    {
-        while(true)
-        {
-            synchronized(worker)
-            {
-                try
-                {
+
+    private void run() {
+        while(true) {
+            synchronized(worker) {
+                try {
                     worker.wait();
-                }
-                catch(InterruptedException ex)
-                {
+                } catch(InterruptedException ex) {
                     break;
                 }
             }
-            
-            while(true)
-            {
+
+            while(true) {
                 Runnable r;
-                synchronized(tasks)
-                {
-                    if(tasks.isEmpty())
-                    {
+                synchronized(tasks) {
+                    if(tasks.isEmpty()) {
                         break;
                     }
                     r = tasks.removeFirst();
                 }
-                try
-                {
+                try {
                     r.run();
-                }
-                catch(Exception ex)
-                {
+                } catch(Exception ex) {
                     System.out.println("A worker task has thrown an exception:");
                     ex.printStackTrace();
                 }
             }
         }
     }
-    
-    public void add(Runnable r)
-    {
-        synchronized(tasks)
-        {
+
+    public void add(Runnable r) {
+        synchronized(tasks) {
             tasks.add(r);
         }
     }
-    
-    public void doWork()
-    {
-        synchronized(worker)
-        {
+
+    public void doWork() {
+        synchronized(worker) {
             worker.notify();
         }
     }
-    
-    public boolean hasWork()
-    {
-        synchronized(tasks)
-        {
+
+    public boolean hasWork() {
+        synchronized(tasks) {
             return !tasks.isEmpty();
         }
     }

+ 33 - 61
src/main/java/me/km/scheduler/SnuviScheduler.java

@@ -9,8 +9,7 @@ import net.minecraftforge.api.distmarker.Dist;
 import net.minecraftforge.api.distmarker.OnlyIn;
 
 @OnlyIn(Dist.DEDICATED_SERVER)
-public class SnuviScheduler implements ISnuviScheduler
-{
+public class SnuviScheduler implements ISnuviScheduler {
     private final ISnuviLogger logger;
     private boolean checker;
     private int counter;
@@ -19,121 +18,94 @@ public class SnuviScheduler implements ISnuviScheduler
     private final HashMap<Integer, SnuviTask> tasks = new HashMap<>();
     private final AsyncWorker worker = new AsyncWorker();
     private boolean noAdding = false;
-    
-    public SnuviScheduler(ISnuviLogger logger)
-    {
+
+    public SnuviScheduler(ISnuviLogger logger) {
         this.logger = logger;
         counter = 0;
         worker.start();
     }
-    
-    public void stop()
-    {
+
+    public void stop() {
         noAdding = true;
         long endTime = System.nanoTime() + 60_000_000_000l;
         logger.print("Waiting until end of synchronized tasks ...");
-        while(!tasks.isEmpty() && System.nanoTime() < endTime)
-        {
+        while(!tasks.isEmpty() && System.nanoTime() < endTime) {
             tick();
         }
         logger.print("Waiting until end of asynchronous tasks ...");
-        while(worker.hasWork() && System.nanoTime() < endTime)
-        {
-            try
-            {
+        while(worker.hasWork() && System.nanoTime() < endTime) {
+            try {
                 Thread.sleep(250);
-            }
-            catch(InterruptedException ex)
-            {
+            } catch(InterruptedException ex) {
             }
         }
         logger.print("the scheduler is now stopped");
     }
-    
-    public void cancelTask(int id)
-    {
+
+    public void cancelTask(int id) {
         removeQueue.add(id);
     }
-    
-    public int scheduleRepeatingTask(Runnable r, long ticks, long rtimer)
-    {
-        if(noAdding)
-        {
+
+    public int scheduleRepeatingTask(Runnable r, long ticks, long rtimer) {
+        if(noAdding) {
             logger.print("scheduling tasks is not allowed on server stop");
             return -1;
         }
-        synchronized(addQueue)
-        {
+        synchronized(addQueue) {
             counter++;
             addQueue.add(new SnuviTask(counter, r, ticks, rtimer));
         }
         return counter;
     }
-    
+
     @Override
-    public int scheduleTask(Runnable r, long delay)
-    { 
+    public int scheduleTask(Runnable r, long delay) {
         return scheduleRepeatingTask(r, delay, 0);
     }
-    
+
     @Override
-    public int scheduleTask(Runnable r)
-    { 
+    public int scheduleTask(Runnable r) {
         return scheduleTask(r, 0);
     }
-    
-    public void tick()
-    {
+
+    public void tick() {
         worker.doWork();
-        try
-        {
-            if(!removeQueue.isEmpty())
-            {
+        try {
+            if(!removeQueue.isEmpty()) {
                 removeQueue.forEach(i -> tasks.remove(i));
                 removeQueue.clear();
             }
-            synchronized(addQueue)
-            {
-                if(!addQueue.isEmpty())
-                {
+            synchronized(addQueue) {
+                if(!addQueue.isEmpty()) {
                     addQueue.forEach(task -> tasks.put(task.getId(), task));
                     addQueue.clear();
                 }
             }
             checker = false;
             long l = System.currentTimeMillis();
-            tasks.values().removeIf(task -> 
-            {
-                if(checker)
-                {
+            tasks.values().removeIf(task -> {
+                if(checker) {
                     return false;
                 }
-                if(System.currentTimeMillis() - l > 25)
-                {
+                if(System.currentTimeMillis() - l > 25) {
                     checker = true;
                     logger.print("scheduler has run longer than 25 ms");
                     return false;
                 }
-                try
-                {
+                try {
                     return task.tick(noAdding);
-                }
-                catch(Exception ex)
-                {
+                } catch(Exception ex) {
                     logger.print("scheduler exception - task will be removed");
                     ex.printStackTrace();
                     return true;
                 }
             });
-        }
-        catch(ConcurrentModificationException ex)
-        {
+        } catch(ConcurrentModificationException ex) {
             logger.print(ex);
         }
     }
-    
-    public AsyncWorker getWorker()
-    {
+
+    public AsyncWorker getWorker() {
         return worker;
     }
 }

+ 12 - 20
src/main/java/me/km/scheduler/SnuviTask.java

@@ -1,43 +1,35 @@
 package me.km.scheduler;
 
-public class SnuviTask
-{
+public class SnuviTask {
     private final int id;
     private final long rtimer;
     private final Runnable r;
     private long timer;
-    
-    public SnuviTask(int id, Runnable r, long delay, long rtimer)
-    {
+
+    public SnuviTask(int id, Runnable r, long delay, long rtimer) {
         this.rtimer = rtimer;
         this.timer = delay;
         this.r = r;
         this.id = id;
     }
 
-    public int getId() 
-    {
+    public int getId() {
         return id;
     }
-    
-    public long getRepeatTimer()
-    {
+
+    public long getRepeatTimer() {
         return rtimer;
     }
-    
-    public boolean isRepeating()
-    {
+
+    public boolean isRepeating() {
         return rtimer > 0;
     }
-    
-    public boolean tick(boolean noRepeat) 
-    {
+
+    public boolean tick(boolean noRepeat) {
         timer -= 1;
-        if(timer <= 0)
-        {
+        if(timer <= 0) {
             r.run();
-            if(rtimer <= 0 || noRepeat)
-            {
+            if(rtimer <= 0 || noRepeat) {
                 return true;
             }
             timer = rtimer;

+ 9 - 17
src/main/java/me/km/snuviscript/CommandGiveUp.java

@@ -6,24 +6,20 @@ import me.km.permissions.Command;
 import net.minecraft.command.ICommandSource;
 import net.minecraft.entity.player.ServerPlayerEntity;
 
-public class CommandGiveUp extends Command
-{
+public class CommandGiveUp extends Command {
     private final Scripts scripts;
-    
-    public CommandGiveUp(Scripts scripts)
-    {
+
+    public CommandGiveUp(Scripts scripts) {
         this.scripts = scripts;
     }
-    
+
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "giveup";
     }
 
     @Override
-    public Iterable<String> getAliases()
-    {
+    public Iterable<String> getAliases() {
         ArrayList<String> list = new ArrayList<>();
         list.add("fuckit");
         list.add("fuckitigiveup");
@@ -34,21 +30,17 @@ public class CommandGiveUp extends Command
     }
 
     @Override
-    public void execute(ICommandSource cs, String[] arg) 
-    {
-        if(!(cs instanceof ServerPlayerEntity))
-        {
+    public void execute(ICommandSource cs, String[] arg) {
+        if(!(cs instanceof ServerPlayerEntity)) {
             sendMessage(cs, "This command is only for players.");
             return;
         }
         ServerPlayerEntity p = (ServerPlayerEntity) cs;
         Script script = scripts.getScript(p);
-        if(script == null)
-        {
+        if(script == null) {
             scripts.getScriptManager().callEvent("player_no_script", (sc) -> ScriptVars.setPlayerVars(sc, p), null);
             return;
         }
         scripts.getScriptManager().callEvent("player_giveup", script, (sc) -> ScriptVars.setPlayerVars(sc, p), null);
     }
 }
-

+ 38 - 78
src/main/java/me/km/snuviscript/CommandScript.java

@@ -12,26 +12,22 @@ import net.minecraft.entity.player.PlayerEntity;
 import net.minecraft.entity.player.ServerPlayerEntity;
 import net.minecraft.server.MinecraftServer;
 
-public class CommandScript extends Command
-{
+public class CommandScript extends Command {
     private final Scripts scripts;
     private final MinecraftServer server;
-    
-    public CommandScript(Scripts scripts, MinecraftServer server)
-    {
+
+    public CommandScript(Scripts scripts, MinecraftServer server) {
         this.scripts = scripts;
         this.server = server;
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "script";
     }
-    
+
     @Override
-    public Iterable<String> getAliases()
-    {
+    public Iterable<String> getAliases() {
         ArrayList<String> list = new ArrayList<>();
         list.add("s");
         return list;
@@ -39,30 +35,22 @@ public class CommandScript extends Command
 
     @SuppressWarnings("unchecked")
     @Override
-    public void execute(ICommandSource cs, String[] arg) 
-    {
-        if(arg.length >= 1)
-        {
-            switch(arg[0].toLowerCase())
-            {
+    public void execute(ICommandSource cs, String[] arg) {
+        if(arg.length >= 1) {
+            switch(arg[0].toLowerCase()) {
                 case "s":
-                case "start":
-                {
-                    if(arg.length >= 2)
-                    {
+                case "start": {
+                    if(arg.length >= 2) {
                         String[] pars = Arrays.copyOfRange(arg, 1, arg.length);
                         scripts.startScript(pars);
                         return;
                     }
                     break;
                 }
-                case "startp":
-                {
-                    if(arg.length >= 3)
-                    {
+                case "startp": {
+                    if(arg.length >= 3) {
                         PlayerEntity p = Utils.getPlayerByName(server, arg[1]);
-                        if(p == null)
-                        {
+                        if(p == null) {
                             sendMessage(cs, String.format("Cannot find player '%s'", arg[1]));
                             return;
                         }
@@ -73,108 +61,80 @@ public class CommandScript extends Command
                     break;
                 }
                 case "v":
-                case "variable":    
-                {
-                    if(arg.length >= 3)
-                    {
-                        try
-                        {
+                case "variable": {
+                    if(arg.length >= 3) {
+                        try {
                             Script sc = scripts.getScriptManager().getScript(Integer.parseInt(arg[1]));
-                            if(sc == null)
-                            {
+                            if(sc == null) {
                                 throw new NumberFormatException();
                             }
                             Variable var = sc.getVar(arg[2]);
-                            if(var != null)
-                            {
+                            if(var != null) {
                                 sendMessage(cs, String.format("%s = %s", arg[2], var.get(sc)));
-                            }
-                            else
-                            {
+                            } else {
                                 sendMessage(cs, String.format("%s = null", arg[2]));
                             }
-                        }
-                        catch(NumberFormatException ex)
-                        {
+                        } catch(NumberFormatException ex) {
                             sendMessage(cs, String.format("'%s' is not a valid id", arg[1]));
                         }
                         return;
                     }
                     break;
                 }
-                case "see":
-                {
+                case "see": {
                     Collection<Script> scs = scripts.getScriptManager().getScripts();
-                    if(scs.isEmpty())
-                    {
+                    if(scs.isEmpty()) {
                         sendMessage(cs, "No scripts are active");
                         return;
                     }
                     sendMessage(cs, "Active scripts:");
-                    scs.forEach(sc ->
-                    {
+                    scs.forEach(sc -> {
                         sendMessage(cs, String.format(" - %s (%d)", sc.getName(), sc.getId()));
-                        scripts.getPlayerList(sc.getId()).forEach(uuid -> 
-                        {
+                        scripts.getPlayerList(sc.getId()).forEach(uuid -> {
                             ServerPlayerEntity p = server.getPlayerList().getPlayerByUUID(uuid);
                             sendMessage(cs, String.format("  - %s", p == null ? "null" : p.getName().getFormattedText()));
                         });
                     });
                     return;
                 }
-                case "term":
-                {
-                    if(arg.length >= 2)
-                    {
-                        try
-                        {
-                            if(arg[1].equals("all"))
-                            {
+                case "term": {
+                    if(arg.length >= 2) {
+                        try {
+                            if(arg[1].equals("all")) {
                                 scripts.clearPlayerRegistry();
-                                if(scripts.getScriptManager().removeScriptsSafe())
-                                {
+                                if(scripts.getScriptManager().removeScriptsSafe()) {
                                     sendMessage(cs, "All active scripts were terminated");
-                                }
-                                else
-                                {
+                                } else {
                                     sendMessage(cs, "Iterating is not allowed currently");
                                 }
                                 return;
                             }
                             int id = Integer.parseInt(arg[1]);
                             Script qd = scripts.getScriptManager().getScript(id);
-                            if(qd != null)
-                            {
+                            if(qd != null) {
                                 scripts.getScriptManager().removeScriptSafe(qd);
                                 sendMessage(cs, String.format("Script '%s' was terminated", qd.getName()));
-                            }
-                            else
-                            {
+                            } else {
                                 sendMessage(cs, String.format("Script id '%d' is not valid", id));
                             }
-                        }
-                        catch(NumberFormatException ex)
-                        {
+                        } catch(NumberFormatException ex) {
                             sendMessage(cs, String.format("'%s' is not a valid id", arg[1]));
-                        } 
-                        catch(Exception ex)
-                        {
+                        } catch(Exception ex) {
                             sendMessage(cs, "Exception on script termination");
                             ex.printStackTrace();
-                        } 
+                        }
                         return;
                     }
                     break;
                 }
             }
         }
-        
+
         sendMessage(cs, "/script ...");
         sendMessage(cs, "start <scripts...>", "starts a script");
         sendMessage(cs, "startp <player> <scripts...>", "starts a player script");
-        sendMessage(cs, "variable <id> <name>", "shows the value of a variable");       
+        sendMessage(cs, "variable <id> <name>", "shows the value of a variable");
         sendMessage(cs, "see", "shows active scripts");
         sendMessage(cs, "term <id/all>", "terminates a script");
     }
 }
-

+ 14 - 28
src/main/java/me/km/snuviscript/DummyScriptBank.java

@@ -1,73 +1,59 @@
 package me.km.snuviscript;
 
-public class DummyScriptBank implements IScriptBank
-{
+public class DummyScriptBank implements IScriptBank {
     @Override
-    public void setVar(String value, String var, int playerId)
-    {
+    public void setVar(String value, String var, int playerId) {
     }
 
     @Override
-    public void deleteVar(String var, int playerId)
-    {
+    public void deleteVar(String var, int playerId) {
     }
 
     @Override
-    public Object getVar(String var, int playerId, Object error)
-    {
+    public Object getVar(String var, int playerId, Object error) {
         return error;
     }
 
     @Override
-    public Object getVar(String var, int playerId)
-    {
+    public Object getVar(String var, int playerId) {
         return null;
     }
 
     @Override
-    public void addMapElement(String map, String key, String value)
-    {
+    public void addMapElement(String map, String key, String value) {
     }
 
     @Override
-    public void removeMapElement(String map, String key)
-    {
+    public void removeMapElement(String map, String key) {
     }
 
     @Override
-    public void removeMap(String map)
-    {
+    public void removeMap(String map) {
     }
 
     @Override
-    public Object getMapValue(String map, String key)
-    {
+    public Object getMapValue(String map, String key) {
         return null;
     }
 
     @Override
-    public void addDualMapElement(String map, String key, String key2, String value)
-    {
+    public void addDualMapElement(String map, String key, String key2, String value) {
     }
 
     @Override
-    public void removeDualMapElement(String map, String key)
-    {
+    public void removeDualMapElement(String map, String key) {
     }
 
     @Override
-    public void removeDualMap(String map)
-    {
+    public void removeDualMap(String map) {
     }
 
     @Override
-    public void removeDualMapElement(String map, String key, String key2)
-    {
+    public void removeDualMapElement(String map, String key, String key2) {
     }
 
     @Override
-    public Object getDualMapValue(String map, String key, String key2)
-    {
+    public Object getDualMapValue(String map, String key, String key2) {
         return null;
     }
 }

Some files were not shown because too many files changed in this diff