1515import net .minecraft .entity .data .DataTracker ;
1616import net .minecraft .nbt .NbtCompound ;
1717import net .minecraft .network .packet .s2c .play .EntityAttributesS2CPacket ;
18- import net .minecraft .network . packet . s2c . play . EntitySpawnS2CPacket ;
18+ import net .minecraft .registry . tag . DamageTypeTags ;
1919import net .minecraft .server .network .ServerPlayerEntity ;
20+ import net .minecraft .server .world .ServerWorld ;
2021import net .minecraft .util .math .BlockPos ;
2122import net .minecraft .world .World ;
23+ import org .jetbrains .annotations .Nullable ;
24+ import xyz .nucleoid .packettweaker .PacketContext ;
2225
2326import java .util .Collection ;
2427import java .util .Collections ;
4548 **/
4649public class SeatEntity extends Entity implements PolymerEntity {
4750 private static final EntityAttributeInstance MAX_HEALTH_NULL = new EntityAttributeInstance (
48- EntityAttributes .GENERIC_MAX_HEALTH , discard -> {
51+ EntityAttributes .MAX_HEALTH , discard -> {
4952 });
5053 private static final Collection <EntityAttributeInstance > MAX_HEALTH_NULL_SINGLE = Collections
5154 .singleton (MAX_HEALTH_NULL );
@@ -72,7 +75,7 @@ public SeatEntity(World world, double x, double y, double z) {
7275 * at a block.
7376 */
7477 @ Override
75- public EntityType <?> getPolymerEntityType (ServerPlayerEntity player ) {
78+ public EntityType <?> getPolymerEntityType (final PacketContext context ) {
7679 return EntityType .ARMOR_STAND ;
7780 }
7881
@@ -154,15 +157,21 @@ public void tick() {
154157 }
155158
156159 @ Override
157- public boolean damage (final DamageSource source , final float amount ) {
158- if (isInvulnerableTo ( source )) {
160+ public boolean damage (final ServerWorld world , final DamageSource source , final float amount ) {
161+ if (! source . isSourceCreativePlayer () && ! source . isIn ( DamageTypeTags . BYPASSES_INVULNERABILITY )) {
159162 return false ;
160163 }
161164
162165 this .remove (RemovalReason .KILLED );
163166 return true ;
164167 }
165168
169+ @ Override
170+ public void onExplodedBy (@ Nullable final Entity entity ) {
171+ // Allows the seat to be destroyed by TNT.
172+ this .remove (RemovalReason .KILLED );
173+ }
174+
166175 protected boolean isDiscardable () {
167176 return this .getWorld ().getBlockState (getAdjustedPos ()).isAir ();
168177 }
0 commit comments