• 0

    posted a message on Making Arrows drop themselves

    Hello, all!


    I have a bit of a problem. See, the mod I'm creating (Thu'umCraft, since the only other Skyrim to Minecraft mod has been abandoned) has some custom arrows. The thing about this is that they are legitimately their own arrows - not arrows with potions on them or what have you.


    The problem is this: In order to fix my rendering issues, my arrow entity class needs to extend EntityArrow. Currently, it extends Entity and implements IProjectile. However, the arrow needs to drop itself (as in, when the player walks over my custom arrow, it drops a custom arrow, rather than a vanilla arrow - which is what normally happens when you have your arrow subclass EntityArrow). My current solution (the version using Entity and IProjectile) means that I am basically reimplementing the EntityArrow's code. If I want to use EntityArrow and have my arrow drop what it's supposed to, however, I need to override onCollideWithPlayer, which needs access to a bunch of private fields. As such, I need to override all of the fields in EntityArrow. In order to get EntityArrow's methods to use my fields (rather than the built-ins), I need to override all of the methods - and so the problem starts anew.


    My question: How do I go about making my arrows drop themselves without overwriting onCollideWithPlayer? I have dug into what happens there and found that it calls player.onItemPickup, which then sends a packet to the server containing the entity and player IDs. I'm thinking I need to intercept that packet, but I have no idea how (I know that it's going to need a handler, but the only resource I've found explaining this - Jabelar's Minecraft Tutorials - does so in very little detail).


    Any help is highly appreciated.


    EntitySkyrimArrow.java (the abstract from which the other entities are derived; this version uses EntityArrow, the additional spawn data is supposed to help with rendering):


    package io.github.tntftw21.thuumcraft.entity.projectile;
    
    import io.github.tntftw21.thuumcraft.item.tool.SkyrimArrow;
    import io.netty.buffer.ByteBuf;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.projectile.EntityArrow;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
    
    public class EntitySkyrimArrow extends EntityArrow implements IEntityAdditionalSpawnData {
        
        public SkyrimArrow arrow;
    
        public EntitySkyrimArrow(World p_i1753_1_, SkyrimArrow arrow)
        {
            super(p_i1753_1_);
            this.arrow = arrow;
            this.setDamage(arrow.getArrowDamage());
        }
    
        public EntitySkyrimArrow(World p_i1754_1_, double p_i1754_2_, double p_i1754_4_, double p_i1754_6_, SkyrimArrow arrow)
        {
            super(p_i1754_1_, p_i1754_2_, p_i1754_4_, p_i1754_6_);
            this.arrow = arrow;
            this.setDamage(arrow.getArrowDamage());
        }
    
        public EntitySkyrimArrow(World p_i1755_1_, EntityLivingBase p_i1755_2_, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_, SkyrimArrow arrow)
        {
            super(p_i1755_1_, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_);
            this.arrow = arrow;
            this.setDamage(arrow.getArrowDamage());
        }
    
        public EntitySkyrimArrow(World p_i1756_1_, EntityLivingBase p_i1756_2_, float p_i1756_3_, SkyrimArrow arrow)
        {
            super(p_i1756_1_, p_i1756_2_, p_i1756_3_);
            this.arrow = arrow;
            this.setDamage(arrow.getArrowDamage());
        }
    
        /**
         * (abstract) Protected helper method to write subclass entity data to NBT.
         */
        public void writeEntityToNBT(NBTTagCompound tagCompound)
        {
            super.writeEntityToNBT(tagCompound);
            NBTTagCompound arrowTag = new NBTTagCompound();
            new ItemStack(this.arrow).writeToNBT(arrowTag);
            tagCompound.setTag("arrow", arrowTag);
        }
    
        /**
         * (abstract) Protected helper method to read subclass entity data from NBT.
         */
        public void readEntityFromNBT(NBTTagCompound tagCompound)
        {
            super.readEntityFromNBT(tagCompound);
            NBTTagCompound arrowTag = (NBTTagCompound)tagCompound.getTag("arrow");
            this.arrow = (SkyrimArrow) (ItemStack.loadItemStackFromNBT(arrowTag)).getItem();
        }
        
        @Override
        public void writeSpawnData(ByteBuf buffer) {
            buffer.writeInt(shootingEntity != null ? shootingEntity.getEntityId() : -1);
        }
        
        @Override
        public void readSpawnData(ByteBuf buffer) {
            Entity shooter = worldObj.getEntityByID(buffer.readInt());
            if (shooter instanceof EntityLivingBase) {
                shootingEntity = (EntityLivingBase) shooter;
            }
        }
    }


    EntityOrcishArrow.java:

    package io.github.tntftw21.thuumcraft.entity.projectile;
    
    import io.github.tntftw21.thuumcraft.item.ModItems;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.world.World;
    
    public class EntityOrcishArrow extends EntitySkyrimArrow {
    
     public EntityOrcishArrow(World world) {
     super(world, ModItems.orcishArrow);
     // TODO Auto-generated constructor stub
     }
    
     public EntityOrcishArrow(World world, double p_i1754_2_,
     double p_i1754_4_, double p_i1754_6_) {
     super(world, p_i1754_2_, p_i1754_4_, p_i1754_6_, ModItems.orcishArrow);
     // TODO Auto-generated constructor stub
     }
    
     public EntityOrcishArrow(World world, EntityLivingBase p_i1755_2_,
     EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) {
     super(world, p_i1755_2_, p_i1755_3_, p_i1755_4_, p_i1755_5_, ModItems.orcishArrow);
     // TODO Auto-generated constructor stub
     }
    
     public EntityOrcishArrow(World world, EntityLivingBase owner,
     Float chargeFloat) {
     super(world, owner, chargeFloat, ModItems.orcishArrow);
     // TODO Auto-generated constructor stub
     }
    }

    RenderOrcishArrow.java (in case you guys wanted it):

    package io.github.tntftw21.thuumcraft.entity.render;
    
    import io.github.tntftw21.thuumcraft.ThuumCraft;
    import io.github.tntftw21.thuumcraft.entity.projectile.EntityOrcishArrow;
    import net.minecraft.client.renderer.Tessellator;
    import net.minecraft.client.renderer.entity.RenderArrow;
    import net.minecraft.entity.Entity;
    import net.minecraft.util.MathHelper;
    import net.minecraft.util.ResourceLocation;
    
    import org.lwjgl.opengl.GL11;
    import org.lwjgl.opengl.GL12;
    
    public class RenderOrcishArrow extends RenderArrow {
    
     private static final ResourceLocation arrowTextures = new ResourceLocation(ThuumCraft.MODID+":textures/entity/orcishArrow.png");
     /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probability, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
     public void doRender(EntityOrcishArrow p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
     {
     this.bindEntityTexture(p_76986_1_);
     GL11.glPushMatrix();
     GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
     GL11.glRotatef(p_76986_1_.prevRotationYaw + (p_76986_1_.rotationYaw - p_76986_1_.prevRotationYaw) * p_76986_9_ - 90.0F, 0.0F, 1.0F, 0.0F);
     GL11.glRotatef(p_76986_1_.prevRotationPitch + (p_76986_1_.rotationPitch - p_76986_1_.prevRotationPitch) * p_76986_9_, 0.0F, 0.0F, 1.0F);
     Tessellator tessellator = Tessellator.instance;
     byte b0 = 0;
     float f2 = 0.0F;
     float f3 = 0.5F;
     float f4 = (float)(0 + b0 * 10) / 32.0F;
     float f5 = (float)(5 + b0 * 10) / 32.0F;
     float f6 = 0.0F;
     float f7 = 0.15625F;
     float f8 = (float)(5 + b0 * 10) / 32.0F;
     float f9 = (float)(10 + b0 * 10) / 32.0F;
     float f10 = 0.05625F;
     GL11.glEnable(GL12.GL_RESCALE_NORMAL);
     float f11 = (float)p_76986_1_.arrowShake - p_76986_9_;
    
     if (f11 > 0.0F)
     {
     float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
     GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
     }
    
     GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
     GL11.glScalef(f10, f10, f10);
     GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
     GL11.glNormal3f(f10, 0.0F, 0.0F);
     tessellator.startDrawingQuads();
     tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
     tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
     tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
     tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
     tessellator.draw();
     GL11.glNormal3f(-f10, 0.0F, 0.0F);
     tessellator.startDrawingQuads();
     tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
     tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
     tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
     tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
     tessellator.draw();
    
     for (int i = 0; i < 4; ++i)
     {
     GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
     GL11.glNormal3f(0.0F, 0.0F, f10);
     tessellator.startDrawingQuads();
     tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
     tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
     tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
     tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
     tessellator.draw();
     }
    
     GL11.glDisable(GL12.GL_RESCALE_NORMAL);
     GL11.glPopMatrix();
     }
    
     /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
     protected ResourceLocation getEntityTexture(EntityOrcishArrow p_110775_1_)
     {
     return arrowTextures;
     }
    
     /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
     protected ResourceLocation getEntityTexture(Entity p_110775_1_)
     {
     return this.getEntityTexture((EntityOrcishArrow)p_110775_1_);
     }
    
     /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
     public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
     {
     this.doRender((EntityOrcishArrow)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
     }
    
    }

    Again, any help anyone can give would be greatly appreciated! Even a link to another forum post is fine.

    Posted in: Modification Development
  • 1

    posted a message on Why most are hating 1.9?
    If you don't like 1.9 just play an older versions it is simple

    I agree that those who dislike 1.9's battle mechanics should just play older versions. I myself have played nothing but 1.7.10 with mods for a long time now, and that's mostly because I feel that all 1.9 really did was steal ideas that were in mods that already existed. Dual wielding? Battlegear 2 already did that. Larger End? Hardcore Ender Expansion.

    My problem with the timed attacks is that it didn't really add any more strategy. You can still spam attacks, it's just that you're spamming them once a second instead of five times a second. The time taken to swing doesn't change with different weapons (i.e. a diamond sword does more damage but takes longer to swing). Instead, it still boils down to who does (and can take) the most damage.

    But then again, I have a bias against Microsoft (which is something that we will not discuss here), and that probably has something to do with it, too. IT could also be that none of the mods I really want have come out for 1.9 yet and it just feels... empty.
    Posted in: Recent Updates and Snapshots
  • 0

    posted a message on Help Needed For Thu'umCraft Textures

    A few months back I was messing around with a mod called SkyrimMC. It worked okay, but there was a lot of stuff missing. When I went searching for an updated version, however, I found, to my dismay, that the mod had been abandoned. This prompted me to make my own mod, which I affectionately refer to as Thu'umCraft, after the well-known magic mod Thaumcraft (the name is subject to change, of course). Development has been going well, but there is one huge problem: I suck at making textures.


    This is where you guys come in. I was hoping that some of you would be willing to help me with this mod by creating some textures for the items, and giving some pointers for the code here and there. This is the source for the mod, and I am perfectly okay with anyone forking, cloning, or otherwise copying it, so long as they don't actually claim it as their own.


    I would like the textures to be no larger than 32x32 for the items, since I expect Thu'umCraft to be a rather large mod when it is finished. If your texture is larger than this it may be considered for a "high res" texture pack, but right now I'm trying to cut back on RAM usage.


    The list of textures I need (list will be updated as items are added and textures provided):


    Stalhrim Item

    Dragonbone Item

    Iron, Steel, Orcish, Elvish, Glass, Ebony, Dragonbone, Daedric, Ancient Nordic and Honed Ancient Nordic versions of:

    Short Swords (except Iron)

    Long Swords

    War Axes (except Iron)

    Battleaxes

    Maces

    Warhammers

    Daggers


    I look forward to finishing this mod, and I hope all of you do as well!


    (Note: This is my first mod, but that means that it will receive the most attention as this is currently the only mod I am working on, don't let my GitHub lie to you.)

    Posted in: Mods Discussion
  • 0

    posted a message on Changing Player's Attack Stats?

    I finally figured this out thanks to Jabelar's Extended Attack Reach tutorial and with my own little bit of magic.

    Posted in: Modification Development
  • 0

    posted a message on [1.7.10-1.8] Forge Modding Tutorials by EMX | Fully Explained! | Latest: Exporting Your Mod

    I tried that tutorial, but Eclipse keeps throwing errors for some reason. This is the problem class (everything else works just fine, but I'm still working on the handler):



    package io.github.tntftw21.thuumcraft.handler;
    
    import io.github.tntftw21.thuumcraft.ThuumCraft;
    import io.github.tntftw21.thuumcraft.item.tool.IExtendedReach;
    import io.netty.buffer.ByteBuf;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.player.EntityPlayerMP;
    import cpw.mods.fml.common.network.ByteBufUtils;
    import cpw.mods.fml.common.network.simpleimpl.IMessage;
    import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
    import cpw.mods.fml.common.network.simpleimpl.MessageContext;
    
    public class MessageExtendedReachAttack implements IMessage {
    	
    	private int entityId;
    	
    	public MessageExtendedReachAttack() {
    		
    	}
    	
    	public MessageExtendedReachAttack(int entityId) {
    		this.entityId = entityId;
    	}
    
    	@Override
    	public void fromBytes(ByteBuf buf) {
    		entityId = ByteBufUtils.readVarInt(buf, 4);
    	}
    
    	@Override
    	public void toBytes(ByteBuf buf) {
    		ByteBufUtils.writeVarInt(buf, entityId, 4);
    	}
    	
    	public static class Handler implements IMessageHandler<MessageExtendedReachAttack, IMessage> {
    		public IMessage onMessage(final MessageExtendedReachAttack message, MessageContext context) {
    			final EntityPlayerMP player = (EntityPlayerMP) context.getServerHandler().playerEntity;
    			player.getServerForPlayer().addScheduledTask(
    					new Runnable() {
    						@Override
    						public void run() {
    							Entity entity = player.worldObj.getEntityByID(message.entityId);
    							if (player.getCurrentEquippedItem() == null) {
    								return;
    							}
    							if (player.getCurrentEquippedItem().getItem() instanceof IExtendedReach) {
    								IExtendedReach weapon = (IExtendedReach) player.getCurrentEquippedItem().getItem();
    								double distanceSq = player.getDistanceSqToEntity(entity);
    								double reachSq = weapon.getReach() * weapon.getReach();
    								if (reachSq >= distanceSq) {
    									player.attackTargetEntityWithCurrentItem(entity);
    								}
    							}
    							return;
    						}
    					}
    			);
    		}
    	}
    
    }


    The problem is that `player.getServerForPlayer().addScheduledTask(new Runnable())` isn't defined for WorldServer (which getServerForPlayer() returns).

    As I said, I've run into problems with this tutorial before, and I think it was this exact problem. My Forge build is 10.13.4.1448 (Yes, I'm still modding towards 1.7.10, but I really don't think much of 1.8 just yet). I've no idea why this is happening, because nobody else seems to have had this problem, and WorldServer doesn't have any methods for scheduling tasks (the only scheduling it does is for blocks and TileEntities).

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [1.7.10-1.8] Forge Modding Tutorials by EMX | Fully Explained! | Latest: Exporting Your Mod

    Could you do a tutorial about making a weapon with longer attack range? I've looked around a bit (which included writing a post here), but I haven't figured out how to do this yet. I know it's possible, though, because Mount & Blade: Battlegear 2 implements the same system (the reason I haven't used their code is because I find it difficult to navigate).

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Changing Player's Attack Stats?

    Hello all! Been awhile since I posted anything...


    So about a week ago, I found the old SkyrimMC mod for 1.7.10. I think that it's a really good idea, but it turns out that SkyrimMC was discontinued awhile back...


    So, being a good Minecrafter, I set out to make my own mod that brings Skyrim to Minecraft!


    The first thing I wanted to get out of the way was weaponry, and I've been working hard on that (all of those textures... Jesus...). However, I didn't just want to add the items. I want to bring EVERYTHING. I want to add dual-wielding for the one-handed weapons, magic and shouts (eventually), and so on.


    That brings me to my current problem: It would make sense to me that I should add weapon reach and attack speeds. It seems nearly impossible to do, however, as every Google search I've tried has led me to nowhere (Jabelar's guide was informative on the theory, but, in practice, Eclipse disagreed totally). I was wondering if anyone could explain how to actually do these things. I do recall seeing something about a weapon attribute I can change, but, then again, I have hallucinated before.


    tl;dr: I need to be able to increase/decrease the player's swing speed and attack range when using my custom weapons for my Skyrim mod.


    (ALL of) my source code is available at my github (no textures, though).


    Happy modding!

    Posted in: Modification Development
  • 0

    posted a message on Sky Factory Tutorial

    Don't know if anyone else has this problem, but Google was completely useless.


    Whenever I unload chunks, they become a swamp biome. I've noticed this problem both in singleplayer and on servers, and said chunks always appear to be in shadow and will never allow you to place blocks in them. The chunks don't render anything (i.e. they won't show that they have any blocks in them). It's almost like lag, except they stay that way until you exit and re-enter the world. As I said, Google didn't help me find a solution, so I'm concerned that maybe I corrupted my world or that my entire Sky Factory install is shot.


    I use Sky Factory 2 on Linux through the ATLauncher. It is completely up-to-date (didn't have the version number handy when I was writing this, and reloading Sky Factory takes forever). I have all of the extra mods installed except for Tails, along with WorldEdit (which I installed to see if I could fix the swamp biome problem). I tried force reloading the chunks (F3+A), reloading textures (F3+T) and reloading all resources (F3+S).


    The console shows nothing of use.

    Posted in: Mods Discussion
  • 0

    posted a message on [1.7.10-1.8] Forge Modding Tutorials by EMX | Fully Explained! | Latest: Exporting Your Mod
    Quote from emx2000»

    take a look at your GuiScreen. You might have mixed serverside and clientside stuff :)


    Thanks, that did the trick! I guess I had accidentally read the wrong part of the file when I put it in :P

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [1.7.10-1.8] Forge Modding Tutorials by EMX | Fully Explained! | Latest: Exporting Your Mod

    Thanks, I hadn't realized that I had to register that (I had followed another tut on basic tile entities, and I don't remember having to do that). Now, though, Forge keeps telling me that "io.github.tntftw21.electromag.ContainerStorage cannot be cast to net.minecraft.client.gui.GuiScreen." The only part of my code that I changed was the part in ModBlocks.java, which registers the tile entity, too. I also tried switching the object passed by GuiHandler.java to use GuiStorage(te, player) instead of ContainerStorage(te, player), but that led to one heck of a crash log. Here is the error from the above:


    [14:31:02] [Client thread/ERROR] [FML]: There was a critical exception handling a packet on channel FML
    java.lang.ClassCastException: io.github.tntftw21.electromag.client.gui.ContainerStorage cannot be cast to net.minecraft.client.gui.GuiScreen
    at cpw.mods.fml.client.FMLClientHandler.showGuiScreen(FMLClientHandler.java:444) ~[FMLClientHandler.class:?]
    at cpw.mods.fml.common.FMLCommonHandler.showGuiScreen(FMLCommonHandler.java:303) ~[FMLCommonHandler.class:?]
    at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:94) ~[FMLNetworkHandler.class:?]
    at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501) ~[EntityPlayer.class:?]
    at cpw.mods.fml.common.network.internal.OpenGuiHandler.channelRead0(OpenGuiHandler.java:16) ~[OpenGuiHandler.class:?]
    at cpw.mods.fml.common.network.internal.OpenGuiHandler.channelRead0(OpenGuiHandler.java:11) ~[OpenGuiHandler.class:?]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[SimpleChannelInboundHandler.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:101) ~[SimpleChannelInboundHandler.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[MessageToMessageDecoder.class:?]
    at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]
    at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]
    at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
    at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
    at net.minecraft.client.multiplayer.PlayerControllerMP.updateController(PlayerControllerMP.java:317) [PlayerControllerMP.class:?]
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1682) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_40]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_40]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_40]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_40]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
    at GradleStart.main(Unknown Source) [start/:?]


    The weird thing is that this error always occurs in triplets (the same one appears three times one after the other, before kicking me from the internal server).

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on [1.7.10-1.8] Forge Modding Tutorials by EMX | Fully Explained! | Latest: Exporting Your Mod

    Hey, I just read your tut about making a custom storage block, and (although it was dealing with storage) it got me much closer to understanding how to make blocks with GUIs like that. My problem, though, is that even after copy/pasting your code (and modifying it a bit so that it references that right parts of my code), Minecraft crashes when I open the GUI, telling me that the TileEntity is "missing a mapping." Below (in the spoiler, hopefully) is the crash log.


    A TileEntity type io.github.tntftw21.electromag.tileentity.TileEntityEMChamber has throw an exception trying to write state. It will not persist. Report this to the mod author
    java.lang.RuntimeException: class io.github.tntftw21.electromag.tileentity.TileEntityEMChamber is missing a mapping! This is a bug!
    at net.minecraft.tileentity.TileEntity.writeToNBT(TileEntity.java:96) ~[TileEntity.class:?]
    at io.github.tntftw21.electromag.tileentity.TileEntityEMChamber.writeToNBT(TileEntityEMChamber.java:100) ~[TileEntityEMChamber.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.writeChunkToNBT(AnvilChunkLoader.java:395) [AnvilChunkLoader.class:?]
    at net.minecraft.world.chunk.storage.AnvilChunkLoader.saveChunk(AnvilChunkLoader.java:204) [AnvilChunkLoader.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.safeSaveChunk(ChunkProviderServer.java:287) [ChunkProviderServer.class:?]
    at net.minecraft.world.gen.ChunkProviderServer.saveChunks(ChunkProviderServer.java:340) [ChunkProviderServer.class:?]
    at net.minecraft.world.WorldServer.saveAllChunks(WorldServer.java:863) [WorldServer.class:?]
    at net.minecraft.server.MinecraftServer.saveAllWorlds(MinecraftServer.java:370) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:405) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:266) [IntegratedServer.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:538) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]


    EMChamber.java:


    package io.github.tntftw21.electromag.block;

    import io.github.tntftw21.electromag.Main;
    import io.github.tntftw21.electromag.creativetabs.ModTabs;
    import io.github.tntftw21.electromag.tileentity.TileEntityEMChamber;

    import java.util.ArrayList;
    import java.util.Random;

    import net.minecraft.block.Block;
    import net.minecraft.block.BlockContainer;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.IIcon;
    import net.minecraft.util.MathHelper;
    import net.minecraft.world.World;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;

    public class EMChamber extends BlockContainer {

    private String frontTexName;
    private String sideTexName;
    public IIcon sideTex;
    public IIcon frontTex;
    private static final String name = "Electromagnetic Chamber";
    private final Random rand = new Random();

    public EMChamber(String unlocalizedName) {
    super(Material.iron);
    this.frontTexName = Main.MODID + ":" + unlocalizedName + "Front";
    this.sideTexName = Main.MODID + ":" + unlocalizedName + "Side";
    this.setBlockName(unlocalizedName)
    .setCreativeTab(ModTabs.tabElectromagItems)
    .setHardness(3.5f)
    .setResistance(25.0f)
    .setHarvestLevel("pickaxe", 1);
    }

    @Override
    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) {
    int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0f / 360.0f) + 0.5d) & 3;

    switch(l) {
    case 0:
    world.setBlockMetadataWithNotify(x, y, z, 2, 2);
    break;
    case 1:
    world.setBlockMetadataWithNotify(x, y, z, 5, 2);
    break;
    case 2:
    world.setBlockMetadataWithNotify(x, y, z, 3, 2);
    break;
    case 3:
    world.setBlockMetadataWithNotify(x, y, z, 4, 2);
    break;
    }
    }
    @SideOnly(Side.CLIENT)
    @Override
    public IIcon getIcon(int side, int meta)
    {
    return side == 1 ? this.sideTex : (side == 0 ? this.sideTex : (side != meta ? this.sideTex : this.frontTex));
    }

    @SideOnly(Side.CLIENT)
    @Override
    public void registerBlockIcons(IIconRegister reg)
    {
    this.sideTex = reg.registerIcon(this.sideTexName);
    this.frontTex = reg.registerIcon(this.frontTexName);
    }
    @Override
    public int damageDropped(int meta) {
    return 0;
    }
    @Override
    public TileEntity createNewTileEntity(World world, int meta) {
    return new TileEntityEMChamber();
    }

    @Override
    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
    if (world.isRemote) {
    return true;
    }

    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null && te instanceof TileEntityEMChamber) {
    player.openGui(Main.instance, 0, world, x, y, z);
    return true;
    }
    return false;
    }

    @Override
    public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
    if (world.isRemote){
    return;
    }
    ArrayList drops = new ArrayList();
    TileEntity teRaw = world.getTileEntity(x, y, z);
    if (teRaw != null && teRaw instanceof TileEntityEMChamber) {
    TileEntityEMChamber te = (TileEntityEMChamber) teRaw;
    for (int i = 0; i < te.getSizeInventory(); i++) {
    ItemStack stack = te.getStackInSlot(i);
    if (stack != null) {
    drops.add(stack.copy());
    }
    }
    }
    for (int i = 0; i < drops.size(); i++) {
    EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5);
    item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25);
    world.spawnEntityInWorld(item);
    }
    }
    }


    TileEntityEMChamber.java:


    package io.github.tntftw21.electromag.tileentity;

    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraftforge.common.util.Constants;

    //TODO Create TileEntityEM and AbilityRegistry
    public class TileEntityEMChamber extends TileEntity implements IInventory {
    private ItemStack[] items = new ItemStack[15];

    @Override
    public int getSizeInventory() {
    return items.length;
    }

    @Override
    public ItemStack getStackInSlot(int slot) {
    return items[slot];
    }

    @Override
    public ItemStack decrStackSize(int slot, int amount) {
    if (items[slot] != null) {
    ItemStack itemStack;
    if (items[slot].stackSize == amount) {
    itemStack = items[slot];
    items[slot] = null;
    markDirty();
    return itemStack;
    } else {
    itemStack = items[slot].splitStack(amount);
    if (items[slot].stackSize == 0)
    items[slot] = null;
    markDirty();
    return itemStack;
    }
    } else {
    return null;
    }
    }

    @Override
    public ItemStack getStackInSlotOnClosing(int slot) {
    if (items[slot] != null) {
    ItemStack itemStack = items[slot];
    items[slot] = null;
    return itemStack;
    } else {
    return null;
    }
    }

    @Override
    public void setInventorySlotContents(int slot, ItemStack stack) {
    items[slot] = stack;
    if (stack != null && stack.stackSize > getInventoryStackLimit()) {
    stack.stackSize = getInventoryStackLimit();
    }
    markDirty();
    }

    @Override
    public String getInventoryName() {
    return "container.storage";
    }

    @Override
    public boolean hasCustomInventoryName() {
    return false;
    }

    @Override
    public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    NBTTagList list = nbt.getTagList("Items", Constants.NBT.TAG_COMPOUND);
    items = new ItemStack[getSizeInventory()];

    for (int i = 0; i < list.tagCount(); i++) {
    NBTTagCompound comp = list.getCompoundTagAt(i);
    int j = comp.getByte("Slot") & 255;
    if (j >= 0 && j < items.length) {
    items[j] = ItemStack.loadItemStackFromNBT(comp);
    }
    }
    }

    @Override
    public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    NBTTagList list = new NBTTagList();
    for (int i = 0; i < items.length; ++i) {
    if (items != null) {
    NBTTagCompound comp = new NBTTagCompound();
    comp.setByte("Slot", (byte)i);
    items.writeToNBT(comp);
    list.appendTag(comp);
    }
    }
    nbt.setTag("Items", list);
    }

    @Override
    public int getInventoryStackLimit() {
    return 64;
    }

    @Override
    public boolean isUseableByPlayer(EntityPlayer player) {
    return worldObj.getTileEntity(xCoord, yCoord, zCoord) != this ? false : player.getDistanceSq((double)xCoord + 0.5d, (double) yCoord + 0.5d, (double) zCoord + 0.5d) <= 64.0d;
    }

    @Override
    public void openInventory() {
    //NOOP
    }

    @Override
    public void closeInventory() {
    //NOOP
    }

    @Override
    public boolean isItemValidForSlot(int slot, ItemStack stack) {
    return true;
    }
    }


    GuiHandler.java:


    package io.github.tntftw21.electromag.handler;

    import io.github.tntftw21.electromag.client.gui.ContainerStorage;
    import io.github.tntftw21.electromag.tileentity.TileEntityEMChamber;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.network.IGuiHandler;

    public class GuiHandler implements IGuiHandler {

    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world,
    int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);

    if (te != null) {
    if (ID == 0) {
    return new ContainerStorage((TileEntityEMChamber)te, player);
    }
    }
    return null;
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world,
    int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);

    if (te != null) {
    if (ID == 0) {
    return new ContainerStorage((TileEntityEMChamber)te, player);
    }
    }
    return null;
    }

    }


    GuiStorage.java:


    package io.github.tntftw21.electromag.client.gui;

    import io.github.tntftw21.electromag.Main;
    import io.github.tntftw21.electromag.tileentity.TileEntityEMChamber;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.client.resources.I18n;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;

    import org.lwjgl.opengl.GL11;

    public class GuiStorage extends GuiContainer {

    private ResourceLocation texture = new ResourceLocation(Main.MODID, "textures/gui/container/storage.png");

    private InventoryPlayer inventory;
    private TileEntityEMChamber te;

    public GuiStorage(TileEntityEMChamber te, EntityPlayer player) {
    super(new ContainerStorage(te, player));
    inventory = player.inventory;
    this.te = te;
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
    Minecraft.getMinecraft().renderEngine.bindTexture(texture);

    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;

    drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    }

    @Override
    protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    fontRendererObj.drawString(I18n.format(te.getInventoryName()), (xSize / 2) - (fontRendererObj.getStringWidth(I18n.format(te.getInventoryName())) / 2), 6, 4210752, false);
    fontRendererObj.drawString(I18n.format(inventory.getInventoryName()), 8, ySize - 96 + 2, 4210752);
    }

    }


    ContainerStorage.java:


    package io.github.tntftw21.electromag.client.gui;

    import io.github.tntftw21.electromag.tileentity.TileEntityEMChamber;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.ItemStack;

    public class ContainerStorage extends Container
    {
    private TileEntityEMChamber te;

    private int slotID = 0;

    public ContainerStorage(TileEntityEMChamber te, EntityPlayer player)
    {
    this.te = te;

    //Storage
    for (int i = 0; i < 3; i++)
    {
    for (int j = 0; j < 5; j++)
    {
    addSlotToContainer(new Slot(te, slotID++, 44 + j * 18, 17 + i * 18));
    }
    }

    //Inventory
    for (int i = 0; i < 3; i++)
    {
    for (int j = 0; j < 9; j++)
    {
    addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
    }
    }
    // Hotbar
    for (int i = 0; i < 9; i++)
    {
    addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
    }
    }

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

    if (slot != null && slot.getHasStack())
    {
    ItemStack stackInSlot = slot.getStack();
    stack = stackInSlot.copy();

    if (slotRaw < 3 * 9)
    {
    if (!mergeItemStack(stackInSlot, 3 * 9, inventorySlots.size(), true))
    {
    return null;
    }
    }
    else if (!mergeItemStack(stackInSlot, 0, 3 * 9, false))
    {
    return null;
    }

    if (stackInSlot.stackSize == 0)
    {
    slot.putStack((ItemStack)null);
    }
    else
    {
    slot.onSlotChanged();
    }
    }
    return stack;
    }

    @Override
    public boolean canInteractWith(EntityPlayer player)
    {
    return te.isUseableByPlayer(player);
    }
    }


    I'm still kind of a noob with modding (even more so with making GUIs and whatnot, since the only tutorials I find are shady at best), so for all I know I could have made a rookie mistake.

    Posted in: Mapping and Modding Tutorials
  • 0

    posted a message on Minecraft killed my GUI
    Okay, so it turned out to be a problem in Firefox, not Minecraft (Firefox had a bunch of graphics libraries it was missing).
    Posted in: Java Edition Support
  • 0

    posted a message on Minecraft killed my GUI
    Well, I'm going to go ahead and mark this as resolved. It turns out that there are some known bugs with the nVidia drivers, and that was causing the problem. After switching to the Nouveau drivers, everything worked swimmingly.



    Sorry for all the trouble, but I was starting to get desperate :P. I had noticed nobody else had my problem, and I just figured that that was because nobody was stupid enough to do what I did. However, it would appear that instead, it was a bug manifesting itself in a different way than usual (my dad apparently has the same problem at his work when logging into another server with a GUI, where the server can still show him doing everything, but he can't see what he's doing, but just didn't bother to tell me until recently).



    And don't worry about all of the hostility, you had every right for it. I only wish that the skepticism shown here was applied to other areas in life as well (especially in UFO encounters).
    Posted in: Java Edition Support
  • 0

    posted a message on Minecraft killed my GUI
    ...



    So, it appears that I can no longer recreate the scenario, which means that either it was going to happen anyway, or it was under just the right conditions. I'd opt for the second, since this is a relatively new GPU.



    However, should the "splotches" appear again, I will screencap them immediately.



    For right now, however, I guess it would be appropriate to "nevermind" this post. Sorry for any trouble I caused you.
    Posted in: Java Edition Support
  • To post a comment, please .