mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-20 12:09:44 +00:00
Assorted renames and reworks for 1.9.4 mappings
Also a change to MultiServantLogic for new TE update tag as per mojang changes
This commit is contained in:
1 parent
8dc4591045
commit
fb9edf9186
8 files changed
+66
-66
No files matched your search
@@ -1,6 +1,6 @@
|
||||
package slimeknights.mantle.client.book;
|
||||
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -34,10 +34,10 @@ public abstract class BookTransformer {
|
||||
public void transform(BookData book) {
|
||||
SectionData index = new SectionData(true) {
|
||||
@Override
|
||||
public void update(StatFileWriter writer) {
|
||||
public void update(StatisticsManager statisticsManager) {
|
||||
pages.clear();
|
||||
|
||||
List<SectionData> visibleSections = parent.getVisibleSections(writer);
|
||||
List<SectionData> visibleSections = parent.getVisibleSections(statisticsManager);
|
||||
|
||||
if(visibleSections.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -3,7 +3,7 @@ package slimeknights.mantle.client.book.data;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -144,12 +144,12 @@ public class BookData implements IDataItem {
|
||||
return findSection(name, null);
|
||||
}
|
||||
|
||||
public SectionData findSection(String name, @Nullable StatFileWriter writer) {
|
||||
public SectionData findSection(String name, @Nullable StatisticsManager statisticsManager) {
|
||||
for(SectionData section : sections) {
|
||||
section.update(writer);
|
||||
section.update(statisticsManager);
|
||||
|
||||
if(section.name.equals(name.toLowerCase())) {
|
||||
return section.isUnlocked(writer) ? section : null;
|
||||
return section.isUnlocked(statisticsManager) ? section : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,16 +160,16 @@ public class BookData implements IDataItem {
|
||||
return getFirstPageNumber(section, null);
|
||||
}
|
||||
|
||||
public int getFirstPageNumber(SectionData section, @Nullable StatFileWriter writer) {
|
||||
public int getFirstPageNumber(SectionData section, @Nullable StatisticsManager statisticsManager) {
|
||||
int pages = 0;
|
||||
for(SectionData sect : sections) {
|
||||
sect.update(writer);
|
||||
sect.update(statisticsManager);
|
||||
|
||||
if(section == sect) {
|
||||
return section.isUnlocked(writer) ? pages + 1 : -1;
|
||||
return section.isUnlocked(statisticsManager) ? pages + 1 : -1;
|
||||
}
|
||||
|
||||
if(!sect.isUnlocked(writer)) {
|
||||
if(!sect.isUnlocked(statisticsManager)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -183,16 +183,16 @@ public class BookData implements IDataItem {
|
||||
return findPage(number, null);
|
||||
}
|
||||
|
||||
public PageData findPage(int number, @Nullable StatFileWriter writer) {
|
||||
public PageData findPage(int number, @Nullable StatisticsManager statisticsManager) {
|
||||
if(number < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int pages = 0;
|
||||
for(SectionData section : sections) {
|
||||
section.update(writer);
|
||||
section.update(statisticsManager);
|
||||
|
||||
if(!section.isUnlocked(writer)) {
|
||||
if(!section.isUnlocked(statisticsManager)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -210,15 +210,15 @@ public class BookData implements IDataItem {
|
||||
return findPage(location, null);
|
||||
}
|
||||
|
||||
public PageData findPage(String location, @Nullable StatFileWriter writer) {
|
||||
return findPage(findPageNumber(location, writer));
|
||||
public PageData findPage(String location, @Nullable StatisticsManager statisticsManager) {
|
||||
return findPage(findPageNumber(location, statisticsManager));
|
||||
}
|
||||
|
||||
public int findPageNumber(String location) {
|
||||
return findPageNumber(location, null);
|
||||
}
|
||||
|
||||
public int findPageNumber(String location, @Nullable StatFileWriter writer) {
|
||||
public int findPageNumber(String location, @Nullable StatisticsManager statisticsManager) {
|
||||
location = location.toLowerCase();
|
||||
|
||||
int pages = 0;
|
||||
@@ -231,9 +231,9 @@ public class BookData implements IDataItem {
|
||||
String pageName = location.substring(location.indexOf('.') + 1);
|
||||
|
||||
for(SectionData section : sections) {
|
||||
section.update(writer);
|
||||
section.update(statisticsManager);
|
||||
|
||||
if(!section.isUnlocked(writer)) {
|
||||
if(!section.isUnlocked(statisticsManager)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -259,12 +259,12 @@ public class BookData implements IDataItem {
|
||||
return getPageCount(null);
|
||||
}
|
||||
|
||||
public int getPageCount(@Nullable StatFileWriter writer) {
|
||||
public int getPageCount(@Nullable StatisticsManager statisticsManager) {
|
||||
int pages = 0;
|
||||
for(SectionData section : sections) {
|
||||
section.update(writer);
|
||||
section.update(statisticsManager);
|
||||
|
||||
pages += section.isUnlocked(writer) ? section.getPageCount() : 0;
|
||||
pages += section.isUnlocked(statisticsManager) ? section.getPageCount() : 0;
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
@@ -273,8 +273,8 @@ public class BookData implements IDataItem {
|
||||
return getFullPageCount(null);
|
||||
}
|
||||
|
||||
public int getFullPageCount(@Nullable StatFileWriter writer) {
|
||||
return (int) Math.ceil((getPageCount(writer) - 1) / 2F) + 1;
|
||||
public int getFullPageCount(@Nullable StatisticsManager statisticsManager) {
|
||||
return (int) Math.ceil((getPageCount(statisticsManager) - 1) / 2F) + 1;
|
||||
}
|
||||
|
||||
public String getItemAction(ItemStackData item) {
|
||||
@@ -287,11 +287,11 @@ public class BookData implements IDataItem {
|
||||
return "";
|
||||
}
|
||||
|
||||
public List<SectionData> getVisibleSections(StatFileWriter writer) {
|
||||
public List<SectionData> getVisibleSections(StatisticsManager statisticsManager) {
|
||||
List<SectionData> visible = new ArrayList<>();
|
||||
|
||||
for(SectionData section : sections) {
|
||||
if(section.isUnlocked(writer) || !section.hideWhenLocked) {
|
||||
if(section.isUnlocked(statisticsManager) || !section.hideWhenLocked) {
|
||||
visible.add(section);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package slimeknights.mantle.client.book.data;
|
||||
import net.minecraft.client.resources.IResource;
|
||||
import net.minecraft.stats.Achievement;
|
||||
import net.minecraft.stats.AchievementList;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -80,7 +80,7 @@ public class SectionData implements IDataItem {
|
||||
icon.location = source.getResourceLocation(icon.file, true);
|
||||
}
|
||||
|
||||
public void update(@Nullable StatFileWriter writer) {
|
||||
public void update(@Nullable StatisticsManager statisticsManager) {
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
@@ -92,13 +92,13 @@ public class SectionData implements IDataItem {
|
||||
return pages.size();
|
||||
}
|
||||
|
||||
public boolean isUnlocked(StatFileWriter writer) {
|
||||
if(writer == null || requirements == null || requirements.length == 0) {
|
||||
public boolean isUnlocked(StatisticsManager statisticsManager) {
|
||||
if(statisticsManager == null || requirements == null || requirements.length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(String achievement : requirements) {
|
||||
if(!requirementSatisfied(achievement, writer)) {
|
||||
if(!requirementSatisfied(achievement, statisticsManager)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public class SectionData implements IDataItem {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean requirementSatisfied(String requirement, StatFileWriter writer) {
|
||||
public static boolean requirementSatisfied(String requirement, StatisticsManager writer) {
|
||||
if(writer == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.CPacketClientStatus;
|
||||
import net.minecraft.stats.StatFileWriter;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -30,7 +30,6 @@ import slimeknights.mantle.client.book.data.BookData;
|
||||
import slimeknights.mantle.client.book.data.PageData;
|
||||
import slimeknights.mantle.client.book.data.element.ItemStackData;
|
||||
import slimeknights.mantle.client.gui.book.element.BookElement;
|
||||
import slimeknights.mantle.client.gui.book.element.SizedBookElement;
|
||||
|
||||
import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOK;
|
||||
import static slimeknights.mantle.client.gui.book.Textures.TEX_BOOKFRONT;
|
||||
@@ -72,18 +71,18 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
private ArrayList<BookElement> leftElements = new ArrayList<>();
|
||||
private ArrayList<BookElement> rightElements = new ArrayList<>();
|
||||
|
||||
public StatFileWriter statFile;
|
||||
public StatisticsManager statisticsManager;
|
||||
|
||||
public static void init() {
|
||||
PAGE_WIDTH = (int) ((PAGE_WIDTH_UNSCALED - (PAGE_PADDING_LEFT + PAGE_PADDING_RIGHT + PAGE_MARGIN + PAGE_MARGIN)) / PAGE_SCALE);
|
||||
PAGE_HEIGHT = (int) ((PAGE_HEIGHT_UNSCALED - (PAGE_PADDING_TOP + PAGE_PADDING_BOT + PAGE_MARGIN + PAGE_MARGIN)) / PAGE_SCALE);
|
||||
}
|
||||
|
||||
public GuiBook(BookData book, StatFileWriter statFile, @Nullable ItemStack item) {
|
||||
public GuiBook(BookData book, StatisticsManager statisticsManager, @Nullable ItemStack item) {
|
||||
this.book = book;
|
||||
this.item = item;
|
||||
|
||||
this.statFile = statFile;
|
||||
this.statisticsManager = statisticsManager;
|
||||
this.mc = Minecraft.getMinecraft();
|
||||
this.fontRendererObj = mc.fontRendererObj;
|
||||
init();
|
||||
@@ -262,8 +261,8 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
GlStateManager.color(1F, 1F, 1F, 1F);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
if((page < book.getFullPageCount(statFile) - 1 || book.getPageCount(statFile) % 2 != 0) && page < book
|
||||
.getFullPageCount(statFile)) {
|
||||
if((page < book.getFullPageCount(statisticsManager) - 1 || book.getPageCount(statisticsManager) % 2 != 0) && page < book
|
||||
.getFullPageCount(statisticsManager)) {
|
||||
drawModalRectWithCustomSizedTexture(width / 2, height / 2 - PAGE_HEIGHT_UNSCALED / 2, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, PAGE_WIDTH_UNSCALED, PAGE_HEIGHT_UNSCALED, TEX_SIZE, TEX_SIZE);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -326,7 +325,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
bookPage = (page - 2) / 2 + 1;
|
||||
}
|
||||
|
||||
if(bookPage >= -1 && bookPage < book.getFullPageCount(statFile)) {
|
||||
if(bookPage >= -1 && bookPage < book.getFullPageCount(statisticsManager)) {
|
||||
if(returner) {
|
||||
oldPage = this.page;
|
||||
}
|
||||
@@ -393,14 +392,14 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
}
|
||||
|
||||
if(page == 0) {
|
||||
PageData page = book.findPage(0, statFile);
|
||||
PageData page = book.findPage(0, statisticsManager);
|
||||
|
||||
if(page != null) {
|
||||
page.content.build(book, rightElements, false);
|
||||
}
|
||||
} else {
|
||||
PageData leftPage = book.findPage((page - 1) * 2 + 1, statFile);
|
||||
PageData rightPage = book.findPage((page - 1) * 2 + 2, statFile);
|
||||
PageData leftPage = book.findPage((page - 1) * 2 + 1, statisticsManager);
|
||||
PageData rightPage = book.findPage((page - 1) * 2 + 2, statisticsManager);
|
||||
|
||||
if(leftPage != null) {
|
||||
leftPage.content.build(book, leftElements, false);
|
||||
@@ -423,7 +422,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
super.initGui();
|
||||
|
||||
if(loadingAchievements) {
|
||||
this.mc.getNetHandler().addToSendQueue(new CPacketClientStatus(CPacketClientStatus.State.REQUEST_STATS));
|
||||
this.mc.getConnection().sendPacket(new CPacketClientStatus((CPacketClientStatus.State.REQUEST_STATS)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -457,7 +456,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
}
|
||||
|
||||
previousArrow.visible = page != -1;
|
||||
nextArrow.visible = page < book.getFullPageCount(statFile) - (book.getPageCount(statFile) % 2 != 0 ? 0 : 1);
|
||||
nextArrow.visible = page < book.getFullPageCount(statisticsManager) - (book.getPageCount(statisticsManager) % 2 != 0 ? 0 : 1);
|
||||
backArrow.visible = oldPage >= -1;
|
||||
|
||||
if(page == -1) {
|
||||
@@ -480,7 +479,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
loadingAchievements = false;
|
||||
|
||||
initGui();
|
||||
openPage(book.findPageNumber(BookHelper.getSavedPage(item), statFile));
|
||||
openPage(book.findPageNumber(BookHelper.getSavedPage(item), statisticsManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -490,7 +489,7 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
}
|
||||
|
||||
if(button instanceof GuiBookmark) {
|
||||
openPage(book.findPageNumber(((GuiBookmark) button).data.page, statFile));
|
||||
openPage(book.findPageNumber(((GuiBookmark) button).data.page, statisticsManager));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -502,8 +501,8 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
}
|
||||
} else if(button == nextArrow) {
|
||||
page++;
|
||||
if(page > book.getFullPageCount(statFile) - (book.getPageCount(statFile) % 2 != 0 ? 0 : 1)) {
|
||||
page = book.getFullPageCount(statFile) - 1;
|
||||
if(page > book.getFullPageCount(statisticsManager) - (book.getPageCount(statisticsManager) % 2 != 0 ? 0 : 1)) {
|
||||
page = book.getFullPageCount(statisticsManager) - 1;
|
||||
}
|
||||
} else if(button == backArrow) {
|
||||
if(oldPage >= -1) {
|
||||
@@ -572,10 +571,10 @@ public class GuiBook extends GuiScreen implements IProgressMeter {
|
||||
return;
|
||||
}
|
||||
|
||||
PageData page = this.page == 0 ? book.findPage(0, statFile) : book.findPage((this.page - 1) * 2 + 1, statFile);
|
||||
PageData page = this.page == 0 ? book.findPage(0, statisticsManager) : book.findPage((this.page - 1) * 2 + 1, statisticsManager);
|
||||
|
||||
if(page == null) {
|
||||
page = book.findPage((this.page - 1) * 2 + 2, statFile);
|
||||
page = book.findPage((this.page - 1) * 2 + 2, statisticsManager);
|
||||
}
|
||||
|
||||
if(this.page == -1) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package slimeknights.mantle.client.gui.book.element;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -29,7 +28,7 @@ public class ElementSection extends SizedBookElement {
|
||||
|
||||
@Override
|
||||
public void draw(int mouseX, int mouseY, float partialTicks, FontRenderer fontRenderer) {
|
||||
boolean unlocked = section.isUnlocked(parent.statFile);
|
||||
boolean unlocked = section.isUnlocked(parent.statisticsManager);
|
||||
boolean hover = isHovered(mouseX, mouseY);
|
||||
|
||||
if(section.icon != null) {
|
||||
@@ -80,7 +79,7 @@ public class ElementSection extends SizedBookElement {
|
||||
if(section != null && isHovered(mouseX, mouseY)) {
|
||||
List<String> text = new ArrayList<>();
|
||||
text.add(section.getTitle());
|
||||
if(!section.isUnlocked(parent.statFile)) {
|
||||
if(!section.isUnlocked(parent.statisticsManager)) {
|
||||
text.add(TextFormatting.RED + "Locked");
|
||||
text.add("Requirements:");
|
||||
|
||||
@@ -88,7 +87,7 @@ public class ElementSection extends SizedBookElement {
|
||||
Achievement achievement = SectionData.findAchievement(requirement);
|
||||
if(achievement != null) {
|
||||
text.add((SectionData
|
||||
.requirementSatisfied(requirement, parent.statFile) ? TextFormatting.GREEN : TextFormatting.RED) + TextFormatting
|
||||
.requirementSatisfied(requirement, parent.statisticsManager) ? TextFormatting.GREEN : TextFormatting.RED) + TextFormatting
|
||||
.getTextWithoutFormattingCodes(achievement.getStatName().getFormattedText()));
|
||||
}
|
||||
}
|
||||
@@ -99,8 +98,8 @@ public class ElementSection extends SizedBookElement {
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if(mouseButton == 0 && section != null && section.isUnlocked(parent.statFile) && isHovered(mouseX, mouseY)) {
|
||||
parent.openPage(parent.book.getFirstPageNumber(section, parent.statFile));
|
||||
if(mouseButton == 0 && section != null && section.isUnlocked(parent.statisticsManager) && isHovered(mouseX, mouseY)) {
|
||||
parent.openPage(parent.book.getFirstPageNumber(section, parent.statisticsManager));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -292,7 +292,7 @@ public class ElementStructure extends SizedBookElement {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiomeGenForCoords(BlockPos pos) {
|
||||
public Biome getBiome(BlockPos blockPos) {
|
||||
return Biomes.JUNGLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
}
|
||||
}
|
||||
|
||||
public void writeCustomNBT(NBTTagCompound tags) {
|
||||
public NBTTagCompound writeCustomNBT(NBTTagCompound tags) {
|
||||
tags.setBoolean("hasMaster", this.hasMaster);
|
||||
if(this.hasMaster) {
|
||||
tags.setInteger("xCenter", this.master.getX());
|
||||
@@ -122,6 +122,7 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
tags.setString("MasterBlockName", GameData.getBlockRegistry().getNameForObject(this.masterBlock).toString());
|
||||
tags.setInteger("masterState", Block.getStateId(this.state));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,17 +132,17 @@ public class MultiServantLogic extends TileEntity implements IServantLogic {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
this.writeCustomNBT(tags);
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tags) {
|
||||
tags = super.writeToNBT(tags);
|
||||
return this.writeCustomNBT(tags);
|
||||
}
|
||||
|
||||
/* Packets */
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
public NBTTagCompound getUpdateTag() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.writeCustomNBT(tag);
|
||||
return new SPacketUpdateTileEntity(this.pos, 1, tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -216,7 +216,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tags) {
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound tags) {
|
||||
super.writeToNBT(tags);
|
||||
|
||||
tags.setInteger("InventorySize", inventory.length);
|
||||
@@ -226,6 +226,7 @@ public class TileInventory extends TileEntity implements IInventory {
|
||||
if(this.hasCustomName()) {
|
||||
tags.setString("CustomName", this.inventoryTitle);
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
/** Writes the contents of the inventory to the tag */
|
||||
|
||||
Reference in new issue
Block a user