-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
518b7b5
commit 2018a58
Showing
6 changed files
with
109 additions
and
49 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
45 changes: 45 additions & 0 deletions
45
projects/pswg_gadgets/src/main/java/dev/pswg/entity/GrenadeEntityWithBlock.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,45 @@ | ||
package dev.pswg.entity; | ||
|
||
import dev.pswg.block.GrenadeBlock; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.EntityType; | ||
import net.minecraft.entity.projectile.thrown.ThrownEntity; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.world.World; | ||
|
||
public class GrenadeEntityWithBlock extends GrenadeEntity | ||
{ | ||
public static final int BLOCK_AGE = 300; | ||
|
||
public GrenadeEntityWithBlock(EntityType<? extends ThrownEntity> entityType, World world) | ||
{ | ||
super(entityType, world); | ||
} | ||
|
||
public GrenadeBlock getBlock() | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public void tick() | ||
{ | ||
if (age >= BLOCK_AGE && !this.isPrimed()) | ||
{ | ||
BlockPos pos = getBlockPos(); | ||
BlockState state = getWorld().getBlockState(pos); | ||
if (state.isAir()) | ||
{ | ||
this.discard(); | ||
getWorld().setBlockState(pos, getBlock().getDefaultState()); | ||
} | ||
else if (getWorld().getBlockState(pos.offset(Direction.UP)).isAir()) | ||
{ | ||
this.discard(); | ||
getWorld().setBlockState(pos.offset(Direction.UP), getBlock().getDefaultState().with(GrenadeBlock.CLUSTER_SIZE, 1)); | ||
} | ||
} | ||
super.tick(); | ||
} | ||
} |
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