From e137e538f8f3182771383ab0b87187513972043a Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 27 Nov 2016 11:39:25 +0100 Subject: [PATCH 01/12] Fix up structure rendering scaling in the book --- .../client/gui/book/element/ElementStructure.java | 15 ++++++++------- .../TestBook/en_US/section1/pagestructure2.json | 2 +- .../TestBook/en_US/section1/pagestructure3.json | 3 +++ .../TestBook/en_US/section1/pagestructure4.json | 3 +++ .../mantle/books/TestBook/sections/section1.json | 10 ++++++++++ .../books/TestBook/structures/stonesmeltery2.json | 11 +++++++++++ .../books/TestBook/structures/stonesmeltery3.json | 10 ++++++++++ .../books/TestBook/structures/stonesmeltery4.json | 10 ++++++++++ 8 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure3.json create mode 100644 src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure4.json create mode 100644 src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery2.json create mode 100644 src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery3.json create mode 100644 src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery4.json diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementStructure.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementStructure.java index f96d38b..511f92f 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementStructure.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementStructure.java @@ -17,10 +17,13 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.util.List; +import java.util.stream.IntStream; +import java.util.stream.Stream; import slimeknights.mantle.client.book.StructureBlockAccess; import slimeknights.mantle.client.book.StructureInfo; import slimeknights.mantle.client.book.data.element.BlockData; +import slimeknights.mantle.client.gui.book.GuiBook; public class ElementStructure extends SizedBookElement implements IButtonClickHandler { @@ -37,13 +40,13 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa public ElementStructure(int x, int y, int width, int height, int[] size, BlockData[] structure) { super(x, y, width, height); - if(size.length == 3) { - scale = size[0] > size[1] ? width / size[0] - 10F : height / size[1] - 10F; + scale = 100f / (float)IntStream.of(size).max().getAsInt(); - if(scale * size[0] > width) { - scale = width / size[0] - 10F; - } + float sx = (float)width / (float)GuiBook.PAGE_WIDTH; + float sy = (float)height / (float)GuiBook.PAGE_HEIGHT; + + scale *= Math.min(sx, sy); xTranslate = x + width / 2;// - (size[0] * scale) / 2; yTranslate = y + height / 2;// - (size[1] * scale) / 2; @@ -51,7 +54,6 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa w = size[0] * scale; h = size[1] * scale; } - init(size, structure); } @@ -61,7 +63,6 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa float rotX = 0; float rotY = 0; float rotZ = 0; - List componentTooltip; public StructureInfo structureData; StructureBlockAccess blockAccess; diff --git a/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure2.json b/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure2.json index cfd6ab9..1e85a71 100644 --- a/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure2.json +++ b/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure2.json @@ -1,3 +1,3 @@ { - "data": "structures/stonesmeltery.json" + "data": "structures/stonesmeltery2.json" } \ No newline at end of file diff --git a/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure3.json b/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure3.json new file mode 100644 index 0000000..d9fc30a --- /dev/null +++ b/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure3.json @@ -0,0 +1,3 @@ +{ + "data": "structures/stonesmeltery3.json" +} \ No newline at end of file diff --git a/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure4.json b/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure4.json new file mode 100644 index 0000000..0edf4ec --- /dev/null +++ b/src/main/resources/assets/mantle/books/TestBook/en_US/section1/pagestructure4.json @@ -0,0 +1,3 @@ +{ + "data": "structures/stonesmeltery4.json" +} \ No newline at end of file diff --git a/src/main/resources/assets/mantle/books/TestBook/sections/section1.json b/src/main/resources/assets/mantle/books/TestBook/sections/section1.json index 64d6600..e26cc75 100644 --- a/src/main/resources/assets/mantle/books/TestBook/sections/section1.json +++ b/src/main/resources/assets/mantle/books/TestBook/sections/section1.json @@ -33,6 +33,16 @@ "type": "structure", "data": "section1/pagestructure2.json" }, + { + "name": "PageStructure", + "type": "structure", + "data": "section1/pagestructure3.json" + }, + { + "name": "PageStructure", + "type": "structure", + "data": "section1/pagestructure4.json" + }, { "name": "PageStructure", "type": "structure", diff --git a/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery2.json b/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery2.json new file mode 100644 index 0000000..ffad0dd --- /dev/null +++ b/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery2.json @@ -0,0 +1,11 @@ +{ + "size": [4, 4, 4], + "text": "This is a nether portal. It leads to the nether.Pretty cool, eh?Lorem Ipsum dolor, Lorem Ipsum Dolores", + "structure": [ + { + "pos": [0, 0, 0], + "endPos": [3, 3, 3], + "block": "minecraft:stonebrick" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery3.json b/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery3.json new file mode 100644 index 0000000..f64e3db --- /dev/null +++ b/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery3.json @@ -0,0 +1,10 @@ +{ + "size": [9, 9, 9], + "structure": [ + { + "pos": [0, 0, 0], + "endPos": [8, 8, 8], + "block": "minecraft:stonebrick" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery4.json b/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery4.json new file mode 100644 index 0000000..086c2c4 --- /dev/null +++ b/src/main/resources/assets/mantle/books/TestBook/structures/stonesmeltery4.json @@ -0,0 +1,10 @@ +{ + "size": [1, 1, 1], + "structure": [ + { + "pos": [0, 0, 0], + "endPos": [0, 0, 0], + "block": "minecraft:stonebrick" + } + ] +} \ No newline at end of file From 6792d017c97b3934b42c8a1ceee9f266ef80d7a3 Mon Sep 17 00:00:00 2001 From: Rowan James Date: Sun, 27 Nov 2016 22:15:19 +1100 Subject: [PATCH 02/12] Fix JSON boolean representation of false (#77) Not all JSON parsers transparently convert `"false"` to `false` --- src/main/resources/mcmod.info | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 18e94a4..65dd6b3 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -14,5 +14,5 @@ "requiredMods": [], "dependencies": [], "dependants": [], - "useDependencyInformation": "false" + "useDependencyInformation": false }] From 8b6531e20f81bb5c302da0f8e10af536fb15b147 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 27 Nov 2016 12:48:51 +0100 Subject: [PATCH 03/12] Version bump to 1.1.2 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index ebb1198..13de7c4 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -mod_version=1.1.1 +mod_version=1.1.2 minecraft_version=1.10.2 forge_version=12.18.1.2084 mappings=snapshot_20160701 From 94cbdffb025013f23a66a7907e3016b9b088ecc9 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 4 Dec 2016 14:50:01 +0100 Subject: [PATCH 04/12] Fix clicking on things that change the page also processing the new page for clicks, resulting in double-forwards with one click --- .../slimeknights/mantle/client/gui/book/GuiBook.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java index 164ac31..32fa234 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java @@ -1,5 +1,7 @@ package slimeknights.mantle.client.gui.book; +import com.google.common.collect.ImmutableList; + import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -20,6 +22,7 @@ import org.lwjgl.input.Mouse; import java.io.IOException; import java.util.ArrayList; +import java.util.List; import javax.annotation.Nullable; @@ -558,9 +561,14 @@ public class GuiBook extends GuiScreen implements IProgressMeter { } // Not foreach to prevent conmodification crashes - for(int i = 0; right ? i < rightElements.size() : i < leftElements.size(); i++) { - BookElement element = right ? rightElements.get(i) : leftElements.get(i); + int oldPage = page; + List elementList = ImmutableList.copyOf(right ? rightElements: leftElements); + for(BookElement element : elementList) { element.mouseClicked(mouseX, mouseY, mouseButton); + // if we changed page stop so we don't act on the new page + if(page != oldPage) { + break; + } } } From 417bdc99c7ead13db1275ee3885932eae8e7e2b6 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sun, 4 Dec 2016 19:48:46 +0100 Subject: [PATCH 05/12] Update version to 1.1.3 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 13de7c4..46cec8e 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -mod_version=1.1.2 +mod_version=1.1.3 minecraft_version=1.10.2 forge_version=12.18.1.2084 mappings=snapshot_20160701 From be27dc7bac801a98e181c83574651d40b038f7dd Mon Sep 17 00:00:00 2001 From: Jasmine Iwanek Date: Sat, 31 Dec 2016 04:44:12 -0800 Subject: [PATCH 06/12] Update for latest forge for 1.10.2 and stable mappings (#79) --- build.properties | 6 +++--- .../mantle/client/ExtraHeartRenderHandler.java | 18 +++++++++--------- .../mantle/client/book/StructureInfo.java | 2 +- .../mantle/client/book/data/BookData.java | 4 ++-- .../mantle/client/gui/GuiMultiModule.java | 6 +++--- .../mantle/client/gui/GuiWidgetSlider.java | 2 +- .../mantle/client/gui/book/BoxRenderer.java | 4 ++-- .../mantle/client/gui/book/GuiBook.java | 6 +++--- .../client/gui/book/element/BookElement.java | 2 +- .../client/gui/book/element/ElementItem.java | 2 +- .../mantle/config/ExampleSync.java | 6 +++--- .../mantle/inventory/SlotWrapper.java | 2 +- .../mantle/multiblock/MultiServantLogic.java | 18 +++++++++--------- .../mantle/tileentity/TileInventory.java | 4 ++-- 14 files changed, 41 insertions(+), 41 deletions(-) diff --git a/build.properties b/build.properties index 46cec8e..f09f14b 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ mod_version=1.1.3 minecraft_version=1.10.2 -forge_version=12.18.1.2084 -mappings=snapshot_20160701 +forge_version=12.18.3.2185 +mappings=stable_29 -jei_version=3.7.+ +jei_version=3.10.0.+ configurate_version=3.1.1 diff --git a/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java b/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java index fd4b3f4..66f9cf9 100644 --- a/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java +++ b/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java @@ -67,7 +67,7 @@ public class ExtraHeartRenderHandler { GlStateManager.enableBlend(); EntityPlayer player = (EntityPlayer)this.mc.getRenderViewEntity(); - int health = MathHelper.ceiling_float_int(player.getHealth()); + int health = MathHelper.ceil(player.getHealth()); boolean highlight = healthUpdateCounter > (long)updateCounter && (healthUpdateCounter - (long)updateCounter) / 3L %2L == 1L; if (health < this.playerHealth && player.hurtResistantTime > 0) @@ -93,14 +93,14 @@ public class ExtraHeartRenderHandler { IAttributeInstance attrMaxHealth = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); float healthMax = (float)attrMaxHealth.getAttributeValue(); - float absorb = MathHelper.ceiling_float_int(player.getAbsorptionAmount()); + float absorb = MathHelper.ceil(player.getAbsorptionAmount()); // CHANGE: simulate 10 hearts max if there's more, so vanilla only renders one row max healthMax = Math.min(healthMax, 20f); health = Math.min(health, 20); absorb = Math.min(absorb, 20); - int healthRows = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F / 10.0F); + int healthRows = MathHelper.ceil((healthMax + absorb) / 2.0F / 10.0F); int rowHeight = Math.max(10 - (healthRows - 2), 3); this.rand.setSeed((long)(updateCounter * 312871)); @@ -116,17 +116,17 @@ public class ExtraHeartRenderHandler { regen = updateCounter % 25; } - final int TOP = 9 * (mc.theWorld.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0); + final int TOP = 9 * (mc.world.getWorldInfo().isHardcoreModeEnabled() ? 5 : 0); final int BACKGROUND = (highlight ? 25 : 16); int MARGIN = 16; if (player.isPotionActive(MobEffects.POISON)) MARGIN += 36; else if (player.isPotionActive(MobEffects.WITHER)) MARGIN += 72; float absorbRemaining = absorb; - for (int i = MathHelper.ceiling_float_int((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) + for (int i = MathHelper.ceil((healthMax + absorb) / 2.0F) - 1; i >= 0; --i) { //int b0 = (highlight ? 1 : 0); - int row = MathHelper.ceiling_float_int((float)(i + 1) / 10.0F) - 1; + int row = MathHelper.ceil((float)(i + 1) / 10.0F) - 1; int x = left + i % 10 * 8; int y = top - row * rowHeight; @@ -188,7 +188,7 @@ public class ExtraHeartRenderHandler { // Extra hearts this.mc.getTextureManager().bindTexture(ICON_HEARTS); - int hp = MathHelper.ceiling_float_int(player.getHealth()); + int hp = MathHelper.ceil(player.getHealth()); renderCustomHearts(xBasePos, yBasePos, potionOffset, hp, false); } @@ -228,7 +228,7 @@ public class ExtraHeartRenderHandler { if(potion != null) { potionOffset = 9; } - if(mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) { + if(mc.world.getWorldInfo().isHardcoreModeEnabled()) { potionOffset += 27; } return potionOffset; @@ -240,7 +240,7 @@ public class ExtraHeartRenderHandler { // Extra hearts this.mc.getTextureManager().bindTexture(ICON_ABSORB); - int absorb = MathHelper.ceiling_float_int(player.getAbsorptionAmount()); + int absorb = MathHelper.ceil(player.getAbsorptionAmount()); renderCustomHearts(xBasePos, yBasePos, potionOffset, absorb, true); } } diff --git a/src/main/java/slimeknights/mantle/client/book/StructureInfo.java b/src/main/java/slimeknights/mantle/client/book/StructureInfo.java index 96af25c..3039e70 100644 --- a/src/main/java/slimeknights/mantle/client/book/StructureInfo.java +++ b/src/main/java/slimeknights/mantle/client/book/StructureInfo.java @@ -62,7 +62,7 @@ public class StructureInfo { state = block.getDefaultState(); for(Map.Entry entry : data.state.entrySet()) { - Optional> property = state.getPropertyNames().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst(); + Optional> property = state.getPropertyKeys().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst(); if(property.isPresent()) { state = setProperty(state, property.get(), entry.getValue()); diff --git a/src/main/java/slimeknights/mantle/client/book/data/BookData.java b/src/main/java/slimeknights/mantle/client/book/data/BookData.java index 2e5f6c8..51033c5 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/BookData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/BookData.java @@ -306,9 +306,9 @@ public class BookData implements IDataItem { } public void openGui(@Nullable ItemStack item) { - if(Minecraft.getMinecraft().thePlayer != null) { + if(Minecraft.getMinecraft().player != null) { Minecraft.getMinecraft() - .displayGuiScreen(new GuiBook(this, Minecraft.getMinecraft().thePlayer.getStatFileWriter(), item)); + .displayGuiScreen(new GuiBook(this, Minecraft.getMinecraft().player.getStatFileWriter(), item)); } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java index 7e7a43c..c584709 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java @@ -127,7 +127,7 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler { } protected void drawPlayerInventoryName() { - String localizedName = Minecraft.getMinecraft().thePlayer.inventory.getDisplayName().getUnformattedText(); + String localizedName = Minecraft.getMinecraft().player.inventory.getDisplayName().getUnformattedText(); this.fontRendererObj.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040); } @@ -222,8 +222,8 @@ public class GuiMultiModule extends GuiContainer { //implements INEIGuiHandler { // update slot positions if(slotIn instanceof SlotWrapper) { - slotIn.xDisplayPosition = ((SlotWrapper) slotIn).parent.xDisplayPosition; - slotIn.yDisplayPosition = ((SlotWrapper) slotIn).parent.yDisplayPosition; + slotIn.xPos = ((SlotWrapper) slotIn).parent.xPos; + slotIn.yPos = ((SlotWrapper) slotIn).parent.yPos; } super.drawSlot(slotIn); diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java index b4ee593..cc9f633 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -50,7 +50,7 @@ public class GuiWidgetSlider extends GuiWidget { maxValue = slideBar.h; increment = 1; - sliderOffset = MathHelper.abs_int(slideBar.w - slider.w) / 2; + sliderOffset = MathHelper.abs(slideBar.w - slider.w) / 2; isScrolling = false; isHighlighted = false; diff --git a/src/main/java/slimeknights/mantle/client/gui/book/BoxRenderer.java b/src/main/java/slimeknights/mantle/client/gui/book/BoxRenderer.java index 24eb252..db4d11c 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/BoxRenderer.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/BoxRenderer.java @@ -49,14 +49,14 @@ public class BoxRenderer { int totalHeight = segH * 3 + segGH * 2; return getTextureMatrixCoords((index % (256 / sprW) * sprW) + (sprW / 2 - totalWidth / 2), (MathHelper - .floor_float(index / (256F / sprH)) * sprH) + (sprH / 2 - totalHeight / 2), segW, segH, segGW, segGH, segId); + .floor(index / (256F / sprH)) * sprH) + (sprH / 2 - totalHeight / 2), segW, segH, segGW, segGH, segId); } public static int[] getTextureMatrixCoords(int u, int v, int segW, int segH, int segGW, int segGH, int segId) { int[] coords = new int[4]; int col = segId % 3; - int row = MathHelper.floor_float(segId / 3F); + int row = MathHelper.floor(segId / 3F); coords[0] = u + col * segW + col * segGW; coords[1] = v + row * segH + row * segGH; diff --git a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java index 32fa234..088a68c 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java @@ -623,7 +623,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter { if(loadingAchievements) { return; } - if(mc.thePlayer == null) { + if(mc.player == null) { return; } @@ -634,9 +634,9 @@ public class GuiBook extends GuiScreen implements IProgressMeter { } if(this.page == -1) { - BookLoader.updateSavedPage(mc.thePlayer, item, ""); + BookLoader.updateSavedPage(mc.player, item, ""); } else if(page != null && page.parent != null) { - BookLoader.updateSavedPage(mc.thePlayer, item, page.parent.name + "." + page.name); + BookLoader.updateSavedPage(mc.player, item, page.parent.name + "." + page.name); } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/BookElement.java b/src/main/java/slimeknights/mantle/client/gui/book/element/BookElement.java index 985d91c..ac91012 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/BookElement.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/BookElement.java @@ -54,7 +54,7 @@ public abstract class BookElement extends Gui { public void renderToolTip(FontRenderer fontRenderer, ItemStack stack, int x, int y) { if(stack != null) { - List list = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips); + List list = stack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips); for(int i = 0; i < list.size(); ++i) { if(i == 0) { diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementItem.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementItem.java index fb07bcb..533e20b 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementItem.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementItem.java @@ -54,7 +54,7 @@ public class ElementItem extends SizedBookElement { } public ElementItem(int x, int y, float scale, ItemStack[] itemCycle, String action) { - super(x, y, MathHelper.floor_float(ITEM_SIZE_HARDCODED * scale), MathHelper.floor_float(ITEM_SIZE_HARDCODED * scale)); + super(x, y, MathHelper.floor(ITEM_SIZE_HARDCODED * scale), MathHelper.floor(ITEM_SIZE_HARDCODED * scale)); this.itemCycle = itemCycle; this.scale = scale; diff --git a/src/main/java/slimeknights/mantle/config/ExampleSync.java b/src/main/java/slimeknights/mantle/config/ExampleSync.java index d39aee8..3fcc20c 100644 --- a/src/main/java/slimeknights/mantle/config/ExampleSync.java +++ b/src/main/java/slimeknights/mantle/config/ExampleSync.java @@ -43,12 +43,12 @@ class ExampleSync { @SubscribeEvent @SideOnly(Side.CLIENT) public void playerJoinedWorld(TickEvent.ClientTickEvent event) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; + EntityPlayerSP player = Minecraft.getMinecraft().player; if(needsRestart) { - player.addChatMessage(new TextComponentString("Configs synced with server. Configs require a restart")); + player.sendMessage(new TextComponentString("Configs synced with server. Configs require a restart")); } else { - player.addChatMessage(new TextComponentString("Configs synced with server.")); + player.sendMessage(new TextComponentString("Configs synced with server.")); } MinecraftForge.EVENT_BUS.unregister(this); } diff --git a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java index 6f7d198..1d904ac 100644 --- a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java +++ b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java @@ -19,7 +19,7 @@ public class SlotWrapper extends Slot { public final Slot parent; public SlotWrapper(Slot slot) { - super(slot.inventory, slot.getSlotIndex(), slot.xDisplayPosition, slot.yDisplayPosition); + super(slot.inventory, slot.getSlotIndex(), slot.xPos, slot.yPos); this.parent = slot; } diff --git a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java index a9d4f93..c458dd2 100644 --- a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java @@ -36,7 +36,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic { return false; } - if(this.worldObj.getBlockState(this.master).getBlock() == this.masterBlock && this.worldObj + if(this.world.getBlockState(this.master).getBlock() == this.masterBlock && this.world .getBlockState(this.master) == this.state) { return true; } @@ -55,7 +55,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic { public void overrideMaster(BlockPos pos) { this.hasMaster = true; this.master = pos; - this.state = this.worldObj.getBlockState(this.master); + this.state = this.world.getBlockState(this.master); this.masterBlock = this.state.getBlock(); } @@ -73,7 +73,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic { @Deprecated public boolean verifyMaster(IMasterLogic logic, BlockPos pos) { - return this.master.equals(pos) && this.worldObj.getBlockState(pos) == this.state && this.worldObj.getBlockState(pos) + return this.master.equals(pos) && this.world.getBlockState(pos) == this.state && this.world.getBlockState(pos) .getBlock() == this.masterBlock; } @@ -97,7 +97,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic { @Override public void notifyMasterOfChange() { if(this.hasValidMaster()) { - IMasterLogic logic = (IMasterLogic) this.worldObj.getTileEntity(this.master); + IMasterLogic logic = (IMasterLogic) this.world.getTileEntity(this.master); logic.notifyChange(this, this.pos); } } @@ -151,20 +151,20 @@ public class MultiServantLogic extends TileEntity implements IServantLogic { @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { this.readCustomNBT(packet.getNbtCompound()); - this.worldObj.notifyLightSet(this.pos); - IBlockState state = worldObj.getBlockState(this.pos); - this.worldObj.notifyBlockUpdate(this.pos, state, state, 3); + this.world.notifyLightSet(this.pos); + IBlockState state = world.getBlockState(this.pos); + this.world.notifyBlockUpdate(this.pos, state, state, 3); } @Nonnull @Override public World getWorld() { - return this.worldObj; + return this.world; } @Deprecated public boolean setMaster(BlockPos pos) { - if(!this.hasMaster || this.worldObj.getBlockState(this.master) != this.state || (this.worldObj + if(!this.hasMaster || this.world.getBlockState(this.master) != this.state || (this.world .getBlockState(this.master) .getBlock() != this.masterBlock)) { this.overrideMaster(pos); diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index 19a83b5..81a8fc4 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -185,9 +185,9 @@ public class TileInventory extends TileEntity implements IInventory { /* Supporting methods */ @Override - public boolean isUseableByPlayer(@Nonnull EntityPlayer entityplayer) { + public boolean isUsableByPlayer(@Nonnull EntityPlayer entityplayer) { // block changed/got broken? - if(worldObj.getTileEntity(pos) != this || worldObj.getBlockState(pos).getBlock() == Blocks.AIR) { + if(world.getTileEntity(pos) != this || world.getBlockState(pos).getBlock() == Blocks.AIR) { return false; } From 242c9105f88928a0e855bf979a0be19052f44f6c Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 9 Jan 2017 15:21:59 +0100 Subject: [PATCH 07/12] Add a base TE for future use and utility functions for TEs --- .../mantle/tileentity/MantleTileEntity.java | 10 ++++++++++ .../slimeknights/mantle/tileentity/TileInventory.java | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/main/java/slimeknights/mantle/tileentity/MantleTileEntity.java diff --git a/src/main/java/slimeknights/mantle/tileentity/MantleTileEntity.java b/src/main/java/slimeknights/mantle/tileentity/MantleTileEntity.java new file mode 100644 index 0000000..c8a47b9 --- /dev/null +++ b/src/main/java/slimeknights/mantle/tileentity/MantleTileEntity.java @@ -0,0 +1,10 @@ +package slimeknights.mantle.tileentity; + +import net.minecraft.tileentity.TileEntity; + +public class MantleTileEntity extends TileEntity { + + public boolean isClient() { + return this.getWorld() != null && this.getWorld().isRemote; + } +} diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index 81a8fc4..5b01a86 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -21,7 +21,7 @@ import java.util.Arrays; import javax.annotation.Nonnull; // Updated version of InventoryLogic in Mantle. Also contains a few bugfixes -public class TileInventory extends TileEntity implements IInventory { +public class TileInventory extends MantleTileEntity implements IInventory { private ItemStack[] inventory; protected String inventoryTitle; From f77a8cdd6d5bf788781a9a8d207f7341de726043 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Mon, 9 Jan 2017 15:22:35 +0100 Subject: [PATCH 08/12] Return a list properly corresponding to the inputs required for oredict Recipematches Also fix it returning its internal representation --- src/main/java/slimeknights/mantle/util/RecipeMatch.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index 1e5abcc..c6e85cd 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -11,6 +11,7 @@ import net.minecraftforge.oredict.OreDictionary; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.stream.IntStream; import slimeknights.mantle.Mantle; @@ -281,7 +282,10 @@ public abstract class RecipeMatch { @Override public List getInputs() { - return oredictEntry; + // transform "Requires 2 Cobblestone" into "2x require 1 Cobblestone" since the oredictEntry only contains stacksize 1 usually + ImmutableList.Builder builder = ImmutableList.builder(); + oredictEntry.forEach(stack -> IntStream.range(0, amountNeeded).forEach(i -> builder.add(stack))); + return builder.build(); } @Override From f339335f10a06ae811e130d425e964c32bbb4ac5 Mon Sep 17 00:00:00 2001 From: boni Date: Mon, 9 Jan 2017 20:29:33 +0100 Subject: [PATCH 09/12] Update version to 1.1.4 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index f09f14b..f803d7d 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -mod_version=1.1.3 +mod_version=1.1.4 minecraft_version=1.10.2 forge_version=12.18.3.2185 mappings=stable_29 From 46cfb2f2d90215baefa027a7dfaeee05d573a7bc Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 11 Feb 2017 14:53:02 +0100 Subject: [PATCH 10/12] Don't stop deserialization of block-metas if an invalid entry is encountered --- src/main/java/slimeknights/mantle/config/BlockMeta.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/slimeknights/mantle/config/BlockMeta.java b/src/main/java/slimeknights/mantle/config/BlockMeta.java index 30a411d..1e0ada4 100644 --- a/src/main/java/slimeknights/mantle/config/BlockMeta.java +++ b/src/main/java/slimeknights/mantle/config/BlockMeta.java @@ -14,6 +14,8 @@ import ninja.leaping.configurate.objectmapping.serialize.TypeSerializer; public class BlockMeta { + private static final BlockMeta MISSING = new BlockMeta(Blocks.AIR, 0); + public transient static final TypeSerializer SERIALIZER = new TypeSerializer() { @Override public BlockMeta deserialize(TypeToken typeToken, ConfigurationNode configurationNode) @@ -23,7 +25,7 @@ public class BlockMeta { Block block = Block.REGISTRY.getObject(new ResourceLocation(parts[0], parts[1])); if(block == Blocks.AIR) { - throw new ObjectMappingException("Block not found: " + val); + return MISSING; } int meta = -1; if(parts.length > 2) { From a1d5c31ca4e5dd5efd722f66744bc8bd4140ddae Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Sat, 11 Feb 2017 15:06:23 +0100 Subject: [PATCH 11/12] Bump version to 1.1.5 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index f803d7d..7f333bc 100644 --- a/build.properties +++ b/build.properties @@ -1,4 +1,4 @@ -mod_version=1.1.4 +mod_version=1.1.5 minecraft_version=1.10.2 forge_version=12.18.3.2185 mappings=stable_29 From 16c1a393637b33a71b829823da0134a226cc9fef Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 1 Oct 2017 09:21:21 +0300 Subject: [PATCH 12/12] Fixed README.md formatting (?) (#84) I'm not sure why between `#` and text are no spaces. In Markdown titles are created by '#' and space after it --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 17f7571..2bc175f 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ -![Mantle logo](https://raw.github.com/SlimeKnights/Mantle/master/src/main/resources/Mantle.png) -#Mantle +![Mantle logo](https://raw.github.com/SlimeKnights/Mantle/master/src/main/resources/Mantle.png) +# Mantle **Shared code for Forge mods** -##Compile from Source +## Compile from Source Note: Git MUST be installed and in the system path to use our scripts. * setup: Run [gradle]in the repository root: `gradlew[.bat] [setupDevWorkspace|setupDecompWorkspace] [eclipse|idea]` * build: Run [gradle]in the repository root: `gradlew[.bat] build' * if obscure gradle issues are found try running 'gradlew clean' or/and 'gradlew cleanCache' -##Issue reporting +## Issue reporting Please include the following: * Minecraft version @@ -21,7 +21,7 @@ Please include the following: * Steps to reproduce * ForgeModLoader-client-0.log (the FML log) from the root folder of the client -##Licenses +## Licenses The MIT License (MIT) Copyright (c) 2013-2014 Slime Knights (mDiyo, fuj1n, Sunstrike, progwml6, pillbox, alexbegt)