Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

quinn50

Members
  • Posts

    14
  • Joined

  • Last visited

Recent Profile Visitors

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

quinn50's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Is there a replacement for gluProject / gluUnProject in 1.15.2 mdk?
  2. I recently made a post about achieving a isometric view, I was able to figure that out pretty easily googling around and figuring out how to make a basic coremod to modify the frustum method in ClippingHelperImpl to prevent chunks / entities fading out behind the player. I have ran into another problem of trying to get the player head to follow where the mouse is on the screen. I currently just use a empty Screen GUI (I don't know if this is the best way of accomplishing this vs ungrabbing the mouse) The things I need to find out how to accomplish is: Have the player face the mouse on screen The best way to have the mouse show on screen (Empty GUI vs ungrabbing the mouse) converting screen to world coordinates (click on block and it raytraces it, and implement the player moving to that block) This is my current prototype code for trying to get the player character to follow the mouse
  3. So I am currently working on a Action RPG hack and slash mod for 1.15.2 and I have having trouble figuring out how to create an isometric view in 1.15.2. I have looked at other mods such as mineshot and shoulder surfing reloaded and I have figured out how to modify the position of the player camera using reflection (ActiveRenderInfo has some methods and fields with access modifiers protected and private. I have tried doing some openGL things but I couldn't figure that out. I also need to figure out how restrict the player from looking up and down. Code for my cameraSetup event handler
  4. Im trying to make a scroll page so that only 6 rows of items show up, and I can't find a replacement for the system in 1.10+ found containerClass.getSlot(index).x/yPos.
  5. Inventory was not being set to the container so whenever initgui was called it was null causing the crash
  6. So I want to create scrollbar that is going to be apart of my custom storage device for my mod, which is going to sort and display items based of their NBT values so that it would be more storage efficient for the player to use. I have tried basing my code off the method that vanilla does for the creative inventory, and I am currently having a issue where when I change the size of the game window the game crashes with a null pointer exception. Crash Log Container Class public class SoulChamberContainer extends Container { TileEntityChamber chamber; GuiChamber gui; public static TileEntityChamber chamberInv; public NonNullList<ItemStack> list = NonNullList.<ItemStack>create(); public SoulChamberContainer(InventoryPlayer playerInv, final TileEntityChamber chamber){ this.chamber = chamber; IItemHandler inventory = chamber.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 140 + i * 18)); } } for (int j = 0; j < 12; ++j) { for (int k = 0; k < 4; ++k) { addSlotToContainer(new soulChamberSlot(inventory, k + j * 4, 80 + k * 18, 18 + j * 18) { @Override public void onSlotChanged() { chamber.markDirty(); } }); } } for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 198)); } } public void scrollTo(float pos) { int i = (this.list.size() + 9 - 1) / 9 - 5; int j = (int)((double)(pos * (float)i) + 0.5D); if (j < 0) { j = 0; } for (int k = 0; k < 5; ++k) { for (int l = 0; l < 9; ++l) { int i1 = l + (k + j) * 9; if (i1 >= 0 && i1 < this.list.size()) { gui.setInventorySlotContents(l + k * 9, (ItemStack) this.list.get(i1)); } else { gui.setInventorySlotContents(l + k * 9, ItemStack.EMPTY); } } } } public boolean moreThan1PageItems() { return this.list.size() > 24; } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(itemstack1, containerSlots, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, itemstack1); } return itemstack; } } GUI Class public class GuiChamber extends GuiContainer { private static final ResourceLocation BACKGROUND = new ResourceLocation(soulomancy.MODID, "textures/gui/chamber.png"); public NonNullList<ItemStack> list = NonNullList.<ItemStack>create(); int ScrollRow = 0; private boolean isScrolling = false; private boolean wasClicking = false; private float scrollCurrent; public static TileEntityChamber chamberInv; private static SoulChamberContainer chamContainer; private InventoryPlayer playerInv; public GuiChamber (Container container, InventoryPlayer playerInv) { super(container); this.playerInv = playerInv; } @Override public void initGui() { super.initGui(); this.buttonList.add(new GuiButton(1, 100, 200, 100, 20, "Button id: 1")); ItemStack is; for (int i = 0; i < 48; ++i) { if (!(chamberInv.getStackInSlot(i) == null)) { is = chamberInv.getStackInSlot(i); }else { is = ItemStack.EMPTY; } if (!(is == null)) { this.list.add(is); chamContainer.list = this.list; } } } @Override public void updateScreen() { super.updateScreen(); } @Override protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 1){ System.out.println("Button id 1: Test"); } } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); // Slot slot boolean flag = Mouse.isButtonDown(0); int k = this.guiLeft; int l = this.guiTop; int i1 = k + 175; int j1 = l + 18; int k1 = i1 + 14; int l1 = j1 + 108; if (!this.wasClicking && flag && mouseX >= i1 && mouseY >= j1 && mouseX < k1 && mouseY < l1) { this.isScrolling = this.needsScrollBars(); System.out.println("DEBUG: Scrollbar Needed"); } if (!flag) { this.isScrolling = false; System.out.println("DEBUG: Not Scrolling"); } else { } this.wasClicking = flag; if (this.isScrolling) { System.out.println("DEBUG: Is Scrolling"); this.scrollCurrent = (mouseY - j1 - 7.5F) / (l1 - j1 - 15.0F); this.scrollCurrent = MathHelper.clamp(this.scrollCurrent, 0.0F, 1.0F); chamContainer.scrollTo(this.scrollCurrent); } } public void handleMouseInput() throws IOException { super.handleMouseInput(); int i = Mouse.getEventDWheel(); if (i != 0 && this.needsScrollBars()) { int j = (((SoulChamberContainer)this.inventorySlots).list.size() + 9 - 1) / 9 - 5; if (i > 0) { i = 1; } if (i < 0) { i = -1; } this.scrollCurrent = (float)((double)this.scrollCurrent - (double)i / (double)j); this.scrollCurrent = MathHelper.clamp(this.scrollCurrent, 0.0F, 1.0F); ((SoulChamberContainer)this.inventorySlots).scrollTo(this.scrollCurrent); } } private boolean needsScrollBars() { if (((SoulChamberContainer)this.inventorySlots).moreThan1PageItems()) { return false; } else { return true; } } public void setInventorySlotContents(int i, ItemStack itemStack) { chamberInv.invContents(i, itemStack); if (itemStack != null && itemStack.getCount() > 64) { itemStack.setCount(64); } chamberInv.markDirty(); } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1, 1, 1, 1); mc.getTextureManager().bindTexture(BACKGROUND); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, 222); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int var5 = (this.width - this.xSize) / 2; int var6 = (this.height - this.ySize) / 2; this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize); int i1 = this.guiLeft + 153; int k = this.guiTop + 18; int l = k + 90; if (needsScrollBars()) { System.out.println("Scroll Activated"); this.drawString(mc.fontRenderer, "fart", 172, 220, 0xffffff); this.drawTexturedModalRect(i1, k + (int)((float)(l - k - 17) * this.scrollCurrent), 0,198, 12, 15); } else { this.drawTexturedModalRect(i1, k, 12, 198, 12, 15); } } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String name = I18n.format(ModBlocks.soulChamber.getUnlocalizedName() + ".name"); fontRenderer.drawString(name, xSize / 2 - fontRenderer.getStringWidth(name) / 2, 6, 0x404040); fontRenderer.drawString(playerInv.getDisplayName().getUnformattedText(), 8, 222 - 94, 0x404040); } public int rowsVisible() { return 6; } } Tile Entity Class public class TileEntityChamber extends TileEntity { private ItemStackHandler inv = new ItemStackHandler(48); private final NonNullList<ItemStack> inventoryContents = NonNullList.withSize(48, net.minecraft.item.ItemStack.EMPTY); public void invContents(int i, ItemStack stack){ this.inventoryContents.set(i, stack); } public ItemStack getStackInSlot(int i){ return i >= 48 ? ItemStack.EMPTY : this.inventoryContents.get(i); } @Override public void markDirty() { super.markDirty(); } public ItemStackHandler getInv() { return inv; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inv.serializeNBT()); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { inv.deserializeNBT(compound.getCompoundTag("inventory")); super.readFromNBT(compound); } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)inv: super.getCapability(capability, facing); } } Also I would like insight on how you would go about having only a certain amount of slots show up per "page", so like I only want 24 slots showing up but as you scroll of course new slots show up.
  7. I potentially fixed the error as I forgot to override markDirty(); in the tileentity class, need to work on getting the scrolling to work.
  8. I have been working on getting a scroll bar to work for both items and a list of buttons which will be based off the items put into the container in which i'm using. Recently during testing I have been having a issue where markDirty(); is infinitely called causing a stackoverflow error whenever I click on a slot inside of the gui of the container I am using, and I would like to find out why and fix it so I can get the scrollbars working properly. GUI CODE: public class GuiChamber extends GuiContainer { private static final ResourceLocation BACKGROUND = new ResourceLocation(soulomancy.MODID, "textures/gui/chamber.png"); ArrayList list = new ArrayList(); int ScrollRow = 0; private boolean isScrolling = false; private boolean wasClicking = false; private float scrollCurrent; public static TileEntityChamber chamberInv; private static SoulChamberContainer chamContainer; private InventoryPlayer playerInv; public GuiChamber (Container container, InventoryPlayer playerInv) { super(container); this.playerInv = playerInv; } @Override public void initGui() { super.initGui(); this.buttonList.add(new GuiButton(1, 100, 200, 100, 20, "Button id: 1")); } @Override protected void actionPerformed(GuiButton button) throws IOException { if (button.id == 1){ System.out.println("Button id 1: Test"); } } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); super.drawScreen(mouseX, mouseY, partialTicks); this.renderHoveredToolTip(mouseX, mouseY); boolean flag = Mouse.isButtonDown(0); int k = this.guiLeft; int l = this.guiTop; int i1 = k + 175; int j1 = l + 18; int k1 = i1 + 14; int l1 = j1 + 108; if (!this.wasClicking && flag && mouseX >= i1 && mouseY >= j1 && mouseX < k1 && mouseY < l1) { this.isScrolling = this.needsScrollBars(); } if (!flag) { this.isScrolling = false; } this.wasClicking = flag; if (this.isScrolling) { this.scrollCurrent = (mouseY - j1 - 7.5F) / (l1 - j1 - 15.0F); this.scrollCurrent = MathHelper.clamp(this.scrollCurrent, 0.0F, 1.0F); scrollTo(this.scrollCurrent); } } private boolean needsScrollBars() { if (chamContainer.moreThan1PageItems()) { return true; } else { return false; } } public void setInventorySlotContents(int i, ItemStack itemStack) { chamberInv.invContents(i, itemStack); if (itemStack != null && itemStack.getMaxStackSize() > 64) { itemStack.setCount(64); } chamberInv.markDirty(); } public void scrollTo(float pos) { int i = (this.list.size() + 9 - 1) / 9 - 5; int j = (int)((double)(pos * (float)i) + 0.5D); if (j < 0) { j = 0; } for (int k = 0; k < 5; ++k) { for (int l = 0; l < 9; ++l) { int i1 = l + (k + j) * 9; if (i1 >= 0 && i1 < this.list.size()) { setInventorySlotContents(l + k * 9, (ItemStack) this.list.get(i1)); } else { setInventorySlotContents(l + k * 9, ItemStack.EMPTY); } } } } @Override protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1, 1, 1, 1); mc.getTextureManager().bindTexture(BACKGROUND); int x = (width - xSize) / 2; int y = (height - ySize) / 2; drawTexturedModalRect(x, y, 0, 0, xSize, 222); } @Override protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { String name = I18n.format(ModBlocks.soulChamber.getUnlocalizedName() + ".name"); fontRenderer.drawString(name, xSize / 2 - fontRenderer.getStringWidth(name) / 2, 6, 0x404040); fontRenderer.drawString(playerInv.getDisplayName().getUnformattedText(), 8, 222 - 94, 0x404040); } /* public int rowsVisible() { return 6; } */ CONTAINER CODE: TileEntityChamber chamber; public static TileEntityChamber chamberInv; public List list = new ArrayList(); public SoulChamberContainer(InventoryPlayer playerInv, final TileEntityChamber chamber){ this.chamber = chamber; IItemHandler inventory = chamber.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.NORTH); for (int i = 0; i < 3; i++) { for (int j = 0; j < 9; j++) { addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 140 + i * 18)); } } for (int j = 0; j < 6 ; ++j) { for (int k = 0; k < 4; ++k) { addSlotToContainer(new soulChamberSlot(inventory, k + j * 4, 80 + k * 18, 18 + j * 18) { @Override public void onSlotChanged() { chamber.markDirty(); } }); } } for (int k = 0; k < 9; k++) { addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 198)); } } public boolean moreThan1PageItems() { return this.list.size() > 24; } @Override public boolean canInteractWith(EntityPlayer playerIn) { return true; } @Override public ItemStack transferStackInSlot(EntityPlayer player, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size(); if (index < containerSlots) { if (!this.mergeItemStack(itemstack1, containerSlots, inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, containerSlots, false)) { return ItemStack.EMPTY; } if (itemstack1.getCount() == 0) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } if (itemstack1.getCount() == itemstack.getCount()) { return ItemStack.EMPTY; } slot.onTake(player, itemstack1); } return itemstack; } TILE ENTITY CODE: private ItemStackHandler inv = new ItemStackHandler(24); private final NonNullList<ItemStack> inventoryContents; public TileEntityChamber(){ this.inventoryContents = NonNullList.<ItemStack>withSize(24, net.minecraft.item.ItemStack.EMPTY); } public void invContents(int i, ItemStack stack){ this.inventoryContents.set(i, stack); } public void markDirty(){ this.markDirty(); } public ItemStackHandler getInv() { return inv; } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { compound.setTag("inventory", inv.serializeNBT()); return super.writeToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound) { inv.deserializeNBT(compound.getCompoundTag("inventory")); super.readFromNBT(compound); } @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY || super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { return capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY ? (T)inv: super.getCapability(capability, facing); }
  9. Hello, I have been having issues trying get my machine to face the player on placement like many other mods, I've tried overriding methods found in the vanilla chest class file however 3/4 of the methods are 'Deprecated', and I was wondering if there is a new method to do this in 1.12?
  10. Sorry for late reply, I implemented this solution thanks for the help.
  11. yes, I have but that is the issue for me it's not grabbing the NBT tag, but other options it does idk what is going on
  12. @SubscribeEvent public void itemPickup(PlayerEvent.ItemPickupEvent event){ ItemStack stack = event.getStack(); if (stack.getItem().equals(ModItems.mobSoul)) { System.out.println("You picked up Mob Soul"); NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) { nbt = new NBTTagCompound(); System.out.println("NBT Created for Mob Soul"); } if (nbt.hasKey("potency")) { nbt.setInteger("potency", nbt.getInteger("potency")); } else { System.out.println("Random Value generated for Potency value"); nbt.setInteger("potency", (int) (Math.random() * 100) + 1); } System.out.println("Value written to NBT tag"); stack.setTagCompound(nbt); } } This is my Event code, so what I want to do is when I pick up my custom item from a mob drop, it will generate a random number to be put inside of a tooltip showing how much "potency" the item has. @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey("potency")) { NBTTagCompound nbt = stack.getTagCompound(); System.out.println(nbt); if (nbt != null && nbt.hasKey("potency")) { int pot = nbt.getInteger("potency"); tooltip.add("Potency: " + pot); } } else { tooltip.add("Potency: N/A"); } } this is my tooltip code, I've tried all of the troubleshooting that I know of, such as just using a onRightClick method using the same general code in the ItemPickupEvent, which worked fine however my issue strides from the event. I want to know if I am doing something generally wrong, as in 1.10 this same method worked for me previously.
  13. @SubscribeEvent public ItemStack soulDrop(LivingDropsEvent event) { DamageSource source = event.getSource(); Entity entity = source.getTrueSource(); EntityPlayer player = (EntityPlayer) entity; ItemStack soul = new ItemStack(ModItems.mobSouls); ItemStack hand = ItemStack.EMPTY; hand = player.getHeldItemMainhand(); NBTTagCompound nbt = soul.getTagCompound(); if (event.getEntity() instanceof EntityLiving && hand.getItem() == Items.IRON_HOE) { event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, new ItemStack(ModItems.mobSouls))); if(nbt == null){ nbt = new NBTTagCompound(); } if(nbt.hasKey("potency")){nbt.setInteger("potency", 0); }else{nbt.setInteger("potency", (int) Math.random()*100);} soul.setTagCompound(nbt); } return soul; } This is my code for item drop event, I have managed to do this prior in 1.10, however, I lost my prior source code.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.