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

(1.10.2) What does on impact netherrack look like for a projectile?


gurujive
 Share

Recommended Posts

Ifnit is a custom projectile there is an onImpact method, otherwise use the ThrowableImpactEvent

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

this is crashing the game when i throw the entity:

"

private int xTile;

private int yTile;

private int zTile;

"

 

"

public void onUpdate()

    {

    super.onUpdate();

    BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile);

"

 

"

    protected void onImpact(RayTraceResult result)

if (!this.worldObj.isRemote)

        {

            this.setDead();

            if (worldObj.getBlockState(null) == Blocks.COAL_BLOCK.getDefaultState())

{

this.worldObj.setBlockState( null, Blocks.FIRE.getDefaultState());

}

"

 

 

 

package guru.tbe.entity;

import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.Item;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class EntityFireOrb extends EntityOrb
{
private static final DataParameter<Integer> FUSE = EntityDataManager.<Integer>createKey(EntityFireOrb.class, DataSerializers.VARINT);
private int explosionPower;
private int fuse;
private int xTile;
private int yTile;
private int zTile;

public EntityFireOrb(World worldIn)
    {
        super(worldIn);
    }
public EntityFireOrb(World worldIn, EntityLivingBase throwerIn)
    {
        super(worldIn, throwerIn);
        this.fuse = 140;
    }
    protected void entityInit()
    {
        this.dataManager.register(FUSE, Integer.valueOf(140));
    }
    protected boolean canTriggerWalking()
    {
        return false;
    }
    public void onUpdate()
    {
    	super.onUpdate();
    	BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile);
    	this.worldObj.spawnParticle(EnumParticleTypes.FLAME, posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, posY + (worldObj.rand.nextFloat() / -2 - worldObj.rand.nextFloat()) / -1, posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, 0, 0, 0);
        --this.fuse;
        if (this.fuse <= 0)
        {
            this.setDead();

            if (!this.worldObj.isRemote)
            {
                this.explode();
            }
        }
        else
        {
            this.handleWaterMovement();
        }
        this.isImmuneToFire();
    }
    private void explode()
    {
        float f = -1.0F;
        this.worldObj.createExplosion(this, this.posX, this.posY + (double)(this.height / 16.0F), this.posZ, (float)this.explosionPower, isDead);
    }
    protected void onImpact(RayTraceResult result)
    {
    	
        if (result.entityHit != null)
        {
            double i = 0;        
            if (!this.isWet() && result.entityHit instanceof EntityCreeper)
            {
            	((EntityCreeper) result.entityHit).ignite();	
            }           
            if (result.entityHit instanceof EntityLivingBase)
            {
                i = 4.7;
            }
            result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i);
            result.entityHit.setFire(;
            float f = 0.0F;
            this.worldObj.createExplosion(this, this.posX, this.posY + (double)(this.height / 16.0F), this.posZ, (float)this.explosionPower, true);
        }
        if (!this.worldObj.isRemote)
        {
            this.setDead();
            if (worldObj.getBlockState(null) == Blocks.COAL_BLOCK.getDefaultState())
		{
			this.worldObj.setBlockState( null, Blocks.FIRE.getDefaultState());
		}
            worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_POP, SoundCategory.NEUTRAL, 1.3F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
        }
        if (this.isInWater())
        {
            {
                worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.3F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
            }
        }
        if (this.isWet())
        {    
        	this.extinguish();
            this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 3, this.posY + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, this.posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Block.getIdFromBlock(Blocks.FLOWING_LAVA)});
            this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX, this.posY, this.posZ, 0.0D, 0.1D, 0.0D, new int[0]);
            this.worldObj.spawnParticle(EnumParticleTypes.CLOUD, this.posX, this.posY, this.posZ, 0.0D, 0.1D, 0.0D, new int[0]);
            worldObj.playSound((EntityPlayer)null, posX, posY, posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.NEUTRAL, 0.3F, 1.5F / (worldObj.rand.nextFloat() * 0.4F + 0.8F));
        }
        if (!this.isWet())
        {
        	for (int i = 0; i < 3; ++i)
            {
            	this.worldObj.spawnParticle(EnumParticleTypes.LAVA, posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, posY + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, 0, 0, 0);
            }
            for (int i = 0; i < 12; ++i)
            {
                this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, this.posY + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, this.posZ + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) / 2, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, ((double)this.rand.nextFloat() - 0.5D) * 0.08D, new int[] {Block.getIdFromBlock(Blocks.FLOWING_LAVA)});
            }
        }
    }
    public void writeEntityToNBT(NBTTagCompound tagCompound)
    {
        super.writeEntityToNBT(tagCompound);
        tagCompound.setInteger("ExplosionPower", this.explosionPower);
        tagCompound.setShort("Fuse", (short)this.getFuse());
    }
    public void readEntityFromNBT(NBTTagCompound tagCompund)
    {
        super.readEntityFromNBT(tagCompund);
        this.setFuse(tagCompund.getShort("Fuse"));
        if (tagCompund.hasKey("ExplosionPower", 99))
        {
            this.explosionPower = tagCompund.getInteger("ExplosionPower");
        }
    }
    public void setFuse(int fuseIn)
    {
        this.dataManager.set(FUSE, Integer.valueOf(fuseIn));
        this.fuse = fuseIn;
    }

    public void notifyDataManagerChange(DataParameter<?> key)
    {
        if (FUSE.equals(key))
        {
            this.fuse = this.getFuseDataManager();
        }
    }  
    public int getFuseDataManager()
    {
        return ((Integer)this.dataManager.get(FUSE)).intValue();
    }
    public int getFuse()
    {
        return this.fuse;
    }   
    public float getBrightness(float partialTicks)
    {
        return 0.001F;
    }
    @SideOnly(Side.CLIENT)
    public int getBrightnessForRender(float partialTicks)
    {
    	return 15728880;
    }
}

Link to comment
Share on other sites

ahha alright  :o

 

 

---- Minecraft Crash Report ----

// Don't do that.

 

Time: 8/11/16 2:56 AM

Description: Ticking entity

 

java.lang.NullPointerException: Ticking entity

at net.minecraft.world.World.isOutsideBuildHeight(World.java:257)

at net.minecraft.world.World.getBlockState(World.java:905)

at guru.tbe.entity.EntityFireOrb.onImpact(EntityFireOrb.java:98)

at guru.tbe.entity.EntityOrb.onUpdate(EntityOrb.java:223)

at guru.tbe.entity.EntityFireOrb.onUpdate(EntityFireOrb.java:52)

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106)

at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872)

at net.minecraft.world.World.updateEntity(World.java:2073)

at net.minecraft.world.World.updateEntities(World.java:1886)

at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644)

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)

at java.lang.Thread.run(Unknown Source)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Thread: Server thread

Stacktrace:

at net.minecraft.world.World.isOutsideBuildHeight(World.java:257)

at net.minecraft.world.World.getBlockState(World.java:905)

at guru.tbe.entity.EntityFireOrb.onImpact(EntityFireOrb.java:98)

at guru.tbe.entity.EntityOrb.onUpdate(EntityOrb.java:223)

at guru.tbe.entity.EntityFireOrb.onUpdate(EntityFireOrb.java:52)

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2106)

at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:872)

at net.minecraft.world.World.updateEntity(World.java:2073)

 

-- Entity being ticked --

Details:

Entity Type: guru.FireOrb (guru.tbe.entity.EntityFireOrb)

Entity ID: 2829

Entity Name: entity.guru.FireOrb.name

Entity's Exact location: -370.35, 44.78, 483.31

Entity's Block location: World: (-371,44,483), Chunk: (at 13,2,3 in -24,30; contains blocks -384,0,480 to -369,255,495), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Entity's Momentum: -0.21, -1.34, -0.74

Entity's Passengers: []

Entity's Vehicle: ~~ERROR~~ NullPointerException: null

Stacktrace:

at net.minecraft.world.World.updateEntities(World.java:1886)

at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:644)

 

-- Affected level --

Details:

Level name: New World

All players: 1 total; [EntityPlayerMP['Player551'/11, l='New World', x=-369.48, y=48.44, z=486.34]]

Chunk stats: ServerChunkCache: 320 Drop: 0

Level seed: -4304635456321882683

Level generator: ID 01 - flat, ver 0. Features enabled: true

Level generator options: 3;minecraft:bedrock,42*minecraft:dirt,minecraft:grass;1;village

Level spawn location: World: (-350,4,459), Chunk: (at 2,0,11 in -22,28; contains blocks -352,0,448 to -337,255,463), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 7142 game time, 7142 day time

Level dimension: 0

Level storage version: 0x04ABD - Anvil

Level weather: Rain time: 87864 (now: false), thunder time: 151512 (now: false)

Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: true

Stacktrace:

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:783)

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687)

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536)

at java.lang.Thread.run(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.10.2

Operating System: Windows Vista (x86) version 6.0

Java Version: 1.8.0_102, Oracle Corporation

Java VM Version: Java HotSpot Client VM (mixed mode), Oracle Corporation

Memory: 668428072 bytes (637 MB) / 1046937600 bytes (998 MB) up to 1046937600 bytes (998 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP 9.32 Powered by Forge 12.18.1.2046 4 mods loaded, 4 mods active

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.1.2046.jar)

UCHIJAAAA Forge{12.18.1.2046} [Minecraft Forge] (forgeSrc-1.10.2-12.18.1.2046.jar)

UCHIJAAAA guru{1.53} [The Basic Elements] (bin)

Loaded coremods (and transformers):

GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.

Profiler Position: N/A (disabled)

Player Count: 1 / 8; [EntityPlayerMP['Player551'/11, l='New World', x=-369.48, y=48.44, z=486.34]]

Type: Integrated Server (map_client.txt)

Is Modded: Definitely; Client brand changed to 'fml,forge'

 

Link to comment
Share on other sites

well I went this way with it too.

 

private int xTile;

private int yTile;

private int zTile;

private BlockPos blockpos;

 

 

 

BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile);

 

 

 

if (worldObj.getBlockState(blockpos) == Blocks.COAL_BLOCK.getDefaultState())

{

this.worldObj.setBlockState( blockpos, Blocks.FIRE.getDefaultState());

}

 

and i still come up with the same crash report.

Link to comment
Share on other sites

hmmm....

 

still crashes.

 

This craps too complicated. I'm going to play some league.

 

public EntityFireOrb(World worldIn, EntityLivingBase throwerIn)
    {
        super(worldIn, throwerIn);
        this.fuse = 140;
        this.xTile = chunkCoordX;
        this.yTile = chunkCoordY;
        this.zTile = chunkCoordZ;
    }

Link to comment
Share on other sites

It should be able to go like this:

 

if (result.blockHit = Blocks.COAL_BLOCK)

{

this.setBlock(posX, posY, posZ);

setBlock = FIRE

}

 

or something like that...

forge is too friggin complicated.

 

like alright... I'd like to set a block on fire with a projectile.

Lemme research that for the next 5 days and possibly fail or succeed at doing it.

(nope, time to play some league)

Link to comment
Share on other sites

Chunk coords are completely different that what you are looking for you can grab the position from the MovingObjectPosition.

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

private BlockPos blockpos;

...

BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile);

 

These two objects are not the same. You should come back when you understand Java because it is clear that you do not know wtf you are doing.

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

 

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

 

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

Link to comment
Share on other sites

private BlockPos blockpos;

...

BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile);

 

These two objects are not the same. You should come back when you understand Java because it is clear that you do not know wtf you are doing.

 

I got a good laugh. :)

"Because, magic doesn't shoot from a dispenser, that's why!"

 

I smited you just for fun though :P

Link to comment
Share on other sites

I got a good laugh. :)

"Because, magic doesn't shoot from a dispenser, that's why!"

 

But magic doesn't shot from a dispenser.

 

private BlockPos blockpos; //class field
...
BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile); //local variable

 

Google "local scope"

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

 

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

 

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

Link to 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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

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

×   Your previous content has been restored.   Clear editor

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

 Share



×
×
  • Create New...

Important Information

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