Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Spyeedy

Forge Modder
  • Joined

  • Last visited

Everything posted by Spyeedy

  1. Hm, can I use the if statements and check if the ItemDamage is equals to a specific value, then return the String of the name?
  2. Okay, so i've created my own Item with 4 metadata value. The problem is that I want each of my metadata items to have a different name instead of having one uniformed name. As you can see in the image below, I used one localization and all the metadata's names have the same name. ItemMetadata class: RegisterItems class: Registered RegisterItems#main in my Mod class's preInit and RegisterItems#registerRenders in my ClientProxy's preInit.
  3. I've looked around the internet and I found a Youtube video, , by Lex Manos AKA The Forge Code God. And surprisingly, after I ran the gradlew build command and went into my build/libs, there are 2 files, the mod AND the source code, 2 files I'm familiar with having used GuideAPI for an old (abandoned) project. As for adding the API into my workspace, I followed a tutorial here.
  4. How do I compile my workspace such that it can be used both as a mod and as an API for my other mods? Also, I want the API to have readable codes and not codes are that unreadable. This is my first time doing it so don't mind me asking plenty of questions about compiling.
  5. Thank you! I thought the getMetadata method existed in the ItemBlock class and when I checked it, there was no method, so I was stumped. But now, I've learnt that the getMetadata method exists in the Item class. Thanks a lot!
  6. Thank you! I thought the getMetadata method existed in the ItemBlock class and when I checked it, there was no method, so I was stumped. But now, I've learnt that the getMetadata method exists in the Item class. Thanks a lot!
  7. Well, I was following a tutorial
  8. I'm confused as to why when I place my block's item of metadata value 2, it reverts to 0. This is the same for metadata value 1. ItemBlock Meta class: BlockFabric class: TestBlocks class: ClientProxy class: Main class: Fabric.json Blockstates:
  9. Do you know how to use if-else statements? What Draco18s is saying is that if the ammo is in the inventory, the bullet entity will be fired, else nothing will happen if () //if player has ammo in inventory { //spawn entity }
  10. Uh well, my mod will not work on server side, so I do not know what's happening on server. Also, I tried removing the maxHealth attribute so the health will not change but to go down the drain, the entity still has the hurt animation (red). [spoiler=Updated Code] public class ExperimentalEntity extends EntityAnimal { /** AI task for player control. */ public final EntityAIControlledByPlayer aiControlledByPlayer; private static final UUID speed_UUID = UUID.fromString("e791d27a-5681-4ef1-8c96-fde0305527b5"); private static final AttributeModifier speed_Modifier = (new AttributeModifier(speed_UUID, "Speed", 1.0D, 0)); public ExperimentalEntity(World worldIn) { super(worldIn); this.tasks.addTask(0, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 1.0F)); this.isImmuneToFire = true; } @Override public boolean isAIDisabled() { return false; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); } @Override protected void updateAITasks() { IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); if (this.riddenByEntity instanceof EntityPlayer && !iattributeinstance.hasModifier(speed_Modifier)) { iattributeinstance.applyModifier(speed_Modifier); } else if (this.riddenByEntity == null && iattributeinstance.hasModifier(speed_Modifier)) { iattributeinstance.removeModifier(speed_Modifier); } super.updateAITasks(); } @Override public boolean interact(EntityPlayer player) { if(!worldObj.isRemote) { player.mountEntity(this); } if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != player) { return true; } else { return false; } } @Override public boolean canBeSteered() { return true; } @Override public void updateRidden() { if (ridingEntity.isDead) { ridingEntity = null; return; } motionX = motionY = motionZ = 0.0D; onUpdate(); if (ridingEntity == null) { return; } ridingEntity.updateRiderPosition(); } @Override public boolean shouldRiderFaceForward(EntityPlayer player) { return this instanceof ExperimentalEntity; } public EntityAIControlledByPlayer getAIControlledByPlayer() { return this.aiControlledByPlayer; } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } }
  11. No it isn't, this is 1.8.9. I'm working out the problems first in 1.8.9 first then I will update it to 1.10
  12. For reasons I do not know, whenever I spawn my Entity, it gets harmed, there's nothing hitting it and yet it is still getting harmed. How I know that it was being harmed? Answer: the Entity has red when it is being harmed. Code: [spoiler=Entity Class] public class ExperimentalEntity extends EntityAnimal { /** AI task for player control. */ public final EntityAIControlledByPlayer aiControlledByPlayer; private static final UUID speed_UUID = UUID.fromString("e791d27a-5681-4ef1-8c96-fde0305527b5"); private static final AttributeModifier speed_Modifier = (new AttributeModifier(speed_UUID, "Speed", 1.0D, 0)); public ExperimentalEntity(World worldIn) { super(worldIn); this.tasks.addTask(0, this.aiControlledByPlayer = new EntityAIControlledByPlayer(this, 1.0F)); this.isImmuneToFire = true; } @Override public boolean isAIDisabled() { return false; } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D); } @Override protected void updateAITasks() { IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); if (this.riddenByEntity instanceof EntityPlayer && !iattributeinstance.hasModifier(speed_Modifier)) { iattributeinstance.applyModifier(speed_Modifier); } else if (this.riddenByEntity == null && iattributeinstance.hasModifier(speed_Modifier)) { iattributeinstance.removeModifier(speed_Modifier); } super.updateAITasks(); } @Override public boolean interact(EntityPlayer player) { if(!worldObj.isRemote) { player.mountEntity(this); } if(riddenByEntity != null && (riddenByEntity instanceof EntityPlayer) && riddenByEntity != player) { return true; } else { return false; } } @Override public boolean canBeSteered() { return true; } @Override public void updateRidden() { if (ridingEntity.isDead) { ridingEntity = null; return; } motionX = motionY = motionZ = 0.0D; onUpdate(); if (ridingEntity == null) { return; } ridingEntity.updateRiderPosition(); } @Override public boolean shouldRiderFaceForward(EntityPlayer player) { return this instanceof ExperimentalEntity; } public EntityAIControlledByPlayer getAIControlledByPlayer() { return this.aiControlledByPlayer; } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } }
  13. That would be loading not saving, as LexManos said you should be using the Capability system. Pardon me for my lack of knowledge of this Capability system. But what is it exactly?
  14. Okay so how do I grab the player's NBT? I've tried calling getEntityData, getNBTTagCompound through EntityPlayerSP with Minecraft.getMinecraft().thePlayer.
  15. How do I do that? I'm scratching my head here. I don't really get the hang of NBT.
  16. Ah sorry, for not stating in the title, I'm using 1.8.9.
  17. getControllingPassenger does not exists in EntityCreature, EntityLiving, EntityLivingBase and Entity.
  18. call readFromNBT from where?
  19. Okay so my custom Inventory's getStackInSlot does not render the item in the overlay. [spoiler=InventoryWeapons] public class InventoryWeapons implements IInventory { private final String name = "Inventory Weapons"; private final String tagName = "InvWeaponsTag"; public static final int INV_SIZE = 2; public ItemStack[] inventory = new ItemStack[iNV_SIZE]; public InventoryWeapons() { } @Override public int getSizeInventory() { return inventory.length; } @Override public ItemStack getStackInSlot(int slot) { return inventory[slot]; } @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); if (stack != null) { if (stack.stackSize > amount) { stack = stack.splitStack(amount); this.markDirty(); } else { this.setInventorySlotContents(slot, null); } } return stack; } @Override public ItemStack removeStackFromSlot(int slot) { ItemStack stack = getStackInSlot(slot); this.setInventorySlotContents(slot, null); return stack; } @Override public void setInventorySlotContents(int slot, ItemStack stack) { this.inventory[slot] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public String getName() { return null; } @Override public boolean hasCustomName() { return name.length() > 0; } @Override public int getInventoryStackLimit() { return 1; } @Override public void markDirty() { for (int i = 0; i < this.getSizeInventory(); ++i) { if (this.getStackInSlot(i) != null && this.getStackInSlot(i).stackSize == 0) { this.inventory[i] = null; } } } @Override public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override public void openInventory(EntityPlayer player) {} @Override public void closeInventory(EntityPlayer player) {} @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return stack.getItem() instanceof ItemWeapons; } public void writeToNBT(NBTTagCompound compound) { NBTTagList items = new NBTTagList(); for (int i = 0; i < getSizeInventory(); ++i) { if (getStackInSlot(i) != null) { NBTTagCompound item = new NBTTagCompound(); item.setByte("Slot", (byte) i); getStackInSlot(i).writeToNBT(item); items.appendTag(item); } } compound.setTag(tagName, items); } public void readFromNBT(NBTTagCompound compound) { NBTTagList items = compound.getTagList(tagName, compound.getId()); for (int i = 0; i < items.tagCount(); ++i) { NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); byte slot = item.getByte("Slot"); if (slot >= 0 && slot < getSizeInventory()) { inventory[slot] = ItemStack.loadItemStackFromNBT(item); } } } @Override public IChatComponent getDisplayName() { return new ChatComponentText(getName()); } @Override public int getField(int id) { return 0; } @Override public void setField(int id, int value) {} @Override public int getFieldCount() { return 0; } @Override public void clear() { for (int i = 0; i < inventory.length; ++i) { inventory[i] = null; } } } [spoiler=GUI Overlay] public class GuiWeaponSlots extends Gui { private static final ResourceLocation texture = new ResourceLocation(Reference.MOD_ID + ":textures/gui/weaponSlots.png"); @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderGameOverlay(RenderGameOverlayEvent.Post event) { if (event.isCancelable() || event.type != ElementType.HEALTH) { Minecraft mc = Minecraft.getMinecraft(); ScaledResolution sr = new ScaledResolution(mc); int i = sr.getScaledWidth() / 2; InventoryWeapons invWeapons = new InventoryWeapons(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); mc.getTextureManager().bindTexture(texture); this.drawTexturedModalRect(i - 121, sr.getScaledHeight() - 22, 0, 0, 22, 22); this.drawTexturedModalRect(i + 101, sr.getScaledHeight() - 22, 0, 0, 22, 22); mc.getRenderItem().renderItemAndEffectIntoGUI(invWeapons.getStackInSlot(0), i - 118, sr.getScaledHeight() - 19); mc.getRenderItem().renderItemAndEffectIntoGUI(invWeapons.getStackInSlot(1), i + 104, sr.getScaledHeight() - 19); } } } Thanks in advance
  20. Do I need to? Looking at the EntityPig class, aiControlledByPlayer does not get initialized.
  21. I'm wondering, are the ElementTypes arranged in a particular order? If so, which is the starting and what order are they arranged in? @Cancelable public class RenderGameOverlayEvent extends Event { public static enum ElementType { ALL, HELMET, PORTAL, CROSSHAIRS, BOSSHEALTH, ARMOR, HEALTH, FOOD, AIR, HOTBAR, EXPERIENCE, TEXT, HEALTHMOUNT, JUMPBAR, CHAT, PLAYER_LIST, DEBUG }
  22. I do not know why the bucket for my custom fluid is not added. I'm using this method to add the bucket FluidRegistry#addBucketForFluid. [spoiler=Fluid class] public class FluidWeb extends Fluid { public FluidWeb(String fluidName, BlockFluidClassic block) { super(fluidName, new ResourceLocation(Reference.MOD_ID + ":blocks/fluids/" + fluidName + "_still"), new ResourceLocation(Reference.MOD_ID + ":blocks/fluids/" + fluidName + "_flow")); this.setUnlocalizedName(fluidName); FluidRegistry.registerFluid(this); this.setBlock(block); } } [spoiler=Registration of Fluid] public class RegisterFluids { public static Fluid web; public static BlockFluidClassic blockFluidWeb; public static void init() { web = new FluidWeb("webfluid", blockFluidWeb); blockFluidWeb = new BlockFluidWeb(web); Main.proxy.registerFluidModels(web); FluidRegistry.addBucketForFluid(web); } } RegisterFluids#init is called in the postInit method in my Main class.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.