Jump to content

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


gurujive

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

    • So, lately my modloader (curseforge) has been loading 162 mods instead of the 97 that my modpack only has, appart of that, when I try to join onto my public server the curseforge logs just starts spamming "OpenGL debug message: id=1280, source=API, type=ERROR, severity=HIGH, message='GL error GL_INVALID_ENUM'" and just freezes, my drivers are up to date, I've reinstalled curseforge, same with minecraft launcher, the java is updated, I've got enough ram and I got no viruses, Long after all this happened, my game could enter my online server and it didn't register as many mods, even my game was running at 40 fps, now I can't even play multiplayer, and when I try singleplayer, it goes about 20 fps to 10
    • It does but I'm struggling to see how to make it work in my recipe? (Its structure is the same as OP's, with a serializer subclass)
    • That looks pretty cool, nice!   Sure, so looking at that JSON file I posted, I pretty much made a record class for each "custom" data type in that JSON. The Input is a good example of why ``` "inputs": [ { "ingredient": { "item": "relativedimensions:aberrant_shard" }, "count": 8 } ], ``` So here's the inputs, it's an array, which we can use the Codec builder's builder.listOf to define an array. Each Item is of some arbitrary object with keys "ingredient" (which we know is an Ingredient) and a "count" which is an int. You don't have to have an intermediate class to map this to necessarily but I found that it's just easier to see the data that way, hence the 'ParticleReboundIngredient' represents one of these inputs.   Let me know if that makes sense or not. 
    • Pretty much, although all the recipes im planning to make on it are shapeless. The idea is that the chamber uses energy to "fuse" the items in each of the center slots together, in this case an ingot. The two slots at the sides are fuel. (A special kind of wood in this case). Here is an image of the interface just for reference (The center slot is the output)   As for the code- Can you elaborate a little bit on it? Seeing three different record classes has confused me a lot. (Elaborate as in why make them in three different records. I understand the code itself more or less)
    • Hello im trying to make a mod and the past few days GSON has almost killed me, when i export the mod and then launch it through minecraft launcher i get java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseString(Ljava/lang/String;)Lcom/google/gson/JsonElement; i have literally tried everything here is my build config   dependencies { minecraft("com.mojang:minecraft:1.8.9") mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9") forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9") compileOnly("cc.polyfrost:oneconfig-1.8.9-forge:0.2.2-alpha+") shadowImpl("cc.polyfrost:oneconfig-wrapper-launchwrapper:1.0.0-beta+") { isTransitive = false exclude(module = "gson") } shadowImpl("org.spongepowered:mixin:0.7.11-SNAPSHOT") { isTransitive = false exclude(module = "gson") } annotationProcessor("org.spongepowered:mixin:0.8.5-SNAPSHOT") shadowImpl("org.javassist:javassist:3.15.0-GA") { isTransitive = false exclude(module = "gson") } shadowImpl("com.neovisionaries:nv-i18n:1.28") { isTransitive = false exclude(module = "gson") } shadowImpl("org.apache.commons:commons-lang3:3.4") { isTransitive = false exclude(module = "gson") } shadowImpl("org.apache.httpcomponents:httpcore:4.4.5") { isTransitive = false exclude(module = "gson") } compileOnly("com.google.code.gson:gson:2.8.6") { isTransitive = false } configurations.all { resolutionStrategy { force("com.google.code.gson:gson:2.8.6") } } shadowImpl(fileTree( mapOf( "dir" to "libs", "include" to listOf("*.jar"), "exclude" to listOf( "asm", "asm-commons", "asm-tree", "gson", "unspecified", "nv-i18n" ) ) )) }  
  • Topics

×
×
  • Create New...

Important Information

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