Jump to content

TheMattyBoy

Forge Modder
  • Posts

    40
  • Joined

  • Last visited

Posts posted by TheMattyBoy

  1. 16 minutes ago, diesieben07 said:

    Stop calling packets packages. They are different things.

    Oh oops, didn't even notice that... Embarrassing...

     

    17 minutes ago, diesieben07 said:

    This is not needed. The server knows who sent the packet.

    Right, thanks.

     

    17 minutes ago, diesieben07 said:

    You cannot blindly trust the entity ID (pianoId in your packet) that the client sends. At least do a check that the client is within range.

    Didn't I already sort of do this by doing world.getEntityByID(message.pianoId).getDistanceSqToEntity(p_apply_1_) < 900.0D in the predicate for finding the players?

     

    20 minutes ago, diesieben07 said:

    Packets must always be registered on both sides.

    Alright, this is what I was having trouble with. If I tried to register a client packet on both sides the server would crash with a NoClassDefFoundError on whatever client-only class I was trying to access in my onMessage method in my message handler, and no amount of side checking or @SideOnly-ing would fix the error. How do I register a packet on both sides, while being able to access client only classes and methods, without the server immediately crashing with a NoClassDefFoundError or NoSuchMethodError?

  2. I'm trying to create a GUI that can play sounds of type MovingSound (as opposed to a normal PositionedSoundRecords, which is what World#playSound uses) when pressed, not only to the player using the GUI, but to everyone within range. Of course, GUI's are exclusively client sided, so I decided to use SimpleImpl to send a message about the sound to the server, but since I'm using a MovingSound I then have to play it through the SoundHandler in Minecraft (which is a client class) on all receiving clients. I'm kinda new to SimpleImpl and networking in general, but from my limited experience it would appear that you have to register your client packets only on the client side and server packets on the server side (if I didn't do this either the server would crash or my client would be kicked from the server, respectively). This, however, poses a problem as I'm trying to send a package that is only registered on the client from a package that is only registered on the server, meaning that I'm effectively trying to send a package that isn't registered (at least, that's how I think it works). I believe there's something wrong with how I register my packets, but as I say I'm new to networking so I don't really know. Help would be greatly appreciated!

     

    GitHub can be found here:

    https://github.com/TheMattyBoy00/petri-mod-2.0/tree/master/Petri_Mod-1.11.2/src/main/java/erikalebenjamattias/petrimod

    My GUI is here (it's long and messy, package is sent at line 324) (if you're wondering why I play the sound on the client and then send it to the server to play to all other clients nearby, it's to reduce latency for the person playing the piano [which is what the GUI is for if you hadn't guessed]):

    https://github.com/TheMattyBoy00/petri-mod-2.0/blob/master/Petri_Mod-1.11.2/src/main/java/erikalebenjamattias/petrimod/client/gui/GuiPianoKeyboard.java#L324

    Package to send to server (a quick println shows that this does in fact find all the players it should that are in range):

    https://github.com/TheMattyBoy00/petri-mod-2.0/blob/master/Petri_Mod-1.11.2/src/main/java/erikalebenjamattias/petrimod/network/NotifyServerOfPianoPlayMessages.java

    Package to send to clients (println in the onMessage() method shows that it does not get called what so ever, and the constructor with the println only gets called on the server where it's called in the server package, despite it being a client event):

    https://github.com/TheMattyBoy00/petri-mod-2.0/blob/master/Petri_Mod-1.11.2/src/main/java/erikalebenjamattias/petrimod/network/NotifyClientOfPianoPlayMessages.java

    Packet handler:

    https://github.com/TheMattyBoy00/petri-mod-2.0/blob/master/Petri_Mod-1.11.2/src/main/java/erikalebenjamattias/petrimod/network/PetriPacketHandler.java

    Packets registered in the client proxy and server proxy respectively. This is where I think I might be doing something wrong.

  3. OK then. Why don't you register it like Minecraft has done it in LootTableList::register(ResourceLocation) (which is a public static method)? That does mean that you have to rename your "loot" folder to "loot_tables", and you probably want to create a sub folder called "chests" where you put your "loot_chest.json" file, but that shouldn't be too big of an issue.

     

    I would try doing something like public static ResourceLocation LOOT_CHEST; in your main mod class, then say LOOT_CHEST = LootTableList.register(new ResourceLocation("nm", "chests/loot_chest")); in your pre-initialization event (maybe another event) and then call this field in your chest.setLootTable method.

  4. So I have a crafting recipe that uses water bottles, which are technically a potion with only an NBT tag to separate them from other potions. Is it possible to check for this NBT tag in the new JSON format for making crafting recipes? If so, what's the syntax? I don't really want players to be able to craft the item with any potion...

    Here's what my JSON file looks like so far:

     

    {
    	"type": "minecraft:crafting_shaped",
    	"pattern": [
    		"iIw",
    		"Db ",
    		" Bi"
    	],
    	"key": {
    		"i": {
    			"item": "minecraft:iron_ingot",
    			"data": 0
    		},
    		"I": {
    			"item": "minecraft:iron_block",
    			"data": 0
    		},
    		"w": {
    			"item": "minecraft:potion",
    			"data": 0,
    			"tag": {"Potion":"minecraft:water"} #<------ This is what isn't working, because I don't know the syntax (if at all possible)
    		},
    		"D": {
    			"item": "minecraft:dispenser",
    			"data": 0
    		},
    		"b": {
    			"item": "minecraft:bucket",
    			"data": 0
    		},
    		"B": {
    			"item": "minecraft:stone_button",
    			"data": 0
    		}
    	},
    	"result": {
    		"item": "gadgetsngoodies:water_gun",
    		"data": 0,
    		"count": 1
    	}
    }

     

  5. 5 minutes ago, Choonster said:

     

    Item#onArmorTick being called in the wrong place is a known issue.

     

     

    6 minutes ago, V0idWa1k3r said:

    This is a bug that had already been reported. Forge just has a lot of other things to work on at the moment. There however is already a PR to fix this issue so it should be fixed in the near future.

    Oh OK, guess I'll just have to wait then... Thanks for replying

    7 minutes ago, Choonster said:

    I'm not sure why the patches would fail to apply like that. It's possible that something in the Gradle cache is corrupted, you can try temporarily renaming the ~/.gradle directory (%USERPROFILE%\.gradle on Windows) and re-running the setupDecompWorkspace task.

    What do you mean by "rename the directory"? If I try to physically rename the folder ".gradle", Windows tells me that I must type a file name (maybe because .gradle is an extension and not a file name? Not sure on that one...)

  6. I've made a mod with a bunch of armor items that worked fine, until I tried updating the mod to 1.12. I dug through the code (ctrl + H is my friend) and found that the only place where Item#onArmorTick (a method that should update the armor every tick) gets called is in InventoryPlayer#setPickedItemStack, a method for handling pickblocking (so I could only fly my jetpack for a split second while pickblocking, which is no good), with a message from Forge saying "FORGE: Tick armor on animation ticks". How would I go about doing that (I don't have a separate class for rendering my armors or anything)? Also, I'm using forge-1.12-14.21.0.2333-mdk, which I know isn't the latest version, but that brings me onto my next problem: whenever I try setting up anything later than 2333 (using gradlew setupDecompWorkspace), it fails, giving me this:

    To honour the JVM settings for this build a new JVM will be forked. Please consi
    der using the daemon: https://docs.gradle.org/2.14/userguide/gradle_daemon.html.
    
    #################################################
             ForgeGradle 2.3-SNAPSHOT-da858a8
      https://github.com/MinecraftForge/ForgeGradle
    #################################################
                   Powered by MCP unknown
                 http://modcoderpack.com
             by: Searge, ProfMobius, Fesh0r,
             R4wk, ZeuX, IngisKahn, bspkrs
    #################################################
    :deobfCompileDummyTask
    :deobfProvidedDummyTask
    :getVersionJson
    :extractUserdev UP-TO-DATE
    :extractDependencyATs SKIPPED
    :extractMcpData SKIPPED
    :extractMcpMappings SKIPPED
    :genSrgs SKIPPED
    :downloadClient SKIPPED
    :downloadServer SKIPPED
    :splitServerJar SKIPPED
    :mergeJars SKIPPED
    :deobfMcSRG SKIPPED
    :decompileMc SKIPPED
    :fixMcSources
    :applySourcePatches
    Patching failed: net/minecraft/command/AdvancementCommand.java Cannot find hunk
    target
      1: Cannot find hunk target @ 0
      2: Cannot find hunk target @ 0
      3: Cannot find hunk target @ 0
      3/4 failed
    :applySourcePatches FAILED
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':applySourcePatches'.
    > com.cloudbees.diff.PatchException: Cannot find hunk target
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.
    
    BUILD FAILED
    
    Total time: 26.664 secs

     

     

    I do realize this may not be the right place to post this, I wasn't sure if this goes here or in Support & Bug Reports, but the latter seems to be more for players using Forge rather than modders, so that's why I chose this subforum.

  7. What I did was to just put Entity#setSize([width of grown animal] * [a factor that goes from the smallest size* when it's a baby, up to 1 when it's an adult], [height of grown animal] * [the same factor]); in EntityLivingBase#onLivingUpdate. In order to calculate the factor I would need to see your code for handling aging, unless you could figure it out yourself?

     

    *By the smallest size I mean say if the smallest version of the animal was 20% the size of the adult one, the "smallest size" would be 0.2, if it was 10% it would be 0.1 etc.

    • Like 1
  8. 10 hours ago, Draco18s said:

    This is because the client is responsible for the player's motion and sends its changes to the server. The server is then resetting the values and updating the client.

    I know, I was just pointing out that it happens and that I need to cancel certain key presses to compensate.

    13 hours ago, Kriptikz said:

    if they are stunned I increment the ticksStunned and if it's less than the duration I use KeyBinding.unPressAllKeys()

    Hey, thank you for bringing this to my attention! The KeyBinding class was just what I needed (even though I settled for a slightly different method in the end).

     

     

    I do believe my problems are solved now, thank you to all of you for your help! I really appreciate it!

    (For those wondering, this is what I settled on):

    entity.setVelocity(0, 0, 0);
    if(entity.posX != entity.prevPosX || entity.posY != entity.prevPosY || entity.posZ != entity.prevPosZ) {
        entity.setPositionAndUpdate(entity.prevPosX, entity.prevPosY, entity.prevPosZ);
    }
    if(entity == Minecraft.getMinecraft().player) {
        KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode(), false);
        KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindBack.getKeyCode(), false);
        KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindLeft.getKeyCode(), false);
        KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindRight.getKeyCode(), false);
        if(((EntityPlayer)entity).capabilities.isFlying) {
            KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindJump.getKeyCode(), false);
            KeyBinding.setKeyBindState(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false);
        }
    }

     

  9. Okay, I sort of solved it by doing this:

    entity.setVelocity(0, 0, 0);
    if(entity.posX != entity.prevPosX || entity.posY != entity.prevPosY || entity.posZ != entity.prevPosZ) {
    	entity.setPositionAndUpdate(entity.prevPosX, entity.prevPosY, entity.prevPosZ);
    }

    but when you try to move, it starts jittering (seen as I'm teleporting the player every tick). Is there a way to cancel keyboard input from only the buttons [W], [A], [D], [SPACE] and [SHIFT]? I seem to remember there was an event for handling keyboard input, but I can't seem to find one.

  10. Well, there are a few reasons. First of all we have the annoying FOV change (I know I could probably fix this with an event). Slowness doesn't affect knockback, so you could just punch out the mobs (again, should be an easy fix but still). Also, I know it might sound dumb but I'd prefer it if you didn't have the slowness icon in the inventory. But the main reason is that slowness doesn't affect all mobs, such as bats, squid and flying players, and it doesn't block vertical movement, so it's easy to just jump out. If I were to use slowness together with constantly setting only motionY to 0, the game would treat mobs as though they were flying, and slowness would have no affect.

  11. Two things: first, I actually do want skeletons to shoot arrows and creepers to explode and what not. I don't want to freeze time, I merely want to freeze mobs in place so that they can't move/fly.

     

    Second, the player is an issue... If I allow the event on the client side, all mobs including the player start jittering like mad when stuck in the ice, and if I limit the event to server side only, it works fine for other mobs but the player doesn't get affected.

     

    Edit: It also brings a whole lot of other problems, such as, as you said, they don't take damage unless you do something about it, same with drowning, suffocating, you can't eat when in the ice, and probably a whole lot more that I haven't thought of... I really don't feel like coding a special case for ALL of these situations.

  12. So I'm creating an "ice" block of sorts that is supposed to freeze any entities that are inside of it's collision box in place (don't worry about how they would ever get in there, I've already got that covered). By "freeze them in place", I mean that their motion X, Y and Z should all be a constant 0 until the ice block breaks. By simply calling Entity#setVelocity in Block#onEntityCollidedWithBlock in my block class and setting each value to 0, it for whatever reason only makes the entities slightly slower. When using the aforementioned technique in conjunction with calling LivingEvent#LivingUpdateEvent and doing this:

    @SubscribeEvent
    public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    	Entity entity = event.getEntity();
    	AxisAlignedBB axisalignedbb = entity.getEntityBoundingBox();
    	BlockPos.PooledMutableBlockPos blockpos = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D);
    	BlockPos.PooledMutableBlockPos blockpos1 = BlockPos.PooledMutableBlockPos.retain(axisalignedbb.maxX - 0.001D, axisalignedbb.maxY - 0.001D, axisalignedbb.maxZ - 0.001D);
    	BlockPos.PooledMutableBlockPos blockpos2 = BlockPos.PooledMutableBlockPos.retain();
    
    	if (entity.world.isAreaLoaded(blockpos, blockpos1)) {
    		for (int i = blockpos.getX(); i <= blockpos1.getX(); ++i) {
               	for (int j = blockpos.getY(); j <= blockpos1.getY(); ++j) {
               		for (int k = blockpos.getZ(); k <= blockpos1.getZ(); ++k)  {
                		blockpos2.setPos(i, j, k);
                		IBlockState iblockstate = entity.world.getBlockState(blockpos2);
                            
                		if(iblockstate.getBlock() == GadgetBlocks.freeze_ray_ice) {
                			entity.setVelocity(0, 0, 0);
                		}
                	}
                }
    		}
    	}
    }

    , I'm able to pretty much stop vertical movement as long as it isn't a flying player or a bat, and oddly enough, most vertical movement too; if I freeze for instance a sheep and lure it with wheat, it won't move, same with baiting a hostile mob - but if the mob decides to wander randomly, as they tend to do, it actually can move around (all be it, very slowly)! This is made extra clear when you as a player get caught; it's very easy to move around with the keyboard. So my question is, is there a way to like cancel all movement before it happens (including players pressing keys)? I can't seem to find an event for it that I can cancel, but there might be some other way I haven't thought of?

     

    Thanks in advance.

     

     

    (Block class in case it's needed)

    package themattyboy.gadgetsngoodies.blocks;
    
    import net.minecraft.block.BlockFrostedIce;
    import net.minecraft.block.SoundType;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemStack;
    import net.minecraft.stats.StatList;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.world.World;
    
    public class BlockFreezeRayIce extends BlockFrostedIce {
    
    	public BlockFreezeRayIce() {
    		this.setSoundType(SoundType.GLASS);
    	}
    	
    	@Override
    	protected void turnIntoWater(World worldIn, BlockPos pos) {
    		worldIn.setBlockToAir(pos);
    	}
    	
    	@Override
    	public boolean causesSuffocation(IBlockState state) {
    		return false;
    	}
    	
    	@Override
    	public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te, ItemStack stack) {
    		player.addStat(StatList.getBlockStats(this));
            player.addExhaustion(0.005F);
    	}
    	
    	@Override
    	public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
    		entity.setVelocity(0, 0, 0);
    	}
    }

     

  13. Quick question. Why are you using recursion? If you already know where the head is just get it that way. Hint they should be in the order that you add them under. And they should still be in the same hierarchy that you added them.

    I know I could, but I'm thinking that I might make a super class for this model and a few others that share similar properties, and by doing this I can easily move the method to that class and insert another parameter to let you find and scale any box you like in the model, if I decide to make the super class that is. Always good to keep the possibility open.

    And unless the addChild creates a new field then you should just be able to call scale your variable called head.

    That's the thing: I don't know how. What you would normally do to scale a part of a model is push a glMatrix around where you render it and scale it with GL11, but since I'm not rendering the box since the parent box does the rendering for it, this isn't really an option. And ModelRenderers don't have a native method for scaling them, besides setting the size of the box in pixels (not what I want), so I can't just simply "scale [my] variable called head".

  14. If you want to scale a certain part of a model, you have to scale it, render it and then set the scale back to the original for the other parts not to be scaled.

    But can it be done without rendering it? As I said, it's a child model (a child of a child of a child to be exact), and child models shouldn't be rendered like normal. Instead, they are added to the parent through

    ModelRenderer#addChild

    in the constructor of the ModelRenderer class, and only the parent (in this case parent of the parent of the parent) is rendered like normal through

    ModelRenderer#render

    .

     

    Here's my code for reference:

    package themattyboy.mesozoicraft.entity.model;
    
    import javax.annotation.Nullable;
    
    import net.minecraft.client.model.ModelBase;
    import net.minecraft.client.model.ModelRenderer;
    import net.minecraft.entity.Entity;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.math.MathHelper;
    import themattyboy.mesozoicraft.entity.prehistoric.carnivore.EntityVelociraptor;
    
    public class ModelVelociraptor extends ModelBase {
    
        public ModelRenderer body;
        public ModelRenderer chest;
        public ModelRenderer neck;
        public ModelRenderer head;
        public ModelRenderer snout;
        public ModelRenderer jaw;
        public ModelRenderer tailOrigin;
        public ModelRenderer tailMiddle;
        public ModelRenderer tailTip;
        public ModelRenderer thighLeft;
        public ModelRenderer shinLeft;
        public ModelRenderer thighRight;
        public ModelRenderer shinRight;
        public ModelRenderer footLeft;
        public ModelRenderer footRight;
        public ModelRenderer toeLeft;
        public ModelRenderer toeRight;
        public ModelRenderer clawLowerLeft;
        public ModelRenderer clawLowerRight;
        public ModelRenderer clawUpperLeft;
        public ModelRenderer clawUpperRight;
        public ModelRenderer upperArmLeft;
        public ModelRenderer upperArmRight;
        public ModelRenderer lowerArmLeft;
        public ModelRenderer lowerArmRight;
        public ModelRenderer handLeft;
        public ModelRenderer handRight;
        public ModelRenderer armFeatherLeft;
        public ModelRenderer armFeatherRight;
        public ModelRenderer tailFeather;
        public ModelRenderer headFeatherLeft;
        public ModelRenderer headFeatherRight;
      
        public ModelVelociraptor() {
        	textureWidth = 64;
        	textureHeight = 64;
        	
        	body = new ModelRenderer(this, 0, 26);
        	body.addBox(-2F, 0F, -8F, 4, 3, ;
        	body.setRotationPoint(0F, 16F, 4F);
        	body.setTextureSize(64, 64);
        	body.mirror = false;
        	setRotation(body, -0.0523599F, 0F, 0F);
        	chest = new ModelRenderer(this, 0, 13);
        	chest.addBox(-1.533333F, 0F, -10F, 3, 3, 10);
        	chest.setRotationPoint(0F, 0F, 0F);
        	chest.setTextureSize(64, 64);
        	chest.mirror = false;
        	setRotation(chest, 0.0523599F, 0F, 0F);
        	neck = new ModelRenderer(this, 0, 6);
        	neck.addBox(-1F, 0F, -5F, 2, 2, 5);
        	neck.setRotationPoint(0F, 0F, -8F);
        	neck.setTextureSize(64, 64);
        	neck.mirror = false;
        	setRotation(neck, -0.6108652F, 0F, 0F);
        	head = new ModelRenderer(this, 0, 0);
        	head.addBox(-1.5F, 0F, -3F, 3, 3, 3);
        	head.setRotationPoint(0F, 0F, -5F);
        	head.setTextureSize(64, 64);
        	head.mirror = false;
        	setRotation(head, 0.0872665F + 0.6108652F, 0F, 0F);
        	snout = new ModelRenderer(this, 12, 0);
        	snout.addBox(-1F, 0F, -3F, 2, 2, 3);
        	snout.setRotationPoint(0F, 0F, -3F);
        	snout.setTextureSize(64, 64);
        	snout.mirror = false;
        	setRotation(snout, 0.0872665F, 0F, 0F);
        	jaw = new ModelRenderer(this, 22, 0);
        	jaw.addBox(-1F, 0F, -2F, 2, 1, 2);
        	jaw.setRotationPoint(0F, 2F, -3F);
        	jaw.setTextureSize(64, 64);
        	jaw.mirror = false;
        	setRotation(jaw, 0F, 0F, 0F);
        	tailOrigin = new ModelRenderer(this, 0, 37);
        	tailOrigin.addBox(-1.5F, 0F, 0F, 3, 3, 6);
        	tailOrigin.setRotationPoint(0F, 0F, -2F);
        	tailOrigin.setTextureSize(64, 64);
        	tailOrigin.mirror = false;
        	setRotation(tailOrigin, 0.2617994F, 0F, 0F);
        	tailMiddle = new ModelRenderer(this, 0, 46);
        	tailMiddle.addBox(-1F, 0F, 0F, 2, 2, 5);
        	tailMiddle.setRotationPoint(0F, 0F, 6F);
        	tailMiddle.setTextureSize(64, 64);
        	tailMiddle.mirror = false;
        	setRotation(tailMiddle, -0.2617994F, 0F, 0F);
        	tailTip = new ModelRenderer(this, 0, 53);
        	tailTip.addBox(-0.5F, 0F, 0F, 1, 1, 4);
        	tailTip.setRotationPoint(0F, 0F, 5F);
        	tailTip.setTextureSize(64, 64);
        	tailTip.mirror = false;
        	setRotation(tailTip, -0.1745329F, 0F, 0F);
        	thighLeft = new ModelRenderer(this, 56, 0);
        	thighLeft.addBox(0F, -1F, -1F, 2, 6, 2);
        	thighLeft.setRotationPoint(1F, 2F, -3F);
        	thighLeft.setTextureSize(64, 64);
        	thighLeft.mirror = false;
        	setRotation(thighLeft, -0.7853982F, 0F, 0F);
        	shinLeft = new ModelRenderer(this, 52, ;
        	shinLeft.addBox(-0.5F, -1F, 0F, 1, 1, 5);
        	shinLeft.setRotationPoint(1F, 5F, 0F);
        	shinLeft.setTextureSize(64, 64);
        	shinLeft.mirror = false;
        	setRotation(shinLeft, 0.7853982F, 0F, 0F);
        	thighRight = new ModelRenderer(this, 56, 0);
        	thighRight.addBox(-2F, -1F, -1F, 2, 6, 2);
        	thighRight.setRotationPoint(-1F, 2F, -3F);
        	thighRight.setTextureSize(64, 64);
        	thighRight.mirror = true;
        	setRotation(thighRight, -0.7853982F, 0F, 0F);
        	shinRight = new ModelRenderer(this, 52, ;
        	shinRight.addBox(-0.5F, -1F, 0F, 1, 1, 5);
        	shinRight.setRotationPoint(-1F, 5F, 0F);
        	shinRight.setTextureSize(64, 64);
        	shinRight.mirror = true;
        	setRotation(shinRight, 0.7853982F, 0F, 0F);
        	footLeft = new ModelRenderer(this, 58, 14);
        	footLeft.addBox(-1F, 0F, 0F, 2, 4, 1);
        	footLeft.setRotationPoint(0F, -1F, 5F);
        	footLeft.setTextureSize(64, 64);
        	footLeft.mirror = false;
        	setRotation(footLeft, -0.7853982F, 0F, 0F);
        	footRight = new ModelRenderer(this, 58, 14);
        	footRight.addBox(-1F, 0F, 0F, 2, 4, 1);
        	footRight.setRotationPoint(0F, -1F, 5F);
        	footRight.setTextureSize(64, 64);
        	footRight.mirror = true;
        	setRotation(footRight, -0.7853982F, 0F, 0F);
        	toeLeft = new ModelRenderer(this, 56, 19);
        	toeLeft.addBox(0F, -1F, -3F, 1, 1, 3);
        	toeLeft.setRotationPoint(0F, 4F, 1F);
        	toeLeft.setTextureSize(64, 64);
        	toeLeft.mirror = false;
        	setRotation(toeLeft, 0.7853982F, -0.1745329F, 0F);
        	toeRight = new ModelRenderer(this, 56, 19);
        	toeRight.addBox(-1F, -1F, -3F, 1, 1, 3);
        	toeRight.setRotationPoint(0F, 4F, 1F);
        	toeRight.setTextureSize(64, 64);
        	toeRight.mirror = true;
        	setRotation(toeRight, 0.7853982F, 0.1745329F, 0F);
        	clawLowerLeft = new ModelRenderer(this, 60, 23);
        	clawLowerLeft.addBox(-0.5F, -2F, -1F, 1, 2, 1);
        	clawLowerLeft.setRotationPoint(-0.55F, 4F, 1F);
        	clawLowerLeft.setTextureSize(64, 64);
        	clawLowerLeft.mirror = false;
        	setRotation(clawLowerLeft, 0.7853982F, 0F, 0F);
        	clawLowerRight = new ModelRenderer(this, 60, 23);
        	clawLowerRight.addBox(-0.5F, -2F, -1F, 1, 2, 1);
        	clawLowerRight.setRotationPoint(0.55F, 4F, 1F);
        	clawLowerRight.setTextureSize(64, 64);
        	clawLowerRight.mirror = true;
        	setRotation(clawLowerRight, 0.7853982F, 0F, 0F);
        	clawUpperLeft = new ModelRenderer(this, 60, 26);
        	clawUpperLeft.addBox(-0.5F, 0F, -1F, 1, 1, 1);
        	clawUpperLeft.setRotationPoint(0F, -2F, -1F);
        	clawUpperLeft.setTextureSize(64, 64);
        	clawUpperLeft.mirror = false;
        	setRotation(clawUpperLeft, 0F, 0F, 0F);
        	clawUpperRight = new ModelRenderer(this, 60, 26);
        	clawUpperRight.addBox(-0.5F, 0F, -1F, 1, 1, 1);
        	clawUpperRight.setRotationPoint(0F, -2F, -1F);
        	clawUpperRight.setTextureSize(64, 64);
        	clawUpperRight.mirror = true;
        	setRotation(clawUpperRight, 0F, 0F, 0F);
        	upperArmLeft = new ModelRenderer(this, 30, 0);
        	upperArmLeft.addBox(0F, 0F, 0F, 1, 3, 1);
        	upperArmLeft.setRotationPoint(1.5F, 1F, -9F);
        	upperArmLeft.setTextureSize(64, 64);
        	upperArmLeft.mirror = false;
        	setRotation(upperArmLeft, 0.1745329F, 0F, 0F);
        	upperArmRight = new ModelRenderer(this, 30, 0);
        	upperArmRight.addBox(-1F, 0F, 0F, 1, 3, 1);
        	upperArmRight.setRotationPoint(-1.5F, 1F, -9F);
        	upperArmRight.setTextureSize(64, 64);
        	upperArmRight.mirror = true;
        	setRotation(upperArmRight, 0.1745329F, 0F, 0F);
        	lowerArmLeft = new ModelRenderer(this, 30, 4);
        	lowerArmLeft.addBox(-1F, 0F, -1F, 1, 2, 1);
        	lowerArmLeft.setRotationPoint(0.9F, 3F, 1F);
        	lowerArmLeft.setTextureSize(64, 64);
        	lowerArmLeft.mirror = false;
        	setRotation(lowerArmLeft, -0.3926991F - 0.1745329F, 0F, 0F);
        	lowerArmRight = new ModelRenderer(this, 30, 4);
        	lowerArmRight.addBox(0F, 0F, -1F, 1, 2, 1);
        	lowerArmRight.setRotationPoint(-0.9F, 3F, 1F);
        	lowerArmRight.setTextureSize(64, 64);
        	lowerArmRight.mirror = true;
        	setRotation(lowerArmRight, -0.3926991F - 0.1745329F, 0F, 0F);
        	handLeft = new ModelRenderer(this, 30, 7);
        	handLeft.addBox(-0.5F, 0F, 0F, 1, 2, 1);
        	handLeft.setRotationPoint(-0.4F, 2F, -1F);
        	handLeft.setTextureSize(64, 64);
        	handLeft.mirror = false;
        	setRotation(handLeft, 0.1745329F + 0.3926991F, 0F, 0F);
        	handRight = new ModelRenderer(this, 30, 7);
        	handRight.addBox(-0.5F, 0F, 0F, 1, 2, 1);
        	handRight.setRotationPoint(0.4F, 2F, -1F);
        	handRight.setTextureSize(64, 64);
        	handRight.mirror = true;
        	setRotation(handRight, 0.1745329F + 0.3926991F, 0F, 0F);
            armFeatherLeft = new ModelRenderer(this, 62, 28);
            armFeatherLeft.addBox(0F, 0F, 0F, 0, 2, 1);
            armFeatherLeft.setRotationPoint(-0.5F, 0F, 0F);
            armFeatherLeft.setTextureSize(64, 64);
            armFeatherLeft.mirror = true;
            setRotation(armFeatherLeft, 0F, 0F, 0F);
            armFeatherRight = new ModelRenderer(this, 62, 28);
            armFeatherRight.addBox(0F, 0F, 0F, 0, 2, 1);
            armFeatherRight.setRotationPoint(0.5F, 0F, 0F);
            armFeatherRight.setTextureSize(64, 64);
            armFeatherRight.mirror = true;
            setRotation(armFeatherRight, 0F, 0F, 0F);
            armFeatherRight.mirror = false;
            tailFeather = new ModelRenderer(this, 0, 58);
            tailFeather.addBox(-2.5F, 0F, -6F, 5, 0, 6);
            tailFeather.setRotationPoint(0F, 0.5F, 4F);
            tailFeather.setTextureSize(64, 64);
            tailFeather.mirror = true;
            setRotation(tailFeather, 0F, 0F, 0F);
            headFeatherLeft = new ModelRenderer(this, 34, 0);
            headFeatherLeft.addBox(0F, -4F, 0F, 0, 4, 6);
            headFeatherLeft.setRotationPoint(0.5F, 1F, -6F);
            headFeatherLeft.setTextureSize(64, 64);
            headFeatherLeft.mirror = true;
            setRotation(headFeatherLeft, 0, 0F, 0F);
            headFeatherLeft.mirror = false;
            headFeatherRight = new ModelRenderer(this, 34, 0);
            headFeatherRight.addBox(0F, -4F, 0F, 0, 4, 6);
            headFeatherRight.setRotationPoint(-0.5F, 1F, -6F);
            headFeatherRight.setTextureSize(64, 64);
            headFeatherRight.mirror = true;
            setRotation(headFeatherRight, 0F, 0F, 0F);
          
        	body.addChild(chest);
        	chest.addChild(neck);
        	neck.addChild(head);
        	head.addChild(snout);
        	head.addChild(jaw);
        	chest.addChild(tailOrigin);
        	tailOrigin.addChild(tailMiddle);
        	tailMiddle.addChild(tailTip);
        	chest.addChild(thighLeft);
        	chest.addChild(thighRight);
        	thighLeft.addChild(shinLeft);
        	thighRight.addChild(shinRight);
        	shinLeft.addChild(footLeft);
        	shinRight.addChild(footRight);
        	footLeft.addChild(toeLeft);
        	footRight.addChild(toeRight);
        	footLeft.addChild(clawLowerLeft);
        	footRight.addChild(clawLowerRight);
        	clawLowerLeft.addChild(clawUpperLeft);
        	clawLowerRight.addChild(clawUpperRight);
        	chest.addChild(upperArmLeft);
        	chest.addChild(upperArmRight);
        	upperArmLeft.addChild(lowerArmLeft);
        	upperArmRight.addChild(lowerArmRight);
        	lowerArmLeft.addChild(handLeft);
        	lowerArmRight.addChild(handRight);
        	lowerArmLeft.addChild(armFeatherLeft);
        	lowerArmRight.addChild(armFeatherRight);
        	tailTip.addChild(tailFeather);
        	neck.addChild(headFeatherLeft);
        	neck.addChild(headFeatherRight);
        }
      
        public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
        	super.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
        	setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
        	body.render(scale);
        }
      
        private void setRotation(ModelRenderer model, float x, float y, float z) {
        	model.rotateAngleX = x;
        	model.rotateAngleY = y;
        	model.rotateAngleZ = z;
        }
      
        public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float headYaw, float headPitch, float scale, Entity entity) {
        	super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, headYaw, headPitch, scale, entity);
        
        	EntityVelociraptor raptor = (EntityVelociraptor)entity;
        	
        	this.scaleHead(body, raptor);
        	
        	this.tailOrigin.rotateAngleY = MathHelper.cos(ageInTicks * 0.075F) * 0.8F * -0.2F + MathHelper.cos(limbSwing * 0.4F) * 0.4F * limbSwingAmount;
        	this.tailMiddle.rotateAngleY = MathHelper.cos(ageInTicks * 0.075F - (float)Math.PI / 3) * 0.6F * -0.2F + MathHelper.cos(limbSwing * 0.4F - (float)Math.PI / 3) * 0.2F * limbSwingAmount;
        	this.tailTip.rotateAngleY = MathHelper.cos(ageInTicks * 0.075F - (float)Math.PI / 2) * 0.4F * -0.2F + MathHelper.cos(limbSwing * 0.4F - (float)Math.PI / 2) * 0.1F * limbSwingAmount;
        
        	this.tailOrigin.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F) * 0.2F * -0.2F + 0.2617994F;
        	this.tailMiddle.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F - (float)Math.PI / 3) * 0.1F * -0.2F - 0.2617994F;
        	this.tailTip.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F - (float)Math.PI / 2) * 0.05F * -0.2F - 0.1745329F;
        
        	this.head.rotateAngleX = headPitch / (180F / (float)Math.PI) + 0.0872665F + 0.6108652F;
        	this.head.rotateAngleY = (headYaw / (180F / (float)Math.PI)) * 0.7F;
        	this.neck.rotateAngleY = (headYaw / (180F / (float)Math.PI)) * 0.3F;
        
        	this.neck.rotateAngleX = -MathHelper.cos(ageInTicks * 0.15F) * 0.4F * -0.2F + (headPitch / (180F / (float)Math.PI)) * 0.3F - 0.6108652F;
        	this.head.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F + (float)Math.PI / 5) * 0.4F * -0.2F + (headPitch / (180F / (float)Math.PI)) * 0.3F + 0.0872665F + 0.6108652F;
        	
        	this.body.rotateAngleX = -MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount - 0.0523599F;
        	this.body.offsetY = MathHelper.cos(ageInTicks * 0.15F) * 0.005F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount;
        	this.body.offsetZ = -MathHelper.cos(ageInTicks * 0.15F) * 0.01F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount;
        	
        	this.body.rotateAngleZ = MathHelper.cos(limbSwing * 0.4F) * 0.075F * limbSwingAmount;
        
        	this.thighLeft.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.1F * limbSwingAmount - 0.7853982F;
        	this.thighRight.rotateAngleX = MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.4F) * 0.1F * limbSwingAmount - 0.7853982F;
        
        	this.shinLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI + (float)Math.PI / 4) * 0.2F * limbSwingAmount + 0.7853982F;
        	this.shinRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI / 4) * 0.2F * limbSwingAmount + 0.7853982F;
        
        	this.footLeft.rotateAngleX = MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.4F * limbSwingAmount + MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount - 0.7853982F;
        	this.footRight.rotateAngleX = MathHelper.cos(limbSwing * 0.4F) * 0.4F * limbSwingAmount + MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount - 0.7853982F;
        	
        	this.toeLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
        	this.toeRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
        	
        	this.clawLowerLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
        	this.clawLowerRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F) * 0.7F * limbSwingAmount - MathHelper.cos(ageInTicks * 0.15F) * 0.1F * -0.2F + MathHelper.cos(limbSwing * 0.8F) * 0.05F * limbSwingAmount + 0.7853982F;
        
        	this.upperArmLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.3F * limbSwingAmount + 0.1745329F;
        	this.upperArmRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F) * 0.3F * limbSwingAmount + 0.1745329F;
        
        	this.lowerArmLeft.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI + (float)Math.PI / 4) * 0.7F * limbSwingAmount - 0.3926991F - 0.1745329F;
        	this.lowerArmRight.rotateAngleX = -MathHelper.cos(limbSwing * 0.4F + (float)Math.PI / 4) * 0.7F * limbSwingAmount - 0.3926991F - 0.1745329F;
        
        	this.handLeft.rotateAngleX = MathHelper.cos(limbSwing * 0.4F + (float)Math.PI) * 0.7F * limbSwingAmount + 0.1745329F + 0.3926991F;
        	this.handRight.rotateAngleX = MathHelper.cos(limbSwing * 0.4F) * 0.7F * limbSwingAmount + 0.1745329F + 0.3926991F;
        	
        	if(raptor.isMouthOpen()) {
        		this.jaw.rotateAngleX = (float)Math.PI / 4;
        	}
        	else {
        		this.jaw.rotateAngleX = 0;
        	}
        	
        	if(limbSwing > 0) {
        		this.neck.rotateAngleX += 0.7F * limbSwingAmount;
        		this.head.rotateAngleX -= 0.7F * limbSwingAmount;
        		
        		this.tailOrigin.rotateAngleX -= 0.3F * limbSwingAmount;
        		this.tailMiddle.rotateAngleX += 0.3F * limbSwingAmount;
        		this.tailTip.rotateAngleX += 0.3F * limbSwingAmount;
        		
        		this.shinLeft.rotateAngleX += 0.4F * limbSwingAmount;
        		this.shinRight.rotateAngleX += 0.4F * limbSwingAmount;
        		
        		this.footLeft.rotateAngleX += 0.7F * limbSwingAmount;
        		this.footRight.rotateAngleX += 0.7F * limbSwingAmount;
        		
        		this.toeLeft.rotateAngleX -= 0.7F * limbSwingAmount;
        		this.toeRight.rotateAngleX -= 0.7F * limbSwingAmount;
        		
        		this.clawLowerLeft.rotateAngleX -= 0.7F * limbSwingAmount;
        		this.clawLowerRight.rotateAngleX -= 0.7F * limbSwingAmount;
        	}
        }
        
        @Nullable
        private ModelRenderer scaleHead(ModelRenderer currentBox, EntityVelociraptor raptor) {
        	for(int i = 0; i < currentBox.childModels.size(); i++) {
        		ModelRenderer box = currentBox.childModels.get(i);
        		if(box == head) {
        			//stuff to scale the head
        			return box;
        		}
        		else {
        			this.scaleHead(box, raptor);
        			return null;
        		}
        	}
    	return null;
        }
    }
    

  15. So I have this model which only calls the

    ModelRenderer#render

    function once, because all other boxes are child models or child models of child models etc. of that

    ModelRenderer

    . Problem is, I want to scale one of these child models (called 'head') and all of it's child models based on conditions, but I'm not sure how I should go about doing that. I have made this method that successfully

    for

    's itself through all child models and their children to find the box I'm looking for:

    @Nullable
    private ModelRenderer scaleHead(ModelRenderer currentBox, EntityVelociraptor raptor) {
        for(int i = 0; i < currentBox.childModels.size(); i++) {
        	ModelRenderer box = currentBox.childModels.get(i);
        	if(box == head) {
        		return box;
        	}
        	else {
        		this.scaleHead(box, raptor);
        		return null;
        	}
        }
        return null;
    }

    But now I'm lost. I tried adding

    GLStateManager#scale

    inside the

    if(box == head)

    statement, but that scaled the whole model, not just the box. I tried pushing a glMatrix in that same statement and then tried, with variable values,

    ModelRenderer#render

    , which rendered the head seperately, and

    ModelRenderer#postRender

    , which turned the entire model on it's side. When I used

    GL11#glScaled

    and fixed values in

    render

    and

    postRender

    , I got the same results respectively. Besides, when I push a glMatrix inside the

    if

    statement, it stops updating the method in real time, which is essential for what I'm doing (I'm calling the method in

    ModelRenderer#setRotationAndAngles

    [i know, probably not the optimal method but it works], so it should update in real time).

     

    I could give you the whole class but it's nearly 400 lines long and I think pretty much everyone here has seen a model renderer class generated in Techne before...

     

    Thanks in advance :)

     

    P.S. For some odd reason, Eclipse highlights the "i++" in the

    for

    loop with a warning and tells me that it's "Dead code". Any idea why this could be?

  16. I want to create my own

    EnumCreatureType

    , and I came across this post from 1.7.10 saying that it didn't work in 1.7.2. But surely that must be fixed by now, right? RIGHT?? If it is, how do I use it? At the moment, this is what I'm doing:

    public static final EnumCreatureType PREHISTORIC = EnumHelper.addCreatureType("Prehistoric", EntityPrehistoric.class, 12, Material.AIR, true, true);

    and then I use it in

    EntityRegistry$addSpawn

    , but when I do this, anytime I try to run the game it crashes, giving me a

    java.lang.UnsupportedOperationException

    .

     

    What am I doing wrong? And if it's just that

    EnumHelper$addCreatureType()

    plain doesn't work, could you please fix it? Thanks.

×
×
  • Create New...

Important Information

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