Turtledove Posted April 15, 2020 Posted April 15, 2020 I'm trying to implement a magic circle that would appear below the players' feet whenever they start casting a spell. So far it all worked fine. In my game logic, whenever I create the object by calling its "non-default" constructor (the one with extra parameters in addition to World) and spawn it in world, its called first (correctly, with all of its variables properly set). But then the "default" MagicCircle(World worldIn) is called somewhere and then the variables are all reset, causing remove() to be called. I've printed all the counters and variables responsible for controlling the magic circle, and they work fine, so I'm unsure where it could be. public EntityMagicCircle(World worldIn) { super(ModEntities.Magic_Circle.getEntityType(), worldIn); } public EnergyBallEntity(World worldIn, LivingEntity caster, int ticksLifetime) { super(ModEntities.Magic_Circle.getEntityType(), worldIn); this.setPosition(caster.getPosX(), caster.getPosY(), caster.getPosZ()); this.ticksLifetime = ticksLifetime; this.ticksAlive = 0; } @Override public void tick() { if (ticksAlive < ticksLifetime) { ticksAlive++; } else { ticksAlive = 0; this.remove(); } } Instead, ticksLifetime and ticksAlive are 0 for some reason, so the magic circle never appears. I'm not doing anything funny when creating the EntityMagicCircle object either. When I comment out this.remove(), the magic circle spawns correctly, so I've no idea how to start approaching this apart from what I've already tried. Quote
Turtledove Posted April 15, 2020 Author Posted April 15, 2020 Because ticksAlive and ticksLifetime are being set to 0 and 0, I tried printing both outside of the condition in tick(), and it prints: (0,0) (0,100) (0,0) (1,100) (0,0) (2,100) ....etc. So for some reason there are two instances being created, and it isn't letting me do anything. Quote
Animefan8888 Posted April 15, 2020 Posted April 15, 2020 1 hour ago, Turtledove said: public void tick() You never call the super Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Animefan8888 Posted April 15, 2020 Posted April 15, 2020 Just now, Turtledove said: So for some reason there are two instances being created, and it isn't letting me do anything. I assume there's one on the client and one on the server. The one on the client likely doesn't know what ticksLifeTime is because it is initialized in the constructor, but when it spawns on the client it doesn't use that constructor use the EntityDataManager field in the Entity class to store your lifetime and alive count. 1 Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Turtledove Posted April 15, 2020 Author Posted April 15, 2020 6 minutes ago, Animefan8888 said: I assume there's one on the client and one on the server. The one on the client likely doesn't know what ticksLifeTime is because it is initialized in the constructor, but when it spawns on the client it doesn't use that constructor use the EntityDataManager field in the Entity class to store your lifetime and alive count. Yup that was it. God damn I can't believe I forgot about the most basic shit, staying up all night was not a good idea... thanks though ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.