-
-
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.
Fragmentation grenade Item, Grenade Tag, Thermal Detonator Fixes & Re…
…ndering
- Loading branch information
1 parent
e5aa692
commit 1898b04
Showing
8 changed files
with
100 additions
and
22 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
6 changes: 6 additions & 0 deletions
6
projects/pswg_gadgets/src/main/generated/data/pswg_gadgets/tags/item/grenades.json
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,6 @@ | ||
{ | ||
"values": [ | ||
"pswg_gadgets:thermal_detonator", | ||
"pswg_gadgets:fragmentation_grenade" | ||
] | ||
} |
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
66 changes: 66 additions & 0 deletions
66
projects/pswg_gadgets/src/main/java/dev/pswg/item/FragmentationGrenadeItem.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,66 @@ | ||
package dev.pswg.item; | ||
|
||
import dev.pswg.Gadgets; | ||
import dev.pswg.entity.FragmentationGrenadeEntity; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.entity.projectile.ProjectileEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.math.Position; | ||
import net.minecraft.util.math.Vec3d; | ||
import net.minecraft.world.World; | ||
|
||
public class FragmentationGrenadeItem extends GrenadeItem | ||
{ | ||
public FragmentationGrenadeItem(Item.Settings settings) | ||
{ | ||
super(settings, Blocks.IRON_BLOCK, Gadgets.FRAGMENTATION_GRENADE_ITEM, 150); | ||
} | ||
|
||
@Override | ||
public void throwEntity(World world, ItemStack stack, PlayerEntity player) | ||
{ | ||
FragmentationGrenadeEntity fg = new FragmentationGrenadeEntity(Gadgets.FRAGMENTATION_GRENADE_ENTITY, world); | ||
if (stack.contains(Gadgets.PRIMING_TIME)) | ||
{ | ||
fg.setLife((int)(stack.get(Gadgets.PRIMING_TIME) + baseTicksToExplosion - world.getTime())); | ||
fg.setPrimed(true); | ||
} | ||
else | ||
{ | ||
fg.setLife(150); | ||
fg.setPrimed(false); | ||
} | ||
fg.setVisible(true); | ||
fg.onSpawnPacket(new EntitySpawnS2CPacket(fg.getId(), fg.getUuid(), player.getX(), player.getY() + 1.5, player.getZ(), -player.getPitch(), -player.getYaw(), fg.getType(), 0, Vec3d.ZERO, player.getHeadYaw())); | ||
fg.setOwner(player); | ||
fg.setVelocity(player, player.getPitch(), player.getYaw(), (float)player.getRotationVector().z * 10, 1.0F, 0F); | ||
|
||
world.spawnEntity(fg); | ||
} | ||
|
||
@Override | ||
public void spawnEntity(World world, int power, ItemStack stack, Entity player) | ||
{ | ||
FragmentationGrenadeEntity fg = new FragmentationGrenadeEntity(Gadgets.FRAGMENTATION_GRENADE_ENTITY, world); | ||
//world.getTime() - baseTicksToExplosion | ||
fg.setLife(stack.contains(Gadgets.PRIMING_TIME) ? (int)(stack.get(Gadgets.PRIMING_TIME) + baseTicksToExplosion - world.getTime()) : 1); | ||
fg.setPrimed(stack.contains(Gadgets.PRIMING_TIME)); | ||
fg.setExplosionPower(power); | ||
fg.onSpawnPacket(new EntitySpawnS2CPacket(fg.getId(), fg.getUuid(), player.getX(), player.getY() + 1, player.getZ(), -player.getPitch(), -player.getYaw(), fg.getType(), 0, Vec3d.ZERO, player.getHeadYaw())); | ||
world.spawnEntity(fg); | ||
} | ||
|
||
// Used for dispensers | ||
@Override | ||
public ProjectileEntity createEntity(World world, Position pos, ItemStack stack, Direction direction) | ||
{ | ||
FragmentationGrenadeEntity fg = new FragmentationGrenadeEntity(Gadgets.FRAGMENTATION_GRENADE_ENTITY, world); | ||
initializeProjectile(fg, pos.getX(), pos.getY(), pos.getZ(), 1f, 0); | ||
return fg; | ||
} | ||
} |
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