添加载具部署器Jade适配
This commit is contained in:
parent
f9b0993a57
commit
876b9ef7b6
2 changed files with 55 additions and 0 deletions
|
@ -1,8 +1,11 @@
|
|||
package com.atsuishio.superbwarfare.compat.jade;
|
||||
|
||||
import com.atsuishio.superbwarfare.block.ContainerBlock;
|
||||
import com.atsuishio.superbwarfare.block.VehicleDeployerBlock;
|
||||
import com.atsuishio.superbwarfare.block.entity.VehicleDeployerBlockEntity;
|
||||
import com.atsuishio.superbwarfare.compat.jade.providers.C4InfoProvider;
|
||||
import com.atsuishio.superbwarfare.compat.jade.providers.ContainerEntityProvider;
|
||||
import com.atsuishio.superbwarfare.compat.jade.providers.VehicleDeployerProvider;
|
||||
import com.atsuishio.superbwarfare.compat.jade.providers.VehicleHealthProvider;
|
||||
import com.atsuishio.superbwarfare.entity.projectile.C4Entity;
|
||||
import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity;
|
||||
|
@ -16,6 +19,7 @@ public class SbwJadePlugin implements IWailaPlugin {
|
|||
|
||||
@Override
|
||||
public void register(IWailaCommonRegistration registration) {
|
||||
registration.registerBlockDataProvider(VehicleDeployerProvider.INSTANCE, VehicleDeployerBlockEntity.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,5 +27,6 @@ public class SbwJadePlugin implements IWailaPlugin {
|
|||
registration.registerEntityComponent(VehicleHealthProvider.INSTANCE, VehicleEntity.class);
|
||||
registration.registerEntityComponent(C4InfoProvider.INSTANCE, C4Entity.class);
|
||||
registration.registerBlockComponent(ContainerEntityProvider.INSTANCE, ContainerBlock.class);
|
||||
registration.registerBlockComponent(VehicleDeployerProvider.INSTANCE, VehicleDeployerBlock.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package com.atsuishio.superbwarfare.compat.jade.providers;
|
||||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.block.ContainerBlock;
|
||||
import com.atsuishio.superbwarfare.block.entity.VehicleDeployerBlockEntity;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import snownee.jade.api.BlockAccessor;
|
||||
import snownee.jade.api.IBlockComponentProvider;
|
||||
import snownee.jade.api.IServerDataProvider;
|
||||
import snownee.jade.api.ITooltip;
|
||||
import snownee.jade.api.config.IPluginConfig;
|
||||
|
||||
public enum VehicleDeployerProvider implements IBlockComponentProvider, IServerDataProvider<BlockAccessor> {
|
||||
INSTANCE;
|
||||
|
||||
private static final ResourceLocation ID = Mod.loc("vehicle_deployer");
|
||||
|
||||
public void appendTooltip(ITooltip iTooltip, BlockAccessor blockAccessor, IPluginConfig iPluginConfig) {
|
||||
var entityType = EntityType.byString(blockAccessor.getServerData().getString("EntityType"));
|
||||
if (entityType.isEmpty()) return;
|
||||
|
||||
// 实体名称显示
|
||||
var registerName = EntityType.getKey(entityType.get()).toString();
|
||||
var translationKey = ContainerBlock.getEntityTranslationKey(registerName);
|
||||
iTooltip.add(Component.translatable(translationKey == null ? "des.superbwarfare.container.empty" : translationKey).withStyle(ChatFormatting.GRAY));
|
||||
|
||||
// 所需尺寸显示
|
||||
int w = (int) (entityType.get().getDimensions().width() + 1);
|
||||
if (w % 2 == 0) w++;
|
||||
int h = (int) (entityType.get().getDimensions().height() + 1);
|
||||
if (h != 0) {
|
||||
iTooltip.add(Component.literal(w + " x " + w + " x " + h).withStyle(ChatFormatting.YELLOW));
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getUid() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appendServerData(CompoundTag compoundTag, BlockAccessor blockAccessor) {
|
||||
var blockEntity = (VehicleDeployerBlockEntity) blockAccessor.getBlockEntity();
|
||||
compoundTag.putString("EntityType", blockEntity.entityData.getString("EntityType"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue