-
Posts
30 -
Joined
-
Last visited
Everything posted by CactusCoffee
-
Hi, Having an issue with an entity that extends EntityThrowable. Sometimes, especially if the thrower is moving forwards, the projectile will register a hit as soon as it spawns, but only on the client side. If the player catches up with the projectile, this can continue to occur, often without triggering a hit on the server side. I thought I had found a way to consistently prevent this, but this solution seems to have stopped working. The vanilla projectiles don't seem to have any logic to prevent this, and yet don't have the issue. I'm not sure what the deciding difference is between my projectile and the vanilla ones. The projectile class: public class EntityMagicOrb extends EntityThrowable implements IEntityAdditionalSpawnData { private SpellProjectile spell; public byte data; private int ignoreTime; public EntityMagicOrb(World world) { super(world); } public EntityMagicOrb(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public EntityMagicOrb(World world, EntityPlayer player, SpellProjectile spell) { super(world, player); this.ignoreEntity = player; this.spell = spell; } @Override protected void onImpact(@Nonnull RayTraceResult result) { boolean kill = false; if (result.typeOfHit == RayTraceResult.Type.ENTITY) { if (!result.entityHit.isDead) { Entity targetEntity = result.entityHit; MultiPartEntityPart part = null; if (targetEntity instanceof MultiPartEntityPart) { part = (MultiPartEntityPart) targetEntity; IEntityMultiPart ientitymultipart = part.parent; if (ientitymultipart instanceof EntityLivingBase) { targetEntity = (EntityLivingBase) ientitymultipart; } } if (spell.projectileEffectOnEntity(this, (EntityPlayer) this.getThrower(), targetEntity, this.getEntityWorld(), part)) { kill = true; } } } else if (result.typeOfHit == RayTraceResult.Type.BLOCK) { if (spell.projectileEffectOnBlock(this, (EntityPlayer) this.getThrower(), this.getEntityWorld(), result.getBlockPos(), result.sideHit)) { kill = true; } } else { spell.projectileEffect(this, (EntityPlayer) this.getThrower(), this.getEntityWorld()); kill = true; } if (kill && !world.isRemote) { this.setDead(); } } @Override public void onUpdate() { if (spell == null) { setDead(); } else { spell.projectileTick(this, this.world); } } public void adjustStartPos() { this.posX += motionX; this.posY += motionY; this.posZ += motionZ; } public Element getElement() { return spell.getElement(); } @Override protected float getGravityVelocity() { return 0.02F; } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setByte("Spell", (byte) spell.getIndex()); nbt.setByte("Data", data); return nbt; } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); spell = (SpellProjectile) Spells.getFromList(nbt.getByte("Spell")); data = nbt.getByte("Data"); } @Override public void writeSpawnData(ByteBuf buffer) { if (spell != null) { buffer.writeInt(spell.getIndex()); } else { buffer.writeInt(-1); } buffer.writeByte(data); } @Override public void readSpawnData(ByteBuf additionalData) { spell = (SpellProjectile) Spells.getFromList(additionalData.readInt()); data = additionalData.readByte(); } public void processProjectile() { if (this.ticksExisted > 100 || this.inGround) { this.setDead(); } else { this.lastTickPosX = this.posX; this.lastTickPosY = this.posY; this.lastTickPosZ = this.posZ; if (!this.world.isRemote) { this.setFlag(6, this.isGlowing()); } this.onEntityUpdate(); Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ); Vec3d vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, vec3d1, false, true, false); vec3d = new Vec3d(this.posX, this.posY, this.posZ); vec3d1 = new Vec3d(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (raytraceresult != null) { vec3d1 = new Vec3d(raytraceresult.hitVec.x, raytraceresult.hitVec.y, raytraceresult.hitVec.z); } Entity entity = null; List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D)); double d0 = 0.0D; boolean flag = false; for (Entity entity1 : list) { if (entity1.canBeCollidedWith()) { if (entity1 == this.ignoreEntity) { flag = true; } else if (this.thrower != null && this.ticksExisted < 2 && this.ignoreEntity == null) { this.ignoreEntity = entity1; flag = true; } else { flag = false; AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().grow(0.3D); RayTraceResult raytraceresult1 = axisalignedbb.calculateIntercept(vec3d, vec3d1); if (raytraceresult1 != null) { double d1 = vec3d.squareDistanceTo(raytraceresult1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } } if (this.ignoreEntity != null) { if (flag) { this.ignoreTime = 2; } else if (this.ignoreTime-- <= 0) { this.ignoreEntity = null; } } if (entity != null) { raytraceresult = new RayTraceResult(entity); } if (raytraceresult != null) { if (raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && this.world.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.PORTAL) { this.setPortal(raytraceresult.getBlockPos()); } else if (!net.minecraftforge.event.ForgeEventFactory.onProjectileImpact(this, raytraceresult)) { this.onImpact(raytraceresult); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; this.rotationYaw = (float) (MathHelper.atan2(this.motionX, this.motionZ) * (180D / Math.PI)); while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; if (!this.hasNoGravity()) { this.motionY -= this.getGravityVelocity(); } this.setPosition(this.posX, this.posY, this.posZ); } } } Note: processProjectile() is mostly copied from the superclass onUpdate(), but modified to remove collision with water. I've tested with both this method and the normal onUpdate(), it's not the source of the issue. And here's the code that spawns the projectile: public boolean spawnProjectile(EntityPlayer player, World world) { if (!world.isRemote) { EntityMagicOrb entity = new EntityMagicOrb(world, player, this); entity.setNoGravity(true); onProjectileShoot(entity, player); entity.adjustStartPos(); world.spawnEntity(entity); return true; } return false; }
-
Issues Starting a "New" Project
CactusCoffee replied to CactusCoffee's topic in Support & Bug Reports
Seems like it sorted itself out after a PC restart. -
Issues Starting a "New" Project
CactusCoffee replied to CactusCoffee's topic in Support & Bug Reports
I did this, it still did not work. Gradle tasks are no longer present, and I can't run anything. -
Hi, getting back into modding with an existing project. Again. I just hit the "Detach Gradle" button in Intellij due to a misclick and it seems to have irrevocably trashed my entire project structure. Right now I am trying to restart by pasting the source code into a fresh forge project, but I am running into trouble when trying to resolve the standard external libraries in the new project. I have redownloaded forge MDK, run setupDecompWorkspace, cleaned out gradle folder in my user home to be safe, double checked tutorials to make sure I'm not forgetting anything. But standard external libraries including the decompiled base game source are not generated, only "compileDummy.jar" and "providedDummy.jar", so I can't continue. Any idea what is going wrong so I can start fresh?
-
(Solved) [1.12.2] Trouble Rendering Custom Projectile Entity
CactusCoffee replied to CactusCoffee's topic in Modder Support
Found the problem. It wasn't getting called because registerEntities wasn't static, since I'm using @Mod.EventBusSubscriber. I knew this would be something stupid, but I didn't think it would be something that stupid. Thank you. -
(Solved) [1.12.2] Trouble Rendering Custom Projectile Entity
CactusCoffee replied to CactusCoffee's topic in Modder Support
It looks like my entity registration method isn't being called at all. The entity registration itself may be wrong too. Here's the registration method: @SubscribeEvent public void registerEntities(RegistryEvent.Register<EntityEntry> event) { System.out.println("Registering Mod Entities"); EntityEntry entry = EntityEntryBuilder.create() .entity(EntityMagicOrb.class) .id(new ResourceLocation(MagicMod.MODID, "magic_orb"), 0) .name("magic_orb") .tracker(64, 20, true) .build(); event.getRegistry().register(entry); } -
(Solved) [1.12.2] Trouble Rendering Custom Projectile Entity
CactusCoffee replied to CactusCoffee's topic in Modder Support
Ah. I did have a feeling it wasn't quite right - i noticed after i marked this solved that the explosion caused by the projectile on impact was slightly off from where it appeared to hit. Thanks for calling that out. The World constructor in the entity class didn't do it, though. Here are the constructors I added: public EntityMagicOrb(World world) { super(world); } public EntityMagicOrb(World world, SpellProjectile spell) { super(world); this.spell = spell; } -
(Solved) [1.12.2] Trouble Rendering Custom Projectile Entity
CactusCoffee replied to CactusCoffee's topic in Modder Support
It actually ended up being something even dumber that I overlooked. In the code I copied from 1.7.10 for spawning the projectile, I had an if (!world.isRemote) check before spawning the entity. So of course the entity didn't appear client-side. Getting rid of that check fixed the issue. Not sure why it worked in 1.7.10, but whatever. Thank you. -
Hi, I'm working on updating my old mod from 1.7.10 to 1.12.2. I'm having trouble updating one of my entities (a projectile similar to a snowball). The entity itself works fine, but I haven't been able to get it to render; it's invisible. I've looked around tutorials and this forum for a while but haven't found anything that worked. Here's my entity renderer class: public class RenderMagicOrb extends Render<EntityMagicOrb> { private static ResourceLocation TEXTURE_RED = new ResourceLocation(MagicMod.MODID, "textures/entity/magic_orb_red.png"); private static ResourceLocation TEXTURE_YELLOW = new ResourceLocation(MagicMod.MODID, "textures/entity/magic_orb_yellow.png"); private static ResourceLocation TEXTURE_GREEN = new ResourceLocation(MagicMod.MODID, "textures/entity/magic_orb_green.png"); private static ResourceLocation TEXTURE_BLUE = new ResourceLocation(MagicMod.MODID, "textures/entity/magic_orb_blue.png"); private static ResourceLocation TEXTURE_BLACK = new ResourceLocation(MagicMod.MODID, "textures/entity/magic_orb_black.png"); private static ResourceLocation TEXTURE_WHITE = new ResourceLocation(MagicMod.MODID, "textures/entity/magic_orb_white.png"); public RenderMagicOrb(RenderManager renderManagerIn) { super(renderManagerIn); } public void doRender(@Nonnull EntityMagicOrb entity, double x, double y, double z, float entityYaw, float partialTicks) { GlStateManager.pushMatrix(); bindEntityTexture(entity); GlStateManager.translate((float)x, (float)y, (float)z); GlStateManager.enableRescaleNormal(); GlStateManager.scale(2.0F, 2.0F, 2.0F); Tessellator tessellator = Tessellator.getInstance(); BufferBuilder bufferbuilder = tessellator.getBuffer(); GlStateManager.rotate(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GlStateManager.rotate((float)(this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * -this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); if (renderOutlines) { GlStateManager.enableColorMaterial(); GlStateManager.enableOutlineMode(this.getTeamColor(entity)); } bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX_NORMAL); bufferbuilder.pos(-0.5D, -0.25D, 0.0D).tex(0.0D, 1.0D).normal(0.0F, 1.0F, 0.0F).endVertex(); bufferbuilder.pos(0.5D, -0.25D, 0.0D).tex(1.0D, 1.0D).normal(0.0F, 1.0F, 0.0F).endVertex(); bufferbuilder.pos(0.5D, 0.75D, 0.0D).tex(1.0D, 0.0D).normal(0.0F, 1.0F, 0.0F).endVertex(); bufferbuilder.pos(-0.5D, 0.75D, 0.0D).tex(0.0D, 0.0D).normal(0.0F, 1.0F, 0.0F).endVertex(); tessellator.draw(); if (renderOutlines) { GlStateManager.disableOutlineMode(); GlStateManager.disableColorMaterial(); } GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); super.doRender(entity, x, y, z, entityYaw, partialTicks); } @Override protected ResourceLocation getEntityTexture(@Nonnull EntityMagicOrb entity) { switch (entity.getElement()) { case RED: return TEXTURE_RED; case YELLOW: return TEXTURE_YELLOW; case GREEN: return TEXTURE_GREEN; case BLUE: return TEXTURE_BLUE; case BLACK: return TEXTURE_BLACK; case WHITE: return TEXTURE_WHITE; } //Default, should never happen return TEXTURE_RED; } } And here's my ClientProxy: @Mod.EventBusSubscriber(Side.CLIENT) public class ClientProxy extends CommonProxy { @Override public void preInit(FMLPreInitializationEvent e) { super.preInit(e); RenderingRegistry.registerEntityRenderingHandler(EntityMagicOrb.class, new IRenderFactory<EntityMagicOrb>() { @Override public Render<? super EntityMagicOrb> createRenderFor(RenderManager manager) { return new RenderMagicOrb(manager); } }); } @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { } @Override public void registerItemRenderer(Item item, int meta, String id) { ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(MagicMod.MODID + ":" + id, "inventory")); } } Here's the entity class itself, though I don't think it's the problem public class EntityMagicOrb extends EntityThrowable implements IEntityAdditionalSpawnData { private SpellProjectile spell; private float gravity = 0.03F; public EntityMagicOrb(World world, EntityPlayer player, SpellProjectile spell) { super(world, player); this.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F); this.spell = spell; } @Override protected void onImpact(RayTraceResult result) { spell.projectileEffect(this, (EntityPlayer) this.getThrower(), this.getEntityWorld()); if (!this.world.isRemote) { this.world.setEntityState(this, (byte)3); this.setDead(); } } @Override public void onUpdate() { super.onUpdate(); if (this.ticksExisted > 400) setDead(); } public Element getElement() { return spell.getElement(); } @Override protected float getGravityVelocity() { return gravity; } @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); nbt.setByte("Spell", (byte) Spells.getPlaceInList(spell)); return nbt; } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); spell = (SpellProjectile) Spells.getFromList(nbt.getByte("Spell")); } @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(Spells.getPlaceInList(spell)); } @Override public void readSpawnData(ByteBuf additionalData) { spell = (SpellProjectile) Spells.getFromList(additionalData.readInt()); } } What am I missing?
-
[1.7.10][SOLVED] Sorting Creative Tab
CactusCoffee replied to CactusCoffee's topic in Modder Support
...Well I'm dumbfounded. Changed it so it got the list from a function instead of a parameter, and added all the blocks. It works just fine. I could swear I tried that before and still got an error. But I guess it doesn't matter, it works. Current status: still incompetent Thanks for your help. -
[1.7.10][SOLVED] Sorting Creative Tab
CactusCoffee replied to CactusCoffee's topic in Modder Support
I thought that was the case. My list currently contains only the items. When I try adding one of the blocks (using Item.getItemFromBlock()), however, I get a nullPointerException: java.lang.NullPointerException: null key in entry: null=0 at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:31) at com.google.common.collect.ImmutableMap.entryOf(ImmutableMap.java:135) at com.google.common.collect.ImmutableMap$Builder.put(ImmutableMap.java:206) at com.google.common.collect.ExplicitOrdering.buildRankMap(ExplicitOrdering.java:56) at com.google.common.collect.ExplicitOrdering.<init>(ExplicitOrdering.java:32) at com.google.common.collect.Ordering.explicit(Ordering.java:162) at com.finneyt.simplymagic.main.SimplyMagicMod.preInit(SimplyMagicMod.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:513) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:931) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) -
It's me again. So I want to sort my mod's creative tab so it isn't a jumbled mess like the vanilla ones, and so I don't have to change item IDs every time I add new stuff to keep the tab neat. I've attempted to follow diesieben07's tutorial on the matter: http://www.minecraftforge.net/forum/index.php/topic,23782.msg120743.html#msg120743 However, I get this error: com.google.common.collect.Ordering$IncomparableValueException: Cannot compare value: net.minecraft.item.ItemBlock@509e4bc4 at com.google.common.collect.ExplicitOrdering.rank(ExplicitOrdering.java:46) at com.google.common.collect.ExplicitOrdering.compare(ExplicitOrdering.java:40) at com.google.common.collect.ByFunctionOrdering.compare(ByFunctionOrdering.java:46) at java.util.TimSort.countRunAndMakeAscending(Unknown Source) at java.util.TimSort.sort(Unknown Source) at java.util.Arrays.sort(Unknown Source) at java.util.ArrayList.sort(Unknown Source) at java.util.Collections.sort(Unknown Source) at com.finneyt.simplymagic.main.SimplyMagicMod$1.displayAllReleventItems(SimplyMagicMod.java:100) at net.minecraft.client.gui.inventory.GuiContainerCreative.setCurrentCreativeTab(GuiContainerCreative.java:508) at net.minecraft.client.gui.inventory.GuiContainerCreative.mouseMovedOrUp(GuiContainerCreative.java:482) at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:354) at net.minecraft.client.gui.inventory.GuiContainer.handleMouseInput(GuiContainer.java) at net.minecraft.client.gui.inventory.GuiContainerCreative.handleMouseInput(GuiContainerCreative.java:598) at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:313) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1720) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) at net.minecraft.client.Minecraft.run(Minecraft.java:951) at net.minecraft.client.main.Main.main(Main.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) Here's the relevant code: import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; import com.google.common.base.Function; import com.google.common.collect.Ordering; public class Mod... { private static Comparator<ItemStack> tabComp; public static final CreativeTabs tab = new CreativeTabs(MODID + "_" + "tab") { @Override @SideOnly(Side.CLIENT) public void displayAllReleventItems(List items) { super.displayAllReleventItems(items); Collections.sort(items, tabComp); } }; @EventHandler public void preInit(FMLPreInitializationEvent event) { tabComp = Ordering.explicit(ModItems.ITEM_ORDER).onResultOf(new Function<ItemStack, Item>() { @Override public Item apply(ItemStack i) { return i.getItem(); } }); } } Please let me know what I'm doing wrong, I don't like being incompetent
-
So I've looked at ScratchForFun's tutorial on the NEI API and did everything as he did - but I get an error. I have the dev & source versions of CCC and NEI, set up the build paths, got them in the mods folder, but nothing's working. Checked the source code and the class it's looking for doesn't seem to be there. Do I need a different version or something?
-
[1.7.10] Registering Key Handler in Client Proxy
CactusCoffee replied to CactusCoffee's topic in Modder Support
That's what I thought. Just making sure. Thanks. -
The mod I am working on uses a key press event - this works fine on single-player but I am trying to make it work in multiplayer. Currently the key handler is registered in the main mod class preInit() using FMLCommonHandler.instance().bus().register(new KeyHandler()). I know that I need to register it in the client proxy instead, but I do not know how to do that - I've looked for tutorials on this but so far what I've found either isn't updated for 1.7.10 or doesn't show the code. I reckon the solution to this is quite simple, but I want to be sure of what I'm doing. Thanks.
-
[1.7.10][Solved] Texture lost upon building
CactusCoffee replied to CactusCoffee's topic in Modder Support
Ok, found that I had an uppercase letter in the resource location. Fixed it. Thanks. -
I just built the first release version of my mod and have been testing it out to make sure everything built properly - apparently it didn't. Here's what one of my GUIs looks like when in forge dev: Here's what it looks like in the release version: I tried reloading Minecraft as well as rebuilding the mod, same thing happened. I searched for some solution to this issue, but found nothing. Is it something I'm doing wrong?
-
[1.7.10] Questions about rendering thrown entities
CactusCoffee replied to CactusCoffee's topic in Modder Support
WOW. GOD DAMMIT. I just found that the reason it didn't work was that I misspelled the element nbt tag in the spawnProjectile method - it's "ElementID" not "Element." Fixed it, it works now. Thanks for your help. -
[1.7.10] Questions about rendering thrown entities
CactusCoffee replied to CactusCoffee's topic in Modder Support
Entity registry: int randomId = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(EntityMagicOrb.class, "Magic Orb", randomId); EntityRegistry.registerModEntity(EntityMagicOrb.class, "Magic Orb", randomId, this.instance, 64, 1, true); Method in staff item that spawns entity: private void spawnProjectile(ItemStack itemStack, World world, EntityPlayer player) { if (!world.isRemote) { world.spawnEntityInWorld(new EntityMagicOrb(world, player, itemStack.stackTagCompound.getInteger("SpellID"), itemStack.stackTagCompound.getInteger("Element"))); } } System out when spawning entity: [11:03:39] [server thread/INFO] [sTDOUT]: [com.finneyt.simplymagic.entity.EntityMagicOrb:writeSpawnData:390]: Write: 0 [11:03:39] [Client thread/INFO] [sTDOUT]: [com.finneyt.simplymagic.entity.EntityMagicOrb:readSpawnData:396]: Read: 0 -
[1.7.10] Questions about rendering thrown entities
CactusCoffee replied to CactusCoffee's topic in Modder Support
I've taken a look at some other mod support requests, and so far I've implemented IEntityAdditionalSpawnData in the entity class and added the writeSpawnData and ReadSpawnData methods: @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(element); } @Override public void readSpawnData(ByteBuf additionalData) { element = additionalData.readInt(); } If I'm understanding this correctly, this should let the renderer as it is use the correct texture. The entity's element value is set in its constructer, and I've also tried using setElement before spawning the entity in the world. It's still just using the default texture. To my understanding, nothing more is required from this, so I've buggered up something, and I don't know how to find out what, or what I did wrong. EDIT: So I did a System.out.println and found that it's not writing. One mystery solved, but I still don't understand why that's occuring. -
[1.7.10] Questions about rendering thrown entities
CactusCoffee replied to CactusCoffee's topic in Modder Support
I did some tinkering with your suggestion and got it to use the texture. Here's the render class as it is now: (package) (imports) public class RenderMagicOrb extends Render { private int element; private static final ResourceLocation texRed = new ResourceLocation(SimplyMagicMod.MODID, "textures/entity/magicorb_red.png"); private static final ResourceLocation texYel = new ResourceLocation(SimplyMagicMod.MODID, "textures/entity/magicorb_yellow.png"); private static final ResourceLocation texGrn = new ResourceLocation(SimplyMagicMod.MODID, "textures/entity/magicorb_green.png"); private static final ResourceLocation texBlu = new ResourceLocation(SimplyMagicMod.MODID, "textures/entity/magicorb_blue.png"); private static final ResourceLocation texBlk = new ResourceLocation(SimplyMagicMod.MODID, "textures/entity/magicorb_black.png"); private static final ResourceLocation texWhi = new ResourceLocation(SimplyMagicMod.MODID, "textures/entity/magicorb_white.png"); public RenderMagicOrb(int data) { this.element = data; } public RenderMagicOrb() { this(0); } public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTick) { bindTexture(chooseTexture(((EntityMagicOrb)entity).getElement())); GL11.glPushMatrix(); GL11.glTranslatef((float)x, (float)y, (float)z); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glScalef(0.5F, 0.5F, 0.5F); Tessellator tessellator = Tessellator.instance; GL11.glRotatef(180.0F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); tessellator.addVertexWithUV(-0.5D, -0.25D, 0.0D, 0, 1); tessellator.addVertexWithUV(0.5D, -0.25D, 0.0D, 1, 1); tessellator.addVertexWithUV(0.5D, 0.75D, 0.0D, 1, 0); tessellator.addVertexWithUV(-0.5D, 0.75D, 0.0D, 0, 0); tessellator.draw(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } private ResourceLocation chooseTexture(int element) { switch (element) { case 1: return texRed; case 2: return texYel; case 3: return texGrn; case 4: return texBlu; case 5: return texBlk; case 6: return texWhi; default: return texWhi; } } @Override protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return TextureMap.locationItemsTexture; } } I still need to figure out how to get the additional spawn data to work, as it's always using the default white texture. So far I haven't found any useful tutorials or other mod support regarding that, I need to do some more digging. Thanks for your help. -
[1.7.10] Questions about rendering thrown entities
CactusCoffee replied to CactusCoffee's topic in Modder Support
I put the breaks in. Not sure how to bind the resourcelocation / use tessellator. -
[1.7.10] Questions about rendering thrown entities
CactusCoffee replied to CactusCoffee's topic in Modder Support
1) Looking at what I'd need to do to get a TextureStitchEvent working, I think it'd probably be easier to just make a hidden item class that handles the icons, unless that's bad practice or something. Thanks for your help. 2) So I added the IAdditionalSpawnData implementation: @Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(element); System.out.println("Spawn data written"); } @Override public void readSpawnData(ByteBuf additionalData) { element = additionalData.readInt(); System.out.println("Spawn data read"); } Tried it out and the methods are being called but it still isn't affecting the entity icon. I don't know if that's a problem with the renderer or with the additional spawn data implementation. I'm probably missing something blindingly obvious but this is an entirely new thing to me. Whatever the case, thanks for your help.