Skip to content

Commit 6f5cd0b

Browse files
committed
fix: πŸ› Fixed boats and minecarts to show title in their guis
1 parent 5620a21 commit 6f5cd0b

File tree

7 files changed

+9
-24
lines changed

7 files changed

+9
-24
lines changed

β€Žgradle.propertiesβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ loader_version_range=[4,)
1313
mod_id=sophisticatedstorageinmotion
1414
mod_name=Sophisticated Storage In Motion
1515
mod_license=All Rights Reserved
16-
mod_version=0.10.25
16+
mod_version=0.10.26
1717
mod_group_id=net.p3pp3rf1y
1818
mod_authors=P3pp3rF1y
1919
mod_description=Sophisticated Storage on moving entities.

β€Žsrc/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/client/MovingStorageItemRenderer.javaβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void render(@Nullable D data, ItemDisplayContext displayContext, PoseStac
2424

2525
T movingStorage = getMovingStorage(mc);
2626
setMovingStoragePropertiesFromData(movingStorage, data);
27-
movingStorage.getStorageHolder().setStorageItemFrom(data.storageItem(), false);
27+
movingStorage.getStorageHolder().setStorageItem(data.storageItem());
2828

2929
poseStack.pushPose();
3030
poseStack.translate(0.5, 0, 0.5);

β€Žsrc/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/EntityStorageHolder.javaβ€Ž

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected boolean isOwnContainer(Player player) {
7171
return false;
7272
}
7373

74-
public void setStorageItemFromMovingStorage(ItemStack movingStorageStack, boolean setupDefaults) {
74+
public void setStorageItemAndCustomNameFromMovingStorageStack(ItemStack movingStorageStack, boolean setupDefaults) {
7575
SimpleItemContent storageItemContents = movingStorageStack.get(ModDataComponents.STORAGE_ITEM.get());
7676
if (storageItemContents == null) {
7777
ItemStack barrel = new ItemStack(ModBlocks.BARREL_ITEM.get());
@@ -81,6 +81,10 @@ public void setStorageItemFromMovingStorage(ItemStack movingStorageStack, boolea
8181
ItemStack storageItem = storageItemContents.copy();
8282
setStorageItemFrom(storageItem, setupDefaults);
8383
}
84+
Component customName = movingStorageStack.get(DataComponents.CUSTOM_NAME);
85+
if (customName != null) {
86+
getEntity().setCustomName(customName);
87+
}
8488
}
8589

8690
@Override

β€Žsrc/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/StorageBoat.javaβ€Ž

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@
3939
import net.p3pp3rf1y.sophisticatedstorageinmotion.init.ModItems;
4040
import net.p3pp3rf1y.sophisticatedstorageinmotion.item.StorageBoatItem;
4141

42-
import javax.annotation.Nullable;
4342
import java.util.Locale;
44-
import java.util.Optional;
4543

4644
public class StorageBoat extends ChestBoat implements IMovingStorageEntity {
47-
private static final EntityDataAccessor<Optional<Component>> DATA_CUSTOM_NAME = SynchedEntityData.defineId(StorageBoat.class, EntityDataSerializers.OPTIONAL_COMPONENT);
4845
static final EntityDataAccessor<ItemStack> DATA_STORAGE_ITEM = SynchedEntityData.defineId(StorageBoat.class, EntityDataSerializers.ITEM_STACK);
4946
static final EntityDataAccessor<WoodType> DATA_WOOD_TYPE = SynchedEntityData.defineId(StorageBoat.class, ModEntities.WOOD_TYPE_SERIALIZER.get());
5047

@@ -71,7 +68,6 @@ public StorageBoat(Level level, double x, double y, double z) {
7168
protected void defineSynchedData(SynchedEntityData.Builder builder) {
7269
super.defineSynchedData(builder);
7370
builder.define(DATA_STORAGE_ITEM, ItemStack.EMPTY);
74-
builder.define(DATA_CUSTOM_NAME, Optional.empty());
7571
builder.define(DATA_WOOD_TYPE, WoodType.OAK);
7672
}
7773

@@ -154,11 +150,6 @@ public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
154150
}
155151
}
156152

157-
@Override
158-
public void setCustomName(@Nullable Component customName) {
159-
entityData.set(DATA_CUSTOM_NAME, Optional.ofNullable(customName));
160-
}
161-
162153
private Component getWoodName(WoodType type) {
163154
return Component.translatable("wood_name." + SophisticatedStorage.MOD_ID + "." + type.name().toLowerCase(Locale.ROOT));
164155
}

β€Žsrc/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/entity/StorageMinecart.javaβ€Ž

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333
import net.p3pp3rf1y.sophisticatedstorageinmotion.init.ModEntities;
3434
import net.p3pp3rf1y.sophisticatedstorageinmotion.init.ModItems;
3535

36-
import javax.annotation.Nullable;
37-
import java.util.Optional;
38-
3936
public class StorageMinecart extends MinecartChest implements IMovingStorageEntity {
40-
private static final EntityDataAccessor<Optional<Component>> DATA_CUSTOM_NAME = SynchedEntityData.defineId(StorageMinecart.class, EntityDataSerializers.OPTIONAL_COMPONENT);
4137
static final EntityDataAccessor<ItemStack> DATA_STORAGE_ITEM = SynchedEntityData.defineId(StorageMinecart.class, EntityDataSerializers.ITEM_STACK);
4238

4339
private final EntityStorageHolder<StorageMinecart> entityStorageHolder;
@@ -63,7 +59,6 @@ public StorageMinecart(Level level, double x, double y, double z) {
6359
protected void defineSynchedData(SynchedEntityData.Builder builder) {
6460
super.defineSynchedData(builder);
6561
builder.define(DATA_STORAGE_ITEM, ItemStack.EMPTY);
66-
builder.define(DATA_CUSTOM_NAME, Optional.empty());
6762
}
6863

6964
@Override
@@ -134,11 +129,6 @@ public void onSyncedDataUpdated(EntityDataAccessor<?> key) {
134129
}
135130
}
136131

137-
@Override
138-
public void setCustomName(@Nullable Component customName) {
139-
entityData.set(DATA_CUSTOM_NAME, Optional.ofNullable(customName));
140-
}
141-
142132
@Override
143133
protected Component getTypeName() {
144134
return Component.translatable(StorageInMotionTranslationHelper.INSTANCE.translEntity("storage_minecart"), getStorageItem().getHoverName());

β€Žsrc/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/item/StorageBoatItem.javaβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) {
169169
private static StorageBoat createBoat(Level level, @Nullable Player player, ItemStack stack, double x, double y, double z) {
170170
StorageBoat boat = new StorageBoat(level, x, y, z);
171171
EntityStorageHolder<?> storageHolder = boat.getStorageHolder();
172-
storageHolder.setStorageItemFromMovingStorage(stack, true);
172+
storageHolder.setStorageItemAndCustomNameFromMovingStorageStack(stack, true);
173173
storageHolder.onPlace();
174174

175175
boat.setWoodType(StorageBoatItem.getWoodType(stack));

β€Žsrc/main/java/net/p3pp3rf1y/sophisticatedstorageinmotion/item/StorageMinecartItem.javaβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public InteractionResult useOn(UseOnContext context) {
115115
private static StorageMinecart createMinecart(ServerLevel serverlevel, BlockPos blockpos, double ascendingOffset, ItemStack stack, @Nullable Player player) {
116116
StorageMinecart minecart = new StorageMinecart(serverlevel, blockpos.getX() + 0.5, blockpos.getY() + 0.0625 + ascendingOffset, blockpos.getZ() + 0.5);
117117
EntityStorageHolder<?> storageHolder = minecart.getStorageHolder();
118-
storageHolder.setStorageItemFromMovingStorage(stack, true);
118+
storageHolder.setStorageItemAndCustomNameFromMovingStorageStack(stack, true);
119119
storageHolder.onPlace();
120120
EntityType.createDefaultStackConfig(serverlevel, stack, player).accept(minecart);
121121
return minecart;

0 commit comments

Comments
Β (0)