Jump to content

ElTotisPro50

Members
  • Posts

    266
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ElTotisPro50

  1. My item class public class MyItem extends Item { public MyItem(Properties properties) { super(properties); } @Override public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand handIn) { ItemStack stack = player.getHeldItemMainhand(); if(player.isSneaking()) { world.playSound(player,player.getPosition(),ModSounds.SOUND.get(),SoundCategory.MASTER, 1, 1); } if(!world.isRemote) { if (player.isSneaking()) { if (stack.getItem() instanceof MyItem) { ThrownMyEntity entity = new ThrownMyEntity(ModEntityTypes.THROWNMYENTITY.get(), world); Vector3d aim = player.getLookVec(); entity.setPosition(player.getPosX() + aim.x * 1.7, player.getPosY() + (aim.y + 0.5) * 1.7, player.getPosZ() + aim.z * 1.7); entity.rotationYaw = player.rotationYaw; entity.rotationPitch = player.rotationPitch; double throwSpeed = 0.7; entity.setMotion(aim.x * throwSpeed,aim.y * throwSpeed,aim.z * throwSpeed); world.addEntity(entity); player.setItemStackToSlot(EquipmentSlotType.MAINHAND, ItemStack.EMPTY); } } } return super.onItemRightClick(world, player, handIn); } } ThrownMyEntity Class public class ThrownMyEntity extends DamagingProjectileEntity implements ITickableTileEntity { private int time; public ThrownMyEntity(EntityType<? extends DamagingProjectileEntity> entityType, World world) { super(entityType,world); } //This makes that the entity cant be pushed @Override public boolean canBePushed() { return false; } //This makes the entity can be hurt(like a ghost) @Override public boolean canBeCollidedWith() { return false; } @Override public void tick() { super.tick(); ++this.time; System.out.println(time); if(!world.isRemote) { if(time == 70) { if(getShooter() instanceof PlayerEntity) { //if(getShooter().getEntity() instanceof PlayerEntity) { this just will throw null again getShooter().getEntity.DOSOMETHINGTOTHESHOOTER } this.remove(); } } } @Override protected void registerData() { } @Override public boolean isInWater() { return false; } @Override public boolean isInLava() { return false; } @Override public boolean isBurning() { return false; } @Override public boolean isGlowing() { return false; } @Override public IPacket<?> createSpawnPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Override public boolean isWet() { return false; } }
  2. would this work? RayTraceResult entityResult = rayTrace(world,player, RayTraceContext.FluidMode.NONE); if(entityResult.getType() == RayTraceResult.Type.ENTITY) { LivingEntity lookedEntity = (LivingEntity)((EntityRayTraceResult)entityResult).getEntity(); }
  3. it uses the method raytrace "if Type.BLOCK" but i dont see anything about .Type.ENTITY or the cow for extract its milk are you sure im in the wrong spot my post says 14 hours ago in Modder Support, it doesnt say in forgegradle and i wrote the post in Modder Support only hmm
  4. so i have a code that ray trace entity but just like 7 blocks away(i cant manage the raytrace distance) and i want to know if there is a better way to do it (if i can manage the detecting distance IS BETTER) RayTraceResult entityResult = Minecraft.getInstance().objectMouseOver; if(entityResult.getType() == RayTraceResult.Type.ENTITY) { Entity lookedEntity = ((EntityRayTraceResult)entityResult).getEntity(); lookedEntity.DOSOMETHINGWITHLOOKEDENTITY; } )
  5. is not throwing nullPointerException or crashing or something it just doesnt do anything @Override public void tick() { super.tick(); ++this.time; System.out.println(time); if(!world.isRemote) { if(time == 70) { if(getShooter() instanceof PlayerEntity) { //if(getShooter().getEntity() instanceof PlayerEntity) { this just will throw null again getShooter().playSound(ModSounds.MYSOUND.get(),1,1); //getShooter().getEntity().playSound(ModSounds.MYSOUND.get(),1,1); doesnt work either } this.remove(); } } }
  6. check if shooter is playerentity? if(getShooter() instanceof PlayerEntity) this.playsound will play the sound in the throwable entity's position right?if i throw my entity with acceleration or motion the player could'nt hear it because the entity is far enough
  7. so i have an entity that extends DamagingProjectileEntity and it has tick method and i want to play a sound(inside of my projectile class) when a little time passes but im trying to do getShooter.playsound or getShooter.getEntity().playsound but it doesnt work(as i said it throws nullPointerException) by the way the crash log ONLY says nullPointerException in that line @Override public void tick() { super.tick(); ++this.time; System.out.println(time); if(!world.isRemote) { if(time == 70) { getShooter().playSound(ModSounds.MYSOUND.get(),1,1); //or getShooter().getEntity().playSound(ModSounds.MYSOUND.get(),1,1); doesnt work either this.remove(); } } }
  8. diesieben why im trying to shoot a fireball with left click event but is not working ("is not working" i mean that the fireball DOESNT appear/add to the world/spawn) @SubscribeEvent public static void leftClickItemEvent(PlayerInteractEvent.LeftClickEmpty event) { PlayerEntity player = event.getPlayer(); World world = player.world; ItemStack stack = player.getHeldItemMainhand(); if(stack.getItem() instanceof MYITEM) { //or if(stack.getItem() == ModItems.MYITEM.get()) none of those works FireballEntity fireball = new FireballEntity(EntityType.FIREBALL,world); Vector3d aim = player.getLookVec(); fireball.setPositionAndUpdate(player.getPosX() + aim.x * 1.7, player.getPosY() + aim.y * 1.7, player.getPosZ() + aim.z * 1.7); fireball.accelerationX = aim.x * 0.6; fireball.accelerationY = aim.y * 0.6; fireball.accelerationZ = aim.z * 0.6; world.addEntity(fireball); } }
  9. in the version 1.12.2 there is a event called "PlayerEmptyClickEvent.LeftClick" but obviusly mojang change the names and i cant find that event(i guess different called) i need an event to detect left click of items(maybe blocks if the event let you)
  10. thats the weird thing, there is not error log, crashing. warning about i cant shift and walk, ANYTHING, i cant post my code but how the heck is this possible?
  11. im using playertickevent,noclipeven,renderplayerevent and renderoverlayevent( just in case you need that info)
  12. when i go to my world and i shift i cant walk, is like im freezed(i can jump but W,A,S,D doesnt work) and when im not shifting i can walk, is there an event or something that is causing that? i tried to create new worlds and is the same,but even is not TOO annoying i dont like it
  13. but the armor stand can't be pushed(in the armor stand class it overrides canbepushed() and returns false)
  14. my entity can be pushed(I DONT WANT MY ENTITY CAN BE PUSHED), i can kill my entity with a sword(I WANT MY ENTITY INMORTAL/OR THAT I CANT HIT IT LIKE IS A GHOST BUT THE BOX COLLIDER STILL EXIST) and it shows the name above the entity(I WANT TO HIDE THE NAME LIKE A NORMAL ANIMAL WITHOUT CHANGING "extends LivingEntity")
  15. luis it worked but speaking of entities: i want my entity invulnerable, hide its name(my class is extending LivingEntity so it shows the name) and make that it cant be pushed but i added those 3 and none of them is working public class MyEntity extends LivingEntity { private float dirX; private float dirZ; private int liveTime; public NonNullList<ItemStack> inventory = NonNullList.<ItemStack>withSize(4, ItemStack.EMPTY); public MyEntity(EntityType<? extends LivingEntity> type, World worldIn) { super(type, worldIn); this.setCustomNameVisible(false); this.setNoGravity(true); } @Override public boolean isImmuneToExplosions() { return true; } @Override public boolean isImmuneToFire() { return true; } @Override public boolean isInvulnerable() { return true; } @Override public boolean canBeRiddenInWater() { return false; } @Override protected boolean canBeRidden(Entity entityIn) { return false; } @Override public boolean canBePushed() { return false; } @Override public void tick() { ++this.liveTime; if(liveTime == 100) { this.removed = true; this.remove(); } super.tick(); } @Override public void setNoGravity(boolean noGravity) { super.setNoGravity(noGravity); } @Override public Iterable<ItemStack> getArmorInventoryList() { return this.inventory; } @Override public ItemStack getItemStackFromSlot(EquipmentSlotType slotIn) { return slotIn.getSlotType() == EquipmentSlotType.Group.ARMOR ? this.inventory.get(slotIn.getIndex()) : ItemStack.EMPTY; } @Override public void setItemStackToSlot(EquipmentSlotType slotIn, ItemStack stack) { } @Override public HandSide getPrimaryHand() { return HandSide.RIGHT; } }
  16. install a plugin for blockbench called ModUtils(i dont know if you solved your problem yet but here is this) it lets you export your normal model AND the VoxelShape for all the 4 directions one problem is that you can collide with your block as normally but the other outlines can be replaced with a block and you can trasspass your block(again from 1 side), you will see in-game what i mean if you do this trick for make it easier https://www.youtube.com/watch?v=NblmRqf1wW8
  17. for example i have my entity (it extends LivingEntity NOT MobEntity or something) and i want to make that when the entity is spawned(via code or spawn egg or /summon) it removes itself when 5 seconds pass i guess i need to use tick() method for make that when entity is spawned it starts counting to 5 but i dont know how to make a counter
  18. i cant run minecraft for something mine not because an error, and in getDefaultName() the return null doesnt give me an error, my gui doesnt open but has a slot and a gui(i know is weird but i have my reasons)
  19. i cant run minecraft right now, but this will work? public class MyTile extends LockableLootTileEntity { private NonNullList<ItemStack> items = NonNullList.withSize(1,ItemStack.EMPTY); //private net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandlerModifiable> handler; not using this public MyTile(TileEntityType<?> tileEntityTypeIn) { super(tileEntityTypeIn); } @Override protected NonNullList<ItemStack> getItems() { return this.items; } @Override protected void setItems(NonNullList<ItemStack> itemsIn) { this.items = itemsIn; } public PipeTile() { this(ModTileEntities.MY_TILE.get()); } @Override public void read(BlockState state, CompoundNBT nbt) { super.read(state, nbt); this.items = NonNullList.withSize(this.getSizeInventory(),ItemStack.EMPTY); if(!this.checkLootAndRead(nbt)) { ItemStackHelper.loadAllItems(nbt,this.items); } } @Override public CompoundNBT write(CompoundNBT compound) { super.write(compound); if(!this.checkLootAndWrite(compound)) { ItemStackHelper.saveAllItems(compound,this.items); } return compound; } @Override protected ITextComponent getDefaultName() { return null; } @Override protected Container createMenu(int id, PlayerInventory player) { return null; } private ItemStackHandler createHandler() { return new ItemStackHandler(2) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public int getSlotLimit(int slot) { return 1; } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if(!isItemValid(slot, stack)) { return stack; } return super.insertItem(slot, stack, simulate); } }; } public ItemStack getItemSlot0() { return this.getStackInSlot(0); } @Override public int getSizeInventory() { return 1; } }
  20. i deleted: private final ItemStackHandler itemHandler = createHandler(); ,but with that i can get and set items from the slots, without it how would i do that for example: public ItemStack getItemSlot0() { return this.itemHandler.getStackInSlot(0); //without itemhandler how i do this }
  21. (i dont care about interact with hoppers im good if my tile cant)
  22. IF I WANT TO INTERACT WITH HOPPERS, so i dont need it right?
  23. and the chest use both of them and obviusly it keeps the items
  24. but how i remove ItemStackHandler if i need it for getCapability(you return handler.cast()) or i just return the super that comes with getCapability() ?
  25. public class MyTile extends LockableLootTileEntity { private final ItemStackHandler itemHandler = createHandler(); private NonNullList<ItemStack> items = NonNullList.withSize(1,ItemStack.EMPTY); private net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandlerModifiable> handler; public MyTile(TileEntityType<?> tileEntityTypeIn) { super(tileEntityTypeIn); } @Override protected NonNullList<ItemStack> getItems() { return this.items; } @Override protected void setItems(NonNullList<ItemStack> itemsIn) { this.items = itemsIn; } public PipeTile() { this(ModTileEntities.MY_TILE.get()); } @Override public void read(BlockState state, CompoundNBT nbt) { super.read(state, nbt); this.items = NonNullList.withSize(this.getSizeInventory(),ItemStack.EMPTY); if(!this.checkLootAndRead(nbt)) { ItemStackHelper.loadAllItems(nbt,this.items); } } @Override public CompoundNBT write(CompoundNBT compound) { super.write(compound); if(!this.checkLootAndWrite(compound)) { ItemStackHelper.saveAllItems(compound,this.items); } return compound; } @Override protected ITextComponent getDefaultName() { return null; } @Override protected Container createMenu(int id, PlayerInventory player) { return null; } private ItemStackHandler createHandler() { return new ItemStackHandler(2) { @Override protected void onContentsChanged(int slot) { markDirty(); } @Override public int getSlotLimit(int slot) { return 1; } @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if(!isItemValid(slot, stack)) { return stack; } return super.insertItem(slot, stack, simulate); } }; } public ItemStack getItemSlot0() { return this.itemHandler.getStackInSlot(0); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { if(cap == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { return handler.cast(); } return super.getCapability(cap, side); } @Override public int getSizeInventory() { return 1; } } besides(from what you are helping me)... for what is the number you put in create handler where you return a new ItemStackHandler(HERE I USED 2 AND WORKS BUT FOR WHAT IS THIS NUMBER)
×
×
  • Create New...

Important Information

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