Skip to content

Commit

Permalink
Fix grenade type and adjust bounciness multipliers
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaHelios committed Jan 2, 2025
1 parent adfedc5 commit 68b9541
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ protected void bounce(HitResult hit)
var blockMultiplier = 1.;

if (getWorld().getBlockState(blockHit.getBlockPos()).getBlock() == Blocks.SLIME_BLOCK)
blockMultiplier = 5;
if (getWorld().getBlockState(blockHit.getBlockPos()).getBlock() == Blocks.HONEY_BLOCK)
blockMultiplier = 3;
if (getWorld().getBlockState(blockHit.getBlockPos()).isIn(BlockTags.WOOL))
blockMultiplier = 0.5;
if (getWorld().getBlockState(blockHit.getBlockPos()).getBlock() == Blocks.HONEY_BLOCK)
blockMultiplier = 2;
if (getWorld().getBlockState(blockHit.getBlockPos()).isIn(BlockTags.WOOL) || getWorld().getBlockState(blockHit.getBlockPos()).isIn(BlockTags.LEAVES))
blockMultiplier = 0.75;

if (blockHit.getSide().equals(Direction.UP) && velocity.lengthSquared() < 0.01)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.damage.DamageTypes;
import net.minecraft.entity.player.PlayerEntity;
Expand Down Expand Up @@ -44,7 +45,7 @@ public <T extends GrenadeBlock> T getBlock()
return null;
}

public <T extends GrenadeEntity> EntityType<T> getEntity()
public EntityType<? extends GrenadeEntity> getEntityType()
{
return null;
}
Expand Down Expand Up @@ -78,7 +79,7 @@ public ActionResult useOnBlock(ItemUsageContext context)
*/
public void throwEntity(World world, ItemStack stack, PlayerEntity player)
{
GrenadeEntity grenade = new GrenadeEntity(getEntity(), world);
GrenadeEntity grenade = getEntityType().create(world, SpawnReason.EVENT);
if (stack.contains(Gadgets.PRIMING_TIME))
{
// By checking if the stack contains PRIMING_TIME, it's impossible to get an NPE
Expand All @@ -103,8 +104,7 @@ public void throwEntity(World world, ItemStack stack, PlayerEntity player)
*/
public void spawnEntity(World world, int power, ItemStack stack, Entity player)
{
GrenadeEntity grenade = new GrenadeEntity(getEntity(), world);
//world.getTime() - baseTicksToExplosion
GrenadeEntity grenade = getEntityType().create(world, SpawnReason.EVENT);
grenade.setLife(stack.contains(Gadgets.PRIMING_TIME) ? (int)(stack.get(Gadgets.PRIMING_TIME) + baseTicksToExplosion - world.getTime()) : 1);
grenade.setPrimed(stack.contains(Gadgets.PRIMING_TIME));
grenade.setExplosionPower(power);
Expand Down Expand Up @@ -290,7 +290,7 @@ public ActionResult useLeft(World world, LivingEntity user, Hand hand)
@Override
public ProjectileEntity createEntity(World world, Position pos, ItemStack stack, Direction direction)
{
GrenadeEntity grenade = new GrenadeEntity(getEntity(), world);
GrenadeEntity grenade = new GrenadeEntity(getEntityType(), world);
initializeProjectile(grenade, pos.getX(), pos.getY(), pos.getZ(), 1f, 0);
return grenade;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package dev.pswg.item;

import dev.pswg.Gadgets;
import dev.pswg.block.GrenadeBlock;
import dev.pswg.block.ThermalDetonatorBlock;
import dev.pswg.entity.GrenadeEntity;
import dev.pswg.entity.ThermalDetonatorEntity;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
Expand All @@ -16,7 +14,7 @@ public ThermalDetonatorItem(Item.Settings settings)
}

@Override
public EntityType<ThermalDetonatorEntity> getEntity()
public EntityType<ThermalDetonatorEntity> getEntityType()
{
return Gadgets.THERMAL_DETONATOR_ENTITY;
}
Expand Down

0 comments on commit 68b9541

Please sign in to comment.