Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

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

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

Jimmeh

Members
  • Joined

  • Last visited

Everything posted by Jimmeh

  1. Hi there! I'm trying to get into modding (gave it a go a couple years ago but gave up). I remember back then there was a Gui class that would be extended to draw your own custom HUD elements. Looking for this class now, I can't seem to find it or a class that sounds like an obvious replacement. I can't seem to find any recent tutorials going over this. Following older tutorials, it would look something like this: public class TestHUD extends Gui { private static final List<RenderGameOverlayEvent.ElementType> skip = Arrays.asList( RenderGameOverlayEvent.ElementType.HEALTH, RenderGameOverlayEvent.ElementType.FOOD, RenderGameOverlayEvent.ElementType.HOTBAR ); public TestHUD() { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onRender(RenderGameOverlayEvent.Pre event){ if(skip.contains(event.getType())){ event.setCanceled(true); } if(event.getType() == RenderGameOverlayEvent.ElementType.TEXT){ //Apparently the TEXT 'layer' provides the best result for rendering custom things. //Perhaps it's the last layer to get rendered? Or first? Minecraft mc = Minecraft.getInstance(); mc.getRenderManager().textureManager.bindTexture(new ResourceLocation("")); drawTextureModalRect(x, y, 0, 0, width, height); } } } Here, I'm simply trying to cancel the rendering of the health bar, food bar and hotbar (both the health and food bars don't render, as intended - however, the hotbar still renders). Then I would want to draw my custom HUD on the screen and this is where I'm having an issue finding which class I need to extend. If you can offer any advice or guidance, I'd greatly appreciate it! Thanks!
  2. Your assumption was correct. I should've noticed that about the Sponge event. It works just fine using the FML events. Well, that'll do for my questions right now. Thanks for all the help! It's appreciated!
  3. Okay, this makes sense! However, it's looking like my proxies aren't getting instantiated even though I'm using the annotation. I believe this to be so because I get a NullPointerException when trying to call "proxy.preInit()". I've watched a few tutorials for this and I'm not doing anything different from them. If you have a moment, could you take a look and see if there's something wrong that catches your eye? Thanks! @SidedProxy(clientSide = "com.aurelios.client.ClientProxy", serverSide = "com.aurelios.server.ServerProxy") public static IProxy proxy; @Listener public void onGamePreInit(GamePreInitializationEvent event){ AureliosPacketHandler.init(); proxy.preInit(); } This is a SpongeForge mod (hence why I'm using GamePreInitializationEvent). For clarity, I did cast GamePreInitializationEvent to FMLPreInitializationEvent and the cast didn't fail, so I think it's safe to assume they are the same thing (or rather an extension of the FML event). And attached is my project structure, so that you can see I have the annotation pointing to the correct classes. Also, I just noticed your name. If you're the Jabelar that wrote the tutorials on Blogspot, thanks for doing that! I have everyone of those bookmarked. They have and definitely will continue to come in handy!
  4. Hi there! I'm jumping into Forge modding for the second time (I didn't last long the first after coming from using Spigot for a few years). All I'm trying to do right now is for the server to send a packet to the player that runs a command. This packet will tell the client to open a GUI. Now, I have the network part of this down, or at least, there's no errors coming from that. The error pops up when I'm trying to call Minecraft.getMinecraft().displayGuiScreen(new myGui()); I call this in my implementation of IMessageHandler, making sure that I have registered this handler to be receiving packets on the client side.I have no idea as to why the above code is throwing the NoSuchMethodError when it's running clientside. My only guess is that it has to do with run-time classpaths being different than compile-time, but I have a shadow plugin I'm using with Gradle to shade in my dependencies. Any help is greatly appreciated! Here's where I'm registering my IMessage and IMessageHandler classes: public class AureliosPacketHandler { public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("aurelios"); private static int id = -1; public static void init() { INSTANCE.registerMessage(PacketOpenGui.GuiPacketHandler.class, PacketOpenGui.class, id++, Side.CLIENT); } } And here's the classes themselves: public class PacketOpenGui implements IMessage { private GuiTypes guiType; public PacketOpenGui(){} public PacketOpenGui(GuiTypes type){ this.guiType = type; } @Override public void fromBytes(ByteBuf buf) { guiType = GuiTypes.getGuiType(buf.readInt()).get(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(guiType.getID()); } public static class GuiPacketHandler implements IMessageHandler<PacketOpenGui, IMessage> { @Override public IMessage onMessage(PacketOpenGui message, MessageContext ctx) { Minecraft.getMinecraft().displayGuiScreen(message.guiType.getGui()); return null; } } } For reference, GuiTypes is simply an Enum to make things easier on me down the road. Again, thanks for any help!
  5. Jimmeh posted a topic in Modder Support
    Extremely simple question, yet strangely, not one I can actually find an answer to on here. How do I add colors and styles to a message I'm sending to players? All the forum threads I can find say EnumChatFormatting but that doesn't seem to exist anymore. Thanks!
  6. Sorry about the late reply. I've been pretty busy! Okay, so I have the deobfuscated console logs of the server and client here. I've tried to "cross reference" them to figure things out, but I'm still having a difficult time. setDead() is only being called clientside, I've noticed. Here's the server: http://hastebin.com/pahiqamasu.css Here's the console: http://hastebin.com/ayihawusez.sql And here's the class in which I've overridden the despawnEntity() and setDead() methods (I left in the whole class that way the line numbers would line up correctly): http://hastebin.com/xehapoquyi.java Once again, all help is greatly appreciated! Thank you!
  7. Alrighty. So I've managed to get the deobfuscated console logs for the client and server. I've sat here trying to trace it one method to the next to figure out why this thing keeps despawning, but I can't seem to figure it out. I've added breakpoints every where I can think to put them, especially within EntityLiving#despawnEntity(). I even added the LivingEntitySpawn.AllowDespawn event, setting that result to Result.DENY, and that did absolutely nothing (in fact, it didn't even fire). I'm completely lost on what to do D: Here's the server console log: http://hastebin.com/acidipizuw.css Here's the EntityAbilityBase referred to in that log: http://hastebin.com/rinejibele.java And lastly, the EntityRock referred to as well: http://hastebin.com/mudoquguwe.java Once again, any help is greatly appreciated, because right now, I can't make custom entities
  8. Okay, so I think I've kinda narrowed it down. I've added printing stacktraces to "despawnEntity()" and "setDead()". The results seem to be this: - Entity spawns - Immediately despawns (despawnEntity()) server side - Client isn't "updated" about this because I still get "onLivingUpdate()" calls client-side - Entity eventually is setDead() client side after a few seconds. I have absolutely no idea where to go from here. There seems to be a break in server -> client synchronicity. That's the best guess I have right now Here's the entity class that I'm using: public class EntityAbilityBase extends EntityTameable { public EntityAbilityBase(World worldIn) { super(worldIn); } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } /** * Checks if this entity is running on a client. * * Required since MCP's isClientWorld returns the exact opposite... * * @return true if the entity runs on a client or false if it runs on a server */ public final boolean isClient() { return worldObj.isRemote; } /** * Checks if this entity is running on a server. * * @return true if the entity runs on a server or false if it runs on a client */ public final boolean isServer() { return !worldObj.isRemote; } @Override protected void despawnEntity(){ System.out.println("DESPAWNED " + this.worldObj.isRemote); for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { System.out.println(ste); } super.despawnEntity(); } @Override public void setDead(){ for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { System.out.println(ste); } super.setDead(); } } Here's the server console log: http://hastebin.com/ulijiloyuq.css And here's the client console log, which finally has setDead() called seconds after the server despawns: http://hastebin.com/aharugajuf.md As always, any help is now beyond appreciated Thanks!
  9. Hey, so I just tested that. It's immediately despawning server-side right after it's spawned in, however, the client-representation isn't "despawned" for a few seconds after, which I find weird. Unfortunately, I have no idea where to go from here Any direction is greatly appreciated!
  10. Hey there! So I have a custom entity that I'm spawning when a player left clicks in the air. I'm doing this via a custom packet sent to the server telling it to spawn that entity. That's all good and well. However, the entity spawns in, doesn't do anything, then despawns after a few seconds. I have no idea where I'm going wrong. I believe I've done the packet handling, entity class, and AI correctly. Here's the respective code: Packet and IMessageHandler classes: public class PacketEntityRockSpawn implements IMessage { //sent from client to server telling it to spawn an EntityRock //Don't need to return anything because we'll keep rock count on server side private String entityID; public PacketEntityRockSpawn(){} public PacketEntityRockSpawn(String id){ this.entityID = id; } @Override public void fromBytes(ByteBuf buf) { entityID = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, entityID); } public static class HandlerEntityRockSpawn implements IMessageHandler<PacketEntityRockSpawn, IMessage> { public HandlerEntityRockSpawn(){} @Override public IMessage onMessage(PacketEntityRockSpawn message, MessageContext ctx) { //received packet from client EntityPlayer player = ctx.getServerHandler().playerEntity; Entity entity = EntityList.createEntityByIDFromName(Test.MODID + "." + message.entityID, player.worldObj); World worldIn = player.worldObj; if (entity instanceof EntityRock && player.worldObj instanceof WorldServer) { ((WorldServer)player.worldObj).addScheduledTask(new Runnable() { @Override public void run() { EntityRock entityRock = (EntityRock) entity; entityRock.setOwner(player); entityRock.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityRock)), (IEntityLivingData) null); worldIn.spawnEntityInWorld(entity); entityRock.playLivingSound(); PlayerHandler.getClientInfo(player).rocks.add(entityRock); System.out.println("" + PlayerHandler.getClientInfo(player).rocks.size()); } }); } return null; } } } Custom Entity Class: public class EntityRock extends EntityAbilityBase{ private EntityLivingBase owner; private double maxTravelDistance; private BlockPos startPosition; private final int HOME_RADIUS = 10; private static final DataParameter<Boolean> DATA_FOLLOWING = EntityDataManager.createKey(EntityRock.class, DataSerializers.BOOLEAN); private static final DataParameter<Boolean> DATA_LAUNCHED = EntityDataManager.createKey(EntityRock.class, DataSerializers.BOOLEAN); public EntityRock(World worldIn) { super(worldIn); this.setSize(1f, 1f); this.experienceValue = 200; this.stepHeight = 1; } public void setOwner(EntityLivingBase base){ this.owner = base; this.setOwnerId(owner.getUniqueID()); this.posX = owner.posX + this.rand.nextInt(3); this.posY = owner.posY + owner.getEyeHeight(); this.posZ = owner.posZ + this.rand.nextInt(3); setHomePosAndDistance(getOwner().getPosition(), HOME_RADIUS); } @Override protected void entityInit(){ super.entityInit(); dataManager.register(DATA_FOLLOWING, true); dataManager.register(DATA_LAUNCHED, false); } @Override protected void initEntityAI(){ System.out.println("TASK ADDED"); this.tasks.addTask(0, new EntityAIFollowBender(this, 1.0, 2.0)); } @Override protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(200.0D); //100 full hearts this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(1.0D); } @Override protected PathNavigate getNewNavigator(World world){ return new PathNavigateFlying(this, world); } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { if(isServerWorld() && getOwner() != null && !getOwner().isDead){ if(dataManager.get(DATA_FOLLOWING)){ setHomePosAndDistance(getOwner().getPosition(), HOME_RADIUS); } else if(dataManager.get(DATA_LAUNCHED)){ setHomePosAndDistance(this.getPosition(), HOME_RADIUS); } } super.onLivingUpdate(); } public void launch(EntityPlayer player) { int yaw = (int)player.rotationYaw; if(yaw<0) { //due to the yaw running a -360 to positive 360 yaw += 360; } //not sure why it's that way yaw+=22; //centers coordinates you may want to drop this line yaw%=360; //and this one if you want a strict interpretation of the zones int facing = yaw/45; // 360degrees divided by 45 == 8 zones (4 normal direction, 4 diagonal) //----------------------- RayTraceResult result = player.worldObj.rayTraceBlocks(player.getPositionEyes(1.0f), player.getLookVec()); //remove task of following owner //add task of going to target //turn step height to 0 //mark start position //play sound if(result == null) return; /*if(result.typeOfHit != RayTraceResult.Type.MISS) this.tasks.removeTask(followTask); if(result.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos pos = new BlockPos(result.hitVec); this.tasks.addTask(0, launhTask = new EntityAITargetBlock(this, 2.0D, Integer.MAX_VALUE, pos)); } else if(result.typeOfHit == RayTraceResult.Type.ENTITY && result.entityHit instanceof EntityLivingBase) this.tasks.addTask(0, entityLaunchTask = new EntityAITargetEntity(this, false, (EntityLivingBase) result.entityHit)); this.stepHeight = 0; this.startPosition = new BlockPos(this.getPositionVector());*/ } @Override public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack){ if(hand.equals(EnumHand.MAIN_HAND)){ } //remove task of following owner //add task of going to target //turn step height to 0 //mark start position //play sound return true; } @Override public void writeEntityToNBT(NBTTagCompound compound){ super.writeEntityToNBT(compound); } @Override public void readFromNBT(NBTTagCompound compound){ super.readFromNBT(compound); } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } @Override public boolean canBePushed(){ return false; } @Override public void fall(float distance, float damageMultiplier) { } @Override public boolean isAIDisabled(){return false;} protected SoundEvent getAmbientSound(){ return TestSounds.Guard; } protected SoundEvent getHurtSound(){return TestSounds.Guard;} protected SoundEvent getDeathSound(){return TestSounds.Guard;} The "base" class it extends: public class EntityAbilityBase extends EntityTameable { public EntityAbilityBase(World worldIn) { super(worldIn); } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } /** * Checks if this entity is running on a client. * * Required since MCP's isClientWorld returns the exact opposite... * * @return true if the entity runs on a client or false if it runs on a server */ public final boolean isClient() { return worldObj.isRemote; } /** * Checks if this entity is running on a server. * * @return true if the entity runs on a server or false if it runs on a client */ public final boolean isServer() { return !worldObj.isRemote; } } The AI task that it gets: public class EntityAIFollowBender extends EntityAIAbilityBase { private EntityLivingBase owner; private double minRadius; public EntityAIFollowBender(EntityAbilityBase ability, double speed, double minRadius) { super(ability, speed); this.minRadius = minRadius; } @Override public boolean shouldExecute(){ owner = ability.getOwner(); if(owner == null || owner.isDead || (owner != null && owner.getPositionVector().distanceTo(ability.getPositionVector()) <= minRadius)){ System.out.println("NOT EXECUTE"); return false; } System.out.println("EXECUTE"); return true; } @Override public void updateTask(){ //if(ability.getNavigator() instanceof PathNavigateFlying){ // ((PathNavigateFlying) ability.getNavigator()).tryMoveToBender(owner, speed); //} else { ability.getNavigator().tryMoveToEntityLiving(owner, speed); //} } } The base class that the AI task extends: public class EntityAIAbilityBase extends EntityAIBase { protected final EntityAbilityBase ability; protected final World world; protected final Random random; protected final double speed; public EntityAIAbilityBase(EntityAbilityBase ability, double speed){ this.ability = ability; this.world = ability.worldObj; this.random = ability.getRNG(); this.speed = speed; } @Override public boolean shouldExecute() { return true; } protected boolean tryMoveToBlockPos(BlockPos pos){ return ability.getNavigator().tryMoveToXYZ(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, speed); } } The custom PathNavigate: public class PathNavigateFlying extends PathNavigateSwimmer { private Random rand = new Random(); private double posX, posY, posZ; public PathNavigateFlying(EntityLiving entitylivingIn, World worldIn) { super(entitylivingIn, worldIn); } @Override protected PathFinder getPathFinder(){ return new PathFinder(new NodeProcessorFlying()); } @Override protected boolean canNavigate(){ return true; } public boolean tryMoveToBender(Entity entity, double speed){ this.posX = entity.posX + Offsets.values()[this.rand.nextInt(3)].getOutput(); this.posY = entity.posY + entity.getEyeHeight(); this.posZ = entity.posZ + Offsets.values()[this.rand.nextInt(3)].getOutput(); boolean a = super.tryMoveToXYZ(posX, posY, posZ, speed); System.out.println("move: " + String.valueOf(this.currentPath == null) + " " + String.valueOf(this.currentPath.getCurrentPathLength() == 0)); return a; } private enum Offsets{ ONE(0), TWO(0.5), THREE(1.0); private double output; Offsets(double in){output = in;} public double getOutput() { return output; } } } And finally the custom node processor: public class NodeProcessorFlying extends SwimNodeProcessor { /** * Returns PathPoint for given coordinates */ @Override public PathPoint getPathPointToCoords(double x, double y, double target){ return openPoint( MathHelper.floor_double(x - (entity.width / 2.0)), MathHelper.floor_double(y + 0.5), MathHelper.floor_double(target - (entity.width / 2.0)) ); } @Override public int findPathOptions(PathPoint[] pathOptions, PathPoint currentPoint, PathPoint targetPoint, float maxDistance){ int i = 0; for(EnumFacing facing: EnumFacing.values()){ PathPoint pathPoint = getSafePoint(entity, currentPoint.xCoord + facing.getFrontOffsetX(), currentPoint.yCoord + facing.getFrontOffsetY(), currentPoint.zCoord + facing.getFrontOffsetZ() ); if(pathPoint != null && !pathPoint.visited && pathPoint.distanceTo(targetPoint) < maxDistance){ pathOptions[i++] = pathPoint; } } return i; } /** * Returns a point that the entity can safely move to */ private PathPoint getSafePoint(Entity entityIn, int x, int y, int z){ BlockPos pos = new BlockPos(x, y, z); entitySizeX = MathHelper.floor_float(entityIn.width + 1); entitySizeY = MathHelper.floor_float(entityIn.height + 1); entitySizeZ = MathHelper.floor_float(entityIn.width + 1); for(int ix = 0; ix < entitySizeX; ix++){ for(int iy = 0; iy < entitySizeY; iy++){ for(int iz = 0; iz < entitySizeZ; iz++){ IBlockState state = blockaccess.getBlockState(pos.add(ix, iy, iz)); if(state.getMaterial() != Material.AIR){ return null; } } } } return openPoint(x, y, z); } I know this is a lot to look at, so any help is greatly appreciated!
  11. For anyone that happens to come across this same problem, just make sure that you registered your event class common/server side and not specifically just client side. Mine was fixed (well, believed to be fixed - I'll update the code tomorrow) by making sure it was registered common/server side.
  12. Thank ya. I'll go find a tutorial on how to do that!
  13. Hey there! So I'm making an "ability" where a player left clicks in the air with an empty hand, and a floating rock spawns and follows the player around. It's suppose to emulate earth bending from Avatar the Last Airbender. I have the PlayerInteractEvent.LeftClickEmpty set up correctly and the entity is spawning correctly, so that's all good. However, this is only being ran client side, meaning that when the EntityRock extends EntityTameable spawns, the super constructor for EntityLiving isn't running the "initEntityAI" code. I suppose I could just call it myself, but I'm willing to bet it's been written that way for a particular reason, perhaps meaning "logic" should be done server-side? Any thoughts or help are appreciated! Here's the event: @SubscribeEvent public void onLeftClick(PlayerInteractEvent.LeftClickEmpty event){ System.out.println("SIDE: " + event.getSide().toString()); EntityPlayer player = event.getEntityPlayer(); if(player.getHeldItem(EnumHand.MAIN_HAND) == null && player.equals(ClientProxy.MINECRAFT.thePlayer)){ EntityRock entity; entity = new EntityRock(player.worldObj); entity.setLocationAndAngles(player.posX, player.posY, player.posZ, MathHelper.wrapDegrees(player.worldObj.rand.nextFloat() * 360.0F), 0.0F); entity.rotationYawHead = entity.rotationYaw; entity.renderYawOffset = entity.rotationYaw; entity.onInitialSpawn(player.worldObj.getDifficultyForLocation(new BlockPos(entity)), (IEntityLivingData)null); player.worldObj.spawnEntityInWorld(entity); entity.playLivingSound(); ClientProxy.clientInfo.rocks.add(entity); } } Here's the EntityRock class: public class EntityRock extends EntityTameable { //Some code copied from Blaze class private EntityLivingBase owner; private double maxTravelDistance; private BlockPos startPosition; private double randomGeneratedOffset; private float heightOffset; /** ticks until heightOffset is randomized */ private int heightOffsetUpdateTime; private EntityAIFollowOwner followTask; private EntityAITargetBlock launhTask; private EntityAITargetEntity entityLaunchTask; public EntityRock(World worldIn) { super(worldIn); this.owner = ClientProxy.MINECRAFT.thePlayer; this.setSize(1f, 1f); this.experienceValue = 200; this.stepHeight = 1; randomGeneratedOffset = this.rand.nextInt(3); //0 - 2 //this.navigator = getNewNavigator(this.worldObj); this.setOwnerId(owner.getUniqueID()); this.posX = owner.posX + this.rand.nextInt(3); this.posY = owner.getEyeHeight() + 1; this.posZ = owner.posZ + this.rand.nextInt(3); this.setHomePosAndDistance(new BlockPos(posX, posY, posZ), Integer.MAX_VALUE); } @Override protected void initEntityAI(){ System.out.println("AI INIT"); //this.tasks.addTask(0, new EntityAIFollowBender(this, ClientProxy.MINECRAFT.thePlayer, 1f, 1.5f, 2.0f)); this.tasks.addTask(0, followTask = new EntityAIFollowOwner(this, 0.5D, 1.5f, 2f)); } @Override protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(200.0D); //100 full hearts this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(1.0D); } public void launch(EntityPlayer player) { int yaw = (int)player.rotationYaw; if(yaw<0) { //due to the yaw running a -360 to positive 360 yaw += 360; } //not sure why it's that way yaw+=22; //centers coordinates you may want to drop this line yaw%=360; //and this one if you want a strict interpretation of the zones int facing = yaw/45; // 360degrees divided by 45 == 8 zones (4 normal direction, 4 diagonal) //----------------------- RayTraceResult result = player.worldObj.rayTraceBlocks(player.getPositionEyes(1.0f), player.getLookVec()); //remove task of following owner //add task of going to target //turn step height to 0 //mark start position //play sound if(result == null) return; if(result.typeOfHit != RayTraceResult.Type.MISS) this.tasks.removeTask(followTask); if(result.typeOfHit == RayTraceResult.Type.BLOCK) { BlockPos pos = new BlockPos(result.hitVec); this.tasks.addTask(0, launhTask = new EntityAITargetBlock(this, 2.0D, Integer.MAX_VALUE, pos)); } else if(result.typeOfHit == RayTraceResult.Type.ENTITY && result.entityHit instanceof EntityLivingBase) this.tasks.addTask(0, entityLaunchTask = new EntityAITargetEntity(this, false, (EntityLivingBase) result.entityHit)); this.stepHeight = 0; this.startPosition = new BlockPos(this.getPositionVector()); //play sound } @Override public EntityAgeable createChild(EntityAgeable ageable) { return null; } @Override public boolean canBeCollidedWith(){ return false; } @Override public void onCollideWithPlayer(EntityPlayer player){ if(player == owner){ return; } } @Override public void collideWithEntity(Entity entity){ } //@Override //protected PathNavigate getNewNavigator(World world){ //return new PathNavigateFollowAbility(this, world); //} @Override public boolean processInteract(EntityPlayer player, EnumHand hand, ItemStack stack){ if(hand.equals(EnumHand.MAIN_HAND)){ } //remove task of following owner //add task of going to target //turn step height to 0 //mark start position //play sound return true; } /** * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons * use this to react to sunlight and start to burn. */ public void onLivingUpdate() { super.onLivingUpdate(); if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } this.onGround = true; //to make the path navigate believe the entity is on the ground so it can execute } protected void updateAITasks() { //may not want them to fly high incase they get in the way of shooting abilities super.updateAITasks(); --this.heightOffsetUpdateTime; if (this.heightOffsetUpdateTime <= 0) { this.heightOffsetUpdateTime = 100; this.heightOffset = 0.5F + (float)this.rand.nextGaussian() * 3.0F; } if (randomGeneratedOffset > 0 && owner != null && !owner.isDead && (Math.abs(this.posY - (owner.posY + owner.getEyeHeight())) > 1.0D)) { this.motionY += (0.30000001192092896D - this.motionY) * 0.30000001192092896D; this.motionY *= randomGeneratedOffset; this.isAirBorne = true; } this.onGround = true; //to make the path navigate believe the entity is on the ground so it can execute } public void fall(float distance, float damageMultiplier) { } @Override public boolean isAIDisabled(){return false;} protected SoundEvent getAmbientSound(){ return TestSounds.Guard; } protected SoundEvent getHurtSound(){return TestSounds.Guard;} protected SoundEvent getDeathSound(){return TestSounds.Guard;} }
  14. I appreciate it! Something simple like this wouldn't really require anything too custom, but this is just a learning experience. I figured it'd be a good way to get introduced to how AI works.
  15. Hi! So I've made a custom entity, EntityRock extends EntityMob. I want the rock to follow the player and float in the air while following. I've managed to get it to float in the air (at least, decent enough for now) by copying most of the code a blaze uses. However, I'm having a hard time getting it to follow the player. It just sits in its original position without moving. I've tried making my own follow entity AI behavior copying that of EntityAIFollowOwner, and after testing the methods used, everything is returning true and it seems to be in working state to move. Looking further into EntityMob -> EntityLiving, I see the pathNavigator is being set to a PathNavigateGround, which seemed like an inherent problem if I wanted my entity to "float" and move. But looking at, say, a bat which constantly floats and moves around, it also receives a PathNavigateGround in its constructor. So now I'm just plain confused Anyways, after seeing that my floating rock was getting a PathNavigateGround, I decided to make my own PathNavigateFollowAbility, thinking that I could simply extend PathNavigateGround and just override anything that had "isOnGround()". However, that didn't seem to work. It still just sat there without following. So looking further into PathNavigateFollowAbility extends PathNavigateGround, I saw that in the "protected PathFinder getPathFinder()", the PathNavigateFollowAbility's nodeProcessor was being set to a WalkNodeProcessor. Well, that too seemed like a problem. So now I'm trying to make my own AbilityTrackNodeProcessor. And this is where we currently are. I've managed to kind of piece parts together to this point, but now I just have no clue what I'm looking at now. This is like an inception-based movement system that never ends in needing tiny, specific parts I figured I'd just outline my thinking before showing code because I'd really just like to understand the process of how NodeProcessor, Path, PathFinder, PathHeap, PathNavigate, PathNodeType and PathPoint work together. This seems rather complicated, perhaps needlessly or perhaps justified. So if anyone can point me to a tutorial, documentation, or be willing to take the time to help me get these concepts understood, I'd really appreciate it! Thanks!
  16. Hey there! So I've made a custom Entity, EntityGuard. There are no errors on loading, however whenever it tries to render the entity (whether from me placing it or a natural spawn), the client crashes. For the sake of not making this one post the length of the screen, I'll provide hastebin links to all my classes. Here's my EntityGuard class: http://hastebin.com/upanerumed.java Here's my ModelGuard class: http://hastebin.com/ehelilukiy.java Here's my RenderGuard class: http://hastebin.com/purehowidu.scala And here's where I'm registering it client side: http://hastebin.com/dicicezoyi.java If it helps, here's the crash: http://hastebin.com/ogebohuwub.pas And here's the console log prior to the crash report being printed: http://hastebin.com/ginuvafoka.md Any help is greatly appreciated!
  17. If anyone has this problem and needs a fix, use GlStateManager.color(255,255,255,255) after drawing an object.
  18. I would use the pop and push methods. public void draw(){ textureManager.bindTexture(get); GlStateManager.pushMatrix(); //---- outline ---- GlStateManager.enableAlpha(); drawTexturedModalRect(0, 0, 0, 0, xSize, ySize); //---- inner ---- drawRect(3, 4, getRightCoord(), ySize - 3, GuiHandler.ENERGYBAR); GlStateManager.popMatrix(); GlStateManager.resetColor(); } Unfortunately that's not it either That's what I have so far
  19. Following up on this, I think either TextureManager or something in GlStateManager needs to be "reset" after being used each time, that way colors don't appear in other objects they're not suppose to. I tried GlStateManager.resetColor(), but that doesn't work
  20. Thanks! I actually did that right as you replied, just to clean up code. haha. So we're almost there. Last thing: The color of that box is being applied to everything (the outline of the bar should be grey, and so should the background of that shop menu (which is a totally different object)). https://gyazo.com/efe4cfd800fa818a2c161fa189d7fd29
  21. The # means you need an instance of that type. So do Color color = new Color(R, G, B).getRGB(); Oooooooh. I thought you guys just did that instead of using a decimal Well, good news is something displayed up top. Bad news is, I have no idea where any of that is coming from O_O https://gyazo.com/57afd183d694cde09cd5c1a2df39ce5a
  22. Do you have any idea which import that is? I can't seem to find any that returns an int value (that's what drawRect() is looking for) The only one I see that returns an int is Color.HSBtoRGB(float hue, float saturation, float brightness)
  23. Only the percentage method has to be a double. I see what you were saying about the doubles. I felt dumb when I realized what you meant. haha. Unfortunately, the rectangle still isn't being drawn. No errors are being thrown. I checked the value for "getRightCoord()" and it's 58, just as it should be. I'm not sure what's going on. Here's the code again: public class GuiEnergyBarTwo extends Gui { private int xSize = 116, ySize = 17; //size of desired window. Max is 256x256 public void draw(){ System.out.println("" + getRightCoord()); TextureManager textureManager = ClientProxy.MINECRAFT.getTextureManager(); textureManager.bindTexture(new ResourceLocation(Test.MODID + ":textures/gui/energybar.png")); GlStateManager.pushMatrix(); //---- inner ---- drawRect(0, 0, getRightCoord(), ySize - 1, 1); //---- outline ---- GlStateManager.enableAlpha(); drawTexturedModalRect(0, 0, 0, 0, xSize, ySize); GlStateManager.popMatrix(); } private int getRightCoord(){ return (int)((ClientProxy.clientInfo.getEnergyPercentage() /100) * xSize); //this returns the retrieved percentage of the length of the rectangle } }
  24. See, that's what I thought at first, but that draw method takes int's and I figured it wouldn't matter much to the player if they have a fraction of energy, ya know?

Important Information

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

Configure browser push notifications

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