diff --git a/build.gradle b/build.gradle index fb4c993..b783f61 100644 --- a/build.gradle +++ b/build.gradle @@ -123,7 +123,7 @@ dependencies { //compile "codechicken:NotEnoughItems:${minecraft_version}-${NEI_version}:dev" //deobfCompile "mezz.jei:jei_${minecraft_version}:${jei_version}" - compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") + //compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") // Configuration shadow "ninja.leaping.configurate:configurate-hocon:${configurate_version}" diff --git a/gradle.properties b/gradle.properties index 3feb5a2..c800146 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,11 +10,11 @@ minecraft_version=1.14.2 minecraft_version_toml=14 # Forge Version Information -forge_version=26.0.25 +forge_version=26.0.43 forge_version_toml=26 # Mappings Information -mappings_version=20190613-1.14.2 +mappings_version=20190621-1.14.2 jei_version=5.0.+ configurate_version=3.3 diff --git a/src/main/java/slimeknights/mantle/block/BlockConnectedTexture.java b/src/main/java/slimeknights/mantle/block/BlockConnectedTexture.java index 69f9b8e..27c5dd5 100644 --- a/src/main/java/slimeknights/mantle/block/BlockConnectedTexture.java +++ b/src/main/java/slimeknights/mantle/block/BlockConnectedTexture.java @@ -70,7 +70,7 @@ public class BlockConnectedTexture extends Block { */ private boolean isSideConnectable(BlockState state, IWorld world, BlockPos pos, Direction side) { final BlockState connected = world.getBlockState(pos.offset(side)); - return connected != null && canConnect(state, connected); + return connected != null && this.canConnect(state, connected); } /** diff --git a/src/main/java/slimeknights/mantle/block/BlockInventory.java b/src/main/java/slimeknights/mantle/block/BlockInventory.java index 25caaa9..7e3c778 100644 --- a/src/main/java/slimeknights/mantle/block/BlockInventory.java +++ b/src/main/java/slimeknights/mantle/block/BlockInventory.java @@ -24,7 +24,6 @@ import slimeknights.mantle.tileentity.TileInventory; // Updated Version of InventoryBlock in Mantle public abstract class BlockInventory extends ContainerBlock { - protected BlockInventory(Block.Properties builder) { super(builder); } diff --git a/src/main/java/slimeknights/mantle/block/BlockStairsBase.java b/src/main/java/slimeknights/mantle/block/BlockStairsBase.java index fa64afd..f98de81 100644 --- a/src/main/java/slimeknights/mantle/block/BlockStairsBase.java +++ b/src/main/java/slimeknights/mantle/block/BlockStairsBase.java @@ -7,7 +7,6 @@ import net.minecraft.block.StairsBlock; // Mojang made the constructor for stairs protected, so this class is basically a wrapper to change that and fix a lighting error public class BlockStairsBase extends StairsBlock { - public BlockStairsBase(Block model) { super(model.getDefaultState(), Block.Properties.from(model)); } diff --git a/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java b/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java index 22ff9c6..343a562 100644 --- a/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java +++ b/src/main/java/slimeknights/mantle/client/ExtraHeartRenderHandler.java @@ -1,8 +1,8 @@ package slimeknights.mantle.client; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.IAttributeInstance; @@ -14,7 +14,7 @@ import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.GuiIngameForge; +import net.minecraftforge.client.ForgeIngameGui; import net.minecraftforge.client.event.RenderGameOverlayEvent; import java.util.Random; @@ -58,9 +58,9 @@ public class ExtraHeartRenderHandler { return; } PlayerEntity player = (PlayerEntity)this.mc.getRenderViewEntity(); - + // extra setup stuff from us - left_height = GuiIngameForge.left_height; + left_height = ForgeIngameGui.left_height; width = mc.mainWindow.getScaledWidth(); height = mc.mainWindow.getScaledHeight(); event.setCanceled(true); @@ -68,7 +68,7 @@ public class ExtraHeartRenderHandler { // start default forge/mc rendering // changes are indicated by comment - mc.profiler.startSection("health"); + mc.getProfiler().startSection("health"); GlStateManager.enableBlend(); int health = MathHelper.ceil(player.getHealth()); @@ -175,15 +175,15 @@ public class ExtraHeartRenderHandler { this.mc.getTextureManager().bindTexture(ICON_VANILLA); - GuiIngameForge.left_height += 10; + ForgeIngameGui.left_height += 10; if(absorb > 0) { - GuiIngameForge.left_height += 10; + ForgeIngameGui.left_height += 10; } event.setCanceled(true); GlStateManager.disableBlend(); - mc.profiler.endSection(); + mc.getProfiler().endSection(); } private void renderExtraHearts(int xBasePos, int yBasePos, PlayerEntity player) { diff --git a/src/main/java/slimeknights/mantle/client/ModelHelper.java b/src/main/java/slimeknights/mantle/client/ModelHelper.java index 4fe6a48..dd767f4 100644 --- a/src/main/java/slimeknights/mantle/client/ModelHelper.java +++ b/src/main/java/slimeknights/mantle/client/ModelHelper.java @@ -97,10 +97,10 @@ public class ModelHelper { @Override public void put(int element, float... data) { - VertexFormatElement.EnumUsage usage = parent.getVertexFormat().getElement(element).getUsage(); + VertexFormatElement.Usage usage = parent.getVertexFormat().getElement(element).getUsage(); // transform normals and position - if(usage == VertexFormatElement.EnumUsage.COLOR && data.length >= 4) { + if(usage == VertexFormatElement.Usage.COLOR && data.length >= 4) { data[0] = r; data[1] = g; data[2] = b; diff --git a/src/main/java/slimeknights/mantle/client/book/BookTransformer.java b/src/main/java/slimeknights/mantle/client/book/BookTransformer.java index 14d0583..05c3ab1 100644 --- a/src/main/java/slimeknights/mantle/client/book/BookTransformer.java +++ b/src/main/java/slimeknights/mantle/client/book/BookTransformer.java @@ -34,9 +34,9 @@ public abstract class BookTransformer { SectionData index = new SectionData(true) { @Override public void update(GuiBook.AdvancementCache advancementCache) { - pages.clear(); + this.pages.clear(); - List visibleSections = parent.getVisibleSections(advancementCache); + List visibleSections = this.parent.getVisibleSections(advancementCache); if(visibleSections.isEmpty()) { return; @@ -90,7 +90,7 @@ public abstract class BookTransformer { if(section.name.equals("index")) { continue; } - if(sectionToTransform != null && !section.name.equals(sectionToTransform)) { + if(this.sectionToTransform != null && !section.name.equals(this.sectionToTransform)) { continue; } diff --git a/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java b/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java index 9606e6c..f1040e2 100644 --- a/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java +++ b/src/main/java/slimeknights/mantle/client/book/StructureBlockAccess.java @@ -14,6 +14,8 @@ import net.minecraft.world.LightType; import net.minecraft.world.IWorldReader; import net.minecraft.world.biome.Biome; import net.minecraft.world.border.WorldBorder; +import net.minecraft.world.chunk.ChunkStatus; +import net.minecraft.world.chunk.IChunk; import net.minecraft.world.dimension.Dimension; import net.minecraft.world.gen.Heightmap.Type; @@ -54,12 +56,12 @@ public class StructureBlockAccess implements IWorldReader int y = pos.getY(); int z = pos.getZ(); - if(y >= 0 && y < structure.length) { - if(x >= 0 && x < structure[y].length) { - if(z >= 0 && z < structure[y][x].length) { - int index = y * (data.structureLength * data.structureWidth) + x * data.structureWidth + z; - if(index <= data.getLimiter()) { - return structure[y][x][z] != null ? structure[y][x][z] : Blocks.AIR.getDefaultState(); + if(y >= 0 && y < this.structure.length) { + if(x >= 0 && x < this.structure[y].length) { + if(z >= 0 && z < this.structure[y][x].length) { + int index = y * (this.data.structureLength * this.data.structureWidth) + x * this.data.structureWidth + z; + if(index <= this.data.getLimiter()) { + return this.structure[y][x][z] != null ? this.structure[y][x][z] : Blocks.AIR.getDefaultState(); } } } @@ -69,7 +71,7 @@ public class StructureBlockAccess implements IWorldReader @Override public boolean isAirBlock(BlockPos pos) { - return getBlockState(pos).getBlock() == Blocks.AIR; + return this.getBlockState(pos).getBlock() == Blocks.AIR; } @Override @@ -87,13 +89,24 @@ public class StructureBlockAccess implements IWorldReader return 0; } + @Nullable @Override - public boolean isChunkLoaded(int x, int z, boolean allowEmpty) { + public IChunk getChunk(int x, int z, ChunkStatus requiredStatus, boolean nonnull) { + return null; + } + + @Override + public boolean chunkExists(int chunkX, int chunkZ) { return false; } @Override - public boolean canSeeSky(BlockPos pos) { + public BlockPos getHeight(Type heightmapType, BlockPos pos) { + return BlockPos.ZERO; + } + + @Override + public boolean func_217337_f(BlockPos pos) { return true; } @@ -102,11 +115,6 @@ public class StructureBlockAccess implements IWorldReader return 0; } - @Override - public PlayerEntity getClosestPlayer(double x, double y, double z, double distance, Predicate predicate) { - return null; - } - @Override public int getSkylightSubtracted() { return 0; diff --git a/src/main/java/slimeknights/mantle/client/book/StructureInfo.java b/src/main/java/slimeknights/mantle/client/book/StructureInfo.java index 62e2f03..8b23bc7 100644 --- a/src/main/java/slimeknights/mantle/client/book/StructureInfo.java +++ b/src/main/java/slimeknights/mantle/client/book/StructureInfo.java @@ -34,8 +34,8 @@ public class StructureInfo { for(int x = 0; x < length; x++) { for(int z = 0; z < width; z++) { for(BlockData data : blockData) { - if(inside(x, y, z, data.pos, data.endPos)) { - states[y][x][z] = convert(data); + if(this.inside(x, y, z, data.pos, data.endPos)) { + states[y][x][z] = this.convert(data); break; } } @@ -43,8 +43,8 @@ public class StructureInfo { } } - data = states; - maxBlockIndex = blockIndex = structureHeight * structureLength * structureWidth; + this.data = states; + this.maxBlockIndex = this.blockIndex = this.structureHeight * this.structureLength * this.structureWidth; } private BlockState convert(BlockData data) { @@ -52,21 +52,18 @@ public class StructureInfo { if(block == null) { return Blocks.AIR.getDefaultState(); } - BlockState state; - if(data.state == null || data.state.isEmpty()) { - state = block.getStateFromMeta(data.meta); - } - else { - state = block.getDefaultState(); + BlockState state = block.getDefaultState(); - for(Map.Entry entry : data.state.entrySet()) { + if (data.state != null || !data.state.isEmpty()) { + for (Map.Entry entry : data.state.entrySet()) { Optional> property = state.getProperties().stream().filter(iProperty -> entry.getKey().equals(iProperty.getName())).findFirst(); - if(property.isPresent()) { - state = setProperty(state, property.get(), entry.getValue()); + if (property.isPresent()) { + state = this.setProperty(state, property.get(), entry.getValue()); } } } + return state; } @@ -82,9 +79,7 @@ public class StructureInfo { private boolean inside(int x, int y, int z, int[] rangeStart, int[] rangeEnd) { if(x >= rangeStart[0] && x <= rangeEnd[0]) { if(y >= rangeStart[1] && y <= rangeEnd[1]) { - if(z >= rangeStart[2] && z <= rangeEnd[2]) { - return true; - } + return z >= rangeStart[2] && z <= rangeEnd[2]; } } @@ -92,43 +87,43 @@ public class StructureInfo { } public void setShowLayer(int layer) { - showLayer = layer; - blockIndex = (layer + 1) * (structureLength * structureWidth) - 1; + this.showLayer = layer; + this.blockIndex = (layer + 1) * (this.structureLength * this.structureWidth) - 1; } public void reset() { - blockIndex = maxBlockIndex; + this.blockIndex = this.maxBlockIndex; } public boolean canStep() { - int index = blockIndex; + int index = this.blockIndex; do { - if(++index >= maxBlockIndex) { + if(++index >= this.maxBlockIndex) { return false; } - } while(isEmpty(index)); + } while(this.isEmpty(index)); return true; } public void step() { - int start = blockIndex; + int start = this.blockIndex; do { - if(++blockIndex >= maxBlockIndex) { - blockIndex = 0; + if(++this.blockIndex >= this.maxBlockIndex) { + this.blockIndex = 0; } - } while(isEmpty(blockIndex) && blockIndex != start); + } while(this.isEmpty(this.blockIndex) && this.blockIndex != start); } private boolean isEmpty(int index) { - int y = index / (structureLength * structureWidth); - int r = index % (structureLength * structureWidth); - int x = r / structureWidth; - int z = r % structureWidth; + int y = index / (this.structureLength * this.structureWidth); + int r = index % (this.structureLength * this.structureWidth); + int x = r / this.structureWidth; + int z = r % this.structureWidth; - return data[y][x][z] == null || data[y][x][z].getBlock() == Blocks.AIR; + return this.data[y][x][z] == null || this.data[y][x][z].getBlock() == Blocks.AIR; } public int getLimiter() { - return blockIndex; + return this.blockIndex; } } diff --git a/src/main/java/slimeknights/mantle/client/book/action/protocol/ProtocolGoToPage.java b/src/main/java/slimeknights/mantle/client/book/action/protocol/ProtocolGoToPage.java index 7d54fb1..78fa068 100644 --- a/src/main/java/slimeknights/mantle/client/book/action/protocol/ProtocolGoToPage.java +++ b/src/main/java/slimeknights/mantle/client/book/action/protocol/ProtocolGoToPage.java @@ -24,7 +24,7 @@ public class ProtocolGoToPage extends ActionProtocol { int pageNum = book.book.findPageNumber(param); if(pageNum >= 0) { - book.openPage(pageNum, returner); + book.openPage(pageNum, this.returner); } } } 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 74efd48..e13135e 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/BookData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/BookData.java @@ -17,6 +17,7 @@ import slimeknights.mantle.client.gui.book.GuiBook; import javax.annotation.Nullable; import java.io.BufferedReader; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -43,25 +44,25 @@ public class BookData implements IDataItem { } public void reset() { - initialized = false; + this.initialized = false; } @Override public void load() { - if(initialized) { + if(this.initialized) { return; } Mantle.logger.info("Started loading book..."); try { - initialized = true; - sections.clear(); - appearance = new AppearanceData(); - itemLinks.clear(); + this.initialized = true; + this.sections.clear(); + this.appearance = new AppearanceData(); + this.itemLinks.clear(); - for(BookRepository repo : repositories) { + for(BookRepository repo : this.repositories) { try { List repoContents = repo.getSections(); - sections.addAll(repoContents); + this.sections.addAll(repoContents); for(SectionData section : repoContents) { section.source = repo; @@ -73,7 +74,7 @@ public class BookData implements IDataItem { page.name = "errorenous"; page.content = new ContentError("Failed to load repository " + repo.toString() + ".", e); error.pages.add(page); - sections.add(error); + this.sections.add(error); e.printStackTrace(); } @@ -82,20 +83,20 @@ public class BookData implements IDataItem { if(repo.resourceExists(appearanceLocation)) { try { - appearance = BookLoader.GSON + this.appearance = BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(appearanceLocation)), AppearanceData.class); } catch(Exception e) { e.printStackTrace(); } } - appearance.load(); + this.appearance.load(); ResourceLocation itemLinkLocation = repo.getResourceLocation("items.json"); if(repo.resourceExists(itemLinkLocation)) { try { - itemLinks = new ArrayList<>(Arrays.asList(BookLoader.GSON + this.itemLinks = new ArrayList<>(Arrays.asList(BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(itemLinkLocation)), ItemStackData.ItemLink[].class))); } catch(Exception e) { e.printStackTrace(); @@ -107,7 +108,7 @@ public class BookData implements IDataItem { if(repo.resourceExists(languageLocation)) { try { BufferedReader br = new BufferedReader(new InputStreamReader(repo.getResource(languageLocation) - .getInputStream(), "UTF-8")); + .getInputStream(), StandardCharsets.UTF_8)); String next = br.readLine(); @@ -116,7 +117,7 @@ public class BookData implements IDataItem { String key = next.substring(0, next.indexOf('=')); String value = next.substring(next.indexOf('=') + 1); - strings.put(key, value); + this.strings.put(key, value); } next = br.readLine(); @@ -126,12 +127,12 @@ public class BookData implements IDataItem { } } - for(int i = 0; i < sections.size(); i++){ - SectionData section = sections.get(i); + for(int i = 0; i < this.sections.size(); i++){ + SectionData section = this.sections.get(i); if(section.name == null) continue; - List matchingSections = sections.stream().filter(sect -> section.name.equalsIgnoreCase(sect.name)).collect(Collectors.toList()); + List matchingSections = this.sections.stream().filter(sect -> section.name.equalsIgnoreCase(sect.name)).collect(Collectors.toList()); if(matchingSections.size() < 2){ continue; } @@ -142,15 +143,14 @@ public class BookData implements IDataItem { linkedSection.addSection(match); if(match != section){ - sections.remove(match); + this.sections.remove(match); } } - - sections.set(i, linkedSection); + this.sections.set(i, linkedSection); } - for(SectionData section : sections) { + for(SectionData section : this.sections) { if(section.source == null) { section.source = BookRepository.DUMMY; } @@ -159,12 +159,12 @@ public class BookData implements IDataItem { section.load(); } - for(BookTransformer transformer : transformers) { + for(BookTransformer transformer : this.transformers) { transformer.transform(this); } // Loads orphaned sections, unless something went wrong, that would only be sections added by a transformer - for(SectionData section : sections) { + for(SectionData section : this.sections) { if(section.source == null) { section.source = BookRepository.DUMMY; } @@ -191,11 +191,11 @@ public class BookData implements IDataItem { } public SectionData findSection(String name) { - return findSection(name, null); + return this.findSection(name, null); } public SectionData findSection(String name, GuiBook.AdvancementCache advancementCache) { - for(SectionData section : sections) { + for(SectionData section : this.sections) { section.update(advancementCache); if(section.name.equals(name.toLowerCase())) { @@ -207,12 +207,12 @@ public class BookData implements IDataItem { } public int getFirstPageNumber(SectionData section) { - return getFirstPageNumber(section, null); + return this.getFirstPageNumber(section, null); } public int getFirstPageNumber(SectionData section, @Nullable GuiBook.AdvancementCache advancementCache) { int pages = 0; - for(SectionData sect : sections) { + for(SectionData sect : this.sections) { sect.update(advancementCache); if(section == sect) { @@ -230,7 +230,7 @@ public class BookData implements IDataItem { } public PageData findPage(int number) { - return findPage(number, null); + return this.findPage(number, null); } public PageData findPage(int number, @Nullable GuiBook.AdvancementCache advancementCache) { @@ -239,7 +239,7 @@ public class BookData implements IDataItem { } int pages = 0; - for(SectionData section : sections) { + for(SectionData section : this.sections) { section.update(advancementCache); if(!section.isUnlocked(advancementCache)) { @@ -258,15 +258,15 @@ public class BookData implements IDataItem { } public PageData findPage(String location) { - return findPage(location, null); + return this.findPage(location, null); } public PageData findPage(String location, @Nullable GuiBook.AdvancementCache advancementCache) { - return findPage(findPageNumber(location, advancementCache)); + return this.findPage(this.findPageNumber(location, advancementCache)); } public int findPageNumber(String location) { - return findPageNumber(location, null); + return this.findPageNumber(location, null); } public int findPageNumber(String location, @Nullable GuiBook.AdvancementCache advancementCache) { @@ -281,7 +281,7 @@ public class BookData implements IDataItem { String sectionName = location.substring(0, location.indexOf('.')); String pageName = location.substring(location.indexOf('.') + 1); - for(SectionData section : sections) { + for(SectionData section : this.sections) { section.update(advancementCache); if(!section.isUnlocked(advancementCache)) { @@ -307,12 +307,12 @@ public class BookData implements IDataItem { } public int getPageCount() { - return getPageCount(null); + return this.getPageCount(null); } public int getPageCount(@Nullable GuiBook.AdvancementCache advancementCache) { int pages = 0; - for(SectionData section : sections) { + for(SectionData section : this.sections) { section.update(advancementCache); pages += section.isUnlocked(advancementCache) ? section.getPageCount() : 0; @@ -321,15 +321,15 @@ public class BookData implements IDataItem { } public int getFullPageCount() { - return getFullPageCount(null); + return this.getFullPageCount(null); } public int getFullPageCount(@Nullable GuiBook.AdvancementCache advancementCache) { - return (int) Math.ceil((getPageCount(advancementCache) - 1) / 2F) + 1; + return (int) Math.ceil((this.getPageCount(advancementCache) - 1) / 2F) + 1; } public String getItemAction(ItemStackData item) { - for(ItemStackData.ItemLink link : itemLinks) { + for(ItemStackData.ItemLink link : this.itemLinks) { if(item.id.equals(link.item.id) && (!link.damageSensitive)) { return link.action; } @@ -341,7 +341,7 @@ public class BookData implements IDataItem { public List getVisibleSections(GuiBook.AdvancementCache advancementCache) { List visible = new ArrayList<>(); - for(SectionData section : sections) { + for(SectionData section : this.sections) { if(section.isUnlocked(advancementCache) || !section.hideWhenLocked) { visible.add(section); } @@ -352,13 +352,13 @@ public class BookData implements IDataItem { public String translate(String string) { - String out = strings.get(string); + String out = this.strings.get(string); return out != null ? out : string; } public void openGui(@Nullable ItemStack item) { - if(!initialized) { - load(); + if(!this.initialized) { + this.load(); } if(Minecraft.getInstance().player != null) { Minecraft.getInstance().displayGuiScreen(new GuiBook(this, item)); @@ -372,8 +372,8 @@ public class BookData implements IDataItem { } public void addTransformer(BookTransformer transformer) { - if(transformer != null && !transformers.contains(transformer)) { - transformers.add(transformer); + if(transformer != null && !this.transformers.contains(transformer)) { + this.transformers.add(transformer); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/LinkedSectionData.java b/src/main/java/slimeknights/mantle/client/book/data/LinkedSectionData.java index e1514d6..70d586a 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/LinkedSectionData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/LinkedSectionData.java @@ -11,35 +11,35 @@ public class LinkedSectionData extends SectionData { @Override public void load() { - pages.clear(); + this.pages.clear(); - name = name.toLowerCase(); + this.name = this.name.toLowerCase(); - for(SectionData section : sections){ - section.parent = parent; - section.unnamedPageCounter = unnamedPageCounter; + for(SectionData section : this.sections){ + section.parent = this.parent; + section.unnamedPageCounter = this.unnamedPageCounter; section.load(); - unnamedPageCounter = section.unnamedPageCounter; + this.unnamedPageCounter = section.unnamedPageCounter; - pages.addAll(section.pages); + this.pages.addAll(section.pages); } - icon.location = source.getResourceLocation(icon.file, true); + this.icon.location = this.source.getResourceLocation(this.icon.file, true); } public void addSection(SectionData data){ - if(!data.name.equalsIgnoreCase(name) && !sections.isEmpty()){ + if(!data.name.equalsIgnoreCase(this.name) && !this.sections.isEmpty()){ throw new IllegalArgumentException("Linked sections must contain all sections of the same name."); } - if(sections.isEmpty()){ - name = data.name; - icon = data.icon; - hideWhenLocked = data.hideWhenLocked; + if(this.sections.isEmpty()){ + this.name = data.name; + this.icon = data.icon; + this.hideWhenLocked = data.hideWhenLocked; } - requirements.addAll(data.requirements); - sections.add(data); + this.requirements.addAll(data.requirements); + this.sections.add(data); } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/PageData.java b/src/main/java/slimeknights/mantle/client/book/data/PageData.java index e7eb1c8..c37ce13 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/PageData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/PageData.java @@ -37,65 +37,65 @@ public class PageData implements IDataItem { public PageData(boolean custom) { if(custom) { - data = "no-load"; + this.data = "no-load"; } } public String translate(String string) { - return parent.translate(string); + return this.parent.translate(string); } @Override @SuppressWarnings("unchecked") public void load() { - if(name == null) { - name = "page" + parent.unnamedPageCounter++; + if(this.name == null) { + this.name = "page" + this.parent.unnamedPageCounter++; } - name = name.toLowerCase(); + this.name = this.name.toLowerCase(); - if(!data.equals("no-load")) { - IResource pageInfo = source.getResource(source.getResourceLocation(data)); + if(!this.data.equals("no-load")) { + IResource pageInfo = this.source.getResource(this.source.getResourceLocation(this.data)); if(pageInfo != null) { - String data = source.resourceToString(pageInfo); + String data = this.source.resourceToString(pageInfo); if(!data.isEmpty()) { - Class ctype = BookLoader.getPageType(type); + Class ctype = BookLoader.getPageType(this.type); try { - content = BookLoader.GSON.fromJson(data, ctype); + this.content = BookLoader.GSON.fromJson(data, ctype); } catch(Exception e) { - content = new ContentError(ctype == null ? "Failed to create a page of type \"" + type + "\", perhaps the type is not registered?" : "Failed to create a page of type \"" + type + "\", perhaps the page file \"" + this.data + "\" is missing or invalid?", e); + this.content = new ContentError(ctype == null ? "Failed to create a page of type \"" + this.type + "\", perhaps the type is not registered?" : "Failed to create a page of type \"" + this.type + "\", perhaps the page file \"" + this.data + "\" is missing or invalid?", e); } } } } - if(content == null) { + if(this.content == null) { try { - content = BookLoader.getPageType(type).newInstance(); + this.content = BookLoader.getPageType(this.type).newInstance(); } catch(InstantiationException | IllegalAccessException | NullPointerException e) { - content = new ContentError("Failed to create a page of type \"" + type + "\", perhaps the type is not registered?"); + this.content = new ContentError("Failed to create a page of type \"" + this.type + "\", perhaps the type is not registered?"); } } try { - content.parent = this; - content.load(); + this.content.parent = this; + this.content.load(); } catch(Exception e) { - content = new ContentError("Failed to load page " + parent.name + "." + name + ".", e); + this.content = new ContentError("Failed to load page " + this.parent.name + "." + this.name + ".", e); e.printStackTrace(); } - content.source = source; + this.content.source = this.source; - for(Field f : content.getClass().getFields()) { + for(Field f : this.content.getClass().getFields()) { if(Modifier.isTransient(f.getModifiers()) || Modifier.isStatic(f.getModifiers()) || Modifier .isFinal(f.getModifiers())) { continue; } try { - if(f.get(content) == null) { + if(f.get(this.content) == null) { continue; } } catch(IllegalAccessException e) { @@ -108,10 +108,10 @@ public class PageData implements IDataItem { if(c.isArray() && c.getComponentType().isAssignableFrom(swap.t)) { try { f.setAccessible(true); - Object[] o = (Object[]) f.get(content); + Object[] o = (Object[]) f.get(this.content); for(Object ob : o) { - swap.swap(source, ob); + swap.swap(this.source, ob); } } catch(IllegalAccessException e) { e.printStackTrace(); @@ -119,9 +119,9 @@ public class PageData implements IDataItem { } else if(swap.t.isAssignableFrom(c)) { try { f.setAccessible(true); - Object o = f.get(content); + Object o = f.get(this.content); - swap.swap(source, o); + swap.swap(this.source, o); } catch(IllegalAccessException e) { e.printStackTrace(); } @@ -142,8 +142,8 @@ public class PageData implements IDataItem { } public String getTitle() { - String title = parent.parent.strings.get(parent.name + "." + name); - return title == null ? name : title; + String title = this.parent.parent.strings.get(this.parent.name + "." + this.name); + return title == null ? this.name : title; } static { diff --git a/src/main/java/slimeknights/mantle/client/book/data/SectionData.java b/src/main/java/slimeknights/mantle/client/book/data/SectionData.java index b418dab..6056aac 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/SectionData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/SectionData.java @@ -36,35 +36,35 @@ public class SectionData implements IDataItem { public SectionData(boolean custom) { if(custom) { - data = "no-load"; + this.data = "no-load"; } } public String translate(String string) { - return parent.translate(string); + return this.parent.translate(string); } @Override public void load() { - if(name == null) { - name = "section" + parent.unnamedSectionCounter++; + if(this.name == null) { + this.name = "section" + this.parent.unnamedSectionCounter++; } - name = name.toLowerCase(); + this.name = this.name.toLowerCase(); - if(!data.equals("no-load")) { - IResource pagesInfo = source.getResource(source.getResourceLocation(data)); + if(!this.data.equals("no-load")) { + IResource pagesInfo = this.source.getResource(this.source.getResourceLocation(this.data)); if(pagesInfo != null) { - String data = source.resourceToString(pagesInfo); + String data = this.source.resourceToString(pagesInfo); if(!data.isEmpty()) { try { - pages = getPages(data); + this.pages = this.getPages(data); } catch(Exception e) { - pages = new ArrayList<>(); + this.pages = new ArrayList<>(); PageData pdError = new PageData(true); pdError.name = "errorrenous"; - pdError.content = new ContentError("Failed to load section " + name + ".", e); - pages.add(pdError); + pdError.content = new ContentError("Failed to load section " + this.name + ".", e); + this.pages.add(pdError); e.printStackTrace(); } @@ -72,13 +72,13 @@ public class SectionData implements IDataItem { } } - for(PageData page : pages) { + for(PageData page : this.pages) { page.parent = this; - page.source = source; + page.source = this.source; page.load(); } - icon.location = source.getResourceLocation(icon.file, true); + this.icon.location = this.source.getResourceLocation(this.icon.file, true); } /** @@ -94,20 +94,20 @@ public class SectionData implements IDataItem { } public String getTitle() { - String title = parent.strings.get(name); - return title == null ? name : title; + String title = this.parent.strings.get(this.name); + return title == null ? this.name : title; } public int getPageCount() { - return pages.size(); + return this.pages.size(); } public boolean isUnlocked(GuiBook.AdvancementCache advancementCache) { - if(advancementCache == null || requirements == null || requirements.size() == 0) { + if(advancementCache == null || this.requirements == null || this.requirements.size() == 0) { return true; } - for(String achievement : requirements) { + for(String achievement : this.requirements) { if(!requirementSatisfied(achievement, advancementCache)) { return false; } diff --git a/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java b/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java index 88f7351..722ae40 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java +++ b/src/main/java/slimeknights/mantle/client/book/data/SectionDataModule.java @@ -15,9 +15,9 @@ public class SectionDataModule extends SectionData { @Override protected ArrayList getPages(String data) { // this should always be the case, but just for safety - if(source instanceof ModuleFileRepository) { + if(this.source instanceof ModuleFileRepository) { // just filters out pages where the module is not loaded - Predicate manager = ((ModuleFileRepository)source).getManager(); + Predicate manager = ((ModuleFileRepository) this.source).getManager(); return new ArrayList<>(Arrays.stream(BookLoader.GSON.fromJson(data, PageDataModule[].class)) .filter((page)->page.module.isEmpty() || manager.test(page.module)) .collect(Collectors.toList())); diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentBlockInteraction.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentBlockInteraction.java index 19120fc..bc8cd4b 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentBlockInteraction.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentBlockInteraction.java @@ -37,24 +37,24 @@ public class ContentBlockInteraction extends PageContent { int x = GuiBook.PAGE_WIDTH / 2 - IMG_SMITHING.width / 2 - 10; int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } list.add(new ElementImage(x, y, IMG_SMITHING.width, IMG_SMITHING.height, IMG_SMITHING, book.appearance.slotColor)); - if(input != null && !input.id.equals("")) { - list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, input.getItems(), input.action)); + if(this.input != null && !this.input.id.equals("")) { + list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, this.input.getItems(), this.input.action)); } - if(block != null && !block.id.equals("")) { - list.add(new ElementItem(x + BLOCK_X, y + BLOCK_Y, BLOCK_SCALE, block.getItems(), block.action)); + if(this.block != null && !this.block.id.equals("")) { + list.add(new ElementItem(x + BLOCK_X, y + BLOCK_Y, BLOCK_SCALE, this.block.getItems(), this.block.action)); } - if(description != null && description.length > 0) { - list.add(new ElementText(0, IMG_SMITHING.height + y + 50, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - IMG_SMITHING.height - y - 50, description)); + if(this.description != null && this.description.length > 0) { + list.add(new ElementText(0, IMG_SMITHING.height + y + 50, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - IMG_SMITHING.height - y - 50, this.description)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentCrafting.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentCrafting.java index 1da1ffb..243edd3 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentCrafting.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentCrafting.java @@ -43,17 +43,17 @@ public class ContentCrafting extends PageContent { int resultX = 100; int resultY = 50; - TextData tdTitle = new TextData(title); + TextData tdTitle = new TextData(this.title); tdTitle.underlined = true; - list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, new TextData[]{tdTitle})); + list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, tdTitle)); - if(grid_size.equalsIgnoreCase("small")) { + if(this.grid_size.equalsIgnoreCase("small")) { x = GuiBook.PAGE_WIDTH / 2 - IMG_CRAFTING_SMALL.width / 2; height = y + IMG_CRAFTING_SMALL.height; list.add(new ElementImage(x, y, IMG_CRAFTING_SMALL.width, IMG_CRAFTING_SMALL.height, IMG_CRAFTING_SMALL, book.appearance.slotColor)); resultX = x + X_RESULT_SMALL; resultY = y + Y_RESULT_SMALL; - } else if(grid_size.equalsIgnoreCase("large")) { + } else if(this.grid_size.equalsIgnoreCase("large")) { x = GuiBook.PAGE_WIDTH / 2 - IMG_CRAFTING_LARGE.width / 2; height = y + IMG_CRAFTING_LARGE.height; list.add(new ElementImage(x, y, IMG_CRAFTING_LARGE.width, IMG_CRAFTING_LARGE.height, IMG_CRAFTING_LARGE, book.appearance.slotColor)); @@ -61,26 +61,26 @@ public class ContentCrafting extends PageContent { resultY = y + Y_RESULT_LARGE; } - if(grid != null) { - for(int i = 0; i < grid.length; i++) { - for(int j = 0; j < grid[i].length; j++) { - if(grid[i][j].id.equals("")) { + if(this.grid != null) { + for(int i = 0; i < this.grid.length; i++) { + for(int j = 0; j < this.grid[i].length; j++) { + if(this.grid[i][j].id.equals("")) { continue; } list.add(new ElementItem(x + SLOT_MARGIN + (SLOT_PADDING + Math .round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * j, y + SLOT_MARGIN + (SLOT_PADDING + Math - .round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * i, ITEM_SCALE, grid[i][j] - .getItems(), grid[i][j].action)); + .round(ElementItem.ITEM_SIZE_HARDCODED * ITEM_SCALE)) * i, ITEM_SCALE, this.grid[i][j] + .getItems(), this.grid[i][j].action)); } } } - if(result != null) { - list.add(new ElementItem(resultX, resultY, ITEM_SCALE, result.getItems(), result.action)); + if(this.result != null) { + list.add(new ElementItem(resultX, resultY, ITEM_SCALE, this.result.getItems(), this.result.action)); } - if(description != null && description.length > 0) { - list.add(new ElementText(0, height + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - height - 5, description)); + if(this.description != null && this.description.length > 0) { + list.add(new ElementText(0, height + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - height - 5, this.description)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentError.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentError.java index 8af41aa..c67bbdd 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentError.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentError.java @@ -27,25 +27,25 @@ public class ContentError extends PageContent { @Override public void build(BookData book, ArrayList list, boolean rightSide) { - addTitle(list, "Error"); + this.addTitle(list, "Error"); StackTraceElement[] stackTrace = null; - if(exception != null){ - stackTrace = exception.getStackTrace(); + if(this.exception != null){ + stackTrace = this.exception.getStackTrace(); } - TextData[] text = new TextData[1 + (exception != null ? 2 : 0) + (stackTrace != null ? 1 + Math.min(stackTrace.length * 2, 8) : 0)]; - text[0] = new TextData(errorStage); + TextData[] text = new TextData[1 + (this.exception != null ? 2 : 0) + (stackTrace != null ? 1 + Math.min(stackTrace.length * 2, 8) : 0)]; + text[0] = new TextData(this.errorStage); text[0].color = "dark_red"; text[0].underlined = true; text[0].paragraph = true; - if(exception != null) { + if(this.exception != null) { text[1] = new TextData("The following error has occured:"); text[1].color = "dark_red"; text[1].paragraph = true; - text[2] = new TextData(exception.getMessage() != null ? exception.getMessage() : exception.getClass() + text[2] = new TextData(this.exception.getMessage() != null ? this.exception.getMessage() : this.exception.getClass() .getSimpleName()); text[2].color = "dark_red"; text[2].paragraph = true; diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentImage.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentImage.java index a931f8d..e872292 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentImage.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentImage.java @@ -20,14 +20,14 @@ public class ContentImage extends PageContent { public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(image != null && image.location != null) { - list.add(new ElementImage(0, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y, image)); + if(this.image != null && this.image.location != null) { + list.add(new ElementImage(0, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y, this.image)); } else { list.add(new ElementImage(ImageData.MISSING)); } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentImageText.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentImageText.java index 8b242a3..36d68d8 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentImageText.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentImageText.java @@ -23,20 +23,20 @@ public class ContentImageText extends PageContent { public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(image != null && image.location != null) { - list.add(new ElementImage(0, y, GuiBook.PAGE_WIDTH, 100, image)); + if(this.image != null && this.image.location != null) { + list.add(new ElementImage(0, y, GuiBook.PAGE_WIDTH, 100, this.image)); } else { list.add(new ElementImage(0, y, 32, 32, ImageData.MISSING)); } - if(text != null && text.length > 0) { - list.add(new ElementText(0, y + 105, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 105 - y, text)); + if(this.text != null && this.text.length > 0) { + list.add(new ElementText(0, y + 105, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 105 - y, this.text)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSectionList.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSectionList.java index bbc041e..a52bd71 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSectionList.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSectionList.java @@ -13,7 +13,7 @@ public class ContentSectionList extends PageContent { protected ArrayList sections = new ArrayList<>(); public boolean addSection(SectionData data) { - return sections.size() < 9 && sections.add(data); + return this.sections.size() < 9 && this.sections.add(data); } @Override @@ -24,14 +24,14 @@ public class ContentSectionList extends PageContent { int ox = (GuiBook.PAGE_WIDTH - width) / 2; int oy = (GuiBook.PAGE_HEIGHT - height) / 2; - for(int i = 0; i < sections.size(); i++) { + for(int i = 0; i < this.sections.size(); i++) { int ix = i % 3; int iy = (int) Math.floor(i / 3F); int x = ox + ix * (ElementSection.WIDTH + 5); int y = oy + iy * (ElementSection.HEIGHT + 5); - list.add(new ElementSection(x, y, sections.get(i))); + list.add(new ElementSection(x, y, this.sections.get(i))); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java index 158813e..2ec3b79 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmelting.java @@ -43,30 +43,30 @@ public class ContentSmelting extends PageContent { int x = GuiBook.PAGE_WIDTH / 2 - IMG_SMELTING.width / 2; int y = TITLE_HEIGHT; - TextData tdTitle = new TextData(title); + TextData tdTitle = new TextData(this.title); tdTitle.underlined = true; - list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, new TextData[]{tdTitle})); + list.add(new ElementText(0, 0, GuiBook.PAGE_WIDTH, 9, tdTitle)); list.add(new ElementImage(x, y, IMG_SMELTING.width, IMG_SMELTING.height, IMG_SMELTING, book.appearance.slotColor)); - if(input != null && !input.id.equals("")) { - list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, input.getItems(), input.action)); + if(this.input != null && !this.input.id.equals("")) { + list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, this.input.getItems(), this.input.action)); } - if(result != null && !result.id.equals("")) { - list.add(new ElementItem(x + RESULT_X, y + RESULT_Y, ITEM_SCALE, result.getItems(), result.action)); + if(this.result != null && !this.result.id.equals("")) { + list.add(new ElementItem(x + RESULT_X, y + RESULT_Y, ITEM_SCALE, this.result.getItems(), this.result.action)); } - list.add(new ElementItem(x + FUEL_X, y + FUEL_Y, ITEM_SCALE, getFuelsList())); + list.add(new ElementItem(x + FUEL_X, y + FUEL_Y, ITEM_SCALE, this.getFuelsList())); - if(description != null && description.length > 0) { - list.add(new ElementText(0, IMG_SMELTING.height + y + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y - 5, description)); + if(this.description != null && this.description.length > 0) { + list.add(new ElementText(0, IMG_SMELTING.height + y + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y - 5, this.description)); } } public NonNullList getFuelsList() { //TODO ask JEI for fuel list if it is present - NonNullList fuels = NonNullList. withSize(28, ItemStack.EMPTY); + NonNullList fuels = NonNullList.withSize(28, ItemStack.EMPTY); fuels.set(0, new ItemStack(Blocks.OAK_SLAB)); fuels.set(1, new ItemStack(Blocks.SPRUCE_SLAB)); fuels.set(2, new ItemStack(Blocks.BIRCH_SLAB)); diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmithing.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmithing.java index 25e3a34..f4ce607 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmithing.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentSmithing.java @@ -39,28 +39,28 @@ public class ContentSmithing extends PageContent { int x = GuiBook.PAGE_WIDTH / 2 - IMG_SMITHING.width / 2; int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } list.add(new ElementImage(x, y, IMG_SMITHING.width, IMG_SMITHING.height, IMG_SMITHING, book.appearance.slotColor)); - if(input != null && !input.id.equals("")) { - list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, input.getItems(), input.action)); + if(this.input != null && !this.input.id.equals("")) { + list.add(new ElementItem(x + INPUT_X, y + INPUT_Y, ITEM_SCALE, this.input.getItems(), this.input.action)); } - if(modifier != null && !modifier.id.equals("")) { - list.add(new ElementItem(x + MODIFIER_X, y + MODIFIER_Y, ITEM_SCALE, modifier.getItems(), modifier.action)); + if(this.modifier != null && !this.modifier.id.equals("")) { + list.add(new ElementItem(x + MODIFIER_X, y + MODIFIER_Y, ITEM_SCALE, this.modifier.getItems(), this.modifier.action)); } - if(result != null && !result.id.equals("")) { - list.add(new ElementItem(x + RESULT_X, y + RESULT_Y, ITEM_SCALE, result.getItems(), result.action)); + if(this.result != null && !this.result.id.equals("")) { + list.add(new ElementItem(x + RESULT_X, y + RESULT_Y, ITEM_SCALE, this.result.getItems(), this.result.action)); } - if(description != null && description.length > 0) { - list.add(new ElementText(0, IMG_SMITHING.height + y + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - IMG_SMITHING.height - y - 5, description)); + if(this.description != null && this.description.length > 0) { + list.add(new ElementText(0, IMG_SMITHING.height + y + 5, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - IMG_SMITHING.height - y - 5, this.description)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentStructure.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentStructure.java index 0c3c8be..f95bbc7 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentStructure.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentStructure.java @@ -28,18 +28,18 @@ public class ContentStructure extends PageContent { @Override public void load() { - BookRepository repo = parent.source; + BookRepository repo = this.parent.source; - if(data == null || data.isEmpty()) { + if(this.data == null || this.data.isEmpty()) { return; } - ResourceLocation location = repo.getResourceLocation(data); + ResourceLocation location = repo.getResourceLocation(this.data); if(location != null && repo.resourceExists(location)) { ContentStructure structure = BookLoader.GSON .fromJson(repo.resourceToString(repo.getResource(location)), ContentStructure.class); - structure.parent = parent; + structure.parent = this.parent; structure.load(); this.size = structure.size; this.structure = structure.structure; @@ -50,30 +50,30 @@ public class ContentStructure extends PageContent { @Override public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } int offset = 0; int structureSizeX = GuiBook.PAGE_WIDTH; int structureSizeY = GuiBook.PAGE_HEIGHT - y - 10; - if(!StringUtils.isNullOrEmpty(text)) { + if(!StringUtils.isNullOrEmpty(this.text)) { offset = 15; structureSizeX -= 2*offset; structureSizeY -= 2*offset; - list.add(new ElementText(0, GuiBook.PAGE_HEIGHT - 10 - 2*offset, GuiBook.PAGE_WIDTH, 2*offset, text)); + list.add(new ElementText(0, GuiBook.PAGE_HEIGHT - 10 - 2*offset, GuiBook.PAGE_WIDTH, 2*offset, this.text)); } - if(size != null && size.length == 3 && structure != null && structure.length > 0) { - boolean showButtons = size[1] > 1; + if(this.size != null && this.size.length == 3 && this.structure != null && this.structure.length > 0) { + boolean showButtons = this.size[1] > 1; if(showButtons) { //structureSizeX -= GuiArrow.ArrowType.REFRESH.w; } - ElementStructure elementStructure = new ElementStructure(offset, y, structureSizeX, structureSizeY, size, structure); + ElementStructure elementStructure = new ElementStructure(offset, y, structureSizeX, structureSizeY, this.size, this.structure); list.add(elementStructure); if(showButtons) { diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTableOfContents.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTableOfContents.java index a3df204..62069c2 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTableOfContents.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTableOfContents.java @@ -17,23 +17,23 @@ public class ContentTableOfContents extends PageContent { public ContentTableOfContents(String title, TextData... contents) { this.title = title; - data = contents; + this.data = contents; } @Override public void build(BookData book, ArrayList list, boolean rightSide) { int y = 0; - if(title != null && !title.trim().isEmpty()) { - addTitle(list, title); + if(this.title != null && !this.title.trim().isEmpty()) { + this.addTitle(list, this.title); y += TITLE_HEIGHT; } - for(int i = 0; i < data.length; i++) { - TextData text = data[i]; + for(int i = 0; i < this.data.length; i++) { + TextData text = this.data[i]; list.add(new ElementText(0, y + i * (int) (Minecraft .getInstance().fontRenderer.FONT_HEIGHT * text.scale), GuiBook.PAGE_WIDTH, Minecraft - .getInstance().fontRenderer.FONT_HEIGHT, new TextData[]{text})); + .getInstance().fontRenderer.FONT_HEIGHT, text)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentText.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentText.java index c858012..eb3b513 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentText.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentText.java @@ -21,14 +21,14 @@ public class ContentText extends PageContent { public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(text != null && text.length > 0) { - list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y, text)); + if(this.text != null && this.text.length > 0) { + list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - y, this.text)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextImage.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextImage.java index 6ce57d7..ec2752f 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextImage.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextImage.java @@ -24,24 +24,24 @@ public class ContentTextImage extends PageContent { public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(text != null && text.length > 0) { - list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 105, text)); + if(this.text != null && this.text.length > 0) { + list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 105, this.text)); } - if(image != null && image.location != null) { - list.add(new ElementImage(0, y + GuiBook.PAGE_HEIGHT - 100, GuiBook.PAGE_WIDTH, 100 - y, image)); + if(this.image != null && this.image.location != null) { + list.add(new ElementImage(0, y + GuiBook.PAGE_HEIGHT - 100, GuiBook.PAGE_WIDTH, 100 - y, this.image)); } else { list.add(new ElementImage(0, y + GuiBook.PAGE_HEIGHT - 100, GuiBook.PAGE_WIDTH, 100 - y, ImageData.MISSING)); } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextLeftImage.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextLeftImage.java index 5c7984a..2604499 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextLeftImage.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextLeftImage.java @@ -25,24 +25,24 @@ public class ContentTextLeftImage extends PageContent { public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(image != null && image.location != null) { - list.add(new ElementImage(0, y, 50, 50, image)); + if(this.image != null && this.image.location != null) { + list.add(new ElementImage(0, y, 50, 50, this.image)); } else { list.add(new ElementImage(0, y, 50, 50, ImageData.MISSING)); } - if(text1 != null && text1.length > 0) { - list.add(new ElementText(55, y, GuiBook.PAGE_WIDTH - 55, 50, text1)); + if(this.text1 != null && this.text1.length > 0) { + list.add(new ElementText(55, y, GuiBook.PAGE_WIDTH - 55, 50, this.text1)); } - if(text2 != null && text2.length > 0) { - list.add(new ElementText(0, y + 55, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 55 - y, text2)); + if(this.text2 != null && this.text2.length > 0) { + list.add(new ElementText(0, y + 55, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 55 - y, this.text2)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextRightImage.java b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextRightImage.java index 4f6c2f1..ee7a8d6 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextRightImage.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/ContentTextRightImage.java @@ -25,24 +25,24 @@ public class ContentTextRightImage extends PageContent { public void build(BookData book, ArrayList list, boolean rightSide) { int y = TITLE_HEIGHT; - if(title == null || title.isEmpty()) { + if(this.title == null || this.title.isEmpty()) { y = 0; } else { - addTitle(list, title); + this.addTitle(list, this.title); } - if(text1 != null && text1.length > 0) { - list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH - 55, 50, text1)); + if(this.text1 != null && this.text1.length > 0) { + list.add(new ElementText(0, y, GuiBook.PAGE_WIDTH - 55, 50, this.text1)); } - if(image != null && image.location != null) { - list.add(new ElementImage(GuiBook.PAGE_WIDTH - 50, y, 50, 50, image)); + if(this.image != null && this.image.location != null) { + list.add(new ElementImage(GuiBook.PAGE_WIDTH - 50, y, 50, 50, this.image)); } else { list.add(new ElementImage(GuiBook.PAGE_WIDTH - 50, y, 50, 50, ImageData.MISSING)); } - if(text2 != null && text2.length > 0) { - list.add(new ElementText(0, y + 55, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 55 - y, text2)); + if(this.text2 != null && this.text2.length > 0) { + list.add(new ElementText(0, y + 55, GuiBook.PAGE_WIDTH, GuiBook.PAGE_HEIGHT - 55 - y, this.text2)); } } } diff --git a/src/main/java/slimeknights/mantle/client/book/data/content/PageContent.java b/src/main/java/slimeknights/mantle/client/book/data/content/PageContent.java index fff49df..9f3c47c 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/content/PageContent.java +++ b/src/main/java/slimeknights/mantle/client/book/data/content/PageContent.java @@ -28,7 +28,7 @@ public abstract class PageContent { public void addTitle(ArrayList list, String title) { TextData tdTitle = new TextData(title); tdTitle.underlined = true; - addTitle(list, new TextData[]{tdTitle}); + this.addTitle(list, new TextData[]{tdTitle}); } public void addTitle(ArrayList list, TextData[] title) { diff --git a/src/main/java/slimeknights/mantle/client/book/data/element/BlockData.java b/src/main/java/slimeknights/mantle/client/book/data/element/BlockData.java index f86cb14..0e9d31a 100644 --- a/src/main/java/slimeknights/mantle/client/book/data/element/BlockData.java +++ b/src/main/java/slimeknights/mantle/client/book/data/element/BlockData.java @@ -9,7 +9,6 @@ public class BlockData { public int[] pos; public int[] endPos; public String block; - public byte meta; public JsonObject nbt; public Map state; } diff --git a/src/main/java/slimeknights/mantle/client/book/repository/BookRepository.java b/src/main/java/slimeknights/mantle/client/book/repository/BookRepository.java index 7b05ed5..65d2463 100644 --- a/src/main/java/slimeknights/mantle/client/book/repository/BookRepository.java +++ b/src/main/java/slimeknights/mantle/client/book/repository/BookRepository.java @@ -14,7 +14,7 @@ public abstract class BookRepository { public abstract List getSections(); public ResourceLocation getResourceLocation(String path) { - return getResourceLocation(path, false); + return this.getResourceLocation(path, false); } public abstract ResourceLocation getResourceLocation(String path, boolean safe); @@ -22,13 +22,13 @@ public abstract class BookRepository { public abstract IResource getResource(ResourceLocation loc); public boolean resourceExists(String location) { - return resourceExists(new ResourceLocation(location)); + return this.resourceExists(new ResourceLocation(location)); } public abstract boolean resourceExists(ResourceLocation location); public String resourceToString(IResource resource) { - return resourceToString(resource, true); + return this.resourceToString(resource, true); } public abstract String resourceToString(IResource resource, boolean skipCommments); diff --git a/src/main/java/slimeknights/mantle/client/book/repository/FileRepository.java b/src/main/java/slimeknights/mantle/client/book/repository/FileRepository.java index 1e1c06e..d8881c1 100644 --- a/src/main/java/slimeknights/mantle/client/book/repository/FileRepository.java +++ b/src/main/java/slimeknights/mantle/client/book/repository/FileRepository.java @@ -27,7 +27,7 @@ public class FileRepository extends BookRepository { @Override public List getSections() { return new ArrayList<>(Arrays.asList(BookLoader.GSON - .fromJson(resourceToString(getResource(getResourceLocation("index.json"))), SectionData[].class))); + .fromJson(this.resourceToString(this.getResource(this.getResourceLocation("index.json"))), SectionData[].class))); } @Override @@ -40,7 +40,7 @@ public class FileRepository extends BookRepository { if(Minecraft.getInstance().getLanguageManager() != null && Minecraft.getInstance().getLanguageManager().getCurrentLanguage() != null) { - langPath = Minecraft.getInstance().getLanguageManager().getCurrentLanguage().getLanguageCode(); + langPath = Minecraft.getInstance().getLanguageManager().getCurrentLanguage().getCode(); } String defaultLangPath = "en_US"; @@ -48,23 +48,23 @@ public class FileRepository extends BookRepository { ResourceLocation res; if(langPath != null) { - res = new ResourceLocation(location + "/" + langPath + "/" + path); - if (resourceExists(res)) { + res = new ResourceLocation(this.location + "/" + langPath + "/" + path); + if (this.resourceExists(res)) { return res; } } - res = new ResourceLocation(location + "/" + defaultLangPath + "/" + path); - if(resourceExists(res)) { + res = new ResourceLocation(this.location + "/" + defaultLangPath + "/" + path); + if(this.resourceExists(res)) { return res; } - res = new ResourceLocation(location + "/" + path); - if(resourceExists(res)) { + res = new ResourceLocation(this.location + "/" + path); + if(this.resourceExists(res)) { return res; } return safe ? new ResourceLocation("") : null; } else { ResourceLocation res = new ResourceLocation(path); - if(resourceExists(res)) { + if(this.resourceExists(res)) { return res; } return safe ? new ResourceLocation("") : null; diff --git a/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java b/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java index 0ab17b9..60a2790 100644 --- a/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java +++ b/src/main/java/slimeknights/mantle/client/book/repository/ModuleFileRepository.java @@ -27,8 +27,8 @@ public class ModuleFileRepository extends FileRepository { @Override public List getSections() { // same as super, except we remove any where the related module is not loaded - return Arrays.stream(BookLoader.GSON.fromJson(resourceToString(getResource(getResourceLocation("index.json"))), SectionDataModule[].class)) - .filter((section)->section.module.isEmpty() || manager.test(section.module)) + return Arrays.stream(BookLoader.GSON.fromJson(this.resourceToString(this.getResource(this.getResourceLocation("index.json"))), SectionDataModule[].class)) + .filter((section)->section.module.isEmpty() || this.manager.test(section.module)) .collect(Collectors.toList()); } @@ -37,6 +37,6 @@ public class ModuleFileRepository extends FileRepository { * @return Predicate to test a module availability */ public Predicate getManager() { - return manager; + return this.manager; } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiElement.java b/src/main/java/slimeknights/mantle/client/gui/GuiElement.java index a26e242..38d87e6 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiElement.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiElement.java @@ -25,7 +25,7 @@ public class GuiElement { public GuiElement(int x, int y, int w, int h, int texW, int texH) { this(x, y, w, h); - setTextureSize(texW, texH); + this.setTextureSize(texW, texH); defaultTexW = texW; defaultTexH = texH; @@ -36,14 +36,12 @@ public class GuiElement { this.y = y; this.w = w; this.h = h; - setTextureSize(defaultTexW, defaultTexH); + this.setTextureSize(defaultTexW, defaultTexH); } - public GuiElement setTextureSize(int w, int h) { - texW = w; - texH = h; - - return this; + public void setTextureSize(int w, int h) { + this.texW = w; + this.texH = h; } public GuiElement shift(int xd, int yd) { @@ -57,8 +55,8 @@ public class GuiElement { * @param yPos Y-Coordinate on the screen */ public int draw(int xPos, int yPos) { - Screen.blit(xPos, yPos, x, y, w, h, texW, texH); - return w; + Screen.blit(xPos, yPos, this.x, this.y, this.w, this.h, this.texW, this.texH); + return this.w; } public static class Builder { diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java b/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java index 719db50..c5f9cd9 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiElementScalable.java @@ -16,36 +16,36 @@ public class GuiElementScalable extends GuiElement { } public int drawScaledX(int xPos, int yPos, int width) { - for(int i = 0; i < width / w; i++) { - draw(xPos + i * w, yPos); + for(int i = 0; i < width / this.w; i++) { + this.draw(xPos + i * this.w, yPos); } // remainder that doesn't fit total width - int remainder = width % w; + int remainder = width % this.w; if(remainder > 0) { - Screen.blit(xPos + width - remainder, yPos, x, y, remainder, h, texW, texH); + Screen.blit(xPos + width - remainder, yPos, this.x, this.y, remainder, this.h, this.texW, this.texH); } return width; } public int drawScaledY(int xPos, int yPos, int height) { - for(int i = 0; i < height / h; i++) { - draw(xPos, yPos + i * h); + for(int i = 0; i < height / this.h; i++) { + this.draw(xPos, yPos + i * this.h); } // remainder that doesn't fit total width - int remainder = height % h; + int remainder = height % this.h; if(remainder > 0) { - Screen.blit(xPos, yPos + height - remainder, x, y, w, remainder, texW, texH); + Screen.blit(xPos, yPos + height - remainder, this.x, this.y, this.w, remainder, this.texW, this.texH); } - return w; + return this.w; } public int drawScaled(int xPos, int yPos, int width, int height) { // we draw full height row-wise int full = height / this.h; for(int i = 0; i < full; i++) { - drawScaledX(xPos, yPos + i * this.h, width); + this.drawScaledX(xPos, yPos + i * this.h, width); } yPos += full * this.h; @@ -53,13 +53,13 @@ public class GuiElementScalable extends GuiElement { // and the remainder is drawn manually int yRest = height % this.h; // the same as drawScaledX but with the remaining height - for(int i = 0; i < width / w; i++) { - drawScaledY(xPos + i * w, yPos, yRest); + for(int i = 0; i < width / this.w; i++) { + this.drawScaledY(xPos + i * this.w, yPos, yRest); } // remainder that doesn't fit total width - int remainder = width % w; + int remainder = width % this.w; if(remainder > 0) { - Screen.blit(xPos + width - remainder, yPos, x, y, remainder, yRest, texW, texH); + Screen.blit(xPos + width - remainder, yPos, this.x, this.y, remainder, yRest, this.texW, this.texH); } return width; @@ -68,7 +68,7 @@ public class GuiElementScalable extends GuiElement { @Override public GuiElementScalable shift(int xd, int yd) { GuiElementScalable element = new GuiElementScalable(this.x + xd, this.y + yd, this.w, this.h); - element.setTextureSize(this.texW, texH); + element.setTextureSize(this.texW, this.texH); return element; } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java index 5ca938e..f8ef435 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiModule.java @@ -2,8 +2,10 @@ package slimeknights.mantle.client.gui; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.renderer.Rectangle2d; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -22,8 +24,8 @@ public abstract class GuiModule extends ContainerScreen public int yOffset = 0; public int xOffset = 0; - public GuiModule(GuiMultiModule parent, Container container, boolean right, boolean bottom) { - super(container); + public GuiModule(GuiMultiModule parent, Container container, PlayerInventory playerInventory, ITextComponent title, boolean right, boolean bottom) { + super(container, playerInventory, title); this.parent = parent; this.right = right; @@ -31,40 +33,40 @@ public abstract class GuiModule extends ContainerScreen } public int guiRight() { - return guiLeft + xSize; + return this.guiLeft + this.xSize; } public int guiBottom() { - return guiTop + ySize; + return this.guiTop + this.ySize; } public Rectangle2d getArea() { - return new Rectangle2d(guiLeft, guiTop, xSize, ySize); + return new Rectangle2d(this.guiLeft, this.guiTop, this.xSize, this.ySize); } @Override - public void initGui() { + public void init() { this.guiLeft = (this.width - this.xSize) / 2; this.guiTop = (this.height - this.ySize) / 2; } public void updatePosition(int parentX, int parentY, int parentSizeX, int parentSizeY) { - if(right) { + if(this.right) { this.guiLeft = parentX + parentSizeX; } else { this.guiLeft = parentX - this.xSize; } - if(bottom) { + if(this.bottom) { this.guiTop = parentY + parentSizeY - this.ySize; } else { this.guiTop = parentY; } - this.guiLeft += xOffset; - this.guiTop += yOffset; + this.guiLeft += this.xOffset; + this.guiTop += this.yOffset; } public boolean shouldDrawSlot(Slot slot) { @@ -77,8 +79,8 @@ public abstract class GuiModule extends ContainerScreen } public boolean isMouseOverFullSlot(double mouseX, double mouseY) { - for(Slot slot : inventorySlots.inventorySlots) { - if(parent.isSlotSelected(slot, mouseX, mouseY) && slot.getHasStack()) { + for(Slot slot : this.container.inventorySlots) { + if(this.parent.isSlotSelected(slot, mouseX, mouseY) && slot.getHasStack()) { return true; } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java index c7c6c9a..5adf1be 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiMultiModule.java @@ -6,9 +6,11 @@ import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screen.inventory.ContainerScreen; import net.minecraft.client.renderer.Rectangle2d; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Slot; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -44,41 +46,41 @@ public class GuiMultiModule extends ContainerScreen public int realWidth; public int realHeight; - public GuiMultiModule(ContainerMultiModule container) { - super(container); + public GuiMultiModule(ContainerMultiModule container, PlayerInventory playerInventory, ITextComponent title) { + super(container, playerInventory, title); - realWidth = -1; - realHeight = -1; + this.realWidth = -1; + this.realHeight = -1; } protected void addModule(GuiModule module) { - modules.add(module); + this.modules.add(module); } public List getModuleAreas() { - List areas = new ArrayList(modules.size()); - for(GuiModule module : modules) { + List areas = new ArrayList(this.modules.size()); + for(GuiModule module : this.modules) { areas.add(module.getArea()); } return areas; } @Override - public void initGui() { - if(realWidth > -1) { + public void init() { + if(this.realWidth > -1) { // has to be reset before calling initGui so the position is getting retained - xSize = realWidth; - ySize = realHeight; + this.xSize = this.realWidth; + this.ySize = this.realHeight; } - super.initGui(); + super.init(); this.cornerX = this.guiLeft; this.cornerY = this.guiTop; - this.realWidth = xSize; - this.realHeight = ySize; + this.realWidth = this.xSize; + this.realHeight = this.ySize; - for(GuiModule module : modules) { - updateSubmodule(module); + for(GuiModule module : this.modules) { + this.updateSubmodule(module); } //this.guiLeft = this.guiTop = 0; @@ -88,17 +90,17 @@ public class GuiMultiModule extends ContainerScreen @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { - for(GuiModule module : modules) { + for(GuiModule module : this.modules) { module.handleDrawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY); } } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - drawContainerName(); - drawPlayerInventoryName(); + this.drawContainerName(); + this.drawPlayerInventoryName(); - for(GuiModule module : modules) { + for(GuiModule module : this.modules) { // set correct state for the module GlStateManager.pushMatrix(); GlStateManager.translatef(-this.guiLeft, -this.guiTop, 0.0F); @@ -111,35 +113,35 @@ public class GuiMultiModule extends ContainerScreen protected void drawBackground(ResourceLocation background) { GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(background); - this.drawTexturedModalRect(cornerX, cornerY, 0, 0, realWidth, realHeight); + this.minecraft.getTextureManager().bindTexture(background); + this.blit(this.cornerX, this.cornerY, 0, 0, this.realWidth, this.realHeight); } protected void drawContainerName() { - ContainerMultiModule multiContainer = (ContainerMultiModule) this.inventorySlots; - String localizedName = multiContainer.getInventoryDisplayName(); + ContainerMultiModule multiContainer = (ContainerMultiModule) this.container; + String localizedName = this.getTitle().getFormattedText();//multiContainer.getInventoryDisplayName(); if(localizedName != null) { - this.fontRenderer.drawString(localizedName, 8, 6, 0x404040); + this.font.drawString(localizedName, 8, 6, 0x404040); } } protected void drawPlayerInventoryName() { String localizedName = Minecraft.getInstance().player.inventory.getDisplayName().getUnformattedComponentText(); - this.fontRenderer.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040); + this.font.drawString(localizedName, 8, this.ySize - 96 + 2, 0x404040); } @Override - public void setWorldAndResolution(Minecraft mc, int width, int height) { - super.setWorldAndResolution(mc, width, height); + public void init(Minecraft mc, int width, int height) { + super.init(mc, width, height); // workaround for NEIs ASM hax. sigh. try { - for(GuiModule module : modules) { - module.setWorldAndResolution(mc, width, height); + for(GuiModule module : this.modules) { + module.init(mc, width, height); if(NEI_Manager != null) { NEI_Manager.set(module, NEI_Manager.get(this)); } - updateSubmodule(module); + this.updateSubmodule(module); } } catch(IllegalAccessException e) { Mantle.logger.error(e); @@ -147,33 +149,33 @@ public class GuiMultiModule extends ContainerScreen } @Override - public void onResize(@Nonnull Minecraft mc, int width, int height) { - super.onResize(mc, width, height); + public void resize(@Nonnull Minecraft mc, int width, int height) { + super.resize(mc, width, height); - for(GuiModule module : modules) { - module.onResize(mc, width, height); - updateSubmodule(module); + for(GuiModule module : this.modules) { + module.resize(mc, width, height); + this.updateSubmodule(module); } } @Override public void render(int mouseX, int mouseY, float partialTicks) { - this.drawDefaultBackground(); - int oldX = guiLeft; - int oldY = guiTop; - int oldW = xSize; - int oldH = ySize; + this.renderBackground(); + int oldX = this.guiLeft; + int oldY = this.guiTop; + int oldW = this.xSize; + int oldH = this.ySize; - guiLeft = cornerX; - guiTop = cornerY; - xSize = realWidth; - ySize = realHeight; + this.guiLeft = this.cornerX; + this.guiTop = this.cornerY; + this.xSize = this.realWidth; + this.ySize = this.realHeight; super.render(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); - guiLeft = oldX; - guiTop = oldY; - xSize = oldW; - ySize = oldH; + this.guiLeft = oldX; + this.guiTop = oldY; + this.xSize = oldW; + this.ySize = oldH; } @@ -197,16 +199,16 @@ public class GuiMultiModule extends ContainerScreen this.guiTop = module.guiTop; } if(module.guiRight() > this.guiLeft + this.xSize) { - xSize = module.guiRight() - this.guiLeft; + this.xSize = module.guiRight() - this.guiLeft; } if(module.guiBottom() > this.guiTop + this.ySize) { - ySize = module.guiBottom() - this.guiTop; + this.ySize = module.guiBottom() - this.guiTop; } } @Override public void drawSlot(Slot slotIn) { - GuiModule module = getModuleForSlot(slotIn.slotNumber); + GuiModule module = this.getModuleForSlot(slotIn.slotNumber); if(module != null) { Slot slot = slotIn; @@ -230,7 +232,7 @@ public class GuiMultiModule extends ContainerScreen @Override public boolean isSlotSelected(Slot slotIn, double mouseX, double mouseY) { - GuiModule module = getModuleForSlot(slotIn.slotNumber); + GuiModule module = this.getModuleForSlot(slotIn.slotNumber); // mouse inside the module of the slot? if(module != null) { @@ -250,7 +252,7 @@ public class GuiMultiModule extends ContainerScreen @Override public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { - GuiModule module = getModuleForPoint(mouseX, mouseY); + GuiModule module = this.getModuleForPoint(mouseX, mouseY); if(module != null) { if(module.handleMouseClicked(mouseX, mouseY, mouseButton)) { return false; @@ -261,7 +263,7 @@ public class GuiMultiModule extends ContainerScreen @Override public boolean mouseDragged(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLastClick, double unkowwn) { - GuiModule module = getModuleForPoint(mouseX, mouseY); + GuiModule module = this.getModuleForPoint(mouseX, mouseY); if(module != null) { if(module.handleMouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick)) { return false; @@ -273,7 +275,7 @@ public class GuiMultiModule extends ContainerScreen @Override public boolean mouseReleased(double mouseX, double mouseY, int state) { - GuiModule module = getModuleForPoint(mouseX, mouseY); + GuiModule module = this.getModuleForPoint(mouseX, mouseY); if(module != null) { if(module.handleMouseReleased(mouseX, mouseY, state)) { return false; @@ -284,7 +286,7 @@ public class GuiMultiModule extends ContainerScreen } protected GuiModule getModuleForPoint(double x, double y) { - for(GuiModule module : modules) { + for(GuiModule module : this.modules) { if(this.isPointInRegion(module.guiLeft, module.guiTop, module.guiRight(), module.guiBottom(), x + this.cornerX, y + this.cornerY)) { return module; @@ -295,12 +297,12 @@ public class GuiMultiModule extends ContainerScreen } protected GuiModule getModuleForSlot(int slotNumber) { - return getModuleForContainer(getContainer().getSlotContainer(slotNumber)); + return this.getModuleForContainer(this.getContainer().getSlotContainer(slotNumber)); } protected GuiModule getModuleForContainer(Container container) { - for(GuiModule module : modules) { - if(module.inventorySlots == container) { + for(GuiModule module : this.modules) { + if(module.getContainer() == container) { return module; } } @@ -308,7 +310,8 @@ public class GuiMultiModule extends ContainerScreen return null; } - protected ContainerMultiModule getContainer() { - return (ContainerMultiModule) inventorySlots; + @Override + public ContainerMultiModule getContainer() { + return (ContainerMultiModule) this.container; } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java index 4165dbb..aa68872 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetSlider.java @@ -48,20 +48,20 @@ public class GuiWidgetSlider extends GuiWidget { this.slideBarTop = slideBarTop; this.slideBarBottom = slideBarBottom; - height = slideBar.h; - width = slideBar.w; - currentValue = minValue = 0; - maxValue = slideBar.h; - increment = 1; + this.height = slideBar.h; + this.width = slideBar.w; + this.currentValue = this.minValue = 0; + this.maxValue = slideBar.h; + this.increment = 1; - sliderOffset = MathHelper.abs(slideBar.w - slider.w) / 2; + this.sliderOffset = MathHelper.abs(slideBar.w - slider.w) / 2; - isScrolling = false; - isHighlighted = false; + this.isScrolling = false; + this.isHighlighted = false; - enabled = true; - hidden = false; - useMouseWheel = false; + this.enabled = true; + this.hidden = false; + this.useMouseWheel = false; } /** Sets the height of the whole slider and slidebar */ @@ -76,14 +76,14 @@ public class GuiWidgetSlider extends GuiWidget { this.increment = stepsize; // just in case - setSliderValue(currentValue); + this.setSliderValue(this.currentValue); } public int getValue() { - if(isHidden()) { + if(this.isHidden()) { return 0; } - return Math.min(maxValue, Math.max(minValue, currentValue)); + return Math.min(this.maxValue, Math.max(this.minValue, this.currentValue)); } public void setEnabled(boolean enabled) { @@ -120,37 +120,37 @@ public class GuiWidgetSlider extends GuiWidget { @Override public void draw() { - if(hidden) { + if(this.hidden) { return; } // slidebar background - slideBarTop.draw(xPos, yPos); - slideBar.drawScaledY(xPos, yPos + slideBarTop.h, getUsableSlidebarHeight()); - slideBarBottom.draw(xPos, yPos + height - slideBarBottom.h); + this.slideBarTop.draw(this.xPos, this.yPos); + this.slideBar.drawScaledY(this.xPos, this.yPos + this.slideBarTop.h, this.getUsableSlidebarHeight()); + this.slideBarBottom.draw(this.xPos, this.yPos + this.height - this.slideBarBottom.h); - int x = xPos + sliderOffset; - int y = yPos + getSliderTop(); + int x = this.xPos + this.sliderOffset; + int y = this.yPos + this.getSliderTop(); // the slider depending on state - if(enabled) { - if(isScrolling) { - sliderDisabled.draw(x, y); + if(this.enabled) { + if(this.isScrolling) { + this.sliderDisabled.draw(x, y); } - else if(isHighlighted) { - sliderHighlighted.draw(x, y); + else if(this.isHighlighted) { + this.sliderHighlighted.draw(x, y); } else { - slider.draw(x, y); + this.slider.draw(x, y); } } else { - sliderDisabled.draw(x, y); + this.sliderDisabled.draw(x, y); } } public void update(int mouseX, int mouseY, boolean useMouseWheel) { - if(!enabled || hidden) { + if(!this.enabled || this.hidden) { return; } @@ -158,62 +158,62 @@ public class GuiWidgetSlider extends GuiWidget { this.useMouseWheel = useMouseWheel; // relative position inside the widget - int x = mouseX - xPos; - int y = mouseY - yPos; + int x = mouseX - this.xPos; + int y = mouseY - this.yPos; // reset click data - if(!mouseDown && clickedBar) { - clickedBar = false; + if(!mouseDown && this.clickedBar) { + this.clickedBar = false; } // button not pressed and scrolling -> stop scrolling - if(!mouseDown && isScrolling) { - isScrolling = false; + if(!mouseDown && this.isScrolling) { + this.isScrolling = false; } // button pressed and scrolling -> update position of slider - else if(isScrolling) { - float d = maxValue - minValue; - float val = (float) (y - clickY) / (float) (getUsableSlidebarHeight() - slider.h); + else if(this.isScrolling) { + float d = this.maxValue - this.minValue; + float val = (float) (y - this.clickY) / (float) (this.getUsableSlidebarHeight() - this.slider.h); val *= d; - if(val < (float) increment / 2f) { + if(val < (float) this.increment / 2f) { // < 1/2 increment - setSliderValue(minValue); + this.setSliderValue(this.minValue); } - else if(val > maxValue - ((float) increment / 2f)) { + else if(val > this.maxValue - ((float) this.increment / 2f)) { // > max-1/2 increment - setSliderValue(maxValue); + this.setSliderValue(this.maxValue); } else { // in between - setSliderValue((int) (minValue + (float) increment * Math.round(val))); + this.setSliderValue((int) (this.minValue + (float) this.increment * Math.round(val))); } } // not scrolling yet but possibly inside the slider - else if(x >= 0 && y >= getSliderTop() && - x - sliderOffset <= slider.w && y <= getSliderTop() + slider.h) { - isHighlighted = true; + else if(x >= 0 && y >= this.getSliderTop() && + x - this.sliderOffset <= this.slider.w && y <= this.getSliderTop() + this.slider.h) { + this.isHighlighted = true; if(mouseDown) { - isScrolling = true; - clickX = x - sliderOffset; - clickY = y - getSliderTop(); + this.isScrolling = true; + this.clickX = x - this.sliderOffset; + this.clickY = y - this.getSliderTop(); } } // not on the slider but clicked on the bar - else if(mouseDown && !clickedBar && + else if(mouseDown && !this.clickedBar && x >= 0 && y >= 0 && - x <= slideBar.w && y <= height) { - if(y < getSliderTop()) { - decrement(); + x <= this.slideBar.w && y <= this.height) { + if(y < this.getSliderTop()) { + this.decrement(); } else { - increment(); + this.increment(); } - clickedBar = true; + this.clickedBar = true; } else { - isHighlighted = false; + this.isHighlighted = false; } } @@ -223,14 +223,14 @@ public class GuiWidgetSlider extends GuiWidget { double mouseX = event.getMouseX(); double mouseY = event.getMouseY(); - if(useMouseWheel) { + if(this.useMouseWheel) { if(dWheel > 0.0) { - decrement(); + this.decrement(); event.setCanceled(true); return; } else if(dWheel < 0.0) { - increment(); + this.increment(); event.setCanceled(true); return; } @@ -238,36 +238,36 @@ public class GuiWidgetSlider extends GuiWidget { } public int increment() { - setSliderValue(currentValue + increment); - return currentValue; + this.setSliderValue(this.currentValue + this.increment); + return this.currentValue; } public int decrement() { - setSliderValue(currentValue - increment); - return currentValue; + this.setSliderValue(this.currentValue - this.increment); + return this.currentValue; } public int setSliderValue(int val) { - if(val > maxValue) { - val = maxValue; + if(val > this.maxValue) { + val = this.maxValue; } - else if(val < minValue) { - val = minValue; + else if(val < this.minValue) { + val = this.minValue; } - currentValue = val; - return currentValue; + this.currentValue = val; + return this.currentValue; } private int getSliderTop() { - float d = maxValue - minValue; - d = (float) (currentValue - minValue) / d; - d *= getUsableSlidebarHeight() - slider.h; + float d = this.maxValue - this.minValue; + d = (float) (this.currentValue - this.minValue) / d; + d *= this.getUsableSlidebarHeight() - this.slider.h; - return (int) d + slideBarTop.h; + return (int) d + this.slideBarTop.h; } private int getUsableSlidebarHeight() { - return height - slideBarTop.h - slideBarBottom.h; + return this.height - this.slideBarTop.h - this.slideBarBottom.h; } } diff --git a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java index 2d7320f..020753f 100644 --- a/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java +++ b/src/main/java/slimeknights/mantle/client/gui/GuiWidgetTabs.java @@ -2,8 +2,8 @@ package slimeknights.mantle.client.gui; import com.google.common.collect.Lists; +import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.ItemRenderer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.item.ItemStack; @@ -46,16 +46,16 @@ public class GuiWidgetTabs extends GuiWidget { this.tabActive[1] = activeCenter; this.tabActive[2] = activeRight; - selected = 0; + this.selected = 0; } public void addTab(ItemStack icon) { - icons.add(icon); + this.icons.add(icon); } public void clear() { - selected = 0; - icons.clear(); + this.selected = 0; + this.icons.clear(); } public void update(int mouseX, int mouseY) { @@ -66,36 +66,36 @@ public class GuiWidgetTabs extends GuiWidget { mouseY -= this.yPos; // update highlighted - highlighted = -1; - if(mouseY >= 0 && mouseY <= tab[1].h) { + this.highlighted = -1; + if(mouseY >= 0 && mouseY <= this.tab[1].h) { // which one did we click? int x = 0; - for(int i = 0; i < icons.size(); i++) { + for(int i = 0; i < this.icons.size(); i++) { // clicking on spacing has no effect - if(mouseX >= x && mouseX < x + tab[1].w) { - highlighted = i; + if(mouseX >= x && mouseX < x + this.tab[1].w) { + this.highlighted = i; break; } - x += tab[1].w; - x += spacing; + x += this.tab[1].w; + x += this.spacing; } } // already clicked - if(clicked) { + if(this.clicked) { // still clicking if(mouseDown) { return; } // release click else { - clicked = false; + this.clicked = false; return; } } // new click else if(mouseDown) { - clicked = true; + this.clicked = true; } // no click - do nothing else { @@ -103,34 +103,34 @@ public class GuiWidgetTabs extends GuiWidget { } // was new click, select highlighted - if(highlighted > -1) { - selected = highlighted; + if(this.highlighted > -1) { + this.selected = this.highlighted; } } @Override public void draw() { - int y = yPos + yOffset; - for(int i = 0; i < icons.size(); i++) { - int x = xPos + i * tab[0].w; + int y = this.yPos + this.yOffset; + for(int i = 0; i < this.icons.size(); i++) { + int x = this.xPos + i * this.tab[0].w; if(i > 0) { - x += i * spacing; + x += i * this.spacing; } GuiElement[] toDraw; - if(i == selected) { - toDraw = tabActive; + if(i == this.selected) { + toDraw = this.tabActive; } else { - toDraw = tab; + toDraw = this.tab; } GuiElement actualTab; - if(i == 0 && x == parent.cornerX) { + if(i == 0 && x == this.parent.cornerX) { actualTab = toDraw[0]; } - else if(x == parent.cornerX + parent.width) { + else if(x == this.parent.cornerX + this.parent.width) { actualTab = toDraw[2]; } else { @@ -140,14 +140,14 @@ public class GuiWidgetTabs extends GuiWidget { // todo: draw all the tabs first and then all the itemstacks so it doesn't have to switch texture in between all the time // rebind texture from drawing an itemstack - Minecraft.getInstance().getTextureManager().bindTexture(tabsResource); + Minecraft.getInstance().getTextureManager().bindTexture(this.tabsResource); actualTab.draw(x, y); - ItemStack icon = icons.get(i); + ItemStack icon = this.icons.get(i); if(icon != null) { RenderHelper.enableGUIStandardItemLighting(); - drawItemStack(icon, x + (actualTab.w - 16) / 2, y + (actualTab.h - 16) / 2); + this.drawItemStack(icon, x + (actualTab.w - 16) / 2, y + (actualTab.h - 16) / 2); RenderHelper.disableStandardItemLighting(); //RenderHelper.enableStandardItemLighting(); } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/GuiArrow.java b/src/main/java/slimeknights/mantle/client/gui/book/GuiArrow.java index aef9954..4378fe5 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/GuiArrow.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/GuiArrow.java @@ -45,7 +45,7 @@ public class GuiArrow extends Button float b = (color & 0xff) / 255.F; GlStateManager.color3f(r, g, b); - AbstractGui.blit(x, y, arrowType.x, arrowType.y, width, height, width, height, 512, 512); + AbstractGui.blit(this.x, this.y, this.arrowType.x, this.arrowType.y, this.width, this.height, this.width, this.height, 512, 512); this.renderBg(minecraft, mouseX, mouseY); } } 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 41e6279..0c41407 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/GuiBook.java @@ -14,6 +14,7 @@ import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.ITextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -80,25 +81,26 @@ public class GuiBook extends Screen PAGE_HEIGHT = (int) ((PAGE_HEIGHT_UNSCALED - (PAGE_PADDING_TOP + PAGE_PADDING_BOT + PAGE_MARGIN + PAGE_MARGIN)) / PAGE_SCALE); } - public GuiBook(BookData book, @Nullable ItemStack item) { + public GuiBook(ITextComponent title, BookData book, @Nullable ItemStack item) { + super(title); this.book = book; this.item = item; this.minecraft = Minecraft.getInstance(); - this.font = minecraft.fontRenderer; - init(); + this.font = this.minecraft.fontRenderer; + this.init(); - advancementCache = new AdvancementCache(); - this.minecraft.player.connection.getAdvancementManager().setListener(advancementCache); + this.advancementCache = new AdvancementCache(); + this.minecraft.player.connection.getAdvancementManager().setListener(this.advancementCache); - openPage(book.findPageNumber(BookHelper.getSavedPage(item), advancementCache)); + this.openPage(book.findPageNumber(BookHelper.getSavedPage(item), this.advancementCache)); } public void drawerTransform(boolean rightSide) { if(rightSide) { - GlStateManager.translatef(width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); + GlStateManager.translatef(this.width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); } else { - GlStateManager.translatef(width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN, height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); + GlStateManager.translatef(this.width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN, 0); } } @@ -106,32 +108,32 @@ public class GuiBook extends Screen protected float leftOffset(boolean rightSide) { if(rightSide) { // from center: go padding + margin to the right - return width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN; + return this.width / 2 + PAGE_PADDING_RIGHT + PAGE_MARGIN; } else { // from center: go page width left, then right with padding and margin - return width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN; + return this.width / 2 - PAGE_WIDTH_UNSCALED + PAGE_PADDING_LEFT + PAGE_MARGIN; } } protected float topOffset() { - return height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN; + return this.height / 2 - PAGE_HEIGHT_UNSCALED / 2 + PAGE_PADDING_TOP + PAGE_MARGIN; } protected int getMouseX(boolean rightSide) { - return (int) ((Minecraft.getInstance().mouseHelper.getMouseX() * this.width / this.minecraft.mainWindow.getFramebufferWidth() - leftOffset(rightSide)) / PAGE_SCALE); + return (int) ((Minecraft.getInstance().mouseHelper.getMouseX() * this.width / this.minecraft.mainWindow.getFramebufferWidth() - this.leftOffset(rightSide)) / PAGE_SCALE); } protected int getMouseY() { - return (int) ((this.height - Minecraft.getInstance().mouseHelper.getMouseY() * this.height / this.minecraft.mainWindow.getFramebufferWidth() - 1 - topOffset()) / PAGE_SCALE); + return (int) ((this.height - Minecraft.getInstance().mouseHelper.getMouseY() * this.height / this.minecraft.mainWindow.getFramebufferWidth() - 1 - this.topOffset()) / PAGE_SCALE); } @Override @SuppressWarnings("ForLoopReplaceableByForEach") public void render(int mouseX, int mouseY, float partialTicks) { - init(); - FontRenderer fontRenderer = book.fontRenderer; + this.init(); + FontRenderer fontRenderer = this.book.fontRenderer; if(fontRenderer == null) { - fontRenderer = minecraft.fontRenderer; + fontRenderer = this.minecraft.fontRenderer; } if(debug) { @@ -172,38 +174,38 @@ public class GuiBook extends Screen GlStateManager.pushMatrix(); GlStateManager.color3f(1F, 1F, 1F); - float coverR = ((book.appearance.coverColor >> 16) & 0xff) / 255.F; - float coverG = ((book.appearance.coverColor >> 8) & 0xff) / 255.F; - float coverB = (book.appearance.coverColor & 0xff) / 255.F; + float coverR = ((this.book.appearance.coverColor >> 16) & 0xff) / 255.F; + float coverG = ((this.book.appearance.coverColor >> 8) & 0xff) / 255.F; + float coverB = (this.book.appearance.coverColor & 0xff) / 255.F; TextureManager render = this.minecraft.textureManager; - if(page == -1) { + if(this.page == -1) { render.bindTexture(TEX_BOOKFRONT); RenderHelper.disableStandardItemLighting(); GlStateManager.color3f(coverR, coverG, coverB); - blit(width / 2 - PAGE_WIDTH_UNSCALED / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + blit(this.width / 2 - PAGE_WIDTH_UNSCALED / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); GlStateManager.color3f(1F, 1F, 1F); - if(!book.appearance.title.isEmpty()) { - blit(width / 2 - PAGE_WIDTH_UNSCALED / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + if(!this.book.appearance.title.isEmpty()) { + blit(this.width / 2 - PAGE_WIDTH_UNSCALED / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); GlStateManager.pushMatrix(); - float scale = fontRenderer.getStringWidth(book.appearance.title) <= 67 ? 2.5F : 2F; + float scale = fontRenderer.getStringWidth(this.book.appearance.title) <= 67 ? 2.5F : 2F; GlStateManager.scalef(scale, scale, 1F); - fontRenderer.drawStringWithShadow(book.appearance.title, (width / 2) / scale + 3 - fontRenderer - .getStringWidth(book.appearance.title) / 2, (height / 2 - fontRenderer.FONT_HEIGHT / 2) / scale - 4, 0xAE8000); + fontRenderer.drawStringWithShadow(this.book.appearance.title, (this.width / 2) / scale + 3 - fontRenderer + .getStringWidth(this.book.appearance.title) / 2, (this.height / 2 - fontRenderer.FONT_HEIGHT / 2) / scale - 4, 0xAE8000); GlStateManager.popMatrix(); } - if(!book.appearance.subtitle.isEmpty()) { + if(!this.book.appearance.subtitle.isEmpty()) { GlStateManager.pushMatrix(); GlStateManager.scalef(1.5F, 1.5F, 1F); - fontRenderer.drawStringWithShadow(book.appearance.subtitle, (width / 2) / 1.5F + 7 - fontRenderer - .getStringWidth(book.appearance.subtitle) / 2, (height / 2 + 100 - fontRenderer.FONT_HEIGHT * 2) / 1.5F, 0xAE8000); + fontRenderer.drawStringWithShadow(this.book.appearance.subtitle, (this.width / 2) / 1.5F + 7 - fontRenderer + .getStringWidth(this.book.appearance.subtitle) / 2, (this.height / 2 + 100 - fontRenderer.FONT_HEIGHT * 2) / 1.5F, 0xAE8000); GlStateManager.popMatrix(); } } else { @@ -211,37 +213,37 @@ public class GuiBook extends Screen RenderHelper.disableStandardItemLighting(); GlStateManager.color3f(coverR, coverG, coverB); - blit(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + blit(this.width / 2 - PAGE_WIDTH_UNSCALED, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, 0, PAGE_WIDTH_UNSCALED * 2, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); GlStateManager.color3f(1F, 1F, 1F); - if(page != 0) { - blit(width / 2 - PAGE_WIDTH_UNSCALED, height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + if(this.page != 0) { + blit(this.width / 2 - PAGE_WIDTH_UNSCALED, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, 0, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); GlStateManager.pushMatrix(); - drawerTransform(false); + this.drawerTransform(false); GlStateManager.scalef(PAGE_SCALE, PAGE_SCALE, 1F); - if(book.appearance.drawPageNumbers) { - String pNum = (page - 1) * 2 + 2 + ""; + if(this.book.appearance.drawPageNumbers) { + String pNum = (this.page - 1) * 2 + 2 + ""; fontRenderer.drawString(pNum, PAGE_WIDTH / 2 - fontRenderer.getStringWidth(pNum) / 2, PAGE_HEIGHT - 10, 0xFFAAAAAA); } - int mX = getMouseX(false); - int mY = getMouseY(); + int mX = this.getMouseX(false); + int mY = this.getMouseY(); // Not foreach to prevent conmodification crashes - for(int i = 0; i < leftElements.size(); i++) { - BookElement element = leftElements.get(i); + for(int i = 0; i < this.leftElements.size(); i++) { + BookElement element = this.leftElements.get(i); GlStateManager.color4f(1F, 1F, 1F, 1F); element.draw(mX, mY, partialTicks, fontRenderer); } // Not foreach to prevent conmodification crashes - for(int i = 0; i < leftElements.size(); i++) { - BookElement element = leftElements.get(i); + for(int i = 0; i < this.leftElements.size(); i++) { + BookElement element = this.leftElements.get(i); GlStateManager.color4f(1F, 1F, 1F, 1F); element.drawOverlay(mX, mY, partialTicks, fontRenderer); @@ -256,34 +258,34 @@ public class GuiBook extends Screen GlStateManager.color4f(1F, 1F, 1F, 1F); RenderHelper.disableStandardItemLighting(); - int fullPageCount = book.getFullPageCount(advancementCache); - if(page < fullPageCount - 1 || book.getPageCount(advancementCache) % 2 != 0) { - blit(width / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); + int fullPageCount = this.book.getFullPageCount(this.advancementCache); + if(this.page < fullPageCount - 1 || this.book.getPageCount(this.advancementCache) % 2 != 0) { + blit(this.width / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE); GlStateManager.pushMatrix(); - drawerTransform(true); + this.drawerTransform(true); GlStateManager.scalef(PAGE_SCALE, PAGE_SCALE, 1F); - if(book.appearance.drawPageNumbers) { - String pNum = (page - 1) * 2 + 3 + ""; + if(this.book.appearance.drawPageNumbers) { + String pNum = (this.page - 1) * 2 + 3 + ""; fontRenderer.drawString(pNum, PAGE_WIDTH / 2 - fontRenderer.getStringWidth(pNum) / 2, PAGE_HEIGHT - 10, 0xFFAAAAAA); } - int mX = getMouseX(true); - int mY = getMouseY(); + int mX = this.getMouseX(true); + int mY = this.getMouseY(); // Not foreach to prevent conmodification crashes - for(int i = 0; i < rightElements.size(); i++) { - BookElement element = rightElements.get(i); + for(int i = 0; i < this.rightElements.size(); i++) { + BookElement element = this.rightElements.get(i); GlStateManager.color4f(1F, 1F, 1F, 1F); element.draw(mX, mY, partialTicks, fontRenderer); } // Not foreach to prevent conmodification crashes - for(int i = 0; i < rightElements.size(); i++) { - BookElement element = rightElements.get(i); + for(int i = 0; i < this.rightElements.size(); i++) { + BookElement element = this.rightElements.get(i); GlStateManager.color4f(1F, 1F, 1F, 1F); element.drawOverlay(mX, mY, partialTicks, fontRenderer); @@ -299,7 +301,7 @@ public class GuiBook extends Screen } public int openPage(int page) { - return openPage(page, false); + return this.openPage(page, false); } public int openPage(int page, boolean returner) { @@ -316,12 +318,12 @@ public class GuiBook extends Screen bookPage = (page - 2) / 2 + 1; } - if(bookPage >= -1 && bookPage < book.getFullPageCount(advancementCache)) { + if(bookPage >= -1 && bookPage < this.book.getFullPageCount(this.advancementCache)) { if(returner) { - oldPage = this.page; + this.oldPage = this.page; } - _setPage(bookPage); + this._setPage(bookPage); } return page % 2 == 0 ? 0 : 1; @@ -329,73 +331,73 @@ public class GuiBook extends Screen public void _setPage(int page) { this.page = page; - buildPages(); + this.buildPages(); } public int getPage(int side) { - if(page == 0 && side == 0) { + if(this.page == 0 && side == 0) { return -1; - } else if(page == 0 && side == 1) { + } else if(this.page == 0 && side == 1) { return 0; } else if(side == 0) { - return (page - 1) * 2 + 1; + return (this.page - 1) * 2 + 1; } else if(side == 1) { - return (page - 2) * 2 + 2; + return (this.page - 2) * 2 + 2; } else { return -1; } } public int getPage_() { - return page; + return this.page; } public ArrayList getElements(int side) { - return side == 0 ? leftElements : side == 1 ? rightElements : null; + return side == 0 ? this.leftElements : side == 1 ? this.rightElements : null; } public void openCover() { - _setPage(-1); + this._setPage(-1); this.leftElements.clear(); this.rightElements.clear(); - buildPages(); + this.buildPages(); } public void itemClicked(ItemStack item) { - StringActionProcessor.process(book.getItemAction(ItemStackData.getItemStackData(item, true)), this); + StringActionProcessor.process(this.book.getItemAction(ItemStackData.getItemStackData(item, true)), this); } private void buildPages() { - leftElements.clear(); - rightElements.clear(); + this.leftElements.clear(); + this.rightElements.clear(); - if(page == -1) { + if(this.page == -1) { return; } - if(page == 0) { - PageData page = book.findPage(0, advancementCache); + if(this.page == 0) { + PageData page = this.book.findPage(0, this.advancementCache); if(page != null) { - page.content.build(book, rightElements, false); + page.content.build(this.book, this.rightElements, false); } } else { - PageData leftPage = book.findPage((page - 1) * 2 + 1, advancementCache); - PageData rightPage = book.findPage((page - 1) * 2 + 2, advancementCache); + PageData leftPage = this.book.findPage((this.page - 1) * 2 + 1, this.advancementCache); + PageData rightPage = this.book.findPage((this.page - 1) * 2 + 2, this.advancementCache); if(leftPage != null) { - leftPage.content.build(book, leftElements, false); + leftPage.content.build(this.book, this.leftElements, false); } if(rightPage != null) { - rightPage.content.build(book, rightElements, true); + rightPage.content.build(this.book, this.rightElements, true); } } - for(BookElement element : leftElements) { + for(BookElement element : this.leftElements) { element.parent = this; } - for(BookElement element : rightElements) { + for(BookElement element : this.rightElements) { element.parent = this; } } @@ -411,84 +413,84 @@ public class GuiBook extends Screen height /= 2F; }*/ - previousArrow = new GuiArrow(0, -50, -50, GuiArrow.ArrowType.PREV, book.appearance.arrowColor, book.appearance.arrowColorHover) { + this.previousArrow = new GuiArrow(0, -50, -50, GuiArrow.ArrowType.PREV, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover) { @Override public void onClick(double mouseX, double mouseY) { - page--; - if(page < -1) { - page = -1; + GuiBook.this.page--; + if(GuiBook.this.page < -1) { + GuiBook.this.page = -1; } - oldPage = -2; - buildPages(); + GuiBook.this.oldPage = -2; + GuiBook.this.buildPages(); } }; - nextArrow = new GuiArrow(1, -50, -50, GuiArrow.ArrowType.NEXT, book.appearance.arrowColor, book.appearance.arrowColorHover) { + this.nextArrow = new GuiArrow(1, -50, -50, GuiArrow.ArrowType.NEXT, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover) { @Override public void onClick(double mouseX, double mouseY) { - page++; - int fullPageCount = book.getFullPageCount(advancementCache); - if(page >= fullPageCount) { - page = fullPageCount - 1; + GuiBook.this.page++; + int fullPageCount = GuiBook.this.book.getFullPageCount(GuiBook.this.advancementCache); + if(GuiBook.this.page >= fullPageCount) { + GuiBook.this.page = fullPageCount - 1; } - oldPage = -2; - buildPages(); + GuiBook.this.oldPage = -2; + GuiBook.this.buildPages(); } }; - backArrow = new GuiArrow(2, width / 2 - GuiArrow.WIDTH / 2, height / 2 + GuiArrow.HEIGHT / 2 + PAGE_HEIGHT/2, GuiArrow.ArrowType.LEFT, book.appearance.arrowColor, book.appearance.arrowColorHover) { + this.backArrow = new GuiArrow(2, this.width / 2 - GuiArrow.WIDTH / 2, this.height / 2 + GuiArrow.HEIGHT / 2 + PAGE_HEIGHT/2, GuiArrow.ArrowType.LEFT, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover) { @Override public void onClick(double mouseX, double mouseY) { - if(oldPage >= -1) { - page = oldPage; + if(GuiBook.this.oldPage >= -1) { + GuiBook.this.page = GuiBook.this.oldPage; } - oldPage = -2; - buildPages(); + GuiBook.this.oldPage = -2; + GuiBook.this.buildPages(); } }; - indexArrow = new GuiArrow(3, width / 2 - PAGE_WIDTH_UNSCALED - GuiArrow.WIDTH / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, GuiArrow.ArrowType.BACK_UP, book.appearance.arrowColor, book.appearance.arrowColorHover) { + this.indexArrow = new GuiArrow(3, this.width / 2 - PAGE_WIDTH_UNSCALED - GuiArrow.WIDTH / 2, this.height / 2 - PAGE_HEIGHT_UNSCALED / 2, GuiArrow.ArrowType.BACK_UP, this.book.appearance.arrowColor, this.book.appearance.arrowColorHover) { @Override public void onClick(double mouseX, double mouseY) { - openPage(book.findPageNumber("index.page1")); + GuiBook.this.openPage(GuiBook.this.book.findPageNumber("index.page1")); - oldPage = -2; - buildPages(); + GuiBook.this.oldPage = -2; + GuiBook.this.buildPages(); } }; - buttons.clear(); - buttons.add(previousArrow); - buttons.add(nextArrow); - buttons.add(backArrow); - buttons.add(indexArrow); + this.buttons.clear(); + this.buttons.add(this.previousArrow); + this.buttons.add(this.nextArrow); + this.buttons.add(this.backArrow); + this.buttons.add(this.indexArrow); - buildPages(); + this.buildPages(); } @Override public void tick() { super.tick(); - previousArrow.visible = page != -1; - nextArrow.visible = page + 1 < book.getFullPageCount(advancementCache); - backArrow.visible = oldPage >= -1; + this.previousArrow.visible = this.page != -1; + this.nextArrow.visible = this.page + 1 < this.book.getFullPageCount(this.advancementCache); + this.backArrow.visible = this.oldPage >= -1; - if(page == -1) { - nextArrow.x = width / 2 + 80; - indexArrow.visible = false; + if(this.page == -1) { + this.nextArrow.x = this.width / 2 + 80; + this.indexArrow.visible = false; } else { - previousArrow.x = width / 2 - 184; - nextArrow.x = width / 2 + 165; + this.previousArrow.x = this.width / 2 - 184; + this.nextArrow.x = this.width / 2 + 165; - indexArrow.visible = book.findSection("index") != null && (page - 1) * 2 + 2 > book.findSection("index") + this.indexArrow.visible = this.book.findSection("index") != null && (this.page - 1) * 2 + 2 > this.book.findSection("index") .getPageCount(); } - previousArrow.y = height / 2 + 75; - nextArrow.y = height / 2 + 75; + this.previousArrow.y = this.height / 2 + 75; + this.nextArrow.y = this.height / 2 + 75; } /*@Override @@ -508,23 +510,23 @@ public class GuiBook extends Screen switch(keyCode) { case GLFW.GLFW_KEY_LEFT: case GLFW.GLFW_KEY_A: - page--; - if(page < -1) { - page = -1; + this.page--; + if(this.page < -1) { + this.page = -1; } - oldPage = -2; - buildPages(); + this.oldPage = -2; + this.buildPages(); return true; case GLFW.GLFW_KEY_RIGHT: case GLFW.GLFW_KEY_D: - page++; - int fullPageCount = book.getFullPageCount(advancementCache); - if(page >= fullPageCount) { - page = fullPageCount - 1; + this.page++; + int fullPageCount = this.book.getFullPageCount(this.advancementCache); + if(this.page >= fullPageCount) { + this.page = fullPageCount - 1; } - oldPage = -2; - buildPages(); + this.oldPage = -2; + this.buildPages(); return true; case GLFW.GLFW_KEY_F3: debug = !debug; @@ -535,53 +537,53 @@ public class GuiBook extends Screen } @Override - public boolean mouseScrolled(double scrollDelta) { + public boolean mouseScrolled(double scrollDelta, double unKnown1, double unKnown2) { if (scrollDelta < 0.0D) { - page++; - int fullPageCount = book.getFullPageCount(advancementCache); - if(page >= fullPageCount) { - page = fullPageCount - 1; + this.page++; + int fullPageCount = this.book.getFullPageCount(this.advancementCache); + if(this.page >= fullPageCount) { + this.page = fullPageCount - 1; } - oldPage = -2; - buildPages(); + this.oldPage = -2; + this.buildPages(); return true; } else if (scrollDelta > 0.0D) { - page--; - if(page < -1) { - page = -1; + this.page--; + if(this.page < -1) { + this.page = -1; } - oldPage = -2; - buildPages(); + this.oldPage = -2; + this.buildPages(); return true; } - return super.mouseScrolled(scrollDelta); + return super.mouseScrolled(scrollDelta, unKnown1, unKnown2); } @Override public boolean mouseClicked(double mouseX, double mouseY, int mouseButton) { boolean right = false; - mouseX = getMouseX(false); - mouseY = getMouseY(); + mouseX = this.getMouseX(false); + mouseY = this.getMouseY(); if(mouseX > PAGE_WIDTH + (PAGE_MARGIN + PAGE_PADDING_LEFT) / PAGE_SCALE) { - mouseX = getMouseX(true); + mouseX = this.getMouseX(true); right = true; } // Not foreach to prevent conmodification crashes - int oldPage = page; - List elementList = ImmutableList.copyOf(right ? rightElements: leftElements); + int oldPage = this.page; + List elementList = ImmutableList.copyOf(right ? this.rightElements : this.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) { + if(this.page != oldPage) { return true; } } @@ -592,17 +594,17 @@ public class GuiBook extends Screen @Override public boolean mouseReleased(double mouseX, double mouseY, int mouseButton) { boolean right = false; - mouseX = getMouseX(false); - mouseY = getMouseY(); + mouseX = this.getMouseX(false); + mouseY = this.getMouseY(); if(mouseX > PAGE_WIDTH + (PAGE_MARGIN + PAGE_PADDING_LEFT) / PAGE_SCALE) { - mouseX = getMouseX(true); + mouseX = this.getMouseX(true); right = true; } // 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); + for(int i = 0; right ? i < this.rightElements.size() : i < this.leftElements.size(); i++) { + BookElement element = right ? this.rightElements.get(i) : this.leftElements.get(i); element.mouseReleased(mouseX, mouseY, mouseButton); } return super.mouseReleased(mouseX, mouseY, mouseButton); @@ -611,17 +613,17 @@ public class GuiBook extends Screen @Override public boolean mouseDragged(double mouseX, double mouseY, int clickedMouseButton, double timeSinceLaslick, double unknown) { boolean right = false; - mouseX = getMouseX(false); - mouseY = getMouseY(); + mouseX = this.getMouseX(false); + mouseY = this.getMouseY(); if(mouseX > PAGE_WIDTH + (PAGE_MARGIN + PAGE_PADDING_LEFT) / PAGE_SCALE) { - mouseX = getMouseX(true); + mouseX = this.getMouseX(true); right = true; } // 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); + for(int i = 0; right ? i < this.rightElements.size() : i < this.leftElements.size(); i++) { + BookElement element = right ? this.rightElements.get(i) : this.leftElements.get(i); element.mouseClickMove(mouseX, mouseY, clickedMouseButton); } @@ -630,25 +632,25 @@ public class GuiBook extends Screen @Override public void removed() { - if(minecraft.player == null) { + if(this.minecraft.player == null) { return; } - PageData page = this.page == 0 ? book.findPage(0, advancementCache) : book.findPage((this.page - 1) * 2 + 1, advancementCache); + PageData page = this.page == 0 ? this.book.findPage(0, this.advancementCache) : this.book.findPage((this.page - 1) * 2 + 1, this.advancementCache); if(page == null) { - page = book.findPage((this.page - 1) * 2 + 2, advancementCache); + page = this.book.findPage((this.page - 1) * 2 + 2, this.advancementCache); } if(this.page == -1) { - BookLoader.updateSavedPage(mc.player, item, ""); + BookLoader.updateSavedPage(this.minecraft.player, this.item, ""); } else if(page != null && page.parent != null) { - BookLoader.updateSavedPage(mc.player, item, page.parent.name + "." + page.name); + BookLoader.updateSavedPage(this.minecraft.player, this.item, page.parent.name + "." + page.name); } } @Override - public boolean doesGuiPauseGame() { + public boolean isPauseScreen() { return false; } @@ -657,20 +659,20 @@ public class GuiBook extends Screen private HashMap nameCache = new HashMap<>(); public AdvancementProgress getProgress(String id){ - return getProgress(getAdvancement(id)); + return this.getProgress(this.getAdvancement(id)); } public AdvancementProgress getProgress(Advancement advancement){ - return progress.get(advancement); + return this.progress.get(advancement); } public Advancement getAdvancement(String id){ - return nameCache.get(new ResourceLocation(id)); + return this.nameCache.get(new ResourceLocation(id)); } @Override public void onUpdateAdvancementProgress(Advancement advancement, AdvancementProgress advancementProgress) { - progress.put(advancement, advancementProgress); + this.progress.put(advancement, advancementProgress); } @Override @@ -680,30 +682,30 @@ public class GuiBook extends Screen @Override public void rootAdvancementAdded(Advancement advancement) { - nameCache.put(advancement.getId(), advancement); + this.nameCache.put(advancement.getId(), advancement); } @Override public void rootAdvancementRemoved(Advancement advancement) { - progress.remove(advancement); - nameCache.remove(advancement.getId()); + this.progress.remove(advancement); + this.nameCache.remove(advancement.getId()); } @Override public void nonRootAdvancementAdded(Advancement advancement) { - nameCache.put(advancement.getId(), advancement); + this.nameCache.put(advancement.getId(), advancement); } @Override public void nonRootAdvancementRemoved(Advancement advancement) { - progress.remove(advancement); - nameCache.remove(advancement.getId()); + this.progress.remove(advancement); + this.nameCache.remove(advancement.getId()); } @Override public void advancementsCleared() { - progress.clear(); - nameCache.clear(); + this.progress.clear(); + this.nameCache.clear(); } } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/GuiBookmark.java b/src/main/java/slimeknights/mantle/client/gui/book/GuiBookmark.java index e42dac2..d1dd532 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/GuiBookmark.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/GuiBookmark.java @@ -32,28 +32,28 @@ public class GuiBookmark extends Button @Override public void render(int mouseX, int mouseY, float partialTicks) { - if(visible) { + if(this.visible) { Minecraft minecraft = Minecraft.getInstance(); - int tex_y = TEX_Y + HEIGHT * type; + int tex_y = TEX_Y + HEIGHT * this.type; minecraft.textureManager.bindTexture(TEX_BOOK); - float r = ((data.color >> 16) & 0xff) / 255.F; - float g = ((data.color >> 8) & 0xff) / 255.F; - float b = (data.color & 0xff) / 255.F; + float r = ((this.data.color >> 16) & 0xff) / 255.F; + float g = ((this.data.color >> 8) & 0xff) / 255.F; + float b = (this.data.color & 0xff) / 255.F; GlStateManager.color3f(r, g, b); - AbstractGui.blit(x, y, TEX_X, tex_y, WIDTH, HEIGHT, width, height, 512, 512); + AbstractGui.blit(this.x, this.y, TEX_X, tex_y, WIDTH, HEIGHT, this.width, this.height, 512, 512); - if(data.text != null && !data.text.isEmpty()) { + if(this.data.text != null && !this.data.text.isEmpty()) { TextDataRenderer - .drawScaledString(minecraft.fontRenderer, data.text, x + 1, y + height / 2 - minecraft.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE); + .drawScaledString(minecraft.fontRenderer, this.data.text, this.x + 1, this.y + this.height / 2 - minecraft.fontRenderer.FONT_HEIGHT * TEXT_SCALE / 2 + 1, 0xFFFFFFFF, true, TEXT_SCALE); } GlStateManager.color3f(1F, 1F, 1F); - if(data.page.equals("ADD")) { - AbstractGui.blit(x + width / 2 - ADD_W / 2, y + height / 2 - ADD_H / 2, ADD_X, ADD_Y, ADD_W, ADD_H, 512, 512); + if(this.data.page.equals("ADD")) { + AbstractGui.blit(this.x + this.width / 2 - ADD_W / 2, this.y + this.height / 2 - ADD_H / 2, ADD_X, ADD_Y, ADD_W, ADD_H, 512, 512); } } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementAnimationToggle.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementAnimationToggle.java index fb06bc6..93701d1 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementAnimationToggle.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementAnimationToggle.java @@ -17,15 +17,15 @@ public class ElementAnimationToggle extends ElementArrow { @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { - if(callback != null && isHovered(mouseX, mouseY)) { - if(callback.onButtonClick(buttonId, this)) { - toggled = !toggled; - updateColor(); + if(this.callback != null && this.isHovered(mouseX, mouseY)) { + if(this.callback.onButtonClick(this.buttonId, this)) { + this.toggled = !this.toggled; + this.updateColor(); } } } protected void updateColor() { - button.color = toggled ? arrowColorActive : arrowColorInactive; + this.button.color = this.toggled ? this.arrowColorActive : this.arrowColorInactive; } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementArrow.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementArrow.java index 762580d..e594aa2 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementArrow.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementArrow.java @@ -11,12 +11,12 @@ public class ElementArrow extends ElementButton { public ElementArrow(int id, IButtonClickHandler handler, int x, int y, GuiArrow.ArrowType arrowType, int arrowColor, int arrowColorHover) { super(id, x, y, arrowType.w, arrowType.h, handler); - button = new GuiArrow(id, x, y, arrowType, arrowColor, arrowColorHover); + this.button = new GuiArrow(id, x, y, arrowType, arrowColor, arrowColorHover); } @Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - button.render(mouseX, mouseY, partialTicks); + this.button.render(mouseX, mouseY, partialTicks); } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementButton.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementButton.java index 088b607..6a07815 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementButton.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementButton.java @@ -14,8 +14,8 @@ public abstract class ElementButton extends SizedBookElement { @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { - if(callback != null && isHovered(mouseX, mouseY)) { - callback.onButtonClick(buttonId, this); + if(this.callback != null && this.isHovered(mouseX, mouseY)) { + this.callback.onButtonClick(this.buttonId, this); } } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementImage.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementImage.java index 26c664f..0645c6a 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementImage.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementImage.java @@ -56,21 +56,21 @@ public class ElementImage extends SizedBookElement { @Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - float r = ((colorMultiplier >> 16) & 0xff) / 255.F; - float g = ((colorMultiplier >> 8) & 0xff) / 255.F; - float b = (colorMultiplier & 0xff) / 255.F; + float r = ((this.colorMultiplier >> 16) & 0xff) / 255.F; + float g = ((this.colorMultiplier >> 8) & 0xff) / 255.F; + float b = (this.colorMultiplier & 0xff) / 255.F; GlStateManager.color3f(r, g, b); - if(image.item == null) { - renderEngine.bindTexture(image.location); + if(this.image.item == null) { + this.renderEngine.bindTexture(this.image.location); - blit(x, y, image.u, image.v, image.uw, image.vh, width, height, image.texWidth, image.texHeight); + blit(this.x, this.y, this.image.u, this.image.v, this.image.uw, this.image.vh, this.width, this.height, this.image.texWidth, this.image.texHeight); } else { GlStateManager.pushMatrix(); - GlStateManager.scalef(width, height, 1F); + GlStateManager.scalef(this.width, this.height, 1F); RenderHelper.enableGUIStandardItemLighting(); - mc.getItemRenderer().renderItemAndEffectIntoGUI(image.item.getItems().get(0), x, y); + this.mc.getItemRenderer().renderItemAndEffectIntoGUI(this.image.item.getItems().get(0), this.x, this.y); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); } 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 cdb0e8f..e97538a 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 @@ -57,7 +57,7 @@ public class ElementItem extends SizedBookElement { public ElementItem(int x, int y, float scale, ItemStack[] itemCycle, String action) { super(x, y, MathHelper.floor(ITEM_SIZE_HARDCODED * scale), MathHelper.floor(ITEM_SIZE_HARDCODED * scale)); - NonNullList nonNullStacks = NonNullList. withSize(itemCycle.length, ItemStack.EMPTY); + NonNullList nonNullStacks = NonNullList.withSize(itemCycle.length, ItemStack.EMPTY); for(int i = 0; i < itemCycle.length; i++) { if(!itemCycle[i].isEmpty()) { nonNullStacks.set(i, itemCycle[i].copy()); @@ -71,24 +71,24 @@ public class ElementItem extends SizedBookElement { @Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - renderTick++; + this.renderTick++; - if(renderTick > ITEM_SWITCH_TICKS) { - renderTick = 0; - currentItem++; + if(this.renderTick > ITEM_SWITCH_TICKS) { + this.renderTick = 0; + this.currentItem++; - if(currentItem >= itemCycle.size()) { - currentItem = 0; + if(this.currentItem >= this.itemCycle.size()) { + this.currentItem = 0; } } RenderHelper.enableGUIStandardItemLighting(); GlStateManager.pushMatrix(); - GlStateManager.translatef(x, y, 0); - GlStateManager.scalef(scale, scale, 1.0F); + GlStateManager.translatef(this.x, this.y, 0); + GlStateManager.scalef(this.scale, this.scale, 1.0F); - if(currentItem < itemCycle.size()) { - mc.getItemRenderer().renderItemAndEffectIntoGUI(itemCycle.get(currentItem), 0, 0); + if(this.currentItem < this.itemCycle.size()) { + this.mc.getItemRenderer().renderItemAndEffectIntoGUI(this.itemCycle.get(this.currentItem), 0, 0); } GlStateManager.popMatrix(); @@ -97,23 +97,23 @@ public class ElementItem extends SizedBookElement { @Override public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - if(isHovered(mouseX, mouseY) && currentItem < itemCycle.size()) { - if(tooltip != null) { - drawHoveringText(tooltip, mouseX, mouseY, fontRenderer); + if(this.isHovered(mouseX, mouseY) && this.currentItem < this.itemCycle.size()) { + if(this.tooltip != null) { + this.drawHoveringText(this.tooltip, mouseX, mouseY, fontRenderer); } else { - renderToolTip(fontRenderer, itemCycle.get(currentItem), mouseX, mouseY); + this.renderToolTip(fontRenderer, this.itemCycle.get(this.currentItem), mouseX, mouseY); } } } @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { - if(mouseButton == 0 && isHovered(mouseX, mouseY) && currentItem < itemCycle.size()) { - if(action != null) { - StringActionProcessor.process(action, parent); + if(mouseButton == 0 && this.isHovered(mouseX, mouseY) && this.currentItem < this.itemCycle.size()) { + if(this.action != null) { + StringActionProcessor.process(this.action, this.parent); } else { - parent.itemClicked(itemCycle.get(currentItem)); + this.parent.itemClicked(this.itemCycle.get(this.currentItem)); } } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java index 7ce6ef2..1c5096a 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementSection.java @@ -27,46 +27,46 @@ public class ElementSection extends SizedBookElement { @Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - boolean unlocked = section.isUnlocked(parent.advancementCache); - boolean hover = isHovered(mouseX, mouseY); + boolean unlocked = this.section.isUnlocked(this.parent.advancementCache); + boolean hover = this.isHovered(mouseX, mouseY); - if(section.icon != null) { - int iconX = x + WIDTH / 2 - IMG_SIZE / 2; - int iconY = y + HEIGHT / 2 - IMG_SIZE / 2; + if(this.section.icon != null) { + int iconX = this.x + WIDTH / 2 - IMG_SIZE / 2; + int iconY = this.y + HEIGHT / 2 - IMG_SIZE / 2; if(hover) { - fill(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, parent.book.appearance.hoverColor); + fill(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, this.parent.book.appearance.hoverColor); } if(unlocked) { GlStateManager.color4f(1F, 1F, 1F, hover ? 1F : 0.5F); } else { - float r = ((parent.book.appearance.lockedSectionColor >> 16) & 0xff) / 255.F; - float g = ((parent.book.appearance.lockedSectionColor >> 8) & 0xff) / 255.F; - float b = (parent.book.appearance.lockedSectionColor & 0xff) / 255.F; + float r = ((this.parent.book.appearance.lockedSectionColor >> 16) & 0xff) / 255.F; + float g = ((this.parent.book.appearance.lockedSectionColor >> 8) & 0xff) / 255.F; + float b = (this.parent.book.appearance.lockedSectionColor & 0xff) / 255.F; GlStateManager.color4f(r, g, b, 0.75F); } - if(section.icon.item == null) { - if(section.icon.location != null) { - renderEngine.bindTexture(section.icon.location); + if(this.section.icon.item == null) { + if(this.section.icon.location != null) { + this.renderEngine.bindTexture(this.section.icon.location); - blit(iconX, iconY, section.icon.u, section.icon.v, section.icon.uw, section.icon.vh, IMG_SIZE, IMG_SIZE, section.icon.texWidth, section.icon.texHeight); + blit(iconX, iconY, this.section.icon.u, this.section.icon.v, this.section.icon.uw, this.section.icon.vh, IMG_SIZE, IMG_SIZE, this.section.icon.texWidth, this.section.icon.texHeight); } } else { GlStateManager.pushMatrix(); GlStateManager.translatef(iconX, iconY, 0); GlStateManager.scalef(2F, 2F, 1F); RenderHelper.enableGUIStandardItemLighting(); - mc.getItemRenderer().renderItemAndEffectIntoGUI(section.icon.item.getItems().get(0), 0, 0); + this.mc.getItemRenderer().renderItemAndEffectIntoGUI(this.section.icon.item.getItems().get(0), 0, 0); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); } } - if(section.parent.appearance.drawSectionListText) { - int textW = fontRenderer.getStringWidth(section.getTitle()); - int textX = x + WIDTH / 2 - textW / 2; - int textY = y + HEIGHT - fontRenderer.FONT_HEIGHT/2; - fontRenderer.drawString(section.getTitle(), + if(this.section.parent.appearance.drawSectionListText) { + int textW = fontRenderer.getStringWidth(this.section.getTitle()); + int textX = this.x + WIDTH / 2 - textW / 2; + int textY = this.y + HEIGHT - fontRenderer.FONT_HEIGHT/2; + fontRenderer.drawString(this.section.getTitle(), textX, textY, hover ? 0xFF000000 : 0x7F000000); @@ -75,23 +75,23 @@ public class ElementSection extends SizedBookElement { @Override public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - if(section != null && isHovered(mouseX, mouseY)) { + if(this.section != null && this.isHovered(mouseX, mouseY)) { List text = new ArrayList<>(); - text.add(section.getTitle()); - if(!section.isUnlocked(parent.advancementCache)) { + text.add(this.section.getTitle()); + if(!this.section.isUnlocked(this.parent.advancementCache)) { text.add(TextFormatting.RED + "Locked"); text.add("Requirements:"); - text.addAll(section.requirements); + text.addAll(this.section.requirements); } - drawHoveringText(text, mouseX, mouseY, fontRenderer); + this.drawHoveringText(text, mouseX, mouseY, fontRenderer); } } @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { - if(mouseButton == 0 && section != null && section.isUnlocked(parent.advancementCache) && isHovered(mouseX, mouseY)) { - parent.openPage(parent.book.getFirstPageNumber(section, parent.advancementCache)); + if(mouseButton == 0 && this.section != null && this.section.isUnlocked(this.parent.advancementCache) && this.isHovered(mouseX, mouseY)) { + this.parent.openPage(this.parent.book.getFirstPageNumber(this.section, this.parent.advancementCache)); } } } 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 ff8b0c7..8cac5a1 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 @@ -39,20 +39,20 @@ 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 = 100f / (float)IntStream.of(size).max().getAsInt(); + this.scale = 100f / (float)IntStream.of(size).max().getAsInt(); float sx = (float)width / (float)GuiBook.PAGE_WIDTH; float sy = (float)height / (float)GuiBook.PAGE_HEIGHT; - scale *= Math.min(sx, sy); + this.scale *= Math.min(sx, sy); - xTranslate = x + width / 2;// - (size[0] * scale) / 2; - yTranslate = y + height / 2;// - (size[1] * scale) / 2; + this.xTranslate = x + width / 2;// - (size[0] * scale) / 2; + this.yTranslate = y + height / 2;// - (size[1] * scale) / 2; - w = size[0] * scale; - h = size[1] * scale; + this.w = size[0] * this.scale; + this.h = size[1] * this.scale; } - init(size, structure); + this.init(size, structure); } boolean canTick = false; @@ -68,12 +68,11 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa public void init(int[] size, BlockData[] data) { int yOff = 0; - structureData = new StructureInfo(size[0], size[1], size[2], data); - blockAccess = new StructureBlockAccess(structureData); + this.structureData = new StructureInfo(size[0], size[1], size[2], data); + this.blockAccess = new StructureBlockAccess(this.structureData); - - rotX = 25; - rotY = -45; + this.rotX = 25; + this.rotY = -45; /* boolean canRenderFormed = multiblock.canRenderFormedStructure(); // yOff = (structureHeight-1)*12+structureWidth*5+structureLength*5+16; @@ -147,38 +146,38 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa @Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - if(lastClick != null) { + if(this.lastClick != null) { if(Minecraft.getInstance().mouseHelper.isLeftDown() || Minecraft.getInstance().mouseHelper.isRightDown()) { - int dx = mouseX - lastClick[0]; - int dy = mouseY - lastClick[1]; + int dx = mouseX - this.lastClick[0]; + int dy = mouseY - this.lastClick[1]; float maxSpeed = 10f; float changeX = Math.min(maxSpeed, dx / 10f); float changeY = Math.min(maxSpeed, dy / 10f); - rotY += changeX; - rotX += changeY; + this.rotY += changeX; + this.rotX += changeY; } else { - lastClick = null; + this.lastClick = null; } } - if(canTick) { - if(++tick % 20 == 0) { - if(structureData.canStep() || ++fullStructureSteps >= 5) { - structureData.step(); - fullStructureSteps = 0; + if(this.canTick) { + if(++this.tick % 20 == 0) { + if(this.structureData.canStep() || ++this.fullStructureSteps >= 5) { + this.structureData.step(); + this.fullStructureSteps = 0; } } } else { - structureData.reset(); - structureData.setShowLayer(9); + this.structureData.reset(); + this.structureData.setShowLayer(9); } - int structureLength = structureData.structureLength; - int structureWidth = structureData.structureWidth; - int structureHeight = structureData.structureHeight; + int structureLength = this.structureData.structureLength; + int structureWidth = this.structureData.structureWidth; + int structureHeight = this.structureData.structureHeight; int xHalf = (structureWidth * 5 - structureLength * 5); int yOffPartial = (structureHeight - 1) * 16 + structureWidth * 8 + structureLength * 8; @@ -196,13 +195,13 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa final BlockRendererDispatcher blockRender = Minecraft.getInstance().getBlockRendererDispatcher(); float f = (float) Math.sqrt(structureHeight * structureHeight + structureWidth * structureWidth + structureLength * structureLength); - yOffTotal = 10 + Math.max(10 + (structureHeight > 1 ? 36 : 0), (int) (f * scale)); + yOffTotal = 10 + Math.max(10 + (structureHeight > 1 ? 36 : 0), (int) (f * this.scale)); //GlStateManager.translate(x + 60, y + 10 + f / 2 * scale, Math.max(structureHeight, Math.max(structureWidth, structureLength))); - GlStateManager.translatef(xTranslate, yTranslate, Math.max(structureHeight, Math.max(structureWidth, structureLength))); + GlStateManager.translatef(this.xTranslate, this.yTranslate, Math.max(structureHeight, Math.max(structureWidth, structureLength))); // todo: translate where it actually needs to be and to counter z-layer of the book - GlStateManager.scalef(scale, -scale, 1); - GlStateManager.rotatef(rotX, 1, 0, 0); - GlStateManager.rotatef(rotY, 0, 1, 0); + GlStateManager.scalef(this.scale, -this.scale, 1); + GlStateManager.rotatef(this.rotX, 1, 0, 0); + GlStateManager.rotatef(this.rotY, 0, 1, 0); GlStateManager.translatef((float)structureLength/-2f, (float)structureHeight/-2f, (float)structureWidth/-2f); @@ -220,18 +219,18 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa } int iterator = 0; - mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); - for(int h = 0; h < structureData.structureHeight; h++) { - for(int l = 0; l < structureData.structureLength; l++) { - for(int w = 0; w < structureData.structureWidth; w++) { + this.mc.getTextureManager().bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE); + for(int h = 0; h < this.structureData.structureHeight; h++) { + for(int l = 0; l < this.structureData.structureLength; l++) { + for(int w = 0; w < this.structureData.structureWidth; w++) { BlockPos pos = new BlockPos(l, h, w); - if(!blockAccess.isAirBlock(pos)) { - BlockState state = blockAccess.getBlockState(pos); + if(!this.blockAccess.isAirBlock(pos)) { + BlockState state = this.blockAccess.getBlockState(pos); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder buffer = tessellator.getBuffer(); buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); Random random = new Random(); - blockRender.renderBlock(state, pos, blockAccess, buffer, random, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); + blockRender.renderBlock(state, pos, this.blockAccess, buffer, random, net.minecraftforge.client.model.data.EmptyModelData.INSTANCE); tessellator.draw(); } } @@ -269,13 +268,13 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa //lastX = mouseX; //lastY = mouseY; - lastClick = new int[] {(int) mouseX, (int) mouseY}; + this.lastClick = new int[] {(int) mouseX, (int) mouseY}; } @Override public void mouseClickMove(double mouseX, double mouseY, int clickedMouseButton) { - int dx = (int) mouseX - lastX; - int dy = (int) mouseX - lastY; + int dx = (int) mouseX - this.lastX; + int dy = (int) mouseX - this.lastY; float maxSpeed = 1f; float changeX = Math.min(maxSpeed, dx/100f); @@ -294,7 +293,7 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa @Override public void mouseReleased(double mouseX, double mouseY, int clickedMouseButton) { super.mouseReleased(mouseX, mouseY, clickedMouseButton); - lastClick = null; + this.lastClick = null; } @Override @@ -302,8 +301,8 @@ public class ElementStructure extends SizedBookElement implements IButtonClickHa //if((clickX >= 40 && clickX < 144 && mx >= 20 && mx < 164) && (clickY >= 30 && clickY < 130 && my >= 30 && my < 180)) { int dx = mx - lastX; int dy = my - lastY; - rotY = rotY + (dx / 104f);// * 80; - rotX = rotX + (dy / 100f);// * 80; + this.rotY = this.rotY + (dx / 104f);// * 80; + this.rotX = this.rotX + (dy / 100f);// * 80; //} } /* diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementText.java b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementText.java index aad1218..6608e4f 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/ElementText.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/ElementText.java @@ -35,26 +35,26 @@ public class ElementText extends SizedBookElement { @Override public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - String action = TextDataRenderer.drawText(x, y, width, height, text, mouseX, mouseY, fontRenderer, tooltip); + String action = TextDataRenderer.drawText(this.x, this.y, this.width, this.height, this.text, mouseX, mouseY, fontRenderer, this.tooltip); - if(doAction) { - doAction = false; - StringActionProcessor.process(action, parent); + if(this.doAction) { + this.doAction = false; + StringActionProcessor.process(action, this.parent); } } @Override public void drawOverlay(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) { - if(tooltip.size() > 0){ - TextDataRenderer.drawTooltip(tooltip, mouseX, mouseY, fontRenderer); - tooltip.clear(); + if(this.tooltip.size() > 0){ + TextDataRenderer.drawTooltip(this.tooltip, mouseX, mouseY, fontRenderer); + this.tooltip.clear(); } } @Override public void mouseClicked(double mouseX, double mouseY, int mouseButton) { if(mouseButton == 0) { - doAction = true; + this.doAction = true; } } } diff --git a/src/main/java/slimeknights/mantle/client/gui/book/element/SizedBookElement.java b/src/main/java/slimeknights/mantle/client/gui/book/element/SizedBookElement.java index af270d8..b676a20 100644 --- a/src/main/java/slimeknights/mantle/client/gui/book/element/SizedBookElement.java +++ b/src/main/java/slimeknights/mantle/client/gui/book/element/SizedBookElement.java @@ -16,6 +16,6 @@ public abstract class SizedBookElement extends BookElement { } public boolean isHovered(double mouseX, double mouseY) { - return mouseX > x && mouseY > y && mouseX < x + width && mouseY < y + height; + return mouseX > this.x && mouseY > this.y && mouseX < this.x + this.width && mouseY < this.y + this.height; } } diff --git a/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java b/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java index 89e6ea9..ccda346 100644 --- a/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java +++ b/src/main/java/slimeknights/mantle/client/model/BakedCompositeModel.java @@ -32,7 +32,7 @@ public class BakedCompositeModel extends BakedWrapper { @Nonnull @Override public List getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { - return parts.get(Optional.fromNullable(side)); + return this.parts.get(Optional.fromNullable(side)); } public static class Builder { @@ -40,16 +40,16 @@ public class BakedCompositeModel extends BakedWrapper { IBakedModel parent; public Builder() { - builders = new ImmutableList.Builder[7]; + this.builders = new ImmutableList.Builder[7]; for(int i = 0; i < 7; i++) { - builders[i] = ImmutableList.builder(); + this.builders[i] = ImmutableList.builder(); } } public void add(IBakedModel model, BlockState state, Random rand) { - add(model, state, null, rand); + this.add(model, state, null, rand); for(Direction side : Direction.values()) { - add(model, state, side, rand); + this.add(model, state, side, rand); } } @@ -62,15 +62,15 @@ public class BakedCompositeModel extends BakedWrapper { index = side.getIndex(); } - builders[index].addAll(model.getQuads(state, side, rand)); + this.builders[index].addAll(model.getQuads(state, side, rand)); } public BakedCompositeModel build(IBakedModel parent) { ImmutableMap.Builder, ImmutableList> map = ImmutableMap.builder(); - map.put(Optional.absent(), builders[6].build()); + map.put(Optional.absent(), this.builders[6].build()); for(Direction side : Direction.values()) { - map.put(Optional.of(side), builders[side.getIndex()].build()); + map.put(Optional.of(side), this.builders[side.getIndex()].build()); } return new BakedCompositeModel(parent, map.build()); diff --git a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java index 02a3b0b..1705c6b 100644 --- a/src/main/java/slimeknights/mantle/inventory/BaseContainer.java +++ b/src/main/java/slimeknights/mantle/inventory/BaseContainer.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.block.Blocks; import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -42,50 +43,51 @@ public abstract class BaseContainer extends Container { public List subContainers = Lists.newArrayList(); - public BaseContainer(T tile) { - this(tile, null); + public BaseContainer(ContainerType containerType, int windowId, T tile) { + this(containerType, windowId, tile, null); } - public BaseContainer(T tile, Direction invDir) { + public BaseContainer(ContainerType containerType, int windowId, T tile, Direction invDir) { + super(containerType, windowId); this.tile = tile; if(tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, invDir).isPresent()) { - itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, invDir); + this.itemHandler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, invDir); } else { - itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new EmptyHandler()); + this.itemHandler = net.minecraftforge.common.util.LazyOptional.of(() -> new EmptyHandler()); } this.world = tile.getWorld(); this.pos = tile.getPos(); - this.originalBlock = world.getBlockState(pos).getBlock(); + this.originalBlock = this.world.getBlockState(this.pos).getBlock(); } public void syncOnOpen(ServerPlayerEntity playerOpened) { // find another player that already has the gui for this tile open ServerWorld server = playerOpened.getServerWorld(); - for(PlayerEntity player : server.playerEntities) { + for(PlayerEntity player : server.getPlayers()) { if(player == playerOpened) { continue; } if(player.openContainer instanceof BaseContainer) { if(this.sameGui((BaseContainer) player.openContainer)) { - syncWithOtherContainer((BaseContainer) player.openContainer, playerOpened); + this.syncWithOtherContainer((BaseContainer) player.openContainer, playerOpened); return; } } } // no player has a container open for the tile - syncNewContainer(playerOpened); + this.syncNewContainer(playerOpened); } public T getTile() { - return tile; + return this.tile; } public IItemHandler getItemHandler() { - return itemHandler.orElse(new EmptyHandler()); + return this.itemHandler.orElse(new EmptyHandler()); } /** @@ -108,16 +110,16 @@ public abstract class BaseContainer extends Container { @Override public boolean canInteractWith(@Nonnull PlayerEntity playerIn) { - Block block = world.getBlockState(pos).getBlock(); + Block block = this.world.getBlockState(this.pos).getBlock(); // does the block we interacted with still exist? - if(block == Blocks.AIR || block != originalBlock) { + if(block == Blocks.AIR || block != this.originalBlock) { return false; } // too far away from block? - return playerIn.getDistanceSq((double) pos.getX() + 0.5d, - (double) pos.getY() + 0.5d, - (double) pos.getZ() + 0.5d) <= maxDist; + return playerIn.getDistanceSq((double) this.pos.getX() + 0.5d, + (double) this.pos.getY() + 0.5d, + (double) this.pos.getZ() + 0.5d) <= this.maxDist; } @Nonnull @@ -127,24 +129,24 @@ public abstract class BaseContainer extends Container { return super.getInventory(); } - public String getInventoryDisplayName() { + /*public String getInventoryDisplayName() { INameable nameable = null; - if (itemHandler.orElse(new EmptyHandler()) instanceof InvWrapper) { - nameable = ((InvWrapper) itemHandler.orElse(new EmptyHandler())).getInv(); + if (this.itemHandler.orElse(new EmptyHandler()) instanceof InvWrapper) { + nameable = ((InvWrapper) this.itemHandler.orElse(new EmptyHandler())).getInv(); // if the inventory doesn't have a name fall back to checking the tileentity if (nameable.getDisplayName() == null) { nameable = null; } } - if(nameable == null && tile instanceof INameable) { - nameable = (INameable) tile; + if(nameable == null && this.tile instanceof INameable) { + nameable = (INameable) this.tile; } if (nameable != null) { ITextComponent textName = nameable.getDisplayName(); return textName != null ? textName.getFormattedText() : nameable.getName().toString(); } return null; - } + }*/ // standard yOffset calculation for chestlike inventories: // yOffset = (numRows - 4) * 18; (the -4 because of the 3 rows of inventory + 1 row of hotbar) @@ -176,13 +178,13 @@ public abstract class BaseContainer extends Container { index++; } - playerInventoryStart = start; + this.playerInventoryStart = start; } @Nonnull @Override protected Slot addSlot(Slot slotIn) { - if(playerInventoryStart >= 0) { + if(this.playerInventoryStart >= 0) { throw new SlimeknightException("BaseContainer: Player inventory has to be last slots. Add all slots before adding the player inventory."); } return super.addSlot(slotIn); @@ -192,7 +194,7 @@ public abstract class BaseContainer extends Container { @Override public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { // we can only support inventory <-> playerInventory - if(playerInventoryStart < 0) { + if(this.playerInventoryStart < 0) { // so we don't do anything if no player inventory is present because we don't know what to do return ItemStack.EMPTY; } @@ -207,14 +209,14 @@ public abstract class BaseContainer extends Container { int end = this.inventorySlots.size(); // Is it a slot in the main inventory? (aka not player inventory) - if(index < playerInventoryStart) { + if(index < this.playerInventoryStart) { // try to put it into the player inventory (if we have a player inventory) - if(!this.mergeItemStack(itemstack1, playerInventoryStart, end, true)) { + if(!this.mergeItemStack(itemstack1, this.playerInventoryStart, end, true)) { return ItemStack.EMPTY; } } // Slot is in the player inventory (if it exists), transfer to main inventory - else if(!this.mergeItemStack(itemstack1, 0, playerInventoryStart, false)) { + else if(!this.mergeItemStack(itemstack1, 0, this.playerInventoryStart, false)) { return ItemStack.EMPTY; } @@ -232,9 +234,9 @@ public abstract class BaseContainer extends Container { // Fix for a vanilla bug: doesn't take Slot.getMaxStackSize into account @Override protected boolean mergeItemStack(@Nonnull ItemStack stack, int startIndex, int endIndex, boolean useEndIndex) { - boolean ret = mergeItemStackRefill(stack, startIndex, endIndex, useEndIndex); + boolean ret = this.mergeItemStackRefill(stack, startIndex, endIndex, useEndIndex); if(!stack.isEmpty() && stack.getCount() > 0) { - ret |= mergeItemStackMove(stack, startIndex, endIndex, useEndIndex); + ret |= this.mergeItemStackMove(stack, startIndex, endIndex, useEndIndex); } return ret; } diff --git a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java index a4cbf53..cf0dcd8 100644 --- a/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java +++ b/src/main/java/slimeknights/mantle/inventory/ContainerMultiModule.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.container.ClickType; import net.minecraft.inventory.container.Container; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -33,8 +34,8 @@ public class ContainerMultiModule extends Bas protected int subContainerSlotStart = -1; protected Set shiftClickContainers = Sets.newHashSet(); - public ContainerMultiModule(T tile) { - super(tile); + public ContainerMultiModule(ContainerType containerType, int windowId, T tile) { + super(containerType, windowId, tile); } @@ -43,31 +44,31 @@ public class ContainerMultiModule extends Bas * @param preferForShiftClick If true shift clicking on slots of the main-container will try to move to this module before the player inventory */ public void addSubContainer(Container subcontainer, boolean preferForShiftClick) { - if(subContainers.isEmpty()) { - subContainerSlotStart = inventorySlots.size(); + if(this.subContainers.isEmpty()) { + this.subContainerSlotStart = this.inventorySlots.size(); } - subContainers.add(subcontainer); + this.subContainers.add(subcontainer); if(preferForShiftClick) { - shiftClickContainers.add(subcontainer); + this.shiftClickContainers.add(subcontainer); } - int begin = inventorySlots.size(); + int begin = this.inventorySlots.size(); for(Object slot : subcontainer.inventorySlots) { SlotWrapper wrapper = new SlotWrapper((Slot) slot); - addSlot(wrapper); - slotContainerMap.put(wrapper.slotNumber, subcontainer); + this.addSlot(wrapper); + this.slotContainerMap.put(wrapper.slotNumber, subcontainer); } - int end = inventorySlots.size(); - subContainerSlotRanges.put(subcontainer, Pair.of(begin, end)); + int end = this.inventorySlots.size(); + this.subContainerSlotRanges.put(subcontainer, Pair.of(begin, end)); } public TC getSubContainer(Class clazz) { - return getSubContainer(clazz, 0); + return this.getSubContainer(clazz, 0); } public TC getSubContainer(Class clazz, int index) { - for(Container sub : subContainers) { + for(Container sub : this.subContainers) { if(clazz.isAssignableFrom(sub.getClass())) { index--; } @@ -80,8 +81,8 @@ public class ContainerMultiModule extends Bas } public Container getSlotContainer(int slotNumber) { - if(slotContainerMap.containsKey(slotNumber)) { - return slotContainerMap.get(slotNumber); + if(this.slotContainerMap.containsKey(slotNumber)) { + return this.slotContainerMap.get(slotNumber); } return this; @@ -90,7 +91,7 @@ public class ContainerMultiModule extends Bas @Override public boolean canInteractWith(@Nonnull PlayerEntity playerIn) { // check if subcontainers are valid - for(Container sub : subContainers) { + for(Container sub : this.subContainers) { if(!sub.canInteractWith(playerIn)) { return false; } @@ -102,7 +103,7 @@ public class ContainerMultiModule extends Bas @Override public void onContainerClosed(PlayerEntity playerIn) { - for(Container sub : subContainers) { + for(Container sub : this.subContainers) { sub.onContainerClosed(playerIn); } @@ -113,7 +114,7 @@ public class ContainerMultiModule extends Bas @Override public ItemStack slotClick(int slotId, int dragType, ClickType type, PlayerEntity player) { if(slotId == -999 && type == ClickType.QUICK_CRAFT) { - for(Container container : subContainers) { + for(Container container : this.subContainers) { container.slotClick(slotId, dragType, type, player); } } @@ -135,35 +136,35 @@ public class ContainerMultiModule extends Bas ItemStack ret = slot.getStack().copy(); ItemStack itemstack = slot.getStack().copy(); - Container container = getSlotContainer(index); + Container container = this.getSlotContainer(index); boolean nothingDone = true; // Is the slot from a module? if(container != this) { // Try moving module -> tile inventory - nothingDone &= moveToTileInventory(itemstack); + nothingDone &= this.moveToTileInventory(itemstack); // Try moving module -> player inventory - nothingDone &= moveToPlayerInventory(itemstack); + nothingDone &= this.moveToPlayerInventory(itemstack); } // Is the slot from the tile? - else if(index < subContainerSlotStart || (index < playerInventoryStart && subContainerSlotStart < 0)) { + else if(index < this.subContainerSlotStart || (index < this.playerInventoryStart && this.subContainerSlotStart < 0)) { // Try moving tile -> preferred modules - nothingDone &= refillAnyContainer(itemstack, subContainers); + nothingDone &= this.refillAnyContainer(itemstack, this.subContainers); // Try moving module -> player inventory - nothingDone &= moveToPlayerInventory(itemstack); + nothingDone &= this.moveToPlayerInventory(itemstack); // Try moving module -> all submodules - nothingDone &= moveToAnyContainer(itemstack, subContainers); + nothingDone &= this.moveToAnyContainer(itemstack, this.subContainers); } // Slot is from the player inventory (if present) - else if(index >= playerInventoryStart && playerInventoryStart >= 0) { + else if(index >= this.playerInventoryStart && this.playerInventoryStart >= 0) { // Try moving player -> tile inventory - nothingDone &= moveToTileInventory(itemstack); + nothingDone &= this.moveToTileInventory(itemstack); // try moving player -> modules - nothingDone &= moveToAnyContainer(itemstack, subContainers); + nothingDone &= this.moveToAnyContainer(itemstack, this.subContainers); } // you violated some assumption or something. Shame on you. else { @@ -174,7 +175,7 @@ public class ContainerMultiModule extends Bas return ItemStack.EMPTY; } - return notifySlotAfterTransfer(playerIn, itemstack, ret, slot); + return this.notifySlotAfterTransfer(playerIn, itemstack, ret, slot); } @Nonnull @@ -202,9 +203,9 @@ public class ContainerMultiModule extends Bas return false; } - int end = subContainerSlotStart; + int end = this.subContainerSlotStart; if(end < 0) { - end = playerInventoryStart; + end = this.playerInventoryStart; } return !this.mergeItemStack(itemstack, 0, end, false); } @@ -214,8 +215,8 @@ public class ContainerMultiModule extends Bas return false; } - return playerInventoryStart > 0 && !this - .mergeItemStack(itemstack, playerInventoryStart, this.inventorySlots.size(), true); + return this.playerInventoryStart > 0 && !this + .mergeItemStack(itemstack, this.playerInventoryStart, this.inventorySlots.size(), true); } protected boolean moveToAnyContainer(@Nonnull ItemStack itemstack, Collection containers) { @@ -224,7 +225,7 @@ public class ContainerMultiModule extends Bas } for(Container submodule : containers) { - if(moveToContainer(itemstack, submodule)) { + if(this.moveToContainer(itemstack, submodule)) { return true; } } @@ -233,7 +234,7 @@ public class ContainerMultiModule extends Bas } protected boolean moveToContainer(@Nonnull ItemStack itemstack, Container container) { - Pair range = subContainerSlotRanges.get(container); + Pair range = this.subContainerSlotRanges.get(container); return !this.mergeItemStack(itemstack, range.getLeft(), range.getRight(), false); } @@ -244,7 +245,7 @@ public class ContainerMultiModule extends Bas } for(Container submodule : containers) { - if(refillContainer(itemstack, submodule)) { + if(this.refillContainer(itemstack, submodule)) { return true; } } @@ -253,16 +254,16 @@ public class ContainerMultiModule extends Bas } protected boolean refillContainer(@Nonnull ItemStack itemstack, Container container) { - Pair range = subContainerSlotRanges.get(container); + Pair range = this.subContainerSlotRanges.get(container); return !this.mergeItemStackRefill(itemstack, range.getLeft(), range.getRight(), false); } /** Searches for a sidechest to display in the UI */ public TE detectTE(Class clazz) { - return ObjectUtils.firstNonNull(detectChest(this.pos.north(), clazz), - detectChest(this.pos.east(), clazz), - detectChest(this.pos.south(), clazz), - detectChest(this.pos.west(), clazz)); + return ObjectUtils.firstNonNull(this.detectChest(this.pos.north(), clazz), + this.detectChest(this.pos.east(), clazz), + this.detectChest(this.pos.south(), clazz), + this.detectChest(this.pos.west(), clazz)); } private TE detectChest(BlockPos pos, Class clazz) { diff --git a/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java b/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java index 08e4a1c..bd51cf3 100644 --- a/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java +++ b/src/main/java/slimeknights/mantle/inventory/ContainerSimpleChest.java @@ -2,14 +2,15 @@ package slimeknights.mantle.inventory; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.container.ContainerType; import net.minecraft.inventory.container.Slot; import slimeknights.mantle.tileentity.TileInventory; public class ContainerSimpleChest extends BaseContainer { - public ContainerSimpleChest(TileInventory tile, int rows, int columns, PlayerInventory playerInventory) { - super(tile); + public ContainerSimpleChest(ContainerType containerType, int windowId, TileInventory tile, int rows, int columns, PlayerInventory playerInventory) { + super(containerType, windowId, tile); int index = 0; @@ -21,13 +22,13 @@ public class ContainerSimpleChest extends BaseContainer { break; } - this.addSlot(createSlot(tile, index, 8 + j * 18, 18 + i * 18)); + this.addSlot(this.createSlot(tile, index, 8 + j * 18, 18 + i * 18)); index++; } } // player inventory - addPlayerInventory(playerInventory, 17, 86); + this.addPlayerInventory(playerInventory, 17, 86); } protected Slot createSlot(IInventory inventory, int index, int x, int y) { diff --git a/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java b/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java index 937aaeb..0b82c68 100644 --- a/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java +++ b/src/main/java/slimeknights/mantle/inventory/SlotCraftingCustom.java @@ -30,10 +30,10 @@ public class SlotCraftingCustom extends CraftingResultSlot @Override @Nonnull public ItemStack onTake(PlayerEntity playerIn, @Nonnull ItemStack stack) { - net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, craftMatrix); + net.minecraftforge.fml.hooks.BasicEventHooks.firePlayerCraftingEvent(playerIn, stack, this.craftMatrix); this.onCrafting(stack); - callback.onCrafting(playerIn, stack, craftMatrix); + this.callback.onCrafting(playerIn, stack, this.craftMatrix); return stack; } diff --git a/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java b/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java index d71963e..a032035 100644 --- a/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java +++ b/src/main/java/slimeknights/mantle/inventory/SlotRestrictedItem.java @@ -13,11 +13,11 @@ public class SlotRestrictedItem extends Slot { public SlotRestrictedItem(Item item, IInventory inventoryIn, int index, int xPosition, int yPosition) { super(inventoryIn, index, xPosition, yPosition); - allowedItem = item; + this.allowedItem = item; } @Override public boolean isItemValid(@Nonnull ItemStack stack) { - return !stack.isEmpty() && stack.getItem() == allowedItem; + return !stack.isEmpty() && stack.getItem() == this.allowedItem; } } diff --git a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java index b0a3e4f..c2b767b 100644 --- a/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java +++ b/src/main/java/slimeknights/mantle/inventory/SlotWrapper.java @@ -25,33 +25,33 @@ public class SlotWrapper extends Slot { @Override public void onSlotChange(ItemStack p_75220_1_, ItemStack p_75220_2_) { - parent.onSlotChange(p_75220_1_, p_75220_2_); + this.parent.onSlotChange(p_75220_1_, p_75220_2_); } @Override public void onSlotChanged() { - parent.onSlotChanged(); + this.parent.onSlotChanged(); } @Override public boolean isItemValid(ItemStack stack) { - return parent.isItemValid(stack); + return this.parent.isItemValid(stack); } @Override public boolean canTakeStack(PlayerEntity playerIn) { - return parent.canTakeStack(playerIn); + return this.parent.canTakeStack(playerIn); } @Override public void putStack(@Nonnull ItemStack stack) { - parent.putStack(stack); + this.parent.putStack(stack); } @Override @Nonnull public ItemStack onTake(PlayerEntity playerIn, ItemStack stack) { - parent.onTake(playerIn, stack); + this.parent.onTake(playerIn, stack); return stack; } @@ -59,66 +59,61 @@ public class SlotWrapper extends Slot { @Override @Nonnull public ItemStack getStack() { - return parent.getStack(); + return this.parent.getStack(); } @Override public boolean getHasStack() { - return parent.getHasStack(); + return this.parent.getHasStack(); } @Override public int getSlotStackLimit() { - return parent.getSlotStackLimit(); + return this.parent.getSlotStackLimit(); } @Override public int getItemStackLimit(ItemStack stack) { - return parent.getItemStackLimit(stack); + return this.parent.getItemStackLimit(stack); } @Override @OnlyIn(Dist.CLIENT) public String getSlotTexture() { - return parent.getSlotTexture(); + return this.parent.getSlotTexture(); } @Nonnull @Override public ItemStack decrStackSize(int amount) { - return parent.decrStackSize(amount); - } - - @Override - public boolean isHere(IInventory inv, int slotIn) { - return parent.isHere(inv, slotIn); + return this.parent.decrStackSize(amount); } @Nonnull @Override public ResourceLocation getBackgroundLocation() { - return parent.getBackgroundLocation(); + return this.parent.getBackgroundLocation(); } @Override public void setBackgroundName(@Nonnull String name) { - parent.setBackgroundName(name); + this.parent.setBackgroundName(name); } @Nonnull @Override public TextureAtlasSprite getBackgroundSprite() { - return parent.getBackgroundSprite(); + return this.parent.getBackgroundSprite(); } @Override public void setBackgroundLocation(@Nonnull ResourceLocation texture) { - parent.setBackgroundLocation(texture); + this.parent.setBackgroundLocation(texture); } @OnlyIn(Dist.CLIENT) @Override public boolean isEnabled() { - return parent.isEnabled(); + return this.parent.isEnabled(); } } diff --git a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java index ff0b46d..cde5cd7 100644 --- a/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java +++ b/src/main/java/slimeknights/mantle/multiblock/MultiServantLogic.java @@ -154,7 +154,7 @@ public class MultiServantLogic extends MantleTileEntity implements IServantLogic @Override public void onDataPacket(NetworkManager net, SUpdateTileEntityPacket packet) { this.readCustomNBT(packet.getNbtCompound()); - this.world.notifyLightSet(this.pos); + //this.world.notifyLightSet(this.pos); BlockState state = world.getBlockState(this.pos); this.world.notifyBlockUpdate(this.pos, state, state, 3); } diff --git a/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java b/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java index 0f8f739..547729f 100644 --- a/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java +++ b/src/main/java/slimeknights/mantle/pulsar/config/PulsarConfig.java @@ -21,7 +21,7 @@ public class PulsarConfig implements IConfiguration private static final Logger LOGGER = LogManager.getLogger(); private final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder(); - private ForgeConfigSpec SPEC = BUILDER.build(); + private ForgeConfigSpec SPEC = this.BUILDER.build(); private final CommentedFileConfig config; @@ -40,11 +40,11 @@ public class PulsarConfig implements IConfiguration * @param description The description for the group that the config entries will be placed in. */ public PulsarConfig(String confName, String description) { - this.config = createConfig(FMLPaths.CONFIGDIR.get(), confName); + this.config = this.createConfig(FMLPaths.CONFIGDIR.get(), confName); this.description = description.toLowerCase(Locale.US); this.builderPushed = false; this.configBuilt = false; - BUILDER.push(this.description); + this.BUILDER.push(this.description); } @Override @@ -53,20 +53,20 @@ public class PulsarConfig implements IConfiguration @Override public void postLoad() { if(!this.configBuilt) { - BUILDER.pop(); - SPEC = BUILDER.build(); - SPEC.setConfig(config); + this.BUILDER.pop(); + this.SPEC = this.BUILDER.build(); + this.SPEC.setConfig(this.config); } - configBuilt = true; + this.configBuilt = true; } @Override public boolean isModuleEnabled(@Nonnull PulseMeta meta) { - ForgeConfigSpec.BooleanValue entry = modules.get(meta.getId()); + ForgeConfigSpec.BooleanValue entry = this.modules.get(meta.getId()); if (entry == null) { - modules.put(meta.getId(), BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled())); + this.modules.put(meta.getId(), this.BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled())); return meta.isEnabled(); } else { return entry.get(); @@ -75,9 +75,9 @@ public class PulsarConfig implements IConfiguration @Override public void addPulse(@Nonnull PulseMeta meta) { - ForgeConfigSpec.BooleanValue entry = modules.get(meta.getId()); + ForgeConfigSpec.BooleanValue entry = this.modules.get(meta.getId()); if (entry == null) { - modules.put(meta.getId(), BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled())); + this.modules.put(meta.getId(), this.BUILDER.comment(meta.getDescription()).worldRestart().define(meta.getId(), meta.isDefaultEnabled())); } } @@ -95,7 +95,7 @@ public class PulsarConfig implements IConfiguration @Override public void flush() { - ((CommentedFileConfig)this.config).save(); + this.config.save(); } public CommentedFileConfig createConfig(Path configBasePath, String configName) { diff --git a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java index b3beaea..28f21a4 100644 --- a/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java +++ b/src/main/java/slimeknights/mantle/pulsar/control/PulseManager.java @@ -74,9 +74,9 @@ public class PulseManager { * @param configName The config file name. */ public PulseManager(String configName) { - init(); - useConfig = true; - conf = new Configuration(configName, log); + this.init(); + this.useConfig = true; + this.conf = new Configuration(configName, this.log); } /** @@ -88,9 +88,9 @@ public class PulseManager { * @param config Configuration handler. */ public PulseManager(IConfiguration config) { - init(); - useConfig = true; - conf = config; + this.init(); + this.useConfig = true; + this.conf = config; } /** @@ -99,13 +99,13 @@ public class PulseManager { private void init() { String modId = ModLoadingContext.get().getActiveContainer().getNamespace(); this.id = modId; - log = LogManager.getLogger("Pulsar-" + modId); - flightpath.setExceptionHandler(new BusExceptionHandler(modId)); + this.log = LogManager.getLogger("Pulsar-" + modId); + this.flightpath.setExceptionHandler(new BusExceptionHandler(modId)); CrashReportExtender.registerCrashCallable(new CrashHandler(modId, this)); // regsister our pulse loader so it can be found by the static method - ALL_PULSES.put(modId, pulses); + ALL_PULSES.put(modId, this.pulses); // Attach us to the mods FML bus - attachToContainerEventBus(this); + this.attachToContainerEventBus(this); } /** @@ -114,7 +114,7 @@ public class PulseManager { * @param handler The Flightpath-compatible exception handler to use. */ public void setPulseExceptionHandler(IExceptionHandler handler) { - flightpath.setExceptionHandler(handler); + this.flightpath.setExceptionHandler(handler); } /** @@ -125,12 +125,12 @@ public class PulseManager { * @param pulse The Pulse to register. */ public void registerPulse(Object pulse) { - if (blockNewRegistrations) throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " + if (this.blockNewRegistrations) throw new RuntimeException("A mod tried to register a plugin after preinit! Pulse: " + pulse); - if (!configLoaded) { - conf.load(); + if (!this.configLoaded) { + this.conf.load(); - configLoaded = true; + this.configLoaded = true; } String id, description, deps, pulseDeps; @@ -156,7 +156,7 @@ public class PulseManager { String[] parsedDeps = deps.split(";"); for (String s : parsedDeps) { if (!ModList.get().isLoaded(s)) { - log.info("Skipping Pulse " + id + "; missing dependency: " + s); + this.log.info("Skipping Pulse " + id + "; missing dependency: " + s); missingDeps = true; enabled = false; break; @@ -165,10 +165,10 @@ public class PulseManager { } PulseMeta meta = new PulseMeta(id, description, forced, enabled, defaultEnabled); - meta.setMissingDeps(missingDeps || !hasRequiredPulses(meta, pulseDeps)); + meta.setMissingDeps(missingDeps || !this.hasRequiredPulses(meta, pulseDeps)); - conf.addPulse(meta); - allPulses.put(pulse, meta); + this.conf.addPulse(meta); + this.allPulses.put(pulse, meta); } /** @@ -178,7 +178,7 @@ public class PulseManager { */ private void attachToContainerEventBus(Object obj) { ModContainer cnt = ModLoadingContext.get().getActiveContainer(); - log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); + this.log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]"); try { FMLModContainer mc = (FMLModContainer)cnt; Field ebf = mc.getClass().getDeclaredField("eventBus"); @@ -207,29 +207,31 @@ public class PulseManager { */ @SubscribeEvent public void propagateEvent(Event evt) { - if (evt instanceof FMLCommonSetupEvent) preInit((FMLCommonSetupEvent) evt); + if (evt instanceof FMLCommonSetupEvent) + this.preInit((FMLCommonSetupEvent) evt); // We use individual buses due to the EventBus class using a Set rather than a List, thus losing the ordering. // This trick is shamelessly borrowed from FML. - flightpath.post(evt); + this.flightpath.post(evt); } private boolean getEnabledFromConfig(PulseMeta meta) { - if (meta.isForced() || !useConfig) return true; // Forced or no config set. + if (meta.isForced() || !this.useConfig) return true; // Forced or no config set. - return conf.isModuleEnabled(meta); + return this.conf.isModuleEnabled(meta); } private void preInit(FMLCommonSetupEvent evt) { - if (!blockNewRegistrations) conf.flush(); // First init call, so flush config - blockNewRegistrations = true; + if (!this.blockNewRegistrations) + this.conf.flush(); // First init call, so flush config + this.blockNewRegistrations = true; } private boolean hasRequiredPulses(PulseMeta meta, String deps) { if (!deps.equals("")) { String[] parsedDeps = deps.split(";"); for (String s : parsedDeps) { - if (!isPulseLoaded(s)) { - log.info("Skipping Pulse " + meta.getId() + "; missing pulse: " + s); + if (!this.isPulseLoaded(s)) { + this.log.info("Skipping Pulse " + meta.getId() + "; missing pulse: " + s); return false; } } @@ -248,7 +250,7 @@ public class PulseManager { if(pulseId.contains(":")) { return isPulseLoadedGlobal(pulseId); } - return isPulseLoaded(pulses, pulseId); + return isPulseLoaded(this.pulses, pulseId); } /** @@ -282,12 +284,12 @@ public class PulseManager { } public Collection getAllPulseMetadata() { - return pulses.values(); + return this.pulses.values(); } @Override public String toString() { - return "PulseManager[" + id + "]"; + return "PulseManager[" + this.id + "]"; } /** * Enable or Disable all Pulses registered @@ -295,19 +297,20 @@ public class PulseManager { * This MUST be called after you register all your pulses using registerPulse and must be called BEFORE preinit */ public void enablePulses() { - if(blockNewRegistrations) throw new RuntimeException("A mod tried to enable their plugins after preinit!"); + if(this.blockNewRegistrations) throw new RuntimeException("A mod tried to enable their plugins after preinit!"); - if(configLoaded) conf.postLoad(); + if(this.configLoaded) + this.conf.postLoad(); - for (Map.Entry entry : allPulses.entrySet()) { + for (Map.Entry entry : this.allPulses.entrySet()) { PulseMeta meta = entry.getValue(); Object pulse = entry.getKey(); - meta.setEnabled(getEnabledFromConfig(meta)); + meta.setEnabled(this.getEnabledFromConfig(meta)); if (meta.isEnabled()) { - pulses.put(pulse, meta); - flightpath.register(pulse); + this.pulses.put(pulse, meta); + this.flightpath.register(pulse); } } } diff --git a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java index 58055dc..59f31e3 100644 --- a/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java +++ b/src/main/java/slimeknights/mantle/pulsar/debug/EventSpy.java @@ -23,12 +23,12 @@ public class EventSpy { @SubscribeEvent public void receive(Event evt) { - log.info("Received event: " + evt); + this.log.info("Received event: " + evt); } @SubscribeEvent public void preInit(final FMLCommonSetupEvent evt) { - log.info("Example preInit hit"); + this.log.info("Example preInit hit"); } } diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java index 95830d5..938f9aa 100755 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/Flightpath.java @@ -55,7 +55,7 @@ public class Flightpath { * @param handler The handler to use. */ public void setExceptionHandler(IExceptionHandler handler) { - synchronized (lock) { + synchronized (this.lock) { this.exceptionHandler = handler; } } @@ -66,9 +66,9 @@ public class Flightpath { * @param obj Object to attach to the bus. */ public void register(Object obj) { - synchronized (lock) { - if (subscribers.containsKey(obj)) return; // Nothing to do. - subscribers.put(obj, locator.findSubscribers(obj)); + synchronized (this.lock) { + if (this.subscribers.containsKey(obj)) return; // Nothing to do. + this.subscribers.put(obj, this.locator.findSubscribers(obj)); } } @@ -80,8 +80,8 @@ public class Flightpath { * @param evt The event to post. */ public void post(Event evt) { - synchronized (lock) { - for (Map.Entry, Map>> ent : subscribers.entrySet()) { + synchronized (this.lock) { + for (Map.Entry, Map>> ent : this.subscribers.entrySet()) { for (Map.Entry, Map> obj: ent.getValue().entrySet()) { if (!obj.getKey().isAssignableFrom(evt.getClass())) continue; for(Map.Entry objEnt : obj.getValue().entrySet()){ @@ -98,18 +98,18 @@ public class Flightpath { } catch(InvocationTargetException ex) { // thrown when a method throws an exception, so use that exception instead of the wrapper for a better stacktrace if(ex.getTargetException() instanceof Exception) { - exceptionHandler.handle((Exception)ex.getTargetException()); + this.exceptionHandler.handle((Exception)ex.getTargetException()); } else { - exceptionHandler.handle(ex); + this.exceptionHandler.handle(ex); } } catch (Exception ex) { // all other exceptions, this means something when wrong with the reflection - exceptionHandler.handle(ex); + this.exceptionHandler.handle(ex); } } } } - exceptionHandler.flush(); + this.exceptionHandler.flush(); } } diff --git a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java index 6abfb29..e84e9b0 100755 --- a/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java +++ b/src/main/java/slimeknights/mantle/pulsar/flightpath/lib/AnnotationLocator.java @@ -34,7 +34,7 @@ public class AnnotationLocator implements ISubscriberLocator { Map, Map> methods = new HashMap, Map>(); for (Method m : obj.getClass().getMethods()) { - if (m.isAnnotationPresent(annotation) && m.getParameterTypes().length == 1) { + if (m.isAnnotationPresent(this.annotation) && m.getParameterTypes().length == 1) { Class param = m.getParameterTypes()[0]; Type filter = null; diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java index 71684bf..fcab490 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/Configuration.java @@ -55,7 +55,7 @@ public class Configuration implements IConfiguration { @Override public void load() { - getModulesFromJson(); + this.getModulesFromJson(); } @Override @@ -63,7 +63,7 @@ public class Configuration implements IConfiguration { @Override public boolean isModuleEnabled(@Nonnull PulseMeta meta) { - ConfigEntry entry = modules.get(meta.getId()); + ConfigEntry entry = this.modules.get(meta.getId()); if (entry == null) { return meta.isEnabled(); } else { @@ -73,48 +73,48 @@ public class Configuration implements IConfiguration { @Override public void addPulse(@Nonnull PulseMeta meta) { - ConfigEntry entry = modules.get(meta.getId()); + ConfigEntry entry = this.modules.get(meta.getId()); if (entry == null) { - modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); + this.modules.put(meta.getId(), new ConfigEntry(meta.isDefaultEnabled(), meta.getDescription())); } } @Override public void flush() { - writeModulesToJson(); + this.writeModulesToJson(); } private void getModulesFromJson() { // Step 1: Does the file exist? - File f = new File(confPath); + File f = new File(this.confPath); if (!f.exists()) { - logger.info("Couldn't find config file; will generate a new one later."); - modules = new HashMap(); + this.logger.info("Couldn't find config file; will generate a new one later."); + this.modules = new HashMap(); return; } // Step 2: File exists. Let's make sure it's usable. if (!(f.canRead() && f.canWrite())) { - throw new FileNotReadWritableException("Could not read/write Pulsar config: " + confPath); + throw new FileNotReadWritableException("Could not read/write Pulsar config: " + this.confPath); } // Step 3: Good enough. Read it. try { try { - modules = parseV1Config(f); + this.modules = this.parseV1Config(f); } catch (Exception ex) { - logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); - Map conf = parseV0Config(f); - logger.info("Found valid v0 configuration. Upgrading it."); - modules = conf; - writeModulesToJson(); - logger.info("Upgrade complete! Config is now in v1 format."); + this.logger.warn("Failed to parse " + f.getName() + " using the v1 parser; trying the v0 parser."); + Map conf = this.parseV0Config(f); + this.logger.info("Found valid v0 configuration. Upgrading it."); + this.modules = conf; + this.writeModulesToJson(); + this.logger.info("Upgrade complete! Config is now in v1 format."); } } catch (Exception ex) { - logger.warn("Invalid config file. Discarding."); + this.logger.warn("Invalid config file. Discarding."); ex.printStackTrace(); - modules = new HashMap(); + this.modules = new HashMap(); } } @@ -149,13 +149,13 @@ public class Configuration implements IConfiguration { private void writeModulesToJson() { try { - JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(confPath)))); + JsonWriter writer = new JsonWriter(new OutputStreamWriter(new FileOutputStream(new File(this.confPath)))); writer.setIndent(" "); - GsonConfig out = new GsonConfig(CONFIG_LEVEL, modules); + GsonConfig out = new GsonConfig(CONFIG_LEVEL, this.modules); gson.toJson(out, GsonConfig.class, writer); writer.close(); } catch (Exception ex) { - logger.warn("Could not write config? " + confPath); + this.logger.warn("Could not write config? " + this.confPath); } } @@ -186,7 +186,7 @@ public class Configuration implements IConfiguration { } public Boolean getEnabled() { - return enabled; + return this.enabled; } public void setEnabled(Boolean enabled) { @@ -194,7 +194,7 @@ public class Configuration implements IConfiguration { } public String getDescription() { - return description; + return this.description; } } @@ -213,11 +213,11 @@ public class Configuration implements IConfiguration { } public int getConfigVersion() { - return CONFIG_VERSION; + return this.CONFIG_VERSION; } public Map getModules() { - return modules; + return this.modules; } } diff --git a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java index 150ae7b..4adf21f 100644 --- a/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java +++ b/src/main/java/slimeknights/mantle/pulsar/internal/CrashHandler.java @@ -22,13 +22,13 @@ public class CrashHandler implements ICrashCallable { @Override public String getLabel() { - return id; + return this.id; } @Override public String call() throws Exception { String out = "\n"; - for (PulseMeta meta : manager.getAllPulseMetadata()) { + for (PulseMeta meta : this.manager.getAllPulseMetadata()) { String state = getStateFromMeta(meta); out += "\t\t- " + meta.getId() + " (" + state + ")\n"; // Yes, yes, manual indenting, I know... } diff --git a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java index 81fc979..8cb5ca4 100644 --- a/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java +++ b/src/main/java/slimeknights/mantle/pulsar/pulse/PulseMeta.java @@ -24,19 +24,19 @@ public class PulseMeta { } public String getId() { - return id; + return this.id; } public String getDescription() { - return description; + return this.description; } public boolean isForced() { - return !missingDeps && forced; + return !this.missingDeps && this.forced; } public boolean isEnabled() { - return !missingDeps && enabled; + return !this.missingDeps && this.enabled; } public void setEnabled(boolean enabled) { @@ -44,10 +44,10 @@ public class PulseMeta { } public void setMissingDeps(boolean missing) { - missingDeps = missing; + this.missingDeps = missing; } public boolean isDefaultEnabled() { - return defaultEnabled; + return this.defaultEnabled; } } diff --git a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java index 3cb1de8..e686505 100644 --- a/src/main/java/slimeknights/mantle/tileentity/TileInventory.java +++ b/src/main/java/slimeknights/mantle/tileentity/TileInventory.java @@ -2,12 +2,16 @@ package slimeknights.mantle.tileentity; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.container.Container; +import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.ListNBT; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraft.util.INameable; import net.minecraft.util.NonNullList; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; @@ -24,7 +28,7 @@ import javax.annotation.Nullable; import slimeknights.mantle.util.ItemStackList; // Updated version of InventoryLogic in Mantle. Also contains a few bugfixes -public class TileInventory extends MantleTileEntity implements IInventory { +public class TileInventory extends MantleTileEntity implements IInventory, INamedContainerProvider, INameable { private NonNullList inventory; protected ITextComponent inventoryTitle; @@ -45,7 +49,7 @@ public class TileInventory extends MantleTileEntity implements IInventory { */ public TileInventory(TileEntityType tileEntityTypeIn, ITextComponent name, int inventorySize, int maxStackSize) { super(tileEntityTypeIn); - this.inventory = NonNullList. withSize(inventorySize, ItemStack.EMPTY); + this.inventory = NonNullList.withSize(inventorySize, ItemStack.EMPTY); this.stackSizeLimit = maxStackSize; this.inventoryTitle = name; this.itemHandler = new InvWrapper(this); @@ -56,13 +60,13 @@ public class TileInventory extends MantleTileEntity implements IInventory { @Override public net.minecraftforge.common.util.LazyOptional getCapability(@Nonnull Capability capability, Direction facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { - return itemHandlerCap.cast(); + return this.itemHandlerCap.cast(); } return super.getCapability(capability, facing); } public IItemHandlerModifiable getItemHandler() { - return itemHandler; + return this.itemHandler; } /* Inventory management */ @@ -70,57 +74,57 @@ public class TileInventory extends MantleTileEntity implements IInventory { @Nonnull @Override public ItemStack getStackInSlot(int slot) { - if(slot < 0 || slot >= inventory.size()) { + if(slot < 0 || slot >= this.inventory.size()) { return ItemStack.EMPTY; } - return inventory.get(slot); + return this.inventory.get(slot); } public boolean isStackInSlot(int slot) { - return !getStackInSlot(slot).isEmpty(); + return !this.getStackInSlot(slot).isEmpty(); } /** Same as resize, but does not call markDirty. Used on loading from NBT */ private void resizeInternal(int size) { // save effort if the size did not change - if(size == inventory.size()) { + if(size == this.inventory.size()) { return; } ItemStackList newInventory = ItemStackList.withSize(size); - for (int i = 0; i < size && i < inventory.size(); i++) { - newInventory.set(i, inventory.get(i)); + for (int i = 0; i < size && i < this.inventory.size(); i++) { + newInventory.set(i, this.inventory.get(i)); } - inventory = newInventory; + this.inventory = newInventory; } public void resize(int size) { - resizeInternal(size); + this.resizeInternal(size); this.markDirtyFast(); } @Override public int getSizeInventory() { - return inventory.size(); + return this.inventory.size(); } @Override public int getInventoryStackLimit() { - return stackSizeLimit; + return this.stackSizeLimit; } @Override public void setInventorySlotContents(int slot, @Nonnull ItemStack itemstack) { - if(slot < 0 || slot >= inventory.size()) { + if(slot < 0 || slot >= this.inventory.size()) { return; } - ItemStack current = inventory.get(slot); - inventory.set(slot, itemstack); + ItemStack current = this.inventory.get(slot); + this.inventory.set(slot, itemstack); - if(!itemstack.isEmpty() && itemstack.getCount() > getInventoryStackLimit()) { - itemstack.setCount(getInventoryStackLimit()); + if(!itemstack.isEmpty() && itemstack.getCount() > this.getInventoryStackLimit()) { + itemstack.setCount(this.getInventoryStackLimit()); } if(!ItemStack.areItemStacksEqual(current, itemstack)) { this.markDirtyFast(); @@ -133,7 +137,7 @@ public class TileInventory extends MantleTileEntity implements IInventory { if(quantity <= 0) { return ItemStack.EMPTY; } - ItemStack itemStack = getStackInSlot(slot); + ItemStack itemStack = this.getStackInSlot(slot); if(itemStack.isEmpty()) { return ItemStack.EMPTY; @@ -141,7 +145,7 @@ public class TileInventory extends MantleTileEntity implements IInventory { // whole itemstack taken out if(itemStack.getCount() <= quantity) { - setInventorySlotContents(slot, ItemStack.EMPTY); + this.setInventorySlotContents(slot, ItemStack.EMPTY); this.markDirtyFast(); return itemStack; } @@ -150,8 +154,8 @@ public class TileInventory extends MantleTileEntity implements IInventory { itemStack = itemStack.split(quantity); // slot is empty, set to ItemStack.EMPTY // isn't this redundant to the above check? - if(getStackInSlot(slot).getCount() == 0) { - setInventorySlotContents(slot, ItemStack.EMPTY); + if(this.getStackInSlot(slot).getCount() == 0) { + this.setInventorySlotContents(slot, ItemStack.EMPTY); } this.markDirtyFast(); @@ -162,25 +166,23 @@ public class TileInventory extends MantleTileEntity implements IInventory { @Nonnull @Override public ItemStack removeStackFromSlot(int slot) { - ItemStack itemStack = getStackInSlot(slot); - setInventorySlotContents(slot, ItemStack.EMPTY); + ItemStack itemStack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, ItemStack.EMPTY); return itemStack; } @Override public boolean isItemValidForSlot(int slot, @Nonnull ItemStack itemstack) { - if(slot < getSizeInventory()) { - if(inventory.get(slot).isEmpty() || itemstack.getCount() + inventory.get(slot).getCount() <= getInventoryStackLimit()) { - return true; - } + if(slot < this.getSizeInventory()) { + return this.inventory.get(slot).isEmpty() || itemstack.getCount() + this.inventory.get(slot).getCount() <= this.getInventoryStackLimit(); } return false; } @Override public void clear() { - for(int i = 0; i < inventory.size(); i++) { - inventory.set(i, ItemStack.EMPTY); + for(int i = 0; i < this.inventory.size(); i++) { + this.inventory.set(i, ItemStack.EMPTY); } } @@ -209,11 +211,11 @@ public class TileInventory extends MantleTileEntity implements IInventory { @Nonnull @Override public ITextComponent getDisplayName() { - if(hasCustomName()) { - return new StringTextComponent(getName().getFormattedText()); + if(this.hasCustomName()) { + return new StringTextComponent(this.getName().getFormattedText()); } - return new TranslationTextComponent(getName().getFormattedText()); + return new TranslationTextComponent(this.getName().getFormattedText()); } @@ -221,12 +223,12 @@ public class TileInventory extends MantleTileEntity implements IInventory { @Override public boolean isUsableByPlayer(@Nonnull PlayerEntity entityplayer) { // block changed/got broken? - if(world.getTileEntity(pos) != this || world.getBlockState(pos).getBlock() == Blocks.AIR) { + if(this.world.getTileEntity(this.pos) != this || this.world.getBlockState(this.pos).getBlock() == Blocks.AIR) { return false; } return - entityplayer.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) + entityplayer.getDistanceSq(this.pos.getX() + 0.5D, this.pos.getY() + 0.5D, this.pos.getZ() + 0.5D) <= 64D; } @@ -246,7 +248,7 @@ public class TileInventory extends MantleTileEntity implements IInventory { super.read(tags); this.resizeInternal(tags.getInt("InventorySize")); - readInventoryFromNBT(tags); + this.readInventoryFromNBT(tags); if(tags.contains("CustomName", 8)) { this.inventoryTitle = ITextComponent.Serializer.fromJson(tags.getString("CustomName")); @@ -258,9 +260,9 @@ public class TileInventory extends MantleTileEntity implements IInventory { public CompoundNBT write(CompoundNBT tags) { super.write(tags); - tags.putInt("InventorySize", inventory.size()); + tags.putInt("InventorySize", this.inventory.size()); - writeInventoryToNBT(tags); + this.writeInventoryToNBT(tags); if(this.hasCustomName()) { tags.putString("CustomName", ITextComponent.Serializer.toJson(this.inventoryTitle)); @@ -289,18 +291,18 @@ public class TileInventory extends MantleTileEntity implements IInventory { public void readInventoryFromNBT(CompoundNBT tag) { ListNBT nbttaglist = tag.getList("Items", 10); - int limit = getInventoryStackLimit(); + int limit = this.getInventoryStackLimit(); ItemStack stack; for(int i = 0; i < nbttaglist.size(); ++i) { CompoundNBT itemTag = nbttaglist.getCompound(i); int slot = itemTag.getByte("Slot") & 255; - if(slot >= 0 && slot < inventory.size()) { + if(slot >= 0 && slot < this.inventory.size()) { stack = ItemStack.read(itemTag); if(!stack.isEmpty() && stack.getCount() > limit) { stack.setCount(limit); } - inventory.set(slot, stack); + this.inventory.set(slot, stack); } } } @@ -321,4 +323,10 @@ public class TileInventory extends MantleTileEntity implements IInventory { return true; } + + @Nullable + @Override + public Container createMenu(int id, PlayerInventory playerInventory, PlayerEntity playerEntity) { + return null; + } } diff --git a/src/main/java/slimeknights/mantle/util/ImmutableConcatList.java b/src/main/java/slimeknights/mantle/util/ImmutableConcatList.java index bebccf8..85c8446 100644 --- a/src/main/java/slimeknights/mantle/util/ImmutableConcatList.java +++ b/src/main/java/slimeknights/mantle/util/ImmutableConcatList.java @@ -19,44 +19,44 @@ public class ImmutableConcatList implements List { protected final FluentIterable iterable; public ImmutableConcatList(List... lists) { - iterable = FluentIterable.from(Iterables.concat(lists)); + this.iterable = FluentIterable.from(Iterables.concat(lists)); } public ImmutableConcatList(List> lists) { - iterable = FluentIterable.from(Iterables.concat(lists)); + this.iterable = FluentIterable.from(Iterables.concat(lists)); } @Override public int size() { - return iterable.size(); + return this.iterable.size(); } @Override public boolean isEmpty() { - return iterable.isEmpty(); + return this.iterable.isEmpty(); } @Override public boolean contains(Object o) { - return iterable.contains(o); + return this.iterable.contains(o); } @Nonnull @Override public Iterator iterator() { - return iterable.iterator(); + return this.iterable.iterator(); } @Nonnull @Override public Object[] toArray() { - return iterable.toList().toArray(); + return this.iterable.toList().toArray(); } @Nonnull @Override public T[] toArray(@Nonnull T[] a) { - return iterable.toList().toArray(a); + return this.iterable.toList().toArray(a); } @Override @@ -72,7 +72,7 @@ public class ImmutableConcatList implements List { @Override public boolean containsAll(@Nonnull Collection c) { for (Object e : c) - if (!contains(e)) + if (!this.contains(e)) return false; return true; } @@ -104,7 +104,7 @@ public class ImmutableConcatList implements List { @Override public E get(int index) { - return iterable.get(index); + return this.iterable.get(index); } @Override @@ -124,7 +124,7 @@ public class ImmutableConcatList implements List { @Override public int indexOf(final Object o) { - Iterator iterator = iterable.iterator(); + Iterator iterator = this.iterable.iterator(); for (int i = 0; iterator.hasNext(); i++) { if(o == iterator.next()) { return i; @@ -136,7 +136,7 @@ public class ImmutableConcatList implements List { @Override public int lastIndexOf(Object o) { - Iterator iterator = iterable.iterator(); + Iterator iterator = this.iterable.iterator(); int j = -1; for (int i = 0; iterator.hasNext(); i++) { if(o == iterator.next()) { @@ -150,7 +150,7 @@ public class ImmutableConcatList implements List { @Nonnull @Override public ListIterator listIterator() { - return listIterator(0); + return this.listIterator(0); } @Nonnull @@ -186,38 +186,38 @@ public class ImmutableConcatList implements List { @Override public final boolean hasNext() { - return position < size; + return this.position < this.size; } @Override public final E next() { - if (!hasNext()) { + if (!this.hasNext()) { throw new NoSuchElementException(); } - return get(position++); + return this.get(this.position++); } @Override public final int nextIndex() { - return position; + return this.position; } @Override public final boolean hasPrevious() { - return position > 0; + return this.position > 0; } @Override public final E previous() { - if (!hasPrevious()) { + if (!this.hasPrevious()) { throw new NoSuchElementException(); } - return get(--position); + return this.get(--this.position); } @Override public final int previousIndex() { - return position - 1; + return this.position - 1; } } } diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatch.java b/src/main/java/slimeknights/mantle/util/RecipeMatch.java index ae909b5..39ff03a 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatch.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatch.java @@ -179,16 +179,16 @@ public abstract class RecipeMatch { @Override public List getInputs() { - return ImmutableList.of(template); + return ImmutableList.of(this.template); } @Override public Optional matches(NonNullList stacks) { List found = Lists.newLinkedList(); - int stillNeeded = amountNeeded; + int stillNeeded = this.amountNeeded; for(ItemStack stack : stacks) { - if(OreDictionary.itemMatches(template, stack, false)) { + if(OreDictionary.itemMatches(this.template, stack, false)) { // add the amount found to the list ItemStack copy = stack.copy(); copy.setCount(Math.min(copy.getCount(), stillNeeded)); @@ -197,7 +197,7 @@ public abstract class RecipeMatch { // we found enough if(stillNeeded <= 0) { - return Optional.of(new Match(found, amountMatched)); + return Optional.of(new Match(found, this.amountMatched)); } } } @@ -217,7 +217,7 @@ public abstract class RecipeMatch { public ItemCombination(int amountMatched, ItemStack... stacks) { super(amountMatched, 0); - NonNullList nonNullStacks = NonNullList. withSize(stacks.length, ItemStack.EMPTY); + NonNullList nonNullStacks = NonNullList.withSize(stacks.length, ItemStack.EMPTY); for(int i = 0; i < stacks.length; i++) { if(!stacks[i].isEmpty()) { nonNullStacks.set(i, stacks[i].copy()); @@ -229,7 +229,7 @@ public abstract class RecipeMatch { @Override public List getInputs() { - return ImmutableList.copyOf(itemStacks); + return ImmutableList.copyOf(this.itemStacks); } @Override @@ -237,8 +237,8 @@ public abstract class RecipeMatch { List found = Lists.newLinkedList(); Set needed = Sets.newHashSet(); - for(int i = 0; i < itemStacks.size(); i++) { - if(!itemStacks.get(i).isEmpty()) { + for(int i = 0; i < this.itemStacks.size(); i++) { + if(!this.itemStacks.get(i).isEmpty()) { needed.add(i); } } @@ -247,7 +247,7 @@ public abstract class RecipeMatch { Iterator iter = needed.iterator(); while(iter.hasNext()) { int index = iter.next(); - ItemStack template = itemStacks.get(index); + ItemStack template = this.itemStacks.get(index); if(ItemStack.areItemsEqual(template, stack) && ItemStack.areItemStackTagsEqual(template, stack)) { // add the amount found to the list ItemStack copy = stack.copy(); @@ -260,7 +260,7 @@ public abstract class RecipeMatch { } if(needed.isEmpty()) { - return Optional.of(new Match(found, amountMatched)); + return Optional.of(new Match(found, this.amountMatched)); } return Optional.empty(); } @@ -293,16 +293,16 @@ public abstract class RecipeMatch { public List getInputs() { // 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))); + this.oredictEntry.forEach(stack -> IntStream.range(0, this.amountNeeded).forEach(i -> builder.add(stack))); return builder.build(); } @Override public Optional matches(NonNullList stacks) { List found = Lists.newLinkedList(); - int stillNeeded = amountNeeded; + int stillNeeded = this.amountNeeded; - for(ItemStack ore : oredictEntry) { + for(ItemStack ore : this.oredictEntry) { for(ItemStack stack : stacks) { if(OreDictionary.itemMatches(ore, stack, false)) { // add the amount found to the list @@ -313,7 +313,7 @@ public abstract class RecipeMatch { // we found enough if(stillNeeded <= 0) { - return Optional.of(new Match(found, amountMatched)); + return Optional.of(new Match(found, this.amountMatched)); } } } diff --git a/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java b/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java index 151251c..7ac4604 100644 --- a/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java +++ b/src/main/java/slimeknights/mantle/util/RecipeMatchRegistry.java @@ -29,12 +29,12 @@ public class RecipeMatchRegistry { } } - return matches(nonNullStacks); + return this.matches(nonNullStacks); } // looks for a match in the given itemstacks public Optional matches(NonNullList stacks) { - for(RecipeMatch recipe : items) { + for(RecipeMatch recipe : this.items) { Optional match = recipe.matches(stacks); if(match.isPresent()) { return match; @@ -52,7 +52,7 @@ public class RecipeMatchRegistry { Optional matchOptional; int sum = 0; - while(sum < minAmount && (matchOptional = matches(stacks)).isPresent()) { + while(sum < minAmount && (matchOptional = this.matches(stacks)).isPresent()) { RecipeMatch.Match match = matchOptional.get(); matches.add(match); RecipeMatch.removeMatch(stacks, match); @@ -81,7 +81,7 @@ public class RecipeMatchRegistry { Optional matchOptional; int sum = 0; - while((matchOptional = matches(stacks)).isPresent()) { + while((matchOptional = this.matches(stacks)).isPresent()) { RecipeMatch.Match match = matchOptional.get(); matches.add(match); RecipeMatch.removeMatch(stacks, match); @@ -106,11 +106,11 @@ public class RecipeMatchRegistry { * @param amountMatched If both item and amount are present, how often did they match? */ public void addItem(String oredictItem, int amountNeeded, int amountMatched) { - items.add(new RecipeMatch.Oredict(oredictItem, amountNeeded, amountMatched)); + this.items.add(new RecipeMatch.Oredict(oredictItem, amountNeeded, amountMatched)); } public void addItem(String oredictItem) { - addItem(oredictItem, 1, 1); + this.addItem(oredictItem, 1, 1); } /** @@ -119,7 +119,7 @@ public class RecipeMatchRegistry { * @param amountMatched For how many matches the block counts (e.g. redstone dust = 1 match, Redstone block = 9) */ public void addItem(Block block, int amountMatched) { - items.add(new RecipeMatch.Item(new ItemStack(block), 1, amountMatched)); + this.items.add(new RecipeMatch.Item(new ItemStack(block), 1, amountMatched)); } /** @@ -130,7 +130,7 @@ public class RecipeMatchRegistry { * @param amountMatched If both item and amount are present, how often did they match? */ public void addItem(Item item, int amountNeeded, int amountMatched) { - items.add(new RecipeMatch.Item(new ItemStack(item), amountNeeded, amountMatched)); + this.items.add(new RecipeMatch.Item(new ItemStack(item), amountNeeded, amountMatched)); } /** @@ -141,18 +141,18 @@ public class RecipeMatchRegistry { * @param amountMatched If both item and amount are present, how often did they match? */ public void addItem(ItemStack item, int amountNeeded, int amountMatched) { - items.add(new RecipeMatch.Item(item, amountNeeded, amountMatched)); + this.items.add(new RecipeMatch.Item(item, amountNeeded, amountMatched)); } /** * Associates an item with this material. Used for repairing and other. */ public void addItem(Item item) { - addItem(item, 1, 1); + this.addItem(item, 1, 1); } public void addRecipeMatch(RecipeMatch match) { - items.add(match); + this.items.add(match); } diff --git a/src/main/java/slimeknights/mantle/util/TradeGeneric.java b/src/main/java/slimeknights/mantle/util/TradeGeneric.java deleted file mode 100644 index 31c2f00..0000000 --- a/src/main/java/slimeknights/mantle/util/TradeGeneric.java +++ /dev/null @@ -1,152 +0,0 @@ -package slimeknights.mantle.util; - -import java.util.Random; - -import javax.annotation.Nonnull; -import net.minecraft.entity.merchant.IMerchant; -import net.minecraft.entity.merchant.villager.VillagerEntity; -import net.minecraft.entity.merchant.villager.VillagerEntity.PriceInfo; -import net.minecraft.entity.merchant.villager.VillagerTrades; -import net.minecraft.item.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.village.MerchantRecipe; -import net.minecraft.village.MerchantRecipeList; - -public class TradeGeneric implements VillagerTrades.ITrade { - private ItemStack input, input2, output; - private PriceInfo inputPrice, input2Price, outputPrice; - - /** - * Creates a new trade of two input stacks for an output stack - * - * @param input First input itemstack - * @param inputPrice Random stack size range for first input - * @param input2 Second input itemstack - * @param input2Price Random stack size range for second input - * @param output Output itemstack - * @param outputPrice Random stack size range for output - */ - public TradeGeneric(ItemStack input, PriceInfo inputPrice, ItemStack input2, PriceInfo input2Price, - ItemStack output, PriceInfo outputPrice) { - - this.input = input; - this.inputPrice = inputPrice; - - this.input2 = input2; - this.input2Price = input2Price; - - this.output = output; - this.outputPrice = outputPrice; - } - - /** - * Creates a new trade of an input stack for an output stack - * - * @param input Input itemstack - * @param inputPrice Random stack size range for input - * @param output Output itemstack - * @param outputPrice Random stack size range for output - */ - public TradeGeneric(ItemStack input, PriceInfo inputPrice, ItemStack output, PriceInfo outputPrice) { - this(input, inputPrice, ItemStack.EMPTY, null, output, outputPrice); - } - - /** - * Creates a new trade with one input for emeralds - * - * @param input Input itemstack - * @param inputPrice Random stack size range for input - * @param outputPrice Random range for output emerald - */ - public TradeGeneric(ItemStack input, PriceInfo inputPrice, PriceInfo outputPrice) { - this(input, inputPrice, ItemStack.EMPTY, null, ItemStack.EMPTY, outputPrice); - } - - /** - * Creates a new trade of emeralds for an output stack - * - * @param inputPrice Random stack size range for input - * @param output Output itemstack - * @param outputPrice Random range for output emerald - */ - public TradeGeneric(PriceInfo inputPrice, ItemStack output, PriceInfo outputPrice) { - this(ItemStack.EMPTY, inputPrice, ItemStack.EMPTY, null, output, outputPrice); - } - - /** - * Getter for the input stack - * @param random random number access - * @return A new instance of the input stack, or a stack containing an emerald if empty - */ - @Nonnull - protected ItemStack getInput(Random random) { - if(input.isEmpty()) { - return new ItemStack(Items.EMERALD); - } - - return input.copy(); - } - - /** - * Getter for the second input stack, returns a new instance - * @param random random number access - * @return A new instance of the second input stack, or nothing if empty - */ - protected ItemStack getInput2(Random random) { - // no copy if empty - if(input2.isEmpty()) { - return ItemStack.EMPTY; - } - return input2.copy(); - } - - /** - * Getter for the output stack - * @param random random number access - * @return A new instance of the output stack, or a stack containing an emerald if null - */ - @Nonnull - protected ItemStack getOutput(Random random) { - if(output.isEmpty()) { - return new ItemStack(Items.EMERALD); - } - - return output.copy(); - } - - @Override - public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random) { - ItemStack input = getInput(random); - ItemStack output = getOutput(random); - - // set random counts - int size = 1; - if(inputPrice != null) { - size = inputPrice.getPrice(random); - } - input.setCount(size); - - // set random counts - size = 1; - if(outputPrice != null) { - size = outputPrice.getPrice(random); - } - output.setCount(size); - - // only modify second stack if it exists - ItemStack input2 = getInput2(random); - if(!input2.isEmpty()) { - // set the size for the second stack - size = 1; - // null means 1 - if(input2Price != null) { - size = input2Price.getPrice(random); - } - - input2.setCount(size); - } - - // create the actual "recipe" - recipeList.add(new MerchantRecipe(input, input2, output)); - } -} diff --git a/src/main/java/slimeknights/mantle/util/TradeRandom.java b/src/main/java/slimeknights/mantle/util/TradeRandom.java deleted file mode 100644 index 26d8937..0000000 --- a/src/main/java/slimeknights/mantle/util/TradeRandom.java +++ /dev/null @@ -1,73 +0,0 @@ -package slimeknights.mantle.util; - -import java.util.Random; - -import javax.annotation.Nonnull; - -import net.minecraft.entity.merchant.villager.VillagerEntity.PriceInfo; -import net.minecraft.item.ItemStack; - -public class TradeRandom extends TradeGeneric { - - // data - private ItemStack[] inputs; - private ItemStack[] outputs; - - /** - * Trade a randomly chosen item item from the list for another randomly chosen item - * @param inputs List of inputs to randomly choose from - * @param inputPrice Random stack size range for input - * @param outputs List of outputs to randomly choose from - * @param outputPrice Random stack size range for output - */ - public TradeRandom(ItemStack[] inputs, PriceInfo inputPrice, ItemStack[] outputs, PriceInfo outputPrice) { - super(ItemStack.EMPTY, inputPrice, ItemStack.EMPTY, outputPrice); - this.inputs = inputs; - this.outputs = outputs; - } - - /** - * Trade a randomly chosen item from the list for emeralds - * @param inputs List of inputs to randomly choose from - * @param inputPrice Random stack size range for input - * @param outputPrice Random stack size range for output - */ - public TradeRandom(ItemStack[] inputs, PriceInfo inputPrice, PriceInfo outputPrice) { - this(inputs, inputPrice, null, outputPrice); - } - - /** - * Trade emeralds for a randomly chosen item from the list - * @param inputPrice Random stack size range for input - * @param outputs List of outputs to randomly choose from - * @param outputPrice Random stack size range for output - */ - public TradeRandom(PriceInfo inputPrice, ItemStack[] outputs, PriceInfo outputPrice) { - this(null, inputPrice, outputs, outputPrice); - } - - @Override - @Nonnull - protected ItemStack getOutput(Random random) { - // array does not exist? return default - if(outputs == null) { - return super.getOutput(random); - } - // return a random stack from the list - int i = random.nextInt(outputs.length); - return outputs[i].copy(); - } - - @Override - @Nonnull - protected ItemStack getInput(Random random) { - // array does not exist? return default - if(inputs == null) { - return super.getInput(random); - } - // return a random stack from the list - int i = random.nextInt(inputs.length); - return inputs[i].copy(); - } - -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 0f06ceb..fa0dd1f 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -1,12 +1,12 @@ # Mantle -- Access Transformer -# GuiContainer -public net.minecraft.client.gui.inventory.GuiContainer field_146999_f # xSize -public net.minecraft.client.gui.inventory.GuiContainer field_147000_g # ySize -public net.minecraft.client.gui.inventory.GuiContainer field_147009_r # guiTop -public net.minecraft.client.gui.inventory.GuiContainer field_147003_i # guiLeft -public net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V # drawSlot -public net.minecraft.client.gui.inventory.GuiContainer func_195362_a(Lnet/minecraft/inventory/Slot;DD)Z # isSlotSelected +# ContainerScreen +public net.minecraft.client.gui.screen.inventory.ContainerScreen field_146999_f # xSize +public net.minecraft.client.gui.screen.inventory.ContainerScreen field_147000_g # ySize +public net.minecraft.client.gui.screen.inventory.ContainerScreen field_147009_r # guiTop +public net.minecraft.client.gui.screen.inventory.ContainerScreen field_147003_i # guiLeft +public net.minecraft.client.gui.screen.inventory.ContainerScreen func_146977_a(Lnet/minecraft/inventory/container/Slot;)V # drawSlot +public net.minecraft.client.gui.screen.inventory.ContainerScreen func_195362_a(Lnet/minecraft/inventory/container/Slot;DD)Z # isSlotSelected -# GuiScreen -public net.minecraft.client.gui.GuiScreen field_146292_n # buttons \ No newline at end of file +# Screen +public net.minecraft.client.gui.screen.Screen buttons # buttons \ No newline at end of file