-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #801 from devs-immortal/2.2.1/1.19.2/bugfix
2.2.1/1.19.2/bugfix
- Loading branch information
Showing
36 changed files
with
420 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
src/main/java/net/id/paradiselost/blocks/decorative/ParadiseLostDirtPathBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
package net.id.paradiselost.blocks.decorative; | ||
|
||
import net.id.paradiselost.blocks.ParadiseLostBlocks; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.DirtPathBlock; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.random.Random; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
public class ParadiseLostDirtPathBlock extends DirtPathBlock { | ||
public ParadiseLostDirtPathBlock(Settings settings) { | ||
|
||
private Supplier<Block> returnTo; | ||
|
||
public ParadiseLostDirtPathBlock(Settings settings, Supplier<Block> returnTo) { | ||
super(settings); | ||
this.returnTo = returnTo; | ||
} | ||
|
||
@Override | ||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { | ||
world.setBlockState(pos, pushEntitiesUpBeforeBlockChange(state, ParadiseLostBlocks.DIRT.getDefaultState(), world, pos)); | ||
world.setBlockState(pos, pushEntitiesUpBeforeBlockChange(state, this.returnTo.get().getDefaultState(), world, pos)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/net/id/paradiselost/entities/projectile/ThrownNitraEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package net.id.paradiselost.entities.projectile; | ||
|
||
import net.id.paradiselost.ParadiseLost; | ||
import net.id.paradiselost.entities.ParadiseLostEntityTypes; | ||
import net.id.paradiselost.items.ParadiseLostItems; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.damage.DamageSource; | ||
import net.minecraft.entity.mob.BlazeEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.entity.projectile.thrown.SnowballEntity; | ||
import net.minecraft.entity.projectile.thrown.ThrownEntity; | ||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.particle.ParticleEffect; | ||
import net.minecraft.particle.ParticleTypes; | ||
import net.minecraft.sound.SoundCategory; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.util.hit.EntityHitResult; | ||
import net.minecraft.util.hit.HitResult; | ||
import net.minecraft.util.math.Box; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.explosion.Explosion; | ||
|
||
public class ThrownNitraEntity extends ThrownItemEntity { | ||
|
||
public ThrownNitraEntity(EntityType<? extends ThrownNitraEntity> entityType, World world) { | ||
super(entityType, world); | ||
} | ||
|
||
public ThrownNitraEntity(World world, LivingEntity owner) { | ||
super(ParadiseLostEntityTypes.THROWN_NITRA, owner, world); | ||
} | ||
|
||
protected void onEntityHit(EntityHitResult entityHitResult) { | ||
super.onEntityHit(entityHitResult); | ||
doDamage(); | ||
} | ||
|
||
protected void onCollision(HitResult hitResult) { | ||
super.onCollision(hitResult); | ||
doDamage(); | ||
if (!this.world.isClient) { | ||
this.world.sendEntityStatus(this, (byte)3); | ||
this.discard(); | ||
} | ||
} | ||
|
||
public void handleStatus(byte status) { | ||
if (status == 3) { | ||
for (int i = 0; i < 4; i++) { | ||
this.world.addParticle(ParticleTypes.EXPLOSION, | ||
this.getX() + this.random.nextDouble() - 0.5, this.getY() + this.random.nextDouble() - 0.5, this.getZ() + this.random.nextDouble() - 0.5, | ||
0.0, 0.0, 0.0 | ||
); | ||
} | ||
this.world.playSound(this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.NEUTRAL, 1.0F, 1.1F + this.random.nextFloat() * 0.4F, false); | ||
} | ||
|
||
} | ||
|
||
private void doDamage() { | ||
var hit = this.world.getOtherEntities(this, new Box(this.getX()-1.5, this.getY()-1.5, this.getZ()-1.5, this.getX()+1.5, this.getY()+1.5, this.getZ()+1.5)); | ||
for (Entity e : hit) { | ||
Vec3d diff = this.getPos().subtract(e.getPos()).negate().normalize(); | ||
e.addVelocity(diff.x, diff.y, diff.z); | ||
e.damage(DamageSource.explosion((LivingEntity) null), 2); | ||
} | ||
} | ||
|
||
@Override | ||
protected Item getDefaultItem() { | ||
return ParadiseLostItems.NITRA_BULB; | ||
} | ||
} |
Oops, something went wrong.