Jump to content

[1.11.2]Gui not rendering item icons when opened from Item, but does when opened from block


Gugu42

Recommended Posts

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 :
wnIPBoC.png

When I open the GUI via the item : 
N4cYzem.png

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

 

Link to comment
Share on other sites

Alright.

Container :
 

Spoiler

package com.gugu42.rcmod;

import com.gugu42.rcmod.client.gui.SlotVendor;
import com.gugu42.rcmod.items.InventoryGadgetronPDA;
import com.gugu42.rcmod.tileentity.TileEntityVendor;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerVendor extends Container {

	protected TileEntityVendor tileEntity;
	protected InventoryGadgetronPDA inv;
	public ContainerVendor(InventoryPlayer inventoryPlayer, TileEntityVendor te, InventoryGadgetronPDA inv) {
		tileEntity = te;
		this.inv = inv;
		if(inv != null){
			System.out.println("Item gui");
			addSlotToContainer(new SlotVendor(inv, 1, 48, 173)); 
			addSlotToContainer(new SlotVendor(inv, 2, 66, 173)); 
			addSlotToContainer(new SlotVendor(inv, 3, 84, 173)); 
			addSlotToContainer(new SlotVendor(inv, 4, 102, 173)); 
			addSlotToContainer(new SlotVendor(inv, 5, 120, 173)); 
			addSlotToContainer(new SlotVendor(inv, 6, 138, 173)); 
			addSlotToContainer(new SlotVendor(inv, 7, 156, 173)); 
			addSlotToContainer(new SlotVendor(inv, 8, 174, 173)); 
			addSlotToContainer(new SlotVendor(inv, 9, 192, 173)); 
		} else {
			addSlotToContainer(new SlotVendor(tileEntity, 1, 48, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 2, 66, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 3, 84, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 4, 102, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 5, 120, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 6, 138, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 7, 156, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 8, 174, 173)); 
			addSlotToContainer(new SlotVendor(tileEntity, 9, 192, 173)); 
		}
	}

	
	
	@Override
	public boolean canInteractWith(EntityPlayer player) {
		if(tileEntity != null){
		return tileEntity.isUsableByPlayer(player);
		} else {
			return true;
		}
	}

	@Override
	public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
        ItemStack stack = ItemStack.EMPTY;
        Slot slotObject = (Slot) inventorySlots.get(slot);

        if (slotObject != null && slotObject.getHasStack()) {
                ItemStack stackInSlot = slotObject.getStack();
                stack = stackInSlot.copy();
                
                if (slot < 1) {
                    if (!this.mergeItemStack(stackInSlot, 5, 42, true)) {
                            return ItemStack.EMPTY;
                    }
                }
                
                else if (!this.mergeItemStack(stackInSlot, 0, 1, false)) {
                	return ItemStack.EMPTY;
                }
                if (stackInSlot.getCount() == 0) {
                        slotObject.putStack(ItemStack.EMPTY);
                } else {
                        slotObject.onSlotChanged();
                }

                if (stackInSlot.getCount() == stack.getCount()) {
                        return ItemStack.EMPTY;
                }
                slotObject.onTake(player, stackInSlot);
        }
        return stack;
	}

    public TileEntityVendor getVendor()
    {
            return this.tileEntity;
    }

}

 

GuiHandler :

Spoiler

package com.gugu42.rcmod.network;

import com.gugu42.rcmod.ContainerVendor;
import com.gugu42.rcmod.client.gui.GuiGadgetronHelper;
import com.gugu42.rcmod.client.gui.GuiShip;
import com.gugu42.rcmod.client.gui.GuiShipPlatform;
import com.gugu42.rcmod.client.gui.GuiVendor;
import com.gugu42.rcmod.items.InventoryGadgetronPDA;
import com.gugu42.rcmod.tileentity.TileEntityShip;
import com.gugu42.rcmod.tileentity.TileEntityShipFiller;
import com.gugu42.rcmod.tileentity.TileEntityShipPlatform;
import com.gugu42.rcmod.tileentity.TileEntityVendor;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler {
	// returns an instance of the Container you made earlier
	@Override
	public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
		TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
		if (tileEntity instanceof TileEntityVendor) {
			return new ContainerVendor(player.inventory, (TileEntityVendor) tileEntity, null);
		}

		if (tileEntity instanceof TileEntityShip) {
			return null;
		}

		if (id == 3) {
			return null;
		}

		if(id == 5){
			return new ContainerVendor(player.inventory, null, new InventoryGadgetronPDA());
		}
		return null;
	}

	// returns an instance of the Gui you made earlier
	@Override
	public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
		TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
		
		if (tileEntity instanceof TileEntityVendor) {
			return new GuiVendor(player.inventory, (TileEntityVendor) tileEntity, player, new ContainerVendor(player.inventory, (TileEntityVendor) tileEntity, null), null);
		}

		if (tileEntity instanceof TileEntityShip || tileEntity instanceof TileEntityShipFiller) {
			if (tileEntity instanceof TileEntityShip) {
				TileEntityShip te = (TileEntityShip) tileEntity;
				return new GuiShip(te, player);
			} else {
				TileEntityShipFiller te2 = (TileEntityShipFiller) tileEntity;
				TileEntityShip te = (TileEntityShip) te2.getOriginalTileEntity();
				System.out.println("Received data for gui : " + x + " " + y + " " + z);

				if (te != null) {
					return new GuiShip(te, player);
				} else {
					System.out.println("ERROR ! NULL TILEENTITY");
					return new GuiShip(null, player);
				}
			}
		}

		if (id == 3) {
			return new GuiGadgetronHelper(player);
		}

		if (id == 4 && tileEntity instanceof TileEntityShipPlatform) {
			TileEntityShipPlatform te = (TileEntityShipPlatform)tileEntity;
			return new GuiShipPlatform(player, te);
		}

		if(id == 5) {
			return new GuiVendor(player.inventory, (TileEntityVendor) tileEntity, player, new ContainerVendor(player.inventory, null, new InventoryGadgetronPDA()), new InventoryGadgetronPDA());
		}
		return null;

	}
}

 

Item :

Spoiler

package com.gugu42.rcmod.items;

import com.gugu42.rcmod.RcMod;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;

public class ItemGadgetronHelper extends Item {

	public ItemGadgetronHelper() {
		super();
		this.setCreativeTab(RcMod.rcGadgTab);
		this.setMaxStackSize(1);
		this.setFull3D();
	}

	@Override
	public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
		super.onItemRightClick(world, player, hand);
		
		ItemStack stack = player.getHeldItem(hand);
		
		if(!world.isRemote)
			player.openGui(RcMod.instance, 5, player.world, 0, 0, 0);
		return new ActionResult(EnumActionResult.SUCCESS, stack);
	}

}

 

Block :

Spoiler

package com.gugu42.rcmod.blocks;

import com.gugu42.rcmod.RcMod;
import com.gugu42.rcmod.client.ClientProxy;
import com.gugu42.rcmod.tileentity.TileEntityVendor;

import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockVendor extends Block implements ITileEntityProvider {

	public BlockVendor(Material par2Material) {
		super(par2Material);
		this.setCreativeTab(RcMod.rcTab);
	}

	public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
		
		TileEntity tileEntity = world.getTileEntity(pos);
		if (tileEntity == null || player.isSneaking() || hand != EnumHand.MAIN_HAND) {
			return false;
		}
		
		player.openGui(RcMod.instance, 0, world, pos.getX(), pos.getY(), pos.getZ());
		world.playSound(null, pos, new SoundEvent(new ResourceLocation("rcmod:MenuOpen")), SoundCategory.BLOCKS, 1.0f, 1.0f);
		//par1World.playSoundAtEntity(par5EntityPlayer, "rcmod:MenuOpen", 1.0F, 1.0F);
		return true;
	}

    /*@SideOnly(Side.CLIENT)
    public void initModel() {
        ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }*/

    @Override
    @SideOnly(Side.CLIENT)
    public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
        return false;
    }

    @Override
    public boolean isBlockNormalCube(IBlockState blockState) {
        return false;
    }

    @Override
    public boolean isOpaqueCube(IBlockState blockState) {
        return false;
    }

	@Override
	public TileEntity createNewTileEntity(World worldIn, int meta) {
		return new TileEntityVendor();
	}
}

 

 

 

Some of the code is dirty, sorry

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So I'm using a mod that adds a "god sword" into the game. This sword is unfortunately not enchantable so I'm looking to change it. The only code that seems related is in the weapon's .class file which is here:  public int getItemEnchantability() { return this.tier.m_6601_(); }   The entire file is below: package blackwolf00.elementalswords.common; import blackwolf00.elementalswords.config.ConfigEffects; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; import com.mojang.blaze3d.platform.InputConstants; import java.util.List; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffects; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.ai.attributes.Attribute; import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Tier; import net.minecraft.world.item.TieredItem; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.Vanishable; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolAction; import net.minecraftforge.common.ToolActions; public class FusionSword extends TieredItem implements Vanishable { private final float totalDamage; private final Tier tier; private final Multimap<Attribute, AttributeModifier> defaultModifiers; public FusionSword(Tier tierIn, int damage, float speed, Item.Properties builderIn) { super(tierIn, builderIn); this.tier = tierIn; this.totalDamage = damage + this.tier.m_6631_(); ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder(); builder.put(Attributes.f_22281_, new AttributeModifier(f_41374_, "Weapon modifier", this.totalDamage, AttributeModifier.Operation.ADDITION)); builder.put(Attributes.f_22283_, new AttributeModifier(f_41375_, "Weapon modifier", speed, AttributeModifier.Operation.ADDITION)); this.defaultModifiers = (Multimap<Attribute, AttributeModifier>)builder.build(); } public int getItemEnchantability() { return this.tier.m_6601_(); } public boolean getIsRepairable(ItemStack toRepair, ItemStack repair) { return (this.tier.m_6282_().test(repair) || isRepairable(toRepair)); } public float getAttackDamage() { return this.totalDamage; } public boolean m_6777_(BlockState state, Level level, BlockPos pos, Player player) { return !player.m_7500_(); } public float m_8102_(ItemStack stack, BlockState state) { return 1.0F; } public boolean m_7579_(ItemStack stack, LivingEntity target, LivingEntity attacker) { stack.m_41622_(1, attacker, entity -> entity.m_21166_(EquipmentSlot.MAINHAND)); return true; } public boolean m_6813_(ItemStack stack, Level level, BlockState state, BlockPos pos, LivingEntity entityLiving) { if (state.m_60800_((BlockGetter)level, pos) != 0.0F) stack.m_41622_(2, entityLiving, entity -> entity.m_21166_(EquipmentSlot.MAINHAND)); return true; } public boolean m_8096_(BlockState blockIn) { return blockIn.m_60713_(Blocks.f_50033_); } public boolean m_5812_(ItemStack item) { return true; } public Multimap<Attribute, AttributeModifier> m_7167_(EquipmentSlot equipmentSlot) { return (equipmentSlot == EquipmentSlot.MAINHAND) ? this.defaultModifiers : super.m_7167_(equipmentSlot); } public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { return super.onLeftClickEntity(stack, player, entity); } @OnlyIn(Dist.CLIENT) public void m_7373_(ItemStack stack, Level level, List<Component> tooltip, TooltipFlag flag) { super.m_7373_(stack, level, tooltip, flag); if (InputConstants.m_84830_(Minecraft.m_91087_().m_91268_().m_85439_(), 340)) { tooltip.add(Component.m_237115_("tooltip.fusion_sword").m_130940_(ChatFormatting.GRAY)); } else { tooltip.add(Component.m_237115_("tooltip.hold_shift").m_130940_(ChatFormatting.GRAY)); } } public InteractionResultHolder<ItemStack> m_7203_(Level level, Player playerIn, InteractionHand handIn) { if (((Boolean)ConfigEffects.JUMP_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19603_, 10000, ((Integer)ConfigEffects.JUMP_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.MOVEMENT_SPEED_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19596_, 10000, ((Integer)ConfigEffects.MOVEMENT_SPEED_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.SLOW_FALLING_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19591_, 10000, ((Integer)ConfigEffects.SLOW_FALLING_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.ABSORPTION_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19617_, 10000, ((Integer)ConfigEffects.ABSORPTION_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.DAMAGE_RESISTANCE_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19606_, 10000, ((Integer)ConfigEffects.DAMAGE_RESISTANCE_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.DAMAGE_BOOST_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19600_, 10000, ((Integer)ConfigEffects.DAMAGE_BOOST_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.CONDUIT_POWER_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19592_, 10000, ((Integer)ConfigEffects.CONDUIT_POWER_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.DOLPHINS_GRACE_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19593_, 10000, ((Integer)ConfigEffects.DOLPHINS_GRACE_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.WATER_BREATHING_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19608_, 10000, ((Integer)ConfigEffects.WATER_BREATHING_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.FIRE_RESISTANCE_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19607_, 10000, ((Integer)ConfigEffects.FIRE_RESISTANCE_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.HEALTH_BOOST_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19616_, 10000, ((Integer)ConfigEffects.HEALTH_BOOST_F_LEVEL.get()).intValue() - 1)); if (((Boolean)ConfigEffects.REGENERATION_F.get()).booleanValue()) playerIn.m_7292_(new MobEffectInstance(MobEffects.f_19605_, 10000, ((Integer)ConfigEffects.REGENERATION_F_LEVEL.get()).intValue() - 1)); return InteractionResultHolder.m_19098_(playerIn.m_21120_(handIn)); } public boolean canPerformAction(ItemStack stack, ToolAction toolAction) { return ToolActions.DEFAULT_SWORD_ACTIONS.contains(toolAction); } } How do I make this thing enchantable?  
    • The mod I'm working on is in 1.19.2. The portal works correctly in Intellij but when I publish the jar, put it in the mods folder of the game it crashes with the following error whenever any entity collides with it: java.lang.IllegalAccessError: class com.github.warrentode.turtleblockacademy.blocks.TBAMiningPortalBlock tried to access protected field net.minecraft.world.entity.Entity.f_19819_ (com.github.warrentode.turtleblockacademy.blocks.TBAMiningPortalBlock is in module [email protected] of loader 'TRANSFORMER' @16c5b50a; net.minecraft.world.entity.Entity is in module [email protected] of loader 'TRANSFORMER' @16c5b50a)     at com.github.warrentode.turtleblockacademy.blocks.TBAMiningPortalBlock.m_7892_(TBAMiningPortalBlock.java:124) ~[turtleblockacademy-2024.2025-1.0.0.jar%23572!/:2024.2025-1.0.0] {re:classloading} The thing is, I have Entity.f_19819_ in my accessTransformer.cfg file in this line: public net.minecraft.world.entity.Entity f_19819_ # portalEntrancePos So what do I need to do to fix this error?
    • It will be about medeaival times
    • the mods are crashing and I'm not sure why so heres everything  crash log https://pastebin.com/RxLKbMNR  L2 Library (12library) has failed to load correctly java.lang.NoClassDefFoundError: org/antarcticgardens/newage/content/energiser/EnergiserBlock L2 Screen Tracker (12screentracker) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.12library.base.L2Registrate Create: Interiors (interiors) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.tterrag.registrate.AbstractRegistrate L2 Damage Tracker (12damagetracker) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate Create Enchantment Industry (create_enchantment_industry) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.Createfiegistrate Create Crafts & Additions (createaddition) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.CreateRegistrate Create Slice & Dice (sliceanddice) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.CreateRegistrate L2 Tabs (12tabs) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate Modular Golems (modulargolems) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate Create: Steam 'n' FRails (railways) has failed to load correctly java.lang.NoClassDefFoundError : Could not initialize class com.simibubi.create.foundation.data.Createfregistrate Cuisine Delight (cuisinedelight) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.12library.base.L2Registrate Create (create) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.Create Guardian Beam Defense (creategbd) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.CreateRegistrate L2 Item Selector (12itemselector) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate
    • hey there, I have been using Forge for years without any problems, but for some time now I have been getting this error message when I click on “Installer” under the downloads. This happens on all versions. I have tried various things but have not gotten any results. If anyone has a solution, I would be very grateful!
  • Topics

×
×
  • Create New...

Important Information

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