Skip to content

Commit

Permalink
Abstractizing grenade entity classes
Browse files Browse the repository at this point in the history
  • Loading branch information
DeltaHelios committed Jan 14, 2025
1 parent 96675ad commit e5b943b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import net.minecraft.world.explosion.ExplosionBehavior;
import net.minecraft.world.explosion.ExplosionImpl;

public class GrenadeEntity extends ThrownEntity
public abstract class GrenadeEntity extends ThrownEntity
{
private static final TrackedData<Integer> LIFE = DataTracker.registerData(GrenadeEntity.class, TrackedDataHandlerRegistry.INTEGER);
private static final TrackedData<Boolean> PRIMED = DataTracker.registerData(GrenadeEntity.class, TrackedDataHandlerRegistry.BOOLEAN);
Expand All @@ -53,10 +53,7 @@ protected void initDataTracker(DataTracker.Builder builder)
builder.add(PRIMED, false);
}

public GrenadeItem getItem()
{
return null;
}
public abstract GrenadeItem getItem();

public int getMinPickUpTime()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;

public class GrenadeEntityWithBlock extends GrenadeEntity
public abstract class GrenadeEntityWithBlock extends GrenadeEntity
{
public static final int BLOCK_TIME = 300;
public int timer = 0;
Expand All @@ -18,10 +18,7 @@ public GrenadeEntityWithBlock(EntityType<? extends ThrownEntity> entityType, Wor
super(entityType, world);
}

public GrenadeBlock getBlock()
{
return null;
}
public abstract GrenadeBlock getBlock();

@Override
public void tick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,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(getEntityType(), world);
GrenadeEntity grenade = getEntityType().create(world, SpawnReason.EVENT);
initializeProjectile(grenade, pos.getX(), pos.getY(), pos.getZ(), 1f, 0);
return grenade;
}
Expand Down

0 comments on commit e5b943b

Please sign in to comment.