Skip to content

Commit 3849b9e

Browse files
committed
Update Ownable.java
fixes ownable tiles not being marked as ownable this does not apply to ones placed before this fix however, so those may need creative mode to remove
1 parent ba36091 commit 3849b9e

1 file changed

Lines changed: 2 additions & 60 deletions

File tree

src/thutcore/java/thut/api/attachments/Ownable.java

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import com.google.common.collect.Sets;
44
import net.minecraft.core.HolderLookup;
5-
import net.minecraft.core.HolderLookup.Provider;
65
import net.minecraft.nbt.CompoundTag;
76
import net.minecraft.resources.ResourceLocation;
87
import net.minecraft.server.level.ServerLevel;
9-
import net.minecraft.world.entity.EntityType;
108
import net.minecraft.world.entity.LivingEntity;
119
import net.minecraft.world.entity.Mob;
1210
import net.minecraft.world.entity.TamableAnimal;
@@ -45,63 +43,6 @@ public static interface IOwnableSerializable extends IOwnable, INBTSerializable<
4543

4644
}
4745

48-
public static class WrapperImpl implements IOwnableSerializable
49-
{
50-
final IOwnable wrapped;
51-
52-
public WrapperImpl(IOwnable wrap)
53-
{
54-
this.wrapped = wrap;
55-
}
56-
57-
@Override
58-
public LivingEntity getOwner()
59-
{
60-
return wrapped.getOwner();
61-
}
62-
63-
@Override
64-
public UUID getOwnerId()
65-
{
66-
return wrapped.getOwnerId();
67-
}
68-
69-
@Override
70-
public boolean isPlayerOwned()
71-
{
72-
return wrapped.isPlayerOwned();
73-
}
74-
75-
@Override
76-
public void setOwner(LivingEntity e)
77-
{
78-
wrapped.setOwner(e);
79-
}
80-
81-
@Override
82-
public void setOwner(UUID id)
83-
{
84-
wrapped.setOwner(id);
85-
}
86-
87-
@Override
88-
public CompoundTag serializeNBT(Provider provider)
89-
{
90-
return null;
91-
}
92-
93-
@Override
94-
public void deserializeNBT(Provider provider, CompoundTag nbt)
95-
{}
96-
97-
@Override
98-
public void setPlayerOwned(boolean playerOwned)
99-
{
100-
wrapped.setPlayerOwned(playerOwned);
101-
}
102-
103-
}
104-
10546
public abstract static class VanillaWrapper<M extends Mob> implements IOwnableSerializable
10647
{
10748

@@ -364,7 +305,6 @@ public CompoundTag serializeNBT(HolderLookup.Provider registries)
364305
public static class ImplTE extends Impl implements IOwnableTE
365306
{}
366307

367-
public static final Set<EntityType<?>> MOBS = Sets.newHashSet();
368308
public static final Set<BlockEntityType<?>> TILES = Sets.newHashSet();
369309

370310
public static final ResourceLocation ID = ResourceLocation.parse("thutcore:ownable");
@@ -377,6 +317,7 @@ public static IOwnable get(final IAttachmentHolder in)
377317
{
378318
if (in == null) return null;
379319
if (in.hasData(TYPE.get())) return in.getData(TYPE.get());
320+
if(in instanceof BlockEntity e && TILES.contains(e.getType())) return in.getData(TYPE.get());
380321
return null;
381322
}
382323

@@ -398,6 +339,7 @@ public IOwnableSerializable apply(IAttachmentHolder mob)
398339
{
399340
if (mob instanceof TamableAnimal animal) return new TameWrapper().Attach(animal);
400341
else if (mob instanceof AbstractHorse horse) return new HorseWrapper().Attach(horse);
342+
else if (mob instanceof BlockEntity) return new ImplTE();
401343
return null;
402344
}
403345

0 commit comments

Comments
 (0)