Jump to content

Gugu42

Members
  • Posts

    38
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I'm working on the Ratchet & Clank mod !

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Gugu42's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I can get the item to render 2D in inventory, but I can't figure out how to render the .obj via an item model json. I'd rather use code to render my item, but I don't understand how/where can I put OpenGL code to render the obj (I use a lib to load objs which is REALLY convenient for me to use, way more than Forge's OBJLoader (support for UVs < 0 and > 1 especially)) Here's my IPerspectiveModel version: And the .json I use to -try- to load my OBJ : Hopefully I can find a way to render my items via code but at the moment; I am lost! EDIT : Changed "transform" to "display" and it works. However, I'm still interested in loading item obj via code
  2. After converting to IItemHandler (only changing the Inventory class), I don't seem to get any changes from it. I mostly do not understand why it works with the block, and not with the item.
  3. I don't need to save the content of the item's inventory (it is set when you open it), do I still need capabilities ? As far as I understand, those are meant to store data right ?
  4. Alright. Container : GuiHandler : Item : Block : Some of the code is dirty, sorry
  5. Hello everyone! I'm having yet another problem Here's how it goes : I have a block, with a TileEntity and a GUI that is a vendor. It shows 9 items at once, which you can click to select and then buy. The GUI is also open-able with an item, to benefit from remote access to the vendor. Here's the problem : When I open my GUI via the block : When I open the GUI via the item : However, in both cases, I can click on the slots to select the items, which means that the items ARE put in the slot in both GUIs, but they're not drawn on the item version. I have tried disabling the render of the background image in case the items were, for some reason, behind the background, and they are not. Here's the GUI code : package com.gugu42.rcmod.client.gui; import java.io.IOException; import org.lwjgl.opengl.GL11; import com.gugu42.rcmod.ContainerVendor; import com.gugu42.rcmod.RcMod; import com.gugu42.rcmod.capabilities.bolt.BoltProvider; import com.gugu42.rcmod.capabilities.bolt.IBolt; import com.gugu42.rcmod.items.EnumRcWeapons; import com.gugu42.rcmod.items.InventoryGadgetronPDA; import com.gugu42.rcmod.items.ItemRcWeap; import com.gugu42.rcmod.network.packets.PacketRefill; import com.gugu42.rcmod.network.packets.PacketVend; import com.gugu42.rcmod.tileentity.TileEntityVendor; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.I18n; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class GuiVendor extends GuiContainer { private static final ResourceLocation texturepath = new ResourceLocation( "rcmod", "textures/gui/vendor_new.png"); private static final ResourceLocation boltTexturePath = new ResourceLocation( "rcmod", "textures/gui/bolt.png"); private GuiButton buyBtn; private GuiButton exitBtn; private EnumRcWeapons weapons; private EntityPlayer player; private TileEntityVendor tileEntity; private ContainerVendor container; private Minecraft mc; private int selectedWeapon = -1; private int mouseX, mouseY; private ItemStack selectedItem; private ItemRcWeap selectedItemWeap; private EntityItem selectedItemEntity; public float rotation; public int weaponIndex = 1; public int lastID = 0; public int centerID = 1; private long timeOfLastAction; public GuiVendor(InventoryPlayer inventoryPlayer, TileEntityVendor tileEntity, EntityPlayer player, ContainerVendor container, InventoryGadgetronPDA inv) { super(new ContainerVendor(inventoryPlayer, tileEntity, inv)); this.player = player; this.tileEntity = tileEntity; this.container = container; this.mc = Minecraft.getMinecraft(); this.xSize = 256; this.ySize = 190; } @Override public void initGui() { super.initGui(); int posX = (this.width - xSize) / 2; int posY = (this.height - ySize) / 2; this.buttonList.clear(); this.buttonList.add(this.buyBtn = new GuiButton(0, posX + 41, posY + 137, 35, 20, I18n.format("gui.vendor.buy"))); this.buttonList.add(this.exitBtn = new GuiButton(1, posX + 181, posY + 137, 35, 20, I18n.format("gui.vendor.exit"))); timeOfLastAction = System.currentTimeMillis(); } @Override public void updateScreen() { putItemsInSlot(); //If the player idles on the gui, the vendor will say "Come on buddy I ain't got all day" or "Sooo... you gonna buy some or what ?" randomly if(System.currentTimeMillis() - timeOfLastAction >= 15000) { mc.player.playSound(new SoundEvent(new ResourceLocation("rcmod:vendor.speech.wait")), 1.0f, 1.0f); timeOfLastAction = System.currentTimeMillis(); } } public void handleSelectedWeapon() { if (selectedItemEntity != null) { selectedItemEntity.rotationYaw = 0; selectedItemEntity.hoverStart = 0; GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glTranslatef(xSize - 200, ySize - 92, 100); GL11.glScalef(-60f, 60f, 60f); GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(rotation, 0, 1, 0); RenderHelper.enableStandardItemLighting(); if (selectedWeapon >= 0 && selectedItem != null) Minecraft.getMinecraft().getRenderManager().doRenderEntity(selectedItemEntity, 0, -0.23, 0, 0, 0, false); RenderHelper.disableStandardItemLighting(); GL11.glPopMatrix(); rotation -= 1f; if (getItemInInventory(player.inventory, selectedItem.getItem()) == ItemStack.EMPTY) { this.mc.fontRendererObj.drawString( "" + EnumRcWeapons.getPriceFromItem(selectedItem .getItem()), 30, 105, 0xFFFFFF); this.buyBtn.displayString = I18n.format("gui.vendor.buy"); } else { this.mc.fontRendererObj.drawString( "" + getItemInInventory(player.inventory, selectedItem.getItem()).getItemDamage() * selectedItemWeap.getPrice(), 30, 105, 0xFFFFFF); this.buyBtn.displayString = I18n.format("gui.vendor.refill"); } this.buyBtn.enabled = true; GL11.glPushMatrix(); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.getTextureManager().bindTexture(boltTexturePath); GL11.glEnable(GL11.GL_BLEND); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(false); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_ALPHA_TEST); //drawTexturedQuadFit(xSize - 185, ySize - 86, 8, 8, 0); drawModalRectWithCustomSizedTexture(xSize - 185, ySize - 86, 0, 0, 8, 8, 64, 64); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDepthMask(true); GL11.glPopMatrix(); } else { this.buyBtn.enabled = false; } } public void putItemsInSlot() { for (int i = 0; i < 9; i++) { if (EnumRcWeapons.getItemFromID(centerID + i) != null) { this.container.putStackInSlot(i, new ItemStack(EnumRcWeapons .getItemFromID(centerID + i).getWeapon())); lastID = i; } else { if (EnumRcWeapons.getItemFromID(i - lastID) != null) { this.container.putStackInSlot( i, new ItemStack(EnumRcWeapons.getItemFromID( i - lastID).getWeapon())); } } } } @Override public void mouseClicked(int par1, int par2, int par3) throws IOException { super.mouseClicked(par1, par2, par3); for (int i = 0; i < 9; i++) { if (isMouseOverSlot(container.getSlot(i), mouseX, mouseY)) { selectedWeapon = i; selectedItem = container.getSlot(i).getStack(); if (selectedItem != null) { selectedItemEntity = new EntityItem(this.mc.world, 0, 0, 0, selectedItem); selectedItemWeap = (ItemRcWeap) selectedItem.getItem(); } mc.player.playSound(new SoundEvent(new ResourceLocation("rcmod:MenuSelect")), 1.0f, 1.0f); weaponIndex = weaponIndex + i; centerID = EnumRcWeapons.getIDFromItem(selectedItemWeap); timeOfLastAction = System.currentTimeMillis(); //When clicking a weapon, will occassionally say "Oh that's a nice one" or "That's a real beauty" if(mc.world.rand.nextInt(10) == 5) mc.player.playSound(new SoundEvent(new ResourceLocation("rcmod:vendor.speech.weapclicked")), 1.0f, 1.0f); } else { //ok you can happen if you want, but not too much pls } } } @Override public void actionPerformed(GuiButton button) { switch (button.id) { case 0: if (getItemInInventory(player.inventory, selectedItem.getItem()) == ItemStack.EMPTY) { IBolt props = player.getCapability(BoltProvider.BOLT_CAP, null); if (props.getCurrentBolt() > 0) { try { PacketVend packetVend = new PacketVend(centerID); RcMod.rcModPacketHandler.sendToServer(packetVend); } catch (Exception exception) { exception.printStackTrace(); } } } else { ItemRcWeap weap = (ItemRcWeap) selectedItem.getItem(); if (weap.useAmmo) { PacketRefill packet = new PacketRefill(centerID); RcMod.rcModPacketHandler.sendToServer(packet); } } break; case 1: mc.player.playSound(new SoundEvent(new ResourceLocation("rcmod:vendor.exit")), 1.0f, 1.0f); player.closeScreen(); break; default: break; } } public boolean doesGuiPauseGame() { return false; } protected void drawGuiContainerForegroundLayer(int par1, int par2) { mouseX = par1; mouseY = par2; handleSelectedWeapon(); if (selectedItemEntity != null) { //Using this check to be sure that there is an item selecred, cuz that works. this.mc.fontRendererObj.drawString( EnumRcWeapons.getItemFromID(centerID).getName(), 108, 16, 0x00FF00); } } @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glEnable(GL11.GL_BLEND); GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); this.mc.renderEngine.bindTexture(texturepath); int x = (width - xSize) / 2; int y = (height - ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, 256, 256); GL11.glDisable(GL11.GL_BLEND); } private boolean isMouseOverSlot(Slot par1Slot, int par2, int par3) { return this.isPointInRegion(par1Slot.xPos, par1Slot.yPos, 16, 16, par2, par3); } private int getSlotContainingItem(InventoryPlayer inventory, Item item) { for (int i = 0; i < inventory.mainInventory.size(); ++i) { if (inventory.mainInventory.get(i) != ItemStack.EMPTY && inventory.mainInventory.get(i).getItem() == item) { return i; } } return -1; } public ItemStack getItemInInventory(InventoryPlayer inventory, Item p_146026_1_) { int i = this.getSlotContainingItem(inventory, p_146026_1_); if (i < 0) { return ItemStack.EMPTY; } else { return inventory.mainInventory.get(i); } } } If any other code is needed, be sure to ask. Please note that this problem is not specific to 1.11.2 since I also had it back in 1.7.10
  6. Hello, I'm the developper of Ratchet & Clank mod, which uses a TON of .obj models for everything (entities, block, items). I used a lot of IItemRenderers, and using the .json is simpler and faster to do than with my old IItemRenderers. Seriously, this is just laziness from the mod's author. I'm in the process of going 1.7.10 -> 1.11.2 and so far it's not very hard, really. If he wants example of how to do things : http://github.com/Gugu42/RatchetAndClankMod/ Edit: He also said "Block based models", and in case he does ask : This doesn't look like block based models EDIT 2 : I just saw the big reply from the mod author. While the argument about 1.7.10 being bigger player-wise, I still argue that the reason it's still that big is because people are not letting it die.
  7. By choosing the texture what kind of texture can you choose ? If it's only color modification, you can look into layers to recolor your item, if it's more complex, I'm guessing a IBakedModel type will have to come into play, but I can't help you with the model part
  8. Oh indeed! Thanks for the resource, I'll update when/if it works for me (with the solution of course).
  9. Update : Adding the "inventory" variant to my json does not work. In code, I use : ModelLoader.setCustomModelResourceLocation(blaster, 0, new ModelResourceLocation(new ResourceLocation(RcMod.MODID, "blaster"), "normal")); Changing normal to inventory makes it use the icon in both hand and inventory, which is not what I want. I cannot find any solutions to this.
  10. Contact the person who made the mod "ultimate_unicorn_mod", and go back to school to learn a bit of politeness.
  11. Hello everyone! I'm facing a small problem updating my mod to 1.11.2 from 1.7.10: I use a LOT of .obj renders, which work well for me, but I get a small problem : In my mod, the icon in inventory is a 2d texture, while the held item is a 3d model. I load my item with a blockstate.json like so : { "forge_marker": 1, "defaults": { "custom": { "flip-v": true }, "model": "rcmod:blaster.obj", "textures": { "#Material__210": "rcmod:models/items/blaster" } }, "variants": { "normal": [{ "transform": { "firstperson": { "translation": [0.2, 0, 0.3], "rotation": [ { "y": 180}, {"x": 0}, {"z": 0} ], "scale": 0.04 }, "thirdperson": { "translation": [0.025, -0.05, 0.23], "rotation": [ { "y": 180}, {"x": 0}, {"z": 0} ], "scale": 0.04 }, "gui": { "translation": [0.3, -0.2, 0], "rotation": [ { "y": -90}, {"x": 0}, {"z": 0} ], "scale": 0.035 }, "ground": { "translation": [0.0, 0.0, -0.1], "scale": 0.024 }, "fixed": { "translation": [-0.2, -0.1, 0.0], "rotation": [ { "y": 90}, {"x": 0}, {"z": 0} ], "scale": 0.03 } }}] } } And I get shown this ingame : As you can see, the model in itself works fine, but the icon in the inventory is just a render of the item. Is there any way to set it to an actual 2d icon ? (such as the other ones shown in the bar)
  12. A bit late, but as I said in my main post, it's a client-side mod, and I cannot make it server side. (It's a HUD kill feed, I want it to work everywhere, not only on modded servers)
  13. Hm, sounds a bit too far for a simple task like this.. I'll just read the chat for death messages I guess. Thanks for the help.
  14. Shouldn't it somehow be ? With the death animations etc... doesn't the client get to know when an entity dies ?
  15. Hello everyone, I'm facing a small problem : I'd like to display deaths on screen with my mod. The display is done, and the mod works perfectly in solo. However, when going into multiplayer (exemple : a VANILLA server), the event is not called, and therefore the death is not added to the display. I'm using LivingDeathEvent to get a player's death, but the event is not triggered when the client isn't also the server (aka solo mode) Is there any way to trigger the event client side without having the server use a mod/plugin ?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.