Jump to content

Entity Not Showing In World


bigbaddevil6

Recommended Posts

I understand there is a thread below this one about what may be the same issue, or same resolution needs to be made, but I read over it and didn't seem to be the same problem.

 

The issue I am currently having is I been following along with VSWE tutorials of modding and they are for 1.6. I generally don't have a problem because I know the changes that were made and how to port it over.

On the other hand this is the first time I've worked with Entities and so I'm trying to learn both at once and it seems to be my downfall. The point is that you have an Item "ItemDroid" and you right click it on the ground and it spawns a floating entity "EntityDroid". When I do it nothing happens, no errors, nothing. The item gets taken away like how its suppose to and the code order means that it had to of ran the line to spawn the entity into the world.

 

I'm probably doing something stupid such as missing a step, have something in the wrong spot, or typo.... I looked at the ItemEgg class and the only difference I could see was they used onItemRightClick where as mine is onItemUseFirst.

 

ItemDroid:

 

 

package com.bigbaddevil7.rustic.item;


import com.bigbaddevil7.rustic.test.EntityDroid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

/**
* Created by bigbaddevil7 on 10/16/2014.
*/
public class ItemDroid extends ItemRustic{
    public ItemDroid(){
        super();
        this.setUnlocalizedName("itemdroid");
    }

    @Override
    public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ){
        if(!world.isRemote){
            world.spawnEntityInWorld(new EntityDroid(world, x + 0.5, y + 1.5, z + 0.5));
            stack.stackSize--;
            return true;
        }else{
            return false;
        }
    }
}

 

 

 

 

EntityDroid:

 

 


package com.bigbaddevil7.rustic.test;

import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

/**
* Created by bigbaddevil7 on 10/16/2014.
*/
public class EntityDroid extends Entity{

    private double startY;
    private double targetY;
    public EntityDroid(World world){
        super(world);
    }

    public EntityDroid(World world, double x, double y, double z){
        this(world);
        posX = x;
        startY = posY = y;
        posZ = z;
    }

    @Override
    protected void entityInit() {

    }

    @Override
    protected void readEntityFromNBT(NBTTagCompound nbtTagCompound) {
        startY = nbtTagCompound.getShort("Start");
        targetY = nbtTagCompound.getShort("Target");
    }

    @Override
    protected void writeEntityToNBT(NBTTagCompound nbtTagCompound) {
        nbtTagCompound.setShort("Start", (short)startY);
        nbtTagCompound.setShort("Target", (short)targetY);
    }

    @Override
    public void onUpdate(){
        super.onUpdate();

        if(!worldObj.isRemote){
            if(targetY == 0 || Math.abs(posY - targetY) < 0.25){
                targetY = startY + worldObj.rand.nextDouble() * 5;
            }

            if(posY < targetY){
                motionY = 0.05;
            }else{
                motionY = -0.05;
            }
        }

        setPosition(posX + motionX, posY + motionY, posZ + motionZ);
    }
}

 

 

 

Link to comment
Share on other sites

I'm not using a model yet. Its should spawn up with a grey rectangle that bobs up and down. Its not that it appears and falls through the ground. It just does not appear at all. Watching the amount of entites in the world and the number never changes. I did the F3+b and no box pops up so it is not even being made.

Link to comment
Share on other sites

Eh.... Well it was registered but never called.... *slams face on desk*. Anyways... you have been extremely helpful. I thank you for your time my dear sir. I knew it was something stupid. It always is with me. Can write the formulas all fine and dandy, but dear god give me something simple like actually calling it and all hell breaks loose.

Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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