mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
test for somewhat dynamic guide books
This commit is contained in:
parent
031414d175
commit
eeeb208879
@ -34,6 +34,8 @@ public class FuelHandler implements IFuelHandler {
|
||||
return 1600;
|
||||
if(fuel.getItem() == ModItems.coke)
|
||||
return 3200;
|
||||
if(fuel.getItem() == ModItems.book_guide)
|
||||
return 800;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1537,6 +1537,8 @@ public class GUIHandler implements IGuiHandler {
|
||||
return new GUIScreenBobmazon(player, BobmazonOfferFactory.getOffers(player.getHeldItem()));
|
||||
case ModItems.guiID_item_book:
|
||||
return new GUIBook(player.inventory);
|
||||
case ModItems.guiID_item_guide:
|
||||
return new GUIIScreenGuide(player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -240,10 +240,15 @@ public abstract class WeaponAbility {
|
||||
|
||||
if(living instanceof EntitySkeleton) {
|
||||
|
||||
if(((EntitySkeleton)living).getSkeletonType() == 0)
|
||||
if(((EntitySkeleton)living).getSkeletonType() == 0) {
|
||||
living.entityDropItem(new ItemStack(Items.skull, 1, 0), 0.0F);
|
||||
else
|
||||
living.entityDropItem(new ItemStack(ModItems.cell_antimatter), 0.0F);
|
||||
} else {
|
||||
|
||||
if(world.rand.nextInt(20) == 0)
|
||||
living.entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F);
|
||||
else
|
||||
living.entityDropItem(new ItemStack(Items.coal, 1, 3), 0.0F);
|
||||
}
|
||||
|
||||
} else if(living instanceof EntityZombie) {
|
||||
living.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
|
||||
|
||||
@ -111,6 +111,7 @@ public class ShredderRecipes {
|
||||
ShredderRecipes.setRecipe(ModBlocks.brick_obsidian, new ItemStack(ModBlocks.gravel_obsidian, 1));
|
||||
ShredderRecipes.setRecipe(Blocks.obsidian, new ItemStack(ModBlocks.gravel_obsidian, 1));
|
||||
ShredderRecipes.setRecipe(Blocks.stone, new ItemStack(Blocks.gravel, 1));
|
||||
ShredderRecipes.setRecipe(ModBlocks.ore_oil_empty, new ItemStack(Blocks.gravel, 1));
|
||||
ShredderRecipes.setRecipe(Blocks.cobblestone, new ItemStack(Blocks.gravel, 1));
|
||||
ShredderRecipes.setRecipe(Blocks.stonebrick, new ItemStack(Blocks.gravel, 1));
|
||||
ShredderRecipes.setRecipe(Blocks.gravel, new ItemStack(Blocks.sand, 1));
|
||||
|
||||
216
src/main/java/com/hbm/inventory/gui/GUIIScreenGuide.java
Normal file
216
src/main/java/com/hbm/inventory/gui/GUIIScreenGuide.java
Normal file
@ -0,0 +1,216 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.items.tool.ItemGuideBook.BookType;
|
||||
import com.hbm.items.tool.ItemGuideBook.GuidePage;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.util.I18nUtil;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIIScreenGuide extends GuiScreen {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/book/book.png");
|
||||
private static final ResourceLocation texture_cover = new ResourceLocation(RefStrings.MODID + ":textures/gui/book/book_cover.png");
|
||||
|
||||
protected int xSize;
|
||||
protected int ySize;
|
||||
protected int guiLeft;
|
||||
protected int guiTop;
|
||||
|
||||
private BookType type;
|
||||
|
||||
int page;
|
||||
int maxPage;
|
||||
|
||||
public GUIIScreenGuide(EntityPlayer player) {
|
||||
|
||||
type = BookType.values()[player.getHeldItem().getItemDamage()];
|
||||
|
||||
page = -1;
|
||||
maxPage = (int)Math.ceil(type.pages.size() / 2D) - 1;
|
||||
|
||||
this.xSize = 272;
|
||||
this.ySize = 182;
|
||||
}
|
||||
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
this.guiLeft = (this.width - this.xSize) / 2;
|
||||
this.guiTop = (this.height - this.ySize) / 2;
|
||||
}
|
||||
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
this.drawDefaultBackground();
|
||||
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
if(page < 0) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture_cover);
|
||||
func_146110_a(guiLeft, guiTop, 0, 0, xSize, ySize, 512, 512);
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
func_146110_a(guiLeft, guiTop, 0, 0, xSize, ySize, 512, 512);
|
||||
|
||||
boolean overLeft = i >= guiLeft + 24 && i < guiLeft + 42 && j >= guiTop + 155 && j < guiTop + 165;
|
||||
boolean overRight = i >= guiLeft + 230 && i < guiLeft + 248 && j >= guiTop + 155 && j < guiTop + 165;
|
||||
|
||||
if(this.page > 0) {
|
||||
|
||||
if(!overLeft)
|
||||
func_146110_a(guiLeft + 24, guiTop + 155, 3, 207, 18, 10, 512, 512);
|
||||
else
|
||||
func_146110_a(guiLeft + 24, guiTop + 155, 26, 207, 18, 10, 512, 512);
|
||||
}
|
||||
|
||||
if(this.page < this.maxPage) {
|
||||
|
||||
if(!overRight)
|
||||
func_146110_a(guiLeft + 230, guiTop + 155, 3, 194, 18, 10, 512, 512);
|
||||
else
|
||||
func_146110_a(guiLeft + 230, guiTop + 155, 26, 194, 18, 10, 512, 512);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawImage(int x, int y, int dimX, int dimY) {
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.setBrightness(240);
|
||||
tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.addVertexWithUV(x, y + dimY, 0.0D, 0, 1);
|
||||
tessellator.addVertexWithUV(x + dimX, y + dimY, 0.0D, 1, 1);
|
||||
tessellator.addVertexWithUV(x + dimX, y, 0.0D, 1, 0);
|
||||
tessellator.addVertexWithUV(x, y, 0.0D, 0, 0);
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
|
||||
if(this.page < 0) {
|
||||
|
||||
float scale = 2;
|
||||
String cover = "HOW 2 SEX";
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(scale, scale, 1F);
|
||||
this.fontRendererObj.drawString(cover, (int)((guiLeft + ((this.xSize / 2) - (this.fontRendererObj.getStringWidth(cover) / 2 * scale))) / scale), (int)((guiTop + 50) / scale), 0xfece00);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int sideOffset = 130;
|
||||
|
||||
for(int i = 0; i < 2; i++) {
|
||||
|
||||
int defacto = this.page * 2 + i;
|
||||
|
||||
if(defacto < this.type.pages.size()) {
|
||||
|
||||
GuidePage page = this.type.pages.get(defacto);
|
||||
|
||||
float scale = page.scale;
|
||||
String text = I18nUtil.resolveKey(page.text);
|
||||
int width = 100;
|
||||
|
||||
int widthScaled = (int) (width * scale);
|
||||
List<String> lines = new ArrayList();
|
||||
String[] words = text.split(" ");
|
||||
|
||||
lines.add(words[0]);
|
||||
int indent = this.fontRendererObj.getStringWidth(words[0]);
|
||||
|
||||
for(int w = 1; w < words.length; w++) {
|
||||
|
||||
indent += this.fontRendererObj.getStringWidth(" " + words[w]);
|
||||
|
||||
if(indent <= widthScaled) {
|
||||
String last = lines.get(lines.size() - 1);
|
||||
lines.set(lines.size() - 1, last += (" " + words[w]));
|
||||
} else {
|
||||
lines.add(words[w]);
|
||||
indent = this.fontRendererObj.getStringWidth(words[w]);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1F/scale, 1F/scale, 1F);
|
||||
|
||||
float topOffset = page.title == null ? 0 : 6 / page.titleScale;
|
||||
|
||||
for(int l = 0; l < lines.size(); l++) {
|
||||
this.fontRendererObj.drawString(lines.get(l), (int)((guiLeft + 20 + i * sideOffset) * scale), (int)((guiTop + 30 + topOffset) * scale + (12 * l)), 4210752);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
if(page.title != null) {
|
||||
|
||||
float tScale = page.titleScale;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(1F/tScale, 1F/tScale, 1F);
|
||||
this.fontRendererObj.drawString(page.title, (int)((guiLeft + 20 + i * sideOffset + ((width / 2) - (this.fontRendererObj.getStringWidth(page.title) / 2 / tScale))) * tScale), (int)((guiTop + 20) * tScale), page.titleColor);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
if(page.image != null) {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(page.image);
|
||||
|
||||
int ix = page.x;
|
||||
|
||||
if(ix == -1)
|
||||
ix = width / 2 - page.sizeX / 2;
|
||||
|
||||
drawImage(guiLeft + 20 + ix + sideOffset * i, guiTop + page.y, page.sizeX, page.sizeY);
|
||||
}
|
||||
|
||||
String pageLabel = (defacto + 1) + "/" + (maxPage * 2 + 1);
|
||||
this.fontRendererObj.drawString(pageLabel, guiLeft + 44 + i * 185 - i * this.fontRendererObj.getStringWidth(pageLabel), guiTop + 156, 4210752);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void mouseClicked(int i, int j, int k) {
|
||||
|
||||
if(page < 0) {
|
||||
page = 0;
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean overLeft = i >= guiLeft + 24 && i < guiLeft + 42 && j >= guiTop + 155 && j < guiTop + 165;
|
||||
boolean overRight = i >= guiLeft + 230 && i < guiLeft + 248 && j >= guiTop + 155 && j < guiTop + 165;
|
||||
|
||||
if(overLeft && page > 0) {
|
||||
page--;
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
|
||||
if(overRight && page < maxPage) {
|
||||
page++;
|
||||
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2051,6 +2051,8 @@ public class ModItems {
|
||||
public static Item record_vc;
|
||||
public static Item record_glass;
|
||||
|
||||
public static Item book_guide;
|
||||
|
||||
public static Item polaroid;
|
||||
public static Item glitch;
|
||||
public static Item letter;
|
||||
@ -2182,6 +2184,7 @@ public class ModItems {
|
||||
public static final int guiID_item_bobmazon = 10103;
|
||||
public static final int guiID_item_sat_coord = 10104;
|
||||
public static final int guiID_item_book = 10105;
|
||||
public static final int guiID_item_guide = 10106;
|
||||
|
||||
public static Item mysteryshovel;
|
||||
public static Item memory;
|
||||
@ -4473,6 +4476,8 @@ public class ModItems {
|
||||
record_ss = new ItemModRecord("ss").setUnlocalizedName("record_ss").setCreativeTab(CreativeTabs.tabMisc).setTextureName(RefStrings.MODID + ":record_ss");
|
||||
record_vc = new ItemModRecord("vc").setUnlocalizedName("record_vc").setCreativeTab(CreativeTabs.tabMisc).setTextureName(RefStrings.MODID + ":record_vc");
|
||||
record_glass = new ItemModRecord("glass").setUnlocalizedName("record_glass").setCreativeTab(null).setTextureName(RefStrings.MODID + ":record_glass");
|
||||
|
||||
book_guide = new ItemGuideBook().setUnlocalizedName("book_guide").setCreativeTab(null).setTextureName(RefStrings.MODID + ":book_guide");
|
||||
|
||||
polaroid = new ItemPolaroid().setUnlocalizedName("polaroid").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":polaroid_" + MainRegistry.polaroidID);
|
||||
glitch = new ItemGlitch().setUnlocalizedName("glitch").setMaxStackSize(1).setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":glitch_" + MainRegistry.polaroidID);
|
||||
@ -6708,6 +6713,9 @@ public class ModItems {
|
||||
GameRegistry.registerItem(record_vc, record_vc.getUnlocalizedName());
|
||||
GameRegistry.registerItem(record_glass, record_glass.getUnlocalizedName());
|
||||
|
||||
//wow we're far down the item registry, is this the cellar?
|
||||
GameRegistry.registerItem(book_guide, book_guide.getUnlocalizedName());
|
||||
|
||||
//Technical Items
|
||||
GameRegistry.registerItem(smoke1, smoke1.getUnlocalizedName());
|
||||
GameRegistry.registerItem(smoke2, smoke2.getUnlocalizedName());
|
||||
|
||||
100
src/main/java/com/hbm/items/tool/ItemGuideBook.java
Normal file
100
src/main/java/com/hbm/items/tool/ItemGuideBook.java
Normal file
@ -0,0 +1,100 @@
|
||||
package com.hbm.items.tool;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.main.MainRegistry;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemGuideBook extends Item {
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
|
||||
if(world.isRemote)
|
||||
player.openGui(MainRegistry.instance, ModItems.guiID_item_guide, world, 0, 0, 0);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { }
|
||||
|
||||
public enum BookType {
|
||||
|
||||
TEST(statFacTest());
|
||||
|
||||
public List<GuidePage> pages;
|
||||
|
||||
private BookType(List<GuidePage> pages) {
|
||||
this.pages = pages;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<GuidePage> statFacTest() {
|
||||
|
||||
List<GuidePage> pages = new ArrayList();
|
||||
pages.add(new GuidePage("book.test.page1").addTitle("Title LMAO", 0x800000, 1F).setScale(2F).addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/smileman.png"), 100, 40, 40));
|
||||
pages.add(new GuidePage("book.test.page1").addTitle("LA SEXO", 0x800000, 0.5F).setScale(1.75F).addImage(new ResourceLocation(RefStrings.MODID + ":textures/gui/book/smileman.png"), 100, 40, 40));
|
||||
pages.add(new GuidePage("test test"));
|
||||
pages.add(new GuidePage("test test test"));
|
||||
pages.add(new GuidePage("test test"));
|
||||
pages.add(new GuidePage("test test test"));
|
||||
pages.add(new GuidePage("test test"));
|
||||
return pages;
|
||||
}
|
||||
|
||||
public static class GuidePage {
|
||||
|
||||
public String title;
|
||||
public int titleColor;
|
||||
public float titleScale;
|
||||
public String text;
|
||||
public ResourceLocation image;
|
||||
public float scale = 1F;
|
||||
public int x;
|
||||
public int y;
|
||||
public int sizeX;
|
||||
public int sizeY;
|
||||
|
||||
public GuidePage() { }
|
||||
|
||||
public GuidePage(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public GuidePage setScale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuidePage addTitle(String title, int color, float scale) {
|
||||
this.title = title;
|
||||
this.titleColor = color;
|
||||
this.titleScale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuidePage addImage(ResourceLocation image, int x, int y, int sizeX, int sizeY) {
|
||||
|
||||
this.image = image;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.sizeX = sizeX;
|
||||
this.sizeY = sizeY;
|
||||
return this;
|
||||
}
|
||||
|
||||
//if the x-coord is -1 then it will automatically try to center the image horizontally
|
||||
public GuidePage addImage(ResourceLocation image, int y, int sizeX, int sizeY) {
|
||||
return addImage(image, -1, y, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ public class TileEntityMachineMissileAssembly extends TileEntity implements ISid
|
||||
ItemMissile part = (ItemMissile)slots[3].getItem();
|
||||
ItemMissile fuselage = (ItemMissile)slots[2].getItem();
|
||||
|
||||
if(part.top == fuselage.bottom)
|
||||
if(part.top == fuselage.bottom && part.type == PartType.FINS)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -86,6 +86,8 @@ armor.thermal=Thermal Sight
|
||||
armor.threshold=Damage threshold of %s
|
||||
armor.vats=Enemy HUD
|
||||
|
||||
book.test.page1=This is a test to demonstrate the e[B]ic linewrap feature of these books. The font scale is customizable and the linewrap adjusts accordingly, which makes writing new pages really easy.
|
||||
|
||||
chem.ASPHALT=Asphalt Production
|
||||
chem.BALEFIRE=BF Rocket Fuel Mixing
|
||||
chem.BP_BIOFUEL=Biofuel Transesterification
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
src/main/resources/assets/hbm/textures/gui/book/smileman.png
Normal file
BIN
src/main/resources/assets/hbm/textures/gui/book/smileman.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
BIN
src/main/resources/assets/hbm/textures/items/book_guide.png
Normal file
BIN
src/main/resources/assets/hbm/textures/items/book_guide.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 319 B |
Loading…
x
Reference in New Issue
Block a user