Skip to content

Commit

Permalink
Update books to 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Mar 25, 2016
1 parent 3f5459c commit 752c2b3
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 43 deletions.
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -145,7 +146,7 @@ public static BookData getBook(String name) {
}

public static void updateSavedPage(EntityPlayer player, ItemStack item, String page) {
if (player.getHeldItem() == null)
if (player.getHeldItem(EnumHand.MAIN_HAND) == null)
return;

BookHelper.writeSavedPage(item, page);
Expand Down
Expand Up @@ -108,7 +108,7 @@ public static Achievement findAchievement(String name) {
if (name == null || name.isEmpty())
return null;

for (Achievement achievement : AchievementList.achievementList) {
for (Achievement achievement : AchievementList.ACHIEVEMENTS) {
if (achievement.statId.equals(name))
return achievement;
}
Expand Down
Expand Up @@ -2,7 +2,8 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.MathHelper;

import static slimeknights.mantle.client.gui.book.Textures.TEX_BOX;

public class BoxRenderer {
Expand Down Expand Up @@ -45,7 +46,8 @@ public static int[] getTextureMatrixCoords(int index, int sprW, int sprH, int se
int totalWidth = segW * 3 + segGW * 2;
int totalHeight = segH * 3 + segGH * 2;

return getTextureMatrixCoords((index % (256 / sprW) * sprW) + (sprW / 2 - totalWidth / 2), (MathHelper.floor_float(index / (256F / sprH)) * sprH) + (sprH / 2 - totalHeight / 2), segW, segH, segGW, segGH, segId);
return getTextureMatrixCoords((index % (256 / sprW) * sprW) + (sprW / 2 - totalWidth / 2), (MathHelper
.floor_float(index / (256F / sprH)) * sprH) + (sprH / 2 - totalHeight / 2), segW, segH, segGW, segGH, segId);
}

public static int[] getTextureMatrixCoords(int u, int v, int segW, int segH, int segGW, int segGH, int segId) {
Expand Down
Expand Up @@ -12,7 +12,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.C16PacketClientStatus;
import net.minecraft.network.play.client.CPacketClientStatus;
import net.minecraft.stats.StatFileWriter;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -333,7 +333,7 @@ public void initGui() {
super.initGui();

if (loadingAchievements) {
this.mc.getNetHandler().addToSendQueue(new C16PacketClientStatus(C16PacketClientStatus.EnumState.REQUEST_STATS));
this.mc.getNetHandler().addToSendQueue(new CPacketClientStatus(CPacketClientStatus.State.REQUEST_STATS));
return;
}

Expand Down
Expand Up @@ -4,9 +4,9 @@
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import slimeknights.mantle.client.book.data.element.TextData;
Expand Down Expand Up @@ -43,18 +43,18 @@ public static String drawText(int x, int y, int boxWidth, int boxHeight, TextDat

String modifiers = "";

modifiers += EnumChatFormatting.getValueByName(item.color);
modifiers += TextFormatting.getValueByName(item.color);

if (item.bold)
modifiers += EnumChatFormatting.BOLD;
modifiers += TextFormatting.BOLD;
if (item.italic)
modifiers += EnumChatFormatting.ITALIC;
modifiers += TextFormatting.ITALIC;
if (item.underlined)
modifiers += EnumChatFormatting.UNDERLINE;
modifiers += TextFormatting.UNDERLINE;
if (item.strikethrough)
modifiers += EnumChatFormatting.STRIKETHROUGH;
modifiers += TextFormatting.STRIKETHROUGH;
if (item.obfuscated)
modifiers += EnumChatFormatting.OBFUSCATED;
modifiers += TextFormatting.OBFUSCATED;

String[] split = cropStringBySize(item.text, modifiers, boxWidth, boxHeight - (atY - y), boxWidth - (atX - x), fr, item.scale);

Expand Down Expand Up @@ -131,7 +131,7 @@ public static String drawText(int x, int y, int boxWidth, int boxHeight, TextDat
drawLabel[i] = label[i];

drawLabel[drawLabel.length > 1 ? drawLabel.length - 2 : 0] = "";
drawLabel[drawLabel.length - 1] = EnumChatFormatting.GRAY + "Action: " + action;
drawLabel[drawLabel.length - 1] = TextFormatting.GRAY + "Action: " + action;
}

if (drawLabel != null) {
Expand Down Expand Up @@ -253,12 +253,12 @@ private static void drawGradientRect(int left, int top, int right, int bottom, i
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.shadeModel(7425);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
worldrenderer.pos((double) right, (double) top, 0D).color(f1, f2, f3, f).endVertex();
worldrenderer.pos((double) left, (double) top, 0D).color(f1, f2, f3, f).endVertex();
worldrenderer.pos((double) left, (double) bottom, 0D).color(f5, f6, f7, f4).endVertex();
worldrenderer.pos((double) right, (double) bottom, 0D).color(f5, f6, f7, f4).endVertex();
VertexBuffer vertexBuffer = tessellator.getBuffer();
vertexBuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
vertexBuffer.pos((double) right, (double) top, 0D).color(f1, f2, f3, f).endVertex();
vertexBuffer.pos((double) left, (double) top, 0D).color(f1, f2, f3, f).endVertex();
vertexBuffer.pos((double) left, (double) bottom, 0D).color(f5, f6, f7, f4).endVertex();
vertexBuffer.pos((double) right, (double) bottom, 0D).color(f5, f6, f7, f4).endVertex();
tessellator.draw();
GlStateManager.shadeModel(7424);
GlStateManager.enableAlpha();
Expand Down
Expand Up @@ -7,7 +7,7 @@
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import slimeknights.mantle.client.gui.book.GuiBook;
Expand Down Expand Up @@ -44,7 +44,7 @@ public void renderToolTip(FontRenderer fontRenderer, ItemStack stack, int x, int
if (i == 0) {
list.set(i, stack.getRarity().rarityColor + list.get(i));
} else {
list.set(i, EnumChatFormatting.GRAY + list.get(i));
list.set(i, TextFormatting.GRAY + list.get(i));
}
}

Expand Down
Expand Up @@ -5,7 +5,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.stats.Achievement;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.text.TextFormatting;

import slimeknights.mantle.client.book.data.SectionData;

public class ElementSection extends BookElement {
Expand Down Expand Up @@ -50,13 +51,14 @@ public void draw(int mouseX, int mouseY, float partialTicks) {
public void drawOverlay(int mouseX, int mouseY, float partialTicks) {
if (section != null && !section.isUnlocked(parent.statFile) && mouseX > x && mouseY > y && mouseX < x + WIDTH && mouseY < y + HEIGHT) {
List<String> l = new ArrayList<>();
l.add(EnumChatFormatting.RED + "Locked");
l.add(TextFormatting.RED + "Locked");
l.add("Requirements:");

for (String requirement : section.requirements) {
Achievement achievement = SectionData.findAchievement(requirement);
if (achievement != null)
l.add((SectionData.requirementSatisfied(requirement, parent.statFile) ? EnumChatFormatting.GREEN : EnumChatFormatting.RED) + EnumChatFormatting.getTextWithoutFormattingCodes(achievement.getStatName().getFormattedText()));
l.add((SectionData.requirementSatisfied(requirement, parent.statFile) ? TextFormatting.GREEN : TextFormatting.RED) + TextFormatting
.getTextWithoutFormattingCodes(achievement.getStatName().getFormattedText()));
}

drawHoveringText(l, mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
Expand Down
Expand Up @@ -8,26 +8,35 @@
import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.model.IBakedModel;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTException;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.common.registry.GameData;
import net.minecraftforge.fml.common.registry.GameRegistry;

import org.lwjgl.opengl.GL11;
import slimeknights.mantle.client.book.data.element.BlockData;
import slimeknights.mantle.client.book.data.element.ItemStackData;

public class ElementStructure extends SizedBookElement {

private BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
private ItemColors itemColors = Minecraft.getMinecraft().getItemColors();
private BlockAccess world;
private float scale = 50.0F;
private float xTranslate = 0F;
Expand Down Expand Up @@ -64,7 +73,7 @@ public void draw(int mouseX, int mouseY, float partialTicks) {

GlStateManager.translate(xTranslate, yTranslate, 500F);

GlStateManager.cullFace(GL11.GL_FRONT);
GlStateManager.cullFace(GlStateManager.CullFace.FRONT);

// Prepare stencil
GL11.glEnable(GL11.GL_STENCIL_TEST);
Expand Down Expand Up @@ -107,7 +116,7 @@ public void draw(int mouseX, int mouseY, float partialTicks) {
for (int z = 0; z < world.getDepth(); z++) {
BlockPos pos = new BlockPos(x, y, z);
IBlockState state = world.getBlockState(pos);
IBakedModel model = mc.getBlockRendererDispatcher().getModelFromBlockState(world.getBlockState(pos), world, pos);
IBakedModel model = mc.getBlockRendererDispatcher().getModelForState(state);

Block block = state.getBlock();

Expand All @@ -122,7 +131,7 @@ public void draw(int mouseX, int mouseY, float partialTicks) {
if (block == null)
return;

int color = block.colorMultiplier(world, pos, 0);
int color = blockColors.colorMultiplier(state, world, pos, 0);
float red = (color >> 16 & 255) / 255.0F;
float green = (color >> 8 & 255) / 255.0F;
float blue = (color & 255) / 255.0F;
Expand All @@ -133,9 +142,9 @@ public void draw(int mouseX, int mouseY, float partialTicks) {
GlStateManager.translate(x, world.getHeight() - y, z);
BlockModelRenderer render = mc.getBlockRendererDispatcher().getBlockModelRenderer();

int i = block.getRenderColor(block.getStateForEntityRender(state));
block.setBlockBoundsBasedOnState(world, pos);

// 1.9 remove this?
//block.setBlockBoundsBasedOnState(world, pos);
int i = blockColors.colorMultiplier(state, world, pos, 0);
GlStateManager.rotate(90F, 0, 1, 0);

if (EntityRenderer.anaglyphEnable) {
Expand All @@ -146,7 +155,7 @@ public void draw(int mouseX, int mouseY, float partialTicks) {
float g = (float) (i >> 8 & 255) / 255.0F;
float b = (float) (i & 255) / 255.0F;

render.renderModelBrightnessColor(model, block.colorMultiplier(world, pos, 0), r, g, b);
render.renderModelBrightnessColor(model, blockColors.colorMultiplier(state, world, pos, 0), r, g, b);

GlStateManager.color(1F, 1F, 1F);
GlStateManager.popMatrix();
Expand All @@ -156,7 +165,7 @@ public void draw(int mouseX, int mouseY, float partialTicks) {
}

GlStateManager.disableLighting();
GlStateManager.cullFace(GL11.GL_BACK);
GlStateManager.cullFace(GlStateManager.CullFace.BACK);
GL11.glDisable(GL11.GL_STENCIL_TEST);
GlStateManager.popMatrix();
}
Expand All @@ -173,7 +182,7 @@ private void setupGuiTransform(int xPosition, int yPosition) {
GlStateManager.enableLighting();
}

private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int color, BlockPos pos) {
private void renderQuads(VertexBuffer renderer, List<BakedQuad> quads, int color, BlockPos pos) {
boolean flag = color == -1;
int i = 0;

Expand All @@ -183,7 +192,7 @@ private void renderQuads(WorldRenderer renderer, List<BakedQuad> quads, int colo

if (flag && bakedquad.hasTintIndex()) {
Block block = world.getBlockState(pos).getBlock();
k = block.colorMultiplier(world, pos, 0);
k = blockColors.colorMultiplier(world.getBlockState(pos), world, pos, 0);

if (EntityRenderer.anaglyphEnable) {
k = TextureUtil.anaglyphColor(k);
Expand Down Expand Up @@ -275,7 +284,7 @@ public boolean isAirBlock(BlockPos pos) {

@Override
public BiomeGenBase getBiomeGenForCoords(BlockPos pos) {
return BiomeGenBase.jungle;
return Biomes.jungle;
}

@Override
Expand All @@ -289,7 +298,7 @@ public int getStrongPower(BlockPos pos, EnumFacing direction) {
return 0;

IBlockState iblockstate = this.getBlockState(pos);
return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction);
return iblockstate.getBlock().getStrongPower(iblockstate, this, pos, direction);
}

@Override
Expand All @@ -302,7 +311,7 @@ public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) {
if (!this.isValid(pos))
return _default;

return getBlockState(pos).getBlock().isSideSolid(this, pos, side);
return getBlockState(pos).getBlock().isSideSolid(this.getBlockState(pos), this, pos, side);
}

public boolean isValid(BlockPos pos) {
Expand Down
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.network.NetHandlerPlayServer;
import net.minecraft.util.EnumHand;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import slimeknights.mantle.client.book.BookHelper;
Expand Down Expand Up @@ -32,7 +33,7 @@ public IMessage handleServer(NetHandlerPlayServer netHandler) {
if (netHandler.playerEntity != null && pageName != null) {
EntityPlayer player = netHandler.playerEntity;

ItemStack is = player.getHeldItem();
ItemStack is = player.getHeldItem(EnumHand.MAIN_HAND);

BookHelper.writeSavedPage(is, pageName);
}
Expand Down

0 comments on commit 752c2b3

Please sign in to comment.