Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.11.2][Solved] Problems with Moving Entities


Recommended Posts

I am trying to make a levitator for entities (entities, itementities and players). I created a ticking tile entity which checks the entities above it and adds to their motionY value. Also, if a player sneaks while above the levitator he should float down (without fall damage) and land on the levitator.
Here I have two problems:

1. The player always takes fall damage, even after I callentity.fallDistance = 0;. Is there any way to remove fall damage which isn't an event (since I already have a ticking tile entity, I'd like to use it for this purpose as well).

2. Items which go on the levitator and have horisontal velocity kind of "rubber band" when they are supposed to go off the levitator. Whenever the item leaves the AxisAllignedBoundingBox of the checking of the levitator, it goes back to it's position and doesn't fall off. Since I'm working on a server (if (world.isRemote()) return; at the beginning), I don't understand why this is happening. I hope someone knows how to figure it out...

 

my tile entity's code, a little bit oddly copied but I hope it's understandable:

@Override
public void update() {
	if (world == null || world.isRemote) return;
	List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getPos().getX(), getPos().getY() + 1, getPos().getZ(), getPos().getX() + 1, getPos().getY() + 1 + ModConfig.LEVITATOR_RANGE.getValue(), getPos().getZ() + 1));
	if (entities.size() > 0) {
		for (Entity entity : entities) {
			if (entity instanceof EntityPlayer) {
				EntityPlayer player = (EntityPlayer) entity;
            	player.fallDistance = 0;
            	if (player.isSneaking()) {
					if (player.motionY > 0) {
						player.motionY -= 0.1;
    	            } else {
        	            if (player.motionY < -0.35) {
        	                player.motionY = -0.35;
            	        }
                	}
	            } else {
    	            if (!player.capabilities.isCreativeMode) {
        	            if (player.motionY < 0.35) {
            	            player.motionY += 0.1;
                	    }
                    	entity.fallDistance = 0;
	                }
				}
			} else if (entity.canBePushed()) {
				if (entity.motionY < 0.35) {
					entity.motionY += 0.1;
				}
			} else if (entity instanceof EntityItem) {
				if (entity.motionY < 0.35) {
					entity.motionY += 0.1;
				}
			}
		}
	}
}

 

Edited by yolp900
Solved! Thank you V0idWa1k3r!
Link to post
Share on other sites

Never mind. I didn't found out that this method is only called on the client. I'll use packets for changing the motion on the server. I just need to figure out how to read and write an entity with a ByteBuf or how to get an entity from it's NBT...

Edited by yolp900
Found out why initial code didn't work.
Link to post
Share on other sites

You should always do entity motion on both sides. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

I changed the code in the method "update". However it is only called on the client side. Is there any way to tell the server to move an entity from the client side? (I know about packets, just don't know how to pass an entity from the client to the server, so it would know which entity to move).

 

The new code:

Spoiler

@Override
public void update() {
    if (world == null) return;
    List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getPos().getX(), getPos().getY() + 1, getPos().getZ(), getPos().getX() + 1, getPos().getY() + 1 + ModConfig.LEVITATOR_RANGE, getPos().getZ() + 1));
    if (entities.size() > 0) {
        for (Entity entity : entities) {
            if (entity instanceof EntityPlayer) {
                EntityPlayer liftedPlayer = (EntityPlayer) entity;
                liftedPlayer.fallDistance = 0;
                if (liftedPlayer.isSneaking()) {
                    if (liftedPlayer.motionY > 0) {
                        liftedPlayer.motionY -= 0.1;
                    } else {
                        if (liftedPlayer.motionY < -0.35) {
                            liftedPlayer.motionY = -0.35;
                        }
                    }
                } else {
                    if (!liftedPlayer.capabilities.isCreativeMode) {
                        if (liftedPlayer.motionY < 0.35) {
                            liftedPlayer.motionY += 0.1;
                        }
                    }
                }
            } else if (entity.canBePushed()) {
                if (entity.motionY < 0.35) {
                    entity.motionY += 0.1;
                }
            } else if (entity instanceof EntityItem) {
                if (entity.motionY < 0.35) {
                    entity.motionY += 0.1;
                }
            }
            entity.velocityChanged = true;
            if (entity.motionY > 0) {
                if (!world.isRemote && random.nextDouble() < 0.75) {
                    NetworkHandler.sendToAllAround(new MessageParticle(ModParticles.Particles.Levitator, entity.posX - (entity.width / 2) + (random.nextDouble() * entity.width), entity.posY, entity.posZ - (entity.width / 2) + (random.nextDouble() * entity.width), random.nextDouble() + 0.25, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, 0, -entity.motionY, 0), world.provider.getDimension(), entity.posX, entity.posY, entity.posZ, 16);

                }
            }
        }
    }
    double i = random.nextDouble();
    if (!world.isRemote && i < 0.15) {
            NetworkHandler.sendToAllAround(new MessageParticle(ModParticles.Particles.Levitator, getPos().getX() + random.nextDouble(), getPos().getY() + 1.01, getPos().getZ() + random.nextDouble(), random.nextDouble() + 0.25, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, 0, 0.1, 0), world.provider.getDimension(), getPos().getX() + 0.5, getPos().getY() + 1.05, getPos().getZ() + 0.5, 16);
    }
}

 

 

Link to post
Share on other sites
5 minutes ago, yolp900 said:

I changed the code in the method "update". However it is only called on the client side.

False. Your update method currently runs on both sides.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites
1 minute ago, Draco18s said:

False. Your update method currently runs on both sides.

I checked if it's running on the server by adding this line to the beginning of the method:

Charming.logger.info("Is this method called by the server? " + !world.isRemote);

And this is the output I got is the following:

[19:24:23] [Client thread/INFO]: Is this method called by the server? false

Repeated every tick. No Server thread calling... Am I doing something wrong...?

Link to post
Share on other sites

Post more code. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

This is my entire TileEntityLevitator:

Spoiler

public class TileEntityLevitator extends ModTileEntity implements ITickable {
    private Random random = new Random();
    private boolean inverted;
    
    @Override
    public void update() {
        Charming.logger.info("Is this method called by the server? " + !world.isRemote);
        if (world == null) return;
        if (on()) {
            List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(getPos().getX(), getPos().getY() + 1, getPos().getZ(), getPos().getX() + 1, getPos().getY() + 1 + ModConfig.LEVITATOR_RANGE.getValue(), getPos().getZ() + 1));
            if (entities.size() > 0) {
                for (Entity entity : entities) {
                    if (entity instanceof EntityPlayer) {
                        EntityPlayer liftedPlayer = (EntityPlayer) entity;
                        liftedPlayer.fallDistance = 0;
                        if (liftedPlayer.isSneaking()) {
                            if (liftedPlayer.motionY > 0) {
                                liftedPlayer.motionY -= 0.1;
                            } else {
                                if (liftedPlayer.motionY < -0.35) {
                                    liftedPlayer.motionY = -0.35;
                                }
                            }
                        } else {
                            if (!liftedPlayer.capabilities.isCreativeMode) {
                                if (liftedPlayer.motionY < 0.35) {
                                    liftedPlayer.motionY += 0.1;
                                }
                            }
                        }
                    } else if (entity.canBePushed()) {
                        if (!CharmingAPI.Levitator.isEntityBlacklistedFromLevitator(entity.getClass())) {
                            if (entity.motionY < 0.35) {
                                entity.motionY += 0.1;
                            }
                        }
                    } else if (entity instanceof EntityItem) {
                        if (!CharmingAPI.Levitator.isItemStackBlacklistedFromLevitator(((EntityItem) entity).getEntityItem())) {
                            if (entity.motionY < 0.35) {
                                entity.motionY += 0.1;
                            }
                        }
                    }
                    entity.velocityChanged = true;
                    if (entity.motionY > 0) {
                        if (!world.isRemote && random.nextDouble() < 0.75) {
                            NetworkHandler.sendToAllAround(new MessageParticle(ModParticles.Particles.Levitator, entity.posX - (entity.width / 2) + (random.nextDouble() * entity.width), entity.posY, entity.posZ - (entity.width / 2) + (random.nextDouble() * entity.width), random.nextDouble() + 0.25, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, 0, -entity.motionY, 0), world.provider.getDimension(), entity.posX, entity.posY, entity.posZ, 16);
                        }
                    }
                }
            }
            double i = random.nextDouble();
            if (!world.isRemote && i < 0.15) {
                NetworkHandler.sendToAllAround(new MessageParticle(ModParticles.Particles.Levitator, getPos().getX() + random.nextDouble(), getPos().getY() + 1.01, getPos().getZ() + random.nextDouble(), random.nextDouble() + 0.25, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, (random.nextDouble() / 4) + 0.5, 0, 0.1, 0), world.provider.getDimension(), getPos().getX() + 0.5, getPos().getY() + 1.05, getPos().getZ() + 0.5, 16);
            }
        }
    }

    public boolean on() {
        if (inverted) {
            return !powered();
        }
        return powered();
    }

    private boolean powered() {
        return world.isBlockPowered(getPos()) || world.isBlockPowered(getPos().up()) || world.isBlockIndirectlyGettingPowered(getPos()) != 0;
    }

    @Override
    public void readFromNBT(NBTTagCompound tag) {
        this.inverted = tag.getBoolean(LibMisc.INVERTED);
    }

    @Override
    @Nonnull
    public NBTTagCompound writeToNBT(NBTTagCompound tag) {
        super.writeToNBT(tag);

        tag.setBoolean(LibMisc.INVERTED, inverted);

        return tag;
    }

}

 

This is ModTileEntity (no real need for it but I find it useful not having to copy paste this code over and over)

Spoiler

public abstract class ModTileEntity extends TileEntity {

    @Override
    @Nonnull
    public NBTTagCompound getUpdateTag() {
        NBTTagCompound tag = new NBTTagCompound();

        this.writeToNBT(tag);
        return tag;
    }

    @Override
    @Nullable
    public SPacketUpdateTileEntity getUpdatePacket() {
        return new SPacketUpdateTileEntity(this.pos, 0, getUpdateTag());
    }

    @Override
    public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
        NBTTagCompound tag = pkt.getNbtCompound();
        this.readFromNBT(tag);
    }

}

 

This is my tile entity registry which is being called from the server-side proxy:

Spoiler

public static void registerTileEntities() {
    registerTileEntity(TileEntityLevitator.class, LibTileEntities.LEVITATOR);
}

private static void registerTileEntity(Class<? extends TileEntity> classTile, String ID) {
    GameRegistry.registerTileEntity(classTile, ID);
}

 

This is the block which provides the tile entity. I don't think this is related, but it might help:

Spoiler

public class BlockLevitator extends ModBlock implements ITileEntityProvider {
    public static final PropertyBool ON_STATE = PropertyBool.create(LibMisc.ON_STATE); //On = true, Off = false.

    public BlockLevitator() {
        super(LibBlocks.LEVITATOR);
        this.setDefaultState(blockState.getBaseState().withProperty(ON_STATE, false));
    }

    @Override
    @Nonnull
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, ON_STATE);
    }

    @Override
    public int getMetaFromState(IBlockState state) {
        return 0;
    }

    @Override
    @Nonnull
    public IBlockState getStateFromMeta(int meta) {
        return super.getStateFromMeta(meta);
    }

    @Override
    public float getBlockHardness(IBlockState state, World world, BlockPos pos) {
        return 4F;
    }

    @Override
    public float getExplosionResistance(World world, BlockPos pos, @Nonnull Entity exploder, Explosion explosion) {
        return 9.5F;
    }

    @Override
    @Nonnull
    public Material getMaterial(IBlockState state) {
        return Material.IRON;
    }

    @Override
    @Nonnull
    public IBlockState getActualState(@Nonnull IBlockState state, IBlockAccess world, BlockPos pos) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile == null || !(tile instanceof TileEntityLevitator)) return super.getActualState(state, world, pos);
        TileEntityLevitator tileLevitator = (TileEntityLevitator) tile;
        return state.withProperty(ON_STATE, tileLevitator.on());
    }

    @Nullable
    @Override
    public TileEntity createNewTileEntity(@Nonnull World worldIn, int meta) {
        return new TileEntityLevitator();
    }
}

 

Anything else I can post which might help this situation?

Link to post
Share on other sites

Well, I can tell you to stop using ITileEntityProvider because it is old and unnecessary. Just override hasTE and getTE in the block class. 

 

Won't solve your problem, though. 

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

I updated to the latest Forge and this seems to be fixed. I'm not sure why, didn't see anything in the changelogs but that's good!
However, a new problem has appeared now, the tile entity starts updating (the update method is only called) after the player hits and updates the block (not updates as in redstone update or block update, but updating the visuals, starting to break the block by left clicking on it). I thought the methods in ModTileEntity:

18 hours ago, yolp900 said:

This is ModTileEntity (no real need for it but I find it useful not having to copy paste this code over and over)

  Reveal hidden contents

 

 

would prevent this from happenning, nut apparently I don't understand the way this "update()" method is called.

Link to post
Share on other sites

You have to call these methods when the data changes:

        worldObj.markBlockRangeForRenderUpdate(pos, pos);
        worldObj.notifyBlockUpdate(pos, getState(), getState(), 3);
        worldObj.scheduleBlockUpdate(pos,this.getBlockType(),0,0);
        markDirty();

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

Do I have to call these methods whenever I call a new TileEntity with data? I mean, The tile entity works great but whenever I re-enter the world it needs to be hit to function.

The only thing I can think which would solve this is to somehow update the tile entity on the constructor, which sounds horrible preformance-wise... Is there something else I can do?

Link to post
Share on other sites

I have tried putting these methods in the tile entitie's constructor, but there was no difference. Every time I enter a world which have one of my tile entities, I need to update it manually by hitting it so it'll start to work. Anybody knows of a solution to this problem or maybe has a different update method than what I use which works?

Link to post
Share on other sites

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

okay, but the problem I have is not that the data isn't changing, but it is that the method "update" isn't being called until one hits the block and causes it to update on the client or something like that. My logger isn't called until I hit the block, and I don't understand why. Unless it's the same thing and I don't understand the connection, I don't think calling this would change anything.

Link to post
Share on other sites

The tile entity's constructor isn't called until I hit the block. How can I update the tile without needing to hit the block? The boolean "inverted" isn't saved as well, and I don't know why that is either.

Link to post
Share on other sites
8 minutes ago, yolp900 said:

The tile entity's constructor isn't called until I hit the block.

THAT doesn't even make sense. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to post
Share on other sites

I thought that my self. added a logger.info("Called") line and it's not called on the client when I enter the world but only when I hit the block (It is called by the server, but the boolean isn't saved anywhere and it doesn't update until I left click the block). I really don't know what's going on. This isn't the first tile entity I've made but it's the most odd...

Link to post
Share on other sites

Assuming that your TE's code had not changed

 

On 6/28/2017 at 7:50 PM, yolp900 said:

@Override public void readFromNBT(NBTTagCompound tag) { this.inverted = tag.getBoolean(LibMisc.INVERTED); }

I think you are missing a super call here. You at the very least need to know the position of TE from the NBT so it can be loaded into the world properly.

  • Like 1
Link to post
Share on other sites
19 minutes ago, V0idWa1k3r said:

Assuming that your TE's code had not changed

 

I think you are missing a super call here. You at the very least need to know the position of TE from the NBT so it can be loaded into the world properly.

That was it! fixed both of my problems! thank you very much! :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • In my code I'm trying to teleport the player to my custom dimension when they interact with an entity. It all works up until the teleporting part of the code. It always crashes the game when I interact with the entity. Thank you in advance! The code: @Override public ActionResultType applyPlayerInteraction(PlayerEntity player, Vec3d vec, Hand hand) { ItemStack stack = player.getHeldItem(hand); if (stack == ItemStack.EMPTY) { player.changeDimension(DimensionType.byName(MyMod.MINING_DIM_TYPE)); }else { player.sendMessage(new TranslationTextComponent("mymod.message.emptyHand")); } return ActionResultType.SUCCESS; }   public static final String MOD_ID = "mymod"; public static final ResourceLocation MINING_DIM_TYPE = new ResourceLocation(MOD_ID, "mining_dim");  
    • don't use this in separate classes, use the EventBusSubscriber annotation instead https://mcforge.readthedocs.io/en/latest/events/intro/#events
    • Im playing with MultiMC. I get to the "Loading world, Bulding Terrain..." screen and then it goes to minecraft dindn't respond. I've been at this for two hour now. I can't find any articles that deal with this error. I also have OptiFine installed, I tried deleting the options text file and restarting but still no luck. I dunno which information is important so I'll post the full log. ---- Minecraft Crash Report ---- WARNING: coremods are present:   LucraftCoreCoreMod (LucraftCore-1.12.2-2.4.16.jar)   MalisisCorePlugin (malisiscore-1.12.2-6.5.1.jar) Contact their authors BEFORE contacting forge // My bad. Time: 7/23/21 5:25 PM Description: Ticking player java.lang.NoSuchMethodError: lucraft.mods.lucraftcore.superpowers.abilities.Ability.getCurrentPlayerAbilities(Lnet/minecraft/entity/player/EntityPlayer;)Ljava/util/List;     at lucraft.mods.speedsterheroes.abilities.AbilityPhasing$EventHandler.onLivingUpdate(AbilityPhasing.java:82)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_54_EventHandler_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)     at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)     at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:581)     at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2095)     at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:234)     at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:382)     at net.minecraft.network.NetHandlerPlayServer.func_73660_a(NetHandlerPlayServer.java:173)     at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:209)     at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:285)     at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180)     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:790)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:279)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace:     at lucraft.mods.speedsterheroes.abilities.AbilityPhasing$EventHandler.onLivingUpdate(AbilityPhasing.java:82)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_54_EventHandler_onLivingUpdate_LivingUpdateEvent.invoke(.dynamic)     at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)     at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)     at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:581)     at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:2095)     at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:234) -- Player being ticked -- Details:     Entity Type: null (net.minecraft.entity.player.EntityPlayerMP)     Entity ID: 1844     Entity Name: RedcreeperYT_     Entity's Exact location: 453.50, 4.00, 91.50     Entity's Block location: World: (453,4,91), Chunk: (at 5,0,11 in 28,5; contains blocks 448,0,80 to 463,255,95), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)     Entity's Momentum: 0.00, 0.00, 0.00     Entity's Passengers: []     Entity's Vehicle: ~~ERROR~~ NullPointerException: null Stacktrace:     at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:382)     at net.minecraft.network.NetHandlerPlayServer.func_73660_a(NetHandlerPlayServer.java:173)     at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.func_73660_a(NetworkDispatcher.java:209)     at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:285) -- Ticking connection -- Details:     Connection: net.minecraft.network.NetworkManager@29c7e996 Stacktrace:     at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:180)     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:790)     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668)     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:279)     at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526)     at java.lang.Thread.run(Unknown Source) -- System Details -- Details:     Minecraft Version: 1.12.2     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_291, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 1306579696 bytes (1246 MB) / 2693267456 bytes (2568 MB) up to 3817865216 bytes (3641 MB)     JVM Flags: 3 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xms512m -Xmx4096m     IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0     FML: MCP 9.42 Powered by Forge 14.23.5.2855 Optifine OptiFine_1.12.2_HD_U_G6_pre1 19 mods loaded, 19 mods active     States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored     | State  | ID              | Version               | Source                                   | Signature                                |     |:------ |:--------------- |:--------------------- |:---------------------------------------- |:---------------------------------------- |     | LCHIJA | minecraft       | 1.12.2                | minecraft.jar                            | None                                     |     | LCHIJA | mcp             | 9.42                  | minecraft.jar                            | None                                     |     | LCHIJA | FML             | 8.0.99.99             | forge-1.12.2-14.23.5.2855-universal.jar  | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCHIJA | forge           | 14.23.5.2855          | forge-1.12.2-14.23.5.2855-universal.jar  | e3c3d50c7c986df74c645c0ac54639741c90a557 |     | LCHIJA | securitycraft   | v1.8.22.2             | [1.12.2]+SecurityCraft+v1.8.22.2.jar     | None                                     |     | LCHIJA | customspawner   | 3.11.4                | Custom-Mob-Spawner-Mod-1.12.2.jar        | None                                     |     | LCHIJA | ptrmodellib     | 1.0.4                 | PTRLib-1.0.4.jar                         | None                                     |     | LCHIJA | props           | 2.6.3                 | Decocraft-2.6.3_1.12.2.jar               | None                                     |     | LCHIJA | jei             | 4.16.1.302            | jei_1.12.2-4.16.1.302.jar                | None                                     |     | LCHIJA | speedsterheroes | 1.12.2-2.0.7          | Quicksilver-Mod-1.12.2.jar               | None                                     |     | LCHIJA | lucraftcore     | 1.12.2-2.4.16         | LucraftCore-1.12.2-2.4.16.jar            | None                                     |     | LCHIJA | malisiscore     | 1.12.2-6.5.1-SNAPSHOT | malisiscore-1.12.2-6.5.1.jar             | None                                     |     | LCHIJA | malisisdoors    | 1.12.2-7.3.0          | malisisdoors-1.12.2-7.3.0.jar            | None                                     |     | LCHIJA | mocreatures     | 12.0.5                | Mo-Creatures-Mod-1.12.2.jar              | None                                     |     | LCHIJA | movingelevators | 1.2.34                | movingelevators-1.2.34-mc1.12.jar        | None                                     |     | LCHIJA | scp             | 2.4.0                 | SCP_Lockdown-1.12.2-2.4.0-hotfix.jar     | None                                     |     | LCHIJA | scple           | 1.0                   | scple-1.0.jar                            | None                                     |     | LCHIJA | thejungle       | 1.2006.1222           | Welcome-to-the-Jungle-Mod-1.12.2.jar     | None                                     |     | LCHIJA | worldedit       | 6.1.10                | worldedit-forge-mc1.12.2-6.1.10-dist.jar | None                                     |     Loaded coremods (and transformers):  LucraftCoreCoreMod (LucraftCore-1.12.2-2.4.16.jar)   lucraft.mods.lucraftcore.core.LCTransformer MalisisCorePlugin (malisiscore-1.12.2-6.5.1.jar)        GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.     Profiler Position: N/A (disabled)     Player Count: 1 / 8; [EntityPlayerMP['RedcreeperYT_'/1844, l='New World', x=453.50, y=4.00, z=91.50]]     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'fml,forge'     OptiFine Version: OptiFine_1.12.2_HD_U_G6_pre1     OptiFine Build: 20210323-161358     Render Distance Chunks: 8     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: null     OpenGlVersion: 4.6.0 NVIDIA 466.27     OpenGlRenderer: NVIDIA GeForce GTX 1650 SUPER/PCIe/SSE2     OpenGlVendor: NVIDIA Corporation     CpuCount: 4
    • Goal: when Entity attacks player, it dies. Code: public class EventHandler { @SubscribeEvent public static void onLivingAttackEvent(LivingAttackEvent event) { if (event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.HEAD).getItem() == ItemInit.LAVA_HELMET.get() && event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.CHEST).getItem() == ItemInit.LAVA_CHEST.get() && event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.LEGS).getItem() == ItemInit.LAVA_LEGGINGS.get() && event.getEntityLiving().getItemStackFromSlot(EquipmentSlotType.FEET).getItem() == ItemInit.LAVA_BOOTS.get()) { if (event.getSource().getTrueSource().getEntity() instanceof MobEntity) { event.getSource().getTrueSource().getEntity().onKillCommand(); } } } } And: @Mod(LavaArmor.MODID) public class LavaArmor { public static final String MODID = "lavaarmor"; public LavaArmor() { IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); bus.addListener(this::setup); ItemInit.ITEMS.register(bus); MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(EventHandler.class); } @SuppressWarnings("deprecation") private void setup(final FMLCommonSetupEvent event) { } } I think I've done everything I've needed. Moreover, the exact same code works fine in my another project. What's wrong?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.