Jump to content


  • Posts

  • Joined

  • Last visited


  • Gender
  • Location
    Canada, Ontairo
  • Personal Text
    It's no stranger to you and me *rich 5s drum solo*

Recent Profile Visitors

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

hugo_the_dwarf's Achievements

Diamond Finder

Diamond Finder (5/8)



  1. Yes you can use the biome in question, using the block broke event (BlockEvent.BreakEvent) using the world you should be able to get the Biome from the block pos worldObj.getBiomeForCoordsBody(blockPosHere) you can then do what logic you need to confirm that the block was indeed broken in your desired biome (I'd use the getBiomeName() and match if it contains "swamp" may have to .toLowerCase() just as a precaution on the returned biome name) from there I recommend using the height of sea level from the world object (worldObj.getSeaLevel()) for your "this is the upper depth of water spawning" then just subtract from that for your lower range worldObj.getSeaLevel() - 17. I'd also probably recommend having the block (Dirt/Grass, gravel?, sand? better way would be to check if the broken blocks material is the material type you're interested in, this would make it work with other modded blocks (as long as they use the same vanilla material)) check around for any nearby blocks of water so they can simulate "saturation" because breaking a lone block of dirt sitting on a long empty stone layer and having it spew out water would be weird. However Draco's Suggestion would allow you to set "Areas" or "Zones" that are already saturated with water and potentially allow you to keep things of where player places water with bucket, fills with dirt, breaks again water still there. But as he's already mentioned, won't be easy.
  2. doesn't the API allow you to access that extended Inventory? If so check the correct slot if your item is there or not
  3. Can make your own with the EntityLivingUpdate Event and simply just use the Entity.Heal() command I have various timers and the like in my mod attached via Capabilities so I can say "This entity can only heal after not being damaged fro 10 seconds"
  4. So my initial planned approach didn't work the way I had planned, which was: Interrupt guiOpen of the vanilla GUI to open mine (works) Take entityID from merchant to send to server so I can collect merchant items (Failed) Apparently from the guiMerchant::getMerchant returns an IMerchant, which I cannot get an entity from because it's actually an instance of NPCMerchant which can't be cast to an entity at all making my plan a complete failure. this was something I was hoping I could have figured out on my own but that's not working. Help is much appreciated on where to start.
  5. Yup that sounds pretty close to my initial plan. I'm just stuck on getting the existing recipes, was hoping that event would have had them populated (and if they are client-side I have no idea why it's NULL in my environment) Was hoping I didn't have to create a bunch of back and forth communications packets and just reuse existing objects and only worry about the transaction packets Currently I have this as my GUI for now, It needs alot of work, but I'm just trying to get the important guts working before I try to make it pretty and add the communication logic (which is not hard for me) package htd.rot.client.gui; import org.lwjgl.opengl.GL11; import htd.rot.Rot; import htd.rot.capability.playerextra.CapPlayerExtra; import htd.rot.capability.playerextra.CapPlayerExtraData; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.entity.IMerchant; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.village.MerchantRecipe; public class GuiShop extends GuiContainer { private static final ResourceLocation texture = new ResourceLocation(Rot.MODID.toLowerCase(), "textures/gui/shop_gui.png"); private EntityPlayer player; private IMerchant merchant; private CapPlayerExtraData capPlayerExtra; private int frameSize = 18; private int itemStartX = 5; private int shopItemStartY = 6; private int playerHotbarStarY = 141; private int buttonId = 0; public GuiShop(IMerchant merchant, EntityPlayer player) { super(new ContainerNull()); this.player = player; this.merchant = merchant; this.xSize = 173; this.ySize = 166; capPlayerExtra = player.getCapability(CapPlayerExtra.CAPABILITY, null); } @Override public void initGui() { super.initGui(); int currentItemId = 0; ItemStack[] items = new ItemStack[] { new ItemStack(Blocks.DIRT), new ItemStack(Items.APPLE) }; for (int row = 0; row < 3; row++) { for (int column = 0; column < 9; column++) { if (currentItemId < items.length) buttonList.add(new GuiShopButton(buttonId++, itemStartX + (frameSize * column), shopItemStartY + (frameSize * row), "", items[currentItemId++], 0)); } } //Attempt at getting the existing selling list if (merchant != null && player != null) { if (!merchant.getRecipes(player).isEmpty())// merchant.getRecipes is NULL, errors because I assumed it wouldn't be NULL { MerchantRecipe existingList; ItemStack soldItem; for (int i = 0; i < merchant.getRecipes(player).size(); i++) { existingList = merchant.getRecipes(player).get(i); soldItem = existingList.getItemToSell(); if (!soldItem.getItem().equals(Items.EMERALD)) { buttonList.add(new GuiShopButton(buttonId++, itemStartX + (frameSize * i), shopItemStartY, "", soldItem, 0)); } } } } } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize); } }
  6. Hmm.. I was hoping to cheap out and just use Custom Buttons for the "slots" so it was a more of click and request the amount deal rather than a container move items around deal. As I'd be able to create a "transaction" Buy 3 stacks of dirt (64 * 3 * 1 gold nugget = 21 gold ingots) but selling some stone gear (in perfect condition) would warrant 2 gold ingots. Making the total transaction just 19 ingots. the transaction list would be sent off tot he server, which would then do the inventory (player) manipulation and complete the sale. But i'm not sure how'd I'd completely incorporate that using the containers (or at least not including the use of Slot)
  7. Hmm, when I debug and view the loaded GuiMerchant object it's got nulls in all the places i'm interested in. Now this Event is registered in my ClientProxy (forgot the mention that) since it's only the client side I wish to alter. As for the Merchant Container being open I think that's ?fine? as it keeps the existing villager logic of "stare at customer while trading" I will probably setup something that when the GUI closes to fire off a packet to tell the villager everything is all good, not sure how I'd reference the container to kill it (other than the player physically moving away from the villager) So looking at the container, and villager(merchant gui/container) I was hoping to just have the nifty Itemstacks of what they are selling and add them to my own list (minus Emeralds sells) because I also wanted to make it so you could "request" items for the villager to "get" and sell later (for mods that have something that is a bit harder/more rare to get) but I'd rather not break other mods villagers. I attached a photo of my debug showing what the GuiMerchant contains for data, which is mostly null (except for the merchant and the player)
  8. Currently I'm trying to upgrade the existing Villager Trading for my mod, And I want to add some "basic" items that are always available (dirt, clay, etc. Changing based on villager profession) but then I also want the existing trades they have to be added into my GUI as well. This is so Villager types from other mods will still have their shopping lists (compatibility is key). So a farmer would always sell leads + what he/she would sell normally (wheat, potatos, etc) However when I go to override the existing villager GUI @SubscribeEvent public void onGuiOpen(GuiOpenEvent e) { if (e.getGui() instanceof GuiMerchant) { GuiMerchant gui = (GuiMerchant) e.getGui(); Minecraft.getMinecraft().displayGuiScreen(new GuiShop(gui.getMerchant(), Minecraft.getMinecraft().thePlayer)); e.setCanceled(true); } } The GuiMerchant "gui" doesn't have any recipes, and the merchantInventory also has null. Is this because it's all clientside? More or less all I need to know is what items that merchant is selling so I can create my own buttons to render those choices. I'll be creating my own packets to send buy/sell requests so I can use my new currency capability. And once I get this working I'll be adding a villager capability so I can attach more options. But right now I'm struggling just getting their current shop list
  9. Thank you, I had not known that. I added: this.mc.getTextureManager().bindTexture(ICONS); at the end of my render code and fixed it.
  10. Currently I have my own overlays or added overlays, I'm slowly replacing the existing HEALTH and FOOD overlays with my own Health and Stamina models and then adding Mana later on. But in my works I've noticed the XP bar has vanished however the XP counter (1, 2, 3 etc) that number still appears if you collect enough xp but the progress bar is not visible package htd.rot.events.client; import htd.rot.Rot; import htd.rot.capability.playerextra.CapPlayerExtra; import htd.rot.capability.playerextra.CapPlayerExtraData; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class EventPlayerOverlayGui extends Gui { // Registered in ClientProxy private Minecraft mc; private static final ResourceLocation staminaTexture = new ResourceLocation(Rot.MODID + ":textures/gui/stam_bar.png"); private int barW = 81, barH = 9; private int innerBarW = barW - 2; public EventPlayerOverlayGui(Minecraft mc) { super(); this.mc = mc; } @SubscribeEvent(priority = EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if (event.getType() == ElementType.FOOD) { event.setCanceled(true); return; } if (event.getType() != ElementType.EXPERIENCE) { return; } ScaledResolution res = event.getResolution(); int bottomScreen = res.getScaledHeight(), halfHeight = bottomScreen / 2; int rightScreen = res.getScaledWidth(), halfWidth = rightScreen / 2; CapPlayerExtraData capPlayerExtra = Minecraft.getMinecraft().thePlayer.getCapability(CapPlayerExtra.CAPABILITY, null); int currentbarwidth = 0; int xPos = halfWidth + 10; int yPos = bottomScreen - 22 - ((this.barH * 2) - 1); // Draw Stam Bar this.mc.getTextureManager().bindTexture(staminaTexture); float currentStam = capPlayerExtra.getCurrentStam(); float maxStam = capPlayerExtra.MAX_STAM; currentbarwidth = MathHelper.clamp_int((int) ((currentStam / maxStam) * this.innerBarW), 0, this.innerBarW); drawTexturedModalRect(xPos, yPos, 0, 0, this.barW, this.barH); drawTexturedModalRect(xPos + 1, yPos, 0, this.barH, currentbarwidth, this.barH); } } Is the issue that I'm extending Gui? I'm doing that so I can use the "drawTexturedModalRect()" method for drawing. And "ScaledResolution" for positioning. EDIT: in the attached image LEFT is my modded version, RIGHT is vanilla
  11. What version of Forge are you using? (I looked at your main repo and I'm guessing 1.11.2) the inventory class used for players PlayerInventory has sub lists inside it "mainInventory", "offHandInventory", and "armorInventory". Try pulling from mainInventory. Now I haven't worked with the Slot class for a bit, so I'm not sure if the constructor would accept that, if that's the case you will have to create an offset of the index so it skips past the armor indexes
  12. Packet? if you're counting with a GUI or HUD you can get the Player object, from there the World from the Player, from there count nearby entities. Even if it's a TE you should be able to get that info if you pass it in the constructor. All entities should be duplicated to the clients so counting them should be easy either side
  13. If you're using the hurt event, you can get it from the damage source attached to the event (for who attacked, just ensure that entity is not null) for closest you could just scan around the affected player either by getting everything in an extended AABB box, entity.worldObj.getEntitiesInAABBexcluding(entityIn, boundingBox, null); entity.getCollisionBoundingBox().expand(x, y, z); you just need to go through the returned list if it's not empty and look for the closest entity, you may have to use tactics like coding the lowest value (IE lowest distance from player) and then use that entity after the loop.
  • Create New...

Important Information

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