Jump to content

[1.14.4] Making a Trident like item


MineModder2000

Recommended Posts

On 9/13/2019 at 6:03 PM, Animefan8888 said:

I told you how to do it in your Trident post. You need to override getSpawnPacket in your Entity class and return your own IPacket that spawns the Entity. The problem is the vanilla one doesn't handle modded entities unless they extend LivingEntity.

package mymod.thrown;

import lists.ItemList;
import mymod.My_Mod;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.ProjectileItemEntity;
import net.minecraft.item.Item;
import net.minecraft.network.IPacket;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class Chert_Entity extends ProjectileItemEntity { // Copies EggEntity
	
    private float damage = 2.5F;

    public Chert_Entity(EntityType<? extends Chert_Entity> p_i50154_1_, World p_i50154_2_) {
    	 
        super(p_i50154_1_, p_i50154_2_);
    }

    public Chert_Entity(World worldIn, LivingEntity throwerIn) {
	   
        super(My_Mod.Chert_Entity, throwerIn, worldIn);
    }
    
    /**
     * Handler for {@link World#setEntityState}
     */
    @OnlyIn(Dist.CLIENT)
    public void handleStatusUpdate(byte id) {
    	 
        if (id == 3) {
        	
        	for(int i = 0; i < 8; ++i) {
        		
        		this.world.addParticle(new ItemParticleData(ParticleTypes.ITEM, this.getItem()), this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D);
        	}
        }
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
    */
    protected void onImpact(RayTraceResult result) {		
    	
    	if (result.getType() == RayTraceResult.Type.BLOCK && (this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.OAK_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.DARK_OAK_LEAVES||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.ACACIA_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.BIRCH_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SPRUCE_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.JUNGLE_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.VINE || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_GRASS || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SEAGRASS || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_SEAGRASS || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.FERN ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.LARGE_FERN ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SUGAR_CANE)) {
    		
    		System.out.println("no");
    	}
    	
    	else {
        	
        	if (result.getType() == RayTraceResult.Type.ENTITY) {
        		
        		((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);
        	}
        	
        	this.world.setEntityState(this, (byte)3);
        	this.remove();
        }
    }

    protected Item func_213885_i() {
    	   
        return ItemList.chert;
    }
    
    @Override
    public IPacket<?> createSpawnPacket() {
    	
        return new SSpawnChertPacket(this);
     }
}

 

package mymod.thrown;

import java.io.IOException;
import java.util.UUID;

import net.minecraft.client.network.play.IClientPlayNetHandler;
import net.minecraft.entity.EntityType;
import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class SSpawnChertPacket implements IPacket<IClientPlayNetHandler> {
   private int entityId;
   private UUID uniqueId;
   private double x;
   private double y;
   private double z;
   private int speedX;
   private int speedY;
   private int speedZ;
   private int pitch;
   private int yaw;
   private EntityType<?> type;
   private int data;

   public SSpawnChertPacket(int p_i50777_1_, UUID p_i50777_2_, double p_i50777_3_, double p_i50777_5_, double p_i50777_7_, float p_i50777_9_, float p_i50777_10_, EntityType<?> p_i50777_11_, int p_i50777_12_, Vec3d p_i50777_13_) {
      this.entityId = p_i50777_1_;
      this.uniqueId = p_i50777_2_;
      this.x = p_i50777_3_;
      this.y = p_i50777_5_;
      this.z = p_i50777_7_;
      this.pitch = MathHelper.floor(p_i50777_9_ * 256.0F / 360.0F);
      this.yaw = MathHelper.floor(p_i50777_10_ * 256.0F / 360.0F);
      this.type = p_i50777_11_;
      this.data = p_i50777_12_;
      this.speedX = (int)(MathHelper.clamp(p_i50777_13_.x, -3.9D, 3.9D) * 8000.0D);
      this.speedY = (int)(MathHelper.clamp(p_i50777_13_.y, -3.9D, 3.9D) * 8000.0D);
      this.speedZ = (int)(MathHelper.clamp(p_i50777_13_.z, -3.9D, 3.9D) * 8000.0D);
   }

   public SSpawnChertPacket(Chert_Entity p_i50778_1_) {
      this(p_i50778_1_, 0);
   }

   public SSpawnChertPacket(Chert_Entity entityIn, int typeIn) {
      this(entityIn.getEntityId(), entityIn.getUniqueID(), entityIn.posX, entityIn.posY, entityIn.posZ, entityIn.rotationPitch, entityIn.rotationYaw, entityIn.getType(), typeIn, entityIn.getMotion());
   }

   public SSpawnChertPacket(Chert_Entity p_i50779_1_, EntityType<Chert_Entity> p_i50779_2_, int p_i50779_3_, BlockPos p_i50779_4_) {
      this(p_i50779_1_.getEntityId(), p_i50779_1_.getUniqueID(), (double)p_i50779_4_.getX(), (double)p_i50779_4_.getY(), (double)p_i50779_4_.getZ(), p_i50779_1_.rotationPitch, p_i50779_1_.rotationYaw, p_i50779_2_, p_i50779_3_, p_i50779_1_.getMotion());
   }

   /**
    * Reads the raw packet data from the data stream.
    */
   @SuppressWarnings("deprecation")
   public void readPacketData(PacketBuffer buf) throws IOException {
      this.entityId = buf.readVarInt();
      this.uniqueId = buf.readUniqueId();
      this.type = Registry.ENTITY_TYPE.getByValue(buf.readVarInt());
      this.x = buf.readDouble();
      this.y = buf.readDouble();
      this.z = buf.readDouble();
      this.pitch = buf.readByte();
      this.yaw = buf.readByte();
      this.data = buf.readInt();
      this.speedX = buf.readShort();
      this.speedY = buf.readShort();
      this.speedZ = buf.readShort();
   }

   /**
    * Writes the raw packet data to the data stream.
    */
   @SuppressWarnings("deprecation")
   public void writePacketData(PacketBuffer buf) throws IOException {
      buf.writeVarInt(this.entityId);
      buf.writeUniqueId(this.uniqueId);
      buf.writeVarInt(Registry.ENTITY_TYPE.getId(this.type));
      buf.writeDouble(this.x);
      buf.writeDouble(this.y);
      buf.writeDouble(this.z);
      buf.writeByte(this.pitch);
      buf.writeByte(this.yaw);
      buf.writeInt(this.data);
      buf.writeShort(this.speedX);
      buf.writeShort(this.speedY);
      buf.writeShort(this.speedZ);
   }

   public void processPacket(IClientPlayNetHandler handler) {
      //handler.handleSpawnGlobalEntity(spear);
   }

   @OnlyIn(Dist.CLIENT)
   public int getEntityID() {
      return this.entityId;
   }

   @OnlyIn(Dist.CLIENT)
   public UUID getUniqueId() {
      return this.uniqueId;
   }

   @OnlyIn(Dist.CLIENT)
   public double getX() {
      return this.x;
   }

   @OnlyIn(Dist.CLIENT)
   public double getY() {
      return this.y;
   }

   @OnlyIn(Dist.CLIENT)
   public double getZ() {
      return this.z;
   }

   @OnlyIn(Dist.CLIENT)
   public double func_218693_g() {
      return (double)this.speedX / 8000.0D;
   }

   @OnlyIn(Dist.CLIENT)
   public double func_218695_h() {
      return (double)this.speedY / 8000.0D;
   }

   @OnlyIn(Dist.CLIENT)
   public double func_218692_i() {
      return (double)this.speedZ / 8000.0D;
   }

   @OnlyIn(Dist.CLIENT)
   public int getPitch() {
      return this.pitch;
   }

   @OnlyIn(Dist.CLIENT)
   public int getYaw() {
      return this.yaw;
   }

   @OnlyIn(Dist.CLIENT)
   public EntityType<?> getType() {
      return this.type;
   }

   @OnlyIn(Dist.CLIENT)
   public int getData() {
      return this.data;
   }
}

 

Still ain't chucking. 

Link to comment
Share on other sites

Just now, MineModder2000 said:

public void processPacket(IClientPlayNetHandler handler) { //handler.handleSpawnGlobalEntity(spear); }

You still don't do anything here. So of course it isn't. And just recently I became aware of an easier/better way of doing this. Instead of returning your own implementation of IPacket you can just use NetworkHooks.getEntitySpawningPacket

  • Thanks 1

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.

Link to comment
Share on other sites

10 minutes ago, Animefan8888 said:

You still don't do anything here. So of course it isn't. And just recently I became aware of an easier/better way of doing this. Instead of returning your own implementation of IPacket you can just use NetworkHooks.getEntitySpawningPacket

  @Override
    public IPacket<?> createSpawnPacket() {
        
        return NetworkHooks.getEntitySpawningPacket(this);
    }

 

I didn't know what to do exactly in there, it's what I meant to ask but I had a brain fart. I've seen this NetWorkHooks technique, somebody showed me there code that had this, but it doesn't work for me....

Link to comment
Share on other sites

3 minutes ago, MineModder2000 said:

I didn't know what to do exactly in there, it's what I meant to ask but I had a brain fart. I've seen this NetWorkHooks technique, somebody showed me there code that had this, but it doesn't work for me....

Post your updated code. Preferably as a working github repo.

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.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

Post your updated code. Preferably as a working github repo.

 

Chert_Entity

Spoiler

package mymod.thrown;

import lists.ItemList;
import mymod.My_Mod;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.ProjectileItemEntity;
import net.minecraft.item.Item;
import net.minecraft.network.IPacket;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkHooks;

public class Chert_Entity extends ProjectileItemEntity { // Copies EggEntity
	
    private float damage = 2.5F;

    public Chert_Entity(EntityType<? extends Chert_Entity> p_i50154_1_, World p_i50154_2_) {
    	 
        super(p_i50154_1_, p_i50154_2_);
    }

    public Chert_Entity(World worldIn, LivingEntity throwerIn) {
	   
        super(My_Mod.Chert_Entity, throwerIn, worldIn);
    }
    
    /**
     * Handler for {@link World#setEntityState}
     */
    @OnlyIn(Dist.CLIENT)
    public void handleStatusUpdate(byte id) {
    	 
        if (id == 3) {
        	
        	for(int i = 0; i < 8; ++i) {
        		
        		this.world.addParticle(new ItemParticleData(ParticleTypes.ITEM, this.getItem()), this.posX, this.posY, this.posZ, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D);
        	}
        }
    }

    /**
     * Called when this EntityThrowable hits a block or entity.
    */
    protected void onImpact(RayTraceResult result) {		
    	
    	if (result.getType() == RayTraceResult.Type.BLOCK && (this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.OAK_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.DARK_OAK_LEAVES||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.ACACIA_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.BIRCH_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SPRUCE_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.JUNGLE_LEAVES ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.VINE || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_GRASS || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SEAGRASS || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.TALL_SEAGRASS || 
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.FERN ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.LARGE_FERN ||
    		this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.SUGAR_CANE)) {
    		
    		System.out.println("no");
    	}
    	
    	else {
        	
        	if (result.getType() == RayTraceResult.Type.ENTITY) {
        		
        		((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);
        	}
        	
        	this.world.setEntityState(this, (byte)3);
        	this.remove();
        }
    }

    protected Item func_213885_i() {
    	   
        return ItemList.chert;
    }
    
    @Override
    public IPacket<?> createSpawnPacket() {
    	
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

 

 

Chert_Renderer

Spoiler

package mymod.thrown;

import com.mojang.blaze3d.platform.GlStateManager;

import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IRendersAsItem;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@SuppressWarnings("deprecation")
@OnlyIn(Dist.CLIENT)
public class Chert_Renderer<T extends Entity & IRendersAsItem> extends EntityRenderer<T> {
   private final net.minecraft.client.renderer.ItemRenderer itemRenderer;
   private final float scale;

   public Chert_Renderer(EntityRendererManager p_i50956_1_, net.minecraft.client.renderer.ItemRenderer p_i50956_2_, float p_i50956_3_) {
      super(p_i50956_1_);
      this.itemRenderer = p_i50956_2_;
      this.scale = p_i50956_3_;
   }

   public Chert_Renderer(EntityRendererManager p_i50957_1_, net.minecraft.client.renderer.ItemRenderer p_i50957_2_) {
      this(p_i50957_1_, p_i50957_2_, 1.0F);
   }

   public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks) {
      GlStateManager.pushMatrix();
      GlStateManager.translatef((float)x, (float)y, (float)z);
      GlStateManager.enableRescaleNormal();
      GlStateManager.scalef(this.scale, this.scale, this.scale);
      GlStateManager.rotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
      GlStateManager.rotatef((float)(this.renderManager.options.thirdPersonView == 2 ? -1 : 1) * this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
      GlStateManager.rotatef(180.0F, 0.0F, 1.0F, 0.0F);
      this.bindTexture(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
      if (this.renderOutlines) {
         GlStateManager.enableColorMaterial();
         GlStateManager.setupSolidRenderingTextureCombine(this.getTeamColor(entity));
      }

      this.itemRenderer.renderItem(((IRendersAsItem)entity).getItem(), ItemCameraTransforms.TransformType.GROUND);
      if (this.renderOutlines) {
         GlStateManager.tearDownSolidRenderingTextureCombine();
         GlStateManager.disableColorMaterial();
      }

      GlStateManager.disableRescaleNormal();
      GlStateManager.popMatrix();
      super.doRender(entity, x, y, z, entityYaw, partialTicks);
   }

   protected ResourceLocation getEntityTexture(Entity entity) {
      return AtlasTexture.LOCATION_BLOCKS_TEXTURE;
   }
}

 

 

Chert (Item)

Spoiler

package mymod.thrown;

import java.util.Map;

import com.google.common.collect.ImmutableMap.Builder;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUseContext;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;

public class Chert extends Item { // Copies EggItem
	
	protected static final Map<Block, Block> BLOCK_STRIPPING_MAP = new Builder<Block, Block>().put(Blocks.OAK_LOG, Blocks.CAMPFIRE).build();

    public Chert(Item.Properties builder) {
	  
        super(builder);
    }

    /**
     * Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, see
     * {@link #onItemUse}.
     */
       
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
    	  
    	ItemStack itemstack = playerIn.getHeldItem(handIn); 
    	
    	if (itemstack.getTag() == null) {
    		
    		itemstack.setTag(new CompoundNBT());
    	}

	    if (playerIn.ticksExisted - itemstack.getTag().getInt("tick_last") >= 16) {
	    	
	    	itemstack.getTag().putInt("tick_last", playerIn.ticksExisted);
	    	
	        if (!playerIn.abilities.isCreativeMode) {
	    	   
	            itemstack.shrink(1);
	        }
	
	        worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
	    	  
	        if (!worldIn.isRemote) {
	        	
			    Chert_Entity chert_entity = new Chert_Entity(worldIn, playerIn);
			    chert_entity.func_213884_b(itemstack);
			    chert_entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.15F, 3.0F);
			    worldIn.addEntity(chert_entity);
	        }
	       
	    playerIn.addStat(Stats.ITEM_USED.get(this));
	    
	    return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
      
	    }
	    
	    else return new ActionResult<>(ActionResultType.PASS, itemstack);
   }
    
   public ActionResultType onItemUse(ItemUseContext context) {
	   
	   return ActionResultType.SUCCESS;  
   }
}

 

 

@Mod

Spoiler

@Mod("mymod")

public class My_Mod
{
    public static EntityType<Chert_Entity> Chert_Entity;


    private void setup(final FMLCommonSetupEvent event)
    {


        RenderingRegistry.registerEntityRenderingHandler(Chert_Entity.class, manager -> new Chert_Renderer<Chert_Entity>(manager, Minecraft.getInstance().getItemRenderer()));
    }



    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {    
        
        @SubscribeEvent
        public static void registerItems(final RegistryEvent.Register<Item> event) {

                event.getRegistry().registerAll(

                ItemList.chert = new Chert(new Item.Properties().group(ItemGroup.COMBAT)).setRegistryName(location("chert"))
            );
        }
        
        @SubscribeEvent
        public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {


            event.getRegistry().registerAll(
                    
                Chert_Entity = register("chert", EntityType.Builder.<Chert_Entity>create(Chert_Entity::new, EntityClassification.MISC).size(0.25F, 0.25F))
            );
        }
        
        private static ResourceLocation location(String name) {
            
            return new ResourceLocation("mymod", name);
        }
        
        @SuppressWarnings("deprecation")
        private static <T extends Entity> EntityType<T> register(String key, EntityType.Builder<T> builder) {
                
            return Registry.register(Registry.ENTITY_TYPE, key, builder.build(key));
        }
    } 

}

 

 

Link to comment
Share on other sites

40 minutes ago, MineModder2000 said:

Chert_Entity = register("chert", EntityType.Builder.<Chert_Entity>create(Chert_Entity::new, EntityClassification.MISC).size(0.25F, 0.25F))

You also need to specify a CustomClientFactory with Builder#setCustomClientFactory it just needs to return a new Chert_Entity you can use the EntityType, World constructor.

  • Thanks 1

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.

Link to comment
Share on other sites

On 9/15/2019 at 6:54 PM, Animefan8888 said:

You also need to specify a CustomClientFactory with Builder#setCustomClientFactory it just needs to return a new Chert_Entity you can use the EntityType, World constructor.

 

Success! Can't wait to try this with the spear. I'm still having some quirks though :

 

  1. If I throw a chert from a stack and then collect more, it'll make a new stack even when there is room (> 64), that stack becomes unstackable. 
  2. Occasionally, a chert won't chuck, expending one anyways. 
Edited by MineModder2000
Link to comment
Share on other sites

29 minutes ago, MineModder2000 said:

Occasionally, a chert won't chuck, expending one anyways. 

Sounds like a client server desync. Put all of your onItemRightClick method in an if statement with !world.isRemote.

30 minutes ago, MineModder2000 said:

If I throw a chert from a stack and then collect more, it'll make a new stack even when there is room (> 64), that stack becomes unstackable.

This is because one stack has nbt and the other doesnt have the same nbt. Try using a custom capability that way they should stack.

  • Thanks 1

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.

Link to comment
Share on other sites

On 9/17/2019 at 9:45 PM, Animefan8888 said:

Sounds like a client server desync. Put all of your onItemRightClick method in an if statement with !world.isRemote.

This is because one stack has nbt and the other doesnt have the same nbt. Try using a custom capability that way they should stack.

 

Followed tutorials and threads that I found around and got this :

 

Interface

Spoiler

package mymod.capability;

public interface TickData {

	public void set(int tick_last);
	
	public int get();
}

 

 

Factory

Spoiler

package mymod.capability;

public class TickDataFactory implements TickData {

	private int tick_last;
	
	@Override
	public void set(int tick_last) {
		
		this.tick_last = tick_last;
	}

	@Override
	public int get() {

		return this.tick_last;
	}
}

 

 

Provider

Spoiler

package mymod.capability;

import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityInject;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;

public class TickDataProvider implements ICapabilitySerializable<INBT> {
	
	@CapabilityInject(TickData.class)
	public static Capability<TickData> capability = null;
	private LazyOptional<TickData> instance = LazyOptional.of(capability::getDefaultInstance);

	@Override
	public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {

		return cap == capability ? instance.cast() : LazyOptional.empty();
	}

	@Override
	public INBT serializeNBT() {

		return capability.getStorage().writeNBT(capability, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null);
	}

	@Override
	public void deserializeNBT(INBT nbt) {

		capability.getStorage().readNBT(capability, this.instance.orElseThrow(() -> new IllegalArgumentException("LazyOptional must not be empty!")), null, nbt);
	}
}

 

 

Storage

Spoiler

package mymod.capability;

import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.Capability.IStorage;

public class TickDataStorage implements IStorage<TickData> {

	@Override
	public INBT writeNBT(Capability<TickData> capability, TickData instance, Direction side) {
		
		CompoundNBT tag = new CompoundNBT();
		tag.putInt("tick_last", instance.get());
		
		return tag;
	}

	@Override
	public void readNBT(Capability<TickData> capability, TickData instance, Direction side, INBT nbt) {
		
		CompoundNBT tag = (CompoundNBT) nbt;
		
		instance.set(tag.getByte("tick_last"));
	}
}

 

 

Chert

Spoiler

package mymod.thrown;

import java.util.Map;

import com.google.common.collect.ImmutableMap.Builder;

import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.world.World;

public class Chert extends Item { // Copies EggItem
	
	protected static final Map<Block, Block> BLOCK_STRIPPING_MAP = new Builder<Block, Block>().put(Blocks.OAK_LOG, Blocks.CAMPFIRE).build();

    public Chert(Item.Properties builder) {
	  
        super(builder);
    }

    /**
     * Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, see
     * {@link #onItemUse}.
     */
       
    public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
    	  
    	ItemStack itemstack = playerIn.getHeldItem(handIn); 
    	
    	if (!worldIn.isRemote) {
    	
    		/*
	    	if (itemstack.getTag() == null) {
	    		
	    		itemstack.setTag(new CompoundNBT());
	    	}
			*/
	
		    if (playerIn.ticksExisted - itemstack.getTag().getInt("tick_last") >= 16) {
		    	
		    	itemstack.getTag().putInt("tick_last", playerIn.ticksExisted);
		   
		        if (!playerIn.abilities.isCreativeMode) {
		    	   
		            itemstack.shrink(1);
		        }
		
		        worldIn.playSound((PlayerEntity) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_EGG_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));  
		        	
				Chert_Entity chert_entity = new Chert_Entity(worldIn, playerIn);
				chert_entity.func_213884_b(itemstack);
				chert_entity.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.15F, 3.0F);
			    worldIn.addEntity(chert_entity);
		        
		       
		    playerIn.addStat(Stats.ITEM_USED.get(this));
		    
		    return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
	      
		    }  
    	}
    	
    	return new ActionResult<>(ActionResultType.PASS, itemstack);
   }
    
   /*
   public ActionResultType onItemUse(ItemUseContext context) {
	   
	   World world = context.getWorld();
	   BlockPos blockpos = context.getPos();
	   BlockState blockstate = world.getBlockState(blockpos);
	   Block block = BLOCK_STRIPPING_MAP.get(blockstate.getBlock());
	   		
	        if (block != null && !world.isRemote) {
	        	
	            world.setBlockState(blockpos, block.getDefaultState(), 11);
	        }

	   return ActionResultType.SUCCESS;  
   }
   */
}

 

 

My_Mod

Spoiler

@Mod("mymod")
public class My_Mod
{


    public My_Mod() {
    	
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        // Register the enqueueIMC method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
        // Register the processIMC method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }

    private void setup(final FMLCommonSetupEvent event)
    {
        CapabilityManager.INSTANCE.register(TickData.class, new TickDataStorage(), TickDataFactory::new);
    }
  
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {	
      
        @SubscribeEvent
    	public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
        	
    		if (event.getObject() instanceof PlayerEntity) {
    			
    			event.addCapability(new ResourceLocation("My_Mod", "chert"), new TickDataProvider());
    		}
    	}
    }
    	

 

 

Wondering if the Chert part is right, as they aren't chucking right now....

Edited by MineModder2000
Link to comment
Share on other sites

43 minutes ago, MineModder2000 said:

Wondering if the Chert part is right, as they aren't chucking right now....

Of course its not correct you never reference your capability on the player.

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.

Link to comment
Share on other sites

8 minutes ago, Animefan8888 said:

Of course its not correct you never reference your capability on the player.

 

I can't figure out what exactly goes in the string

 

     @SubscribeEvent
        public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
            
            if (event.getObject() instanceof PlayerEntity) {
                
                event.addCapability(new ResourceLocation("My_Mod", "tick_last"), new TickDataProvider());
            }
        }

 

 

Link to comment
Share on other sites

Just now, MineModder2000 said:

I can't figure out what exactly goes in the string

A unique registry name. What you have is fine. I believe it is used for saving to disk, but I could be wrong.

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.

Link to comment
Share on other sites

Just now, MineModder2000 said:

 

I see, well I already had that block of code in before you previous comment, it's not working. 

I don't understand what you mean by not working. What did you expect to happen vs what is happening? What portion of code is it we are talking about.

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.

Link to comment
Share on other sites

Okay I have this now, tried to replicate what I did with the throw-able entity, it's not appearing though :

 

My_Mod

Spoiler

@Mod("mymod")

public class My_Mod
{
    public static EntityType<Spear_Entity> Spear_Entity;

    public My_Mod() {
    	
    	teisr = new Spear_TEISR();
    
        // Register the setup method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
        // Register the enqueueIMC method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
        // Register the processIMC method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
        // Register the doClientStuff method for modloading
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);

        // Register ourselves for server and other game events we are interested in
        MinecraftForge.EVENT_BUS.register(this);
    }
  
    private void setup(final FMLCommonSetupEvent event)
    {
        
        RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE);
    }
  
    @SubscribeEvent
    public static void registerItems(final RegistryEvent.Register<Item> event) {
        	
        		event.getRegistry().registerAll(

        		ItemList.spear = new Spear(new Item.Properties().maxDamage(10).setTEISR(teisr).group(ItemGroup.COMBAT)).setRegistryName(location("spear")),
        	);
        }
  
    @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {	
    	
      @SubscribeEvent
      public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
            
            event.getRegistry().registerAll(
            		
            	EntityType.Builder.<Spear_Entity>create(Spear_Entity::new, EntityClassification.MISC).setCustomClientFactory((spawnEntity,                       world) -> new Spear_Entity(Spear_Entity, world)).build("spear").setRegistryName("mymod", "spear"),
            );
        }
    }       

 

 

Spear_Model

Spoiler

package mymod.spear;

import net.minecraft.client.renderer.entity.model.RendererModel;
import net.minecraft.client.renderer.model.Model;
import net.minecraft.util.ResourceLocation;

public class Spear_Model extends Model {
	public static final ResourceLocation TEXTURE_LOCATION = new ResourceLocation("mymod", "spear");
	private final RendererModel modelRenderer;

	public Spear_Model() {
		
	     this.textureWidth = 32;
	     this.textureHeight = 32;
	     this.modelRenderer = new RendererModel(this, 0, 0);
	     this.modelRenderer.addBox(-0.5F, -4.0F, -0.5F, 1, 31, 1, 0.0F);
	     RendererModel renderermodel = new RendererModel(this, 4, 0);
	     renderermodel.addBox(-1.5F, 0.0F, -0.5F, 3, 2, 1);
	     this.modelRenderer.addChild(renderermodel);
	     RendererModel renderermodel1 = new RendererModel(this, 4, 3);
	     renderermodel1.addBox(-2.5F, -3.0F, -0.5F, 1, 4, 1);
	     this.modelRenderer.addChild(renderermodel1);
	     RendererModel renderermodel2 = new RendererModel(this, 4, 3);
	     renderermodel2.mirror = true;
	     renderermodel2.addBox(1.5F, -3.0F, -0.5F, 1, 4, 1);
	     this.modelRenderer.addChild(renderermodel2);
	}

	public void renderer() {
		
	     this.modelRenderer.render(0.0625F);
	}

}

 

 

Spear_Factory

Spoiler

package mymod.spear;

import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraftforge.fml.client.registry.IRenderFactory;

public class Spear_Factory implements IRenderFactory<Spear_Entity> {
	
	public static final Spear_Factory INSTANCE = new Spear_Factory();
	private Spear_Renderer spear_Renderer;

	@Override
	public EntityRenderer<? super Spear_Entity> createRenderFor(EntityRendererManager manager) {
		
		spear_Renderer = new Spear_Renderer(manager);
		
		return spear_Renderer;
	}
}

 

 

Spear_Renderer

Spoiler

package mymod.spear;

import com.mojang.blaze3d.platform.GLX;
import com.mojang.blaze3d.platform.GlStateManager;

import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
public class Spear_Renderer extends EntityRenderer<Spear_Entity> {
   public static final ResourceLocation field_203087_a = new ResourceLocation("mymod", "textures/entity/spear.png");
   private final Spear_Model field_203088_f = new Spear_Model();

   public Spear_Renderer(EntityRendererManager p_i48828_1_) {
      super(p_i48828_1_);
   }

   public void doRender(Spear_Entity entity, double x, double y, double z, float entityYaw, float partialTicks) {
      this.bindEntityTexture(entity);
      GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
      GlStateManager.pushMatrix();
      GlStateManager.disableLighting();
      GlStateManager.translatef((float)x, (float)y, (float)z);
      GlStateManager.rotatef(MathHelper.lerp(partialTicks, entity.prevRotationYaw, entity.rotationYaw) - 90.0F, 0.0F, 1.0F, 0.0F);
      GlStateManager.rotatef(MathHelper.lerp(partialTicks, entity.prevRotationPitch, entity.rotationPitch) + 90.0F, 0.0F, 0.0F, 1.0F);
      this.field_203088_f.renderer();
      GlStateManager.popMatrix();
      this.func_203085_b(entity, x, y, z, entityYaw, partialTicks);
      super.doRender(entity, x, y, z, entityYaw, partialTicks);
      GlStateManager.enableLighting();
   }

   protected ResourceLocation getEntityTexture(Spear_Entity entity) {
      return field_203087_a;
   }

   protected void func_203085_b(Spear_Entity p_203085_1_, double p_203085_2_, double p_203085_4_, double p_203085_6_, float p_203085_8_, float p_203085_9_) {
      Entity entity = p_203085_1_.getShooter();
      if (entity != null && p_203085_1_.func_203047_q()) {
         Tessellator tessellator = Tessellator.getInstance();
         BufferBuilder bufferbuilder = tessellator.getBuffer();
         double d0 = (double)(MathHelper.lerp(p_203085_9_ * 0.5F, entity.rotationYaw, entity.prevRotationYaw) * ((float)Math.PI / 180F));
         double d1 = Math.cos(d0);
         double d2 = Math.sin(d0);
         double d3 = MathHelper.lerp((double)p_203085_9_, entity.prevPosX, entity.posX);
         double d4 = MathHelper.lerp((double)p_203085_9_, entity.prevPosY + (double)entity.getEyeHeight() * 0.8D, entity.posY + (double)entity.getEyeHeight() * 0.8D);
         double d5 = MathHelper.lerp((double)p_203085_9_, entity.prevPosZ, entity.posZ);
         double d6 = d1 - d2;
         double d7 = d2 + d1;
         double d8 = MathHelper.lerp((double)p_203085_9_, p_203085_1_.prevPosX, p_203085_1_.posX);
         double d9 = MathHelper.lerp((double)p_203085_9_, p_203085_1_.prevPosY, p_203085_1_.posY);
         double d10 = MathHelper.lerp((double)p_203085_9_, p_203085_1_.prevPosZ, p_203085_1_.posZ);
         double d11 = (double)((float)(d3 - d8));
         double d12 = (double)((float)(d4 - d9));
         double d13 = (double)((float)(d5 - d10));
         double d14 = Math.sqrt(d11 * d11 + d12 * d12 + d13 * d13);
         int i = p_203085_1_.getEntityId() + p_203085_1_.ticksExisted;
         double d15 = (double)((float)i + p_203085_9_) * -0.1D;
         double d16 = Math.min(0.5D, d14 / 30.0D);
         GlStateManager.disableTexture();
         GlStateManager.disableLighting();
         GlStateManager.disableCull();
         GLX.glMultiTexCoord2f(GLX.GL_TEXTURE1, 255.0F, 255.0F);
         bufferbuilder.begin(5, DefaultVertexFormats.POSITION_COLOR);
         @SuppressWarnings("unused")
		 int j = 37;
         int k = 7 - i % 7;
         @SuppressWarnings("unused")
		 double d17 = 0.1D;

         for(int l = 0; l <= 37; ++l) {
            double d18 = (double)l / 37.0D;
            float f = 1.0F - (float)((l + k) % 7) / 7.0F;
            double d19 = d18 * 2.0D - 1.0D;
            d19 = (1.0D - d19 * d19) * d16;
            double d20 = p_203085_2_ + d11 * d18 + Math.sin(d18 * Math.PI * 8.0D + d15) * d6 * d19;
            double d21 = p_203085_4_ + d12 * d18 + Math.cos(d18 * Math.PI * 8.0D + d15) * 0.02D + (0.1D + d19) * 1.0D;
            double d22 = p_203085_6_ + d13 * d18 + Math.sin(d18 * Math.PI * 8.0D + d15) * d7 * d19;
            float f1 = 0.87F * f + 0.3F * (1.0F - f);
            float f2 = 0.91F * f + 0.6F * (1.0F - f);
            float f3 = 0.85F * f + 0.5F * (1.0F - f);
            bufferbuilder.pos(d20, d21, d22).color(f1, f2, f3, 1.0F).endVertex();
            bufferbuilder.pos(d20 + 0.1D * d19, d21 + 0.1D * d19, d22).color(f1, f2, f3, 1.0F).endVertex();
            if (l > p_203085_1_.returningTicks * 2) {
               break;
            }
         }

         tessellator.draw();
         bufferbuilder.begin(5, DefaultVertexFormats.POSITION_COLOR);

         for(int i1 = 0; i1 <= 37; ++i1) {
            double d23 = (double)i1 / 37.0D;
            float f4 = 1.0F - (float)((i1 + k) % 7) / 7.0F;
            double d24 = d23 * 2.0D - 1.0D;
            d24 = (1.0D - d24 * d24) * d16;
            double d25 = p_203085_2_ + d11 * d23 + Math.sin(d23 * Math.PI * 8.0D + d15) * d6 * d24;
            double d26 = p_203085_4_ + d12 * d23 + Math.cos(d23 * Math.PI * 8.0D + d15) * 0.01D + (0.1D + d24) * 1.0D;
            double d27 = p_203085_6_ + d13 * d23 + Math.sin(d23 * Math.PI * 8.0D + d15) * d7 * d24;
            float f5 = 0.87F * f4 + 0.3F * (1.0F - f4);
            float f6 = 0.91F * f4 + 0.6F * (1.0F - f4);
            float f7 = 0.85F * f4 + 0.5F * (1.0F - f4);
            bufferbuilder.pos(d25, d26, d27).color(f5, f6, f7, 1.0F).endVertex();
            bufferbuilder.pos(d25 + 0.1D * d24, d26, d27 + 0.1D * d24).color(f5, f6, f7, 1.0F).endVertex();
            if (i1 > p_203085_1_.returningTicks * 2) {
               break;
            }
         }

         tessellator.draw();
         GlStateManager.enableLighting();
         GlStateManager.enableTexture();
         GlStateManager.enableCull();
      }
   }
}

 

 

Spear_TEISR

Spoiler

package mymod.spear;

import java.util.Arrays;
import java.util.Comparator;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.function.Supplier;

import org.apache.commons.lang3.StringUtils;

import com.mojang.authlib.GameProfile;
import com.mojang.blaze3d.platform.GlStateManager;

import lists.ItemList;
import net.minecraft.block.AbstractSkullBlock;
import net.minecraft.block.BedBlock;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.ShulkerBoxBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BannerTextures;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.entity.model.ShieldModel;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.SkullTileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.BannerItem;
import net.minecraft.item.BlockItem;
import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.ShieldItem;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.BannerTileEntity;
import net.minecraft.tileentity.BedTileEntity;
import net.minecraft.tileentity.ChestTileEntity;
import net.minecraft.tileentity.ConduitTileEntity;
import net.minecraft.tileentity.EnderChestTileEntity;
import net.minecraft.tileentity.ShulkerBoxTileEntity;
import net.minecraft.tileentity.SkullTileEntity;
import net.minecraft.tileentity.TrappedChestTileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;

public class Spear_TEISR implements Supplier<Callable<ItemStackTileEntityRenderer>>, Callable<ItemStackTileEntityRenderer> {
	private static final ShulkerBoxTileEntity[] SHULKER_BOXES = Arrays.stream(DyeColor.values()).sorted(Comparator.comparingInt(DyeColor::getId)).map(ShulkerBoxTileEntity::new).toArray((p_199929_0_) -> {
	return new ShulkerBoxTileEntity[p_199929_0_];});
	private static final ShulkerBoxTileEntity SHULKER_BOX = new ShulkerBoxTileEntity((DyeColor)null);
	public static final ItemStackTileEntityRenderer instance = new ItemStackTileEntityRenderer();
	private final ChestTileEntity chestBasic = new ChestTileEntity();
	private final ChestTileEntity chestTrap = new TrappedChestTileEntity();
	private final EnderChestTileEntity enderChest = new EnderChestTileEntity();
	private final BannerTileEntity banner = new BannerTileEntity();
	private final BedTileEntity bed = new BedTileEntity();
	@SuppressWarnings("unused")
	private final SkullTileEntity skull = new SkullTileEntity();
	private final ConduitTileEntity conduit = new ConduitTileEntity();
	private final ShieldModel modelShield = new ShieldModel();
	private final Spear_Model spear = new Spear_Model();

	@Override
	public Callable<ItemStackTileEntityRenderer> get() {
		
		return this;
	}

	@Override
	public ItemStackTileEntityRenderer call() throws Exception {
		
		return null;
	}
	
	public void renderByItem(ItemStack itemStackIn) {
	      Item item = itemStackIn.getItem();
	      if (item instanceof BannerItem) {
	         this.banner.loadFromItemStack(itemStackIn, ((BannerItem)item).getColor());
	         TileEntityRendererDispatcher.instance.renderAsItem(this.banner);
	      } else if (item instanceof BlockItem && ((BlockItem)item).getBlock() instanceof BedBlock) {
	         this.bed.setColor(((BedBlock)((BlockItem)item).getBlock()).getColor());
	         TileEntityRendererDispatcher.instance.renderAsItem(this.bed);
	      } else if (item == Items.SHIELD) {
	         if (itemStackIn.getChildTag("BlockEntityTag") != null) {
	            this.banner.loadFromItemStack(itemStackIn, ShieldItem.getColor(itemStackIn));
	            Minecraft.getInstance().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
	         } else {
	            Minecraft.getInstance().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
	         }

	         GlStateManager.pushMatrix();
	         GlStateManager.scalef(1.0F, -1.0F, -1.0F);
	         this.modelShield.render();
	         if (itemStackIn.hasEffect()) {
	            this.renderEffect(this.modelShield::render);
	         }

	         GlStateManager.popMatrix();
	      } else if (item instanceof BlockItem && ((BlockItem)item).getBlock() instanceof AbstractSkullBlock) {
	         GameProfile gameprofile = null;
	         if (itemStackIn.hasTag()) {
	            CompoundNBT compoundnbt = itemStackIn.getTag();
	            if (compoundnbt.contains("SkullOwner", 10)) {
	               gameprofile = NBTUtil.readGameProfile(compoundnbt.getCompound("SkullOwner"));
	            } else if (compoundnbt.contains("SkullOwner", 8) && !StringUtils.isBlank(compoundnbt.getString("SkullOwner"))) {
	               GameProfile gameprofile1 = new GameProfile((UUID)null, compoundnbt.getString("SkullOwner"));
	               gameprofile = SkullTileEntity.updateGameProfile(gameprofile1);
	               compoundnbt.remove("SkullOwner");
	               compoundnbt.put("SkullOwner", NBTUtil.writeGameProfile(new CompoundNBT(), gameprofile));
	            }
	         }

	         if (SkullTileEntityRenderer.instance != null) {
	            GlStateManager.pushMatrix();
	            GlStateManager.disableCull();
	            SkullTileEntityRenderer.instance.render(0.0F, 0.0F, 0.0F, (Direction)null, 180.0F, ((AbstractSkullBlock)((BlockItem)item).getBlock()).getSkullType(), gameprofile, -1, 0.0F);
	            GlStateManager.enableCull();
	            GlStateManager.popMatrix();
	         }
	      } else if (item == ItemList.spear) {
	         Minecraft.getInstance().getTextureManager().bindTexture(new ResourceLocation("mymod", "spear"));
	         GlStateManager.pushMatrix();
	         GlStateManager.scalef(1.0F, -1.0F, -1.0F);
	         this.spear.renderer();
	         if (itemStackIn.hasEffect()) {
	            this.renderEffect(this.spear::renderer);
	         }

	         GlStateManager.popMatrix();
	      } else if (item instanceof BlockItem && ((BlockItem)item).getBlock() == Blocks.CONDUIT) {
	         TileEntityRendererDispatcher.instance.renderAsItem(this.conduit);
	      } else if (item == Blocks.ENDER_CHEST.asItem()) {
	         TileEntityRendererDispatcher.instance.renderAsItem(this.enderChest);
	      } else if (item == Blocks.TRAPPED_CHEST.asItem()) {
	         TileEntityRendererDispatcher.instance.renderAsItem(this.chestTrap);
	      } else if (Block.getBlockFromItem(item) instanceof ShulkerBoxBlock) {
	         DyeColor dyecolor = ShulkerBoxBlock.getColorFromItem(item);
	         if (dyecolor == null) {
	            TileEntityRendererDispatcher.instance.renderAsItem(SHULKER_BOX);
	         } else {
	            TileEntityRendererDispatcher.instance.renderAsItem(SHULKER_BOXES[dyecolor.getId()]);
	         }
	      } else {
	         TileEntityRendererDispatcher.instance.renderAsItem(this.chestBasic);
	      }

	   }

	   private void renderEffect(Runnable renderModelFunction) {
	      GlStateManager.color3f(0.5019608F, 0.2509804F, 0.8F);
	      Minecraft.getInstance().getTextureManager().bindTexture(ItemRenderer.RES_ITEM_GLINT);
	      ItemRenderer.renderEffect(Minecraft.getInstance().getTextureManager(), renderModelFunction, 1);
	   }
}

 

 

Spear

Spoiler

package mymod.spear;

import com.google.common.collect.Multimap;

import net.minecraft.block.BlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MoverType;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.AbstractArrowEntity;
import net.minecraft.inventory.EquipmentSlotType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.UseAction;
import net.minecraft.stats.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

public class Spear extends Item { // copies TridentItem 
   public Spear(Properties builder) {
      super(builder);
      this.addPropertyOverride(new ResourceLocation("throwing"), (p_210315_0_, p_210315_1_, p_210315_2_) -> {
         return p_210315_2_ != null && p_210315_2_.isHandActive() && p_210315_2_.getActiveItemStack() == p_210315_0_ ? 1.0F : 0.0F;
      });
   }

   public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) {
      return !player.isCreative();
   }

   /**
    * returns the action that specifies what animation to play when the items is being used
    */
   public UseAction getUseAction(ItemStack stack) {
      return UseAction.SPEAR;
   }

   /**
    * How long it takes to use or consume an item
    */
   public int getUseDuration(ItemStack stack) {
      return 72000;
   }

   /**
    * Returns true if this item has an enchantment glint. By default, this returns <code>stack.isItemEnchanted()</code>,
    * but other items can override it (for instance, written books always return true).
    *  
    * Note that if you override this method, you generally want to also call the super version (on {@link Item}) to get
    * the glint for enchanted items. Of course, that is unnecessary if the overwritten version always returns true.
    */
   @OnlyIn(Dist.CLIENT)
   public boolean hasEffect(ItemStack stack) {
      return false;
   }

   /**
    * Called when the player stops using an Item (stops holding the right mouse button).
    */
   public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
      if (entityLiving instanceof PlayerEntity) {
         PlayerEntity playerentity = (PlayerEntity)entityLiving;
         int i = this.getUseDuration(stack) - timeLeft;
         if (i >= 10) {
            int j = EnchantmentHelper.getRiptideModifier(stack);
            if (j <= 0 || playerentity.isWet()) {
               if (!worldIn.isRemote) {
                  stack.damageItem(1, playerentity, (p_220047_1_) -> {
                     p_220047_1_.sendBreakAnimation(entityLiving.getActiveHand());
                  });
                  if (j == 0) {
                     Spear_Entity spear_entity = new Spear_Entity(worldIn, playerentity, stack);
                     spear_entity.shoot(playerentity, playerentity.rotationPitch, playerentity.rotationYaw, 0.0F, 2.5F + (float)j * 0.5F, 1.0F);
                     if (playerentity.abilities.isCreativeMode) {
                    	 spear_entity.pickupStatus = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY;
                     }

                     worldIn.addEntity(spear_entity);
                     worldIn.playMovingSound((PlayerEntity)null, spear_entity, SoundEvents.ITEM_TRIDENT_THROW, SoundCategory.PLAYERS, 1.0F, 1.0F);
                     if (!playerentity.abilities.isCreativeMode) {
                         playerentity.inventory.deleteStack(stack);
                     }
                  }
               }

               playerentity.addStat(Stats.ITEM_USED.get(this));
               if (j > 0) {
                  float f7 = playerentity.rotationYaw;
                  float f = playerentity.rotationPitch;
                  float f1 = -MathHelper.sin(f7 * ((float)Math.PI / 180F)) * MathHelper.cos(f * ((float)Math.PI / 180F));
                  float f2 = -MathHelper.sin(f * ((float)Math.PI / 180F));
                  float f3 = MathHelper.cos(f7 * ((float)Math.PI / 180F)) * MathHelper.cos(f * ((float)Math.PI / 180F));
                  float f4 = MathHelper.sqrt(f1 * f1 + f2 * f2 + f3 * f3);
                  float f5 = 3.0F * ((1.0F + (float)j) / 4.0F);
                  f1 = f1 * (f5 / f4);
                  f2 = f2 * (f5 / f4);
                  f3 = f3 * (f5 / f4);
                  playerentity.addVelocity((double)f1, (double)f2, (double)f3);
                  playerentity.startSpinAttack(20);
                  if (playerentity.onGround) {
                    @SuppressWarnings("unused")
					float f6 = 1.1999999F;
                     playerentity.move(MoverType.SELF, new Vec3d(0.0D, (double)1.1999999F, 0.0D));
                  }

                  SoundEvent soundevent;
                  if (j >= 3) {
                     soundevent = SoundEvents.ITEM_TRIDENT_RIPTIDE_3;
                  } else if (j == 2) {
                     soundevent = SoundEvents.ITEM_TRIDENT_RIPTIDE_2;
                  } else {
                     soundevent = SoundEvents.ITEM_TRIDENT_RIPTIDE_1;
                  }

                  worldIn.playMovingSound((PlayerEntity)null, playerentity, soundevent, SoundCategory.PLAYERS, 1.0F, 1.0F);
               }

            }
         }
      }
   }

   /**
    * Called to trigger the item's "innate" right click behavior. To handle when this item is used on a Block, see
    * {@link #onItemUse}.
    */
   public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
      ItemStack itemstack = playerIn.getHeldItem(handIn);
      if (itemstack.getDamage() >= itemstack.getMaxDamage()) {
         return new ActionResult<>(ActionResultType.FAIL, itemstack);
      } else if (EnchantmentHelper.getRiptideModifier(itemstack) > 0 && !playerIn.isWet()) {
         return new ActionResult<>(ActionResultType.FAIL, itemstack);
      } else {
         playerIn.setActiveHand(handIn);
         return new ActionResult<>(ActionResultType.SUCCESS, itemstack);
      }
   }

   /**
    * Current implementations of this method in child classes do not use the entry argument beside ev. They just raise
    * the damage on the stack.
    */
   public boolean hitEntity(ItemStack stack, LivingEntity target, LivingEntity attacker) {
      stack.damageItem(1, attacker, (p_220048_0_) -> {
         p_220048_0_.sendBreakAnimation(EquipmentSlotType.MAINHAND);
      });
      return true;
   }

   /**
    * Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
    */
   public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) {
      if ((double)state.getBlockHardness(worldIn, pos) != 0.0D) {
         stack.damageItem(2, entityLiving, (p_220046_0_) -> {
            p_220046_0_.sendBreakAnimation(EquipmentSlotType.MAINHAND);
         });
      }

      return true;
   }

   /**
    * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
    */
   public Multimap<String, AttributeModifier> getAttributeModifiers(EquipmentSlotType equipmentSlot) {
    @SuppressWarnings("deprecation")
	Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot);
      if (equipmentSlot == EquipmentSlotType.MAINHAND) {
         multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", 8.0D, AttributeModifier.Operation.ADDITION));
         multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", (double)-2.9F, AttributeModifier.Operation.ADDITION));
      }

      return multimap;
   }

   /**
    * Return the enchantability factor of the item, most of the time is based on material.
    */
   public int getItemEnchantability() {
      return 1;
   }
   
   public Item.Properties maxStackSize(int maxStackSizeIn) {
	   
	   
	   return null;
   }
}

 

 

Spear_Entity

Spoiler

package mymod.spear;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntityType.IFactory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.IPacket;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.network.NetworkHooks;

public class Spear_Entity extends TridentEntity implements IFactory<Spear_Entity>{
    
    public Spear_Entity(EntityType<Spear_Entity> p_i50148_1_, World p_i50148_2_) {
        
        super(p_i50148_1_, p_i50148_2_);
    }

    public Spear_Entity(World worldIn, PlayerEntity playerentity, ItemStack stack) {

        super(worldIn, playerentity, stack);
    }

    @Override
    public Spear_Entity create(EntityType<Spear_Entity> p_create_1_, World p_create_2_) {

        return this;
    }
   
    @Override
    @OnlyIn(Dist.CLIENT)
    public IPacket<?> createSpawnPacket() {
        
        return NetworkHooks.getEntitySpawningPacket(this);
    }
}

 

Edited by MineModder2000
Link to comment
Share on other sites

19 minutes ago, MineModder2000 said:

Bump

18 minutes ago, MineModder2000 said:

Bump

Don't do that, especially when it reveals that you've made two threads on essentially the same topic

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

Spoiler

Logs (Most issues require logs to diagnose):

Spoiler

Please post logs using one of the following sites (Thank you Lumber Wizard for the list):

https://gist.github.com/100MB Requires member (Free)

https://pastebin.com/: 512KB as guest, 10MB as Pro ($$$)

https://hastebin.com/: 400KB

Do NOT use sites like Mediafire, Dropbox, OneDrive, Google Drive, or a site that has a countdown before offering downloads.

 

What to provide:

...for Crashes and Runtime issues:

Minecraft 1.14.4 and newer:

Post debug.log

Older versions:

Please update...

 

...for Installer Issues:

Post your installer log, found in the same place you ran the installer

This log will be called either installer.log or named the same as the installer but with .log on the end

Note for Windows users:

Windows hides file extensions by default so the installer may appear without the .jar extension then when the .log is added the log will appear with the .jar extension

 

Where to get it:

Mojang Launcher: When using the Mojang launcher debug.log is found in .minecraft\logs.

 

Curse/Overwolf: If you are using the Curse Launcher, their configurations break Forge's log settings, fortunately there is an easier workaround than I originally thought, this works even with Curse's installation of the Minecraft launcher as long as it is not launched THROUGH Twitch:

Spoiler
  1. Make sure you have the correct version of Forge installed (some packs are heavily dependent on one specific build of Forge)
  2. Make a launcher profile targeting this version of Forge.
  3. Set the launcher profile's GameDir property to the pack's instance folder (not the instances folder, the folder that has the pack's name on it).
  4. Now launch the pack through that profile and follow the "Mojang Launcher" instructions above.

Video:

Spoiler

 

 

 

or alternately, 

 

Fallback ("No logs are generated"):

If you don't see logs generated in the usual place, provide the launcher_log.txt from .minecraft

 

Server Not Starting:

Spoiler

If your server does not start or a command window appears and immediately goes away, run the jar manually and provide the output.

 

Reporting Illegal/Inappropriate Adfocus Ads:

Spoiler

Get a screenshot of the URL bar or copy/paste the whole URL into a thread on the General Discussion board with a description of the Ad.

Lex will need the Ad ID contained in that URL to report it to Adfocus' support team.

 

Posting your mod as a GitHub Repo:

Spoiler

When you have an issue with your mod the most helpful thing you can do when asking for help is to provide your code to those helping you. The most convenient way to do this is via GitHub or another source control hub.

When setting up a GitHub Repo it might seem easy to just upload everything, however this method has the potential for mistakes that could lead to trouble later on, it is recommended to use a Git client or to get comfortable with the Git command line. The following instructions will use the Git Command Line and as such they assume you already have it installed and that you have created a repository.

 

  1. Open a command prompt (CMD, Powershell, Terminal, etc).
  2. Navigate to the folder you extracted Forge’s MDK to (the one that had all the licenses in).
  3. Run the following commands:
    1. git init
    2. git remote add origin [Your Repository's URL]
      • In the case of GitHub it should look like: https://GitHub.com/[Your Username]/[Repo Name].git
    3. git fetch
    4. git checkout --track origin/master
    5. git stage *
    6. git commit -m "[Your commit message]"
    7. git push
  4. Navigate to GitHub and you should now see most of the files.
    • note that it is intentional that some are not synced with GitHub and this is done with the (hidden) .gitignore file that Forge’s MDK has provided (hence the strictness on which folder git init is run from)
  5. Now you can share your GitHub link with those who you are asking for help.

[Workaround line, please ignore]

 

Link to comment
Share on other sites

So this is what I get when I throw a spear :

 

Spoiler

[12:53:21] [Client thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Client
java.lang.RuntimeException: Missing custom spawn data for entity type net.minecraft.entity.EntityType@bd4ee01
    at net.minecraft.entity.EntityType.customClientSpawn(EntityType.java:533) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.FMLPlayMessages$SpawnEntity.lambda$null$0(FMLPlayMessages.java:153) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at java.util.Optional.map(Unknown Source) ~[?:1.8.0_221] {}
    at net.minecraftforge.fml.network.FMLPlayMessages$SpawnEntity.lambda$handle$2(FMLPlayMessages.java:153) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.NetworkEvent$Context.enqueueWork(NetworkEvent.java:185) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.FMLPlayMessages$SpawnEntity.handle(FMLPlayMessages.java:145) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.simple.IndexedMessageCodec.lambda$tryDecode$3(IndexedMessageCodec.java:114) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at java.util.Optional.ifPresent(Unknown Source) ~[?:1.8.0_221] {}
    at net.minecraftforge.fml.network.simple.IndexedMessageCodec.tryDecode(IndexedMessageCodec.java:114) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.simple.IndexedMessageCodec.consume(IndexedMessageCodec.java:147) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.simple.SimpleChannel.networkEventListener(SimpleChannel.java:65) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.doCastFilter(EventBus.java:212) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.lambda$addListener$11(EventBus.java:204) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:258) ~[eventbus-1.0.0-service.jar:?] {}
    at net.minecraftforge.fml.network.NetworkInstance.dispatch(NetworkInstance.java:82) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraftforge.fml.network.NetworkHooks.lambda$onCustomPayload$0(NetworkHooks.java:69) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at java.util.Optional.map(Unknown Source) ~[?:1.8.0_221] {}
    at net.minecraftforge.fml.network.NetworkHooks.onCustomPayload(NetworkHooks.java:69) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraft.client.network.play.ClientPlayNetHandler.handleCustomPayload(ClientPlayNetHandler.java:1916) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:runtimedistcleaner:A}
    at net.minecraft.network.play.server.SCustomPayloadPlayPacket.processPacket(SCustomPayloadPlayPacket.java:61) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraft.network.play.server.SCustomPayloadPlayPacket.processPacket(SCustomPayloadPlayPacket.java:11) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:140) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:accesstransformer:B}
    at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:110) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:accesstransformer:B}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:accesstransformer:B}
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:893) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:384) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:128) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {pl:runtimedistcleaner:A}
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] {}
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] {}
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_221] {}
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_221] {}
    at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-3.2.0.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:50) [modlauncher-3.2.0.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:68) [modlauncher-3.2.0.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:80) [modlauncher-3.2.0.jar:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-3.2.0.jar:?] {}
    at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:101) [forge-1.14.4-28.1.0_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {}

 

 

Link to comment
Share on other sites

  • 3 weeks later...

Okay how about we at least try to solve the problem of it not rendering correctly while its being readied for a toss? The TridentItem class has a resource location titled "throwing", I need to replicate the same, and put whatever belongs in there. I already point to my own "mymod", "throwing" in my Spear class, but I'm not sure what exactly is next. 

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

    • i tried downloading the drivers but it says no AMD graphics hardware
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • 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
  • Topics

×
×
  • Create New...

Important Information

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