Java Can';t在多人游戏机上注册自定义剑
在客户端和服务器端出现了一些大的“nooby”错误(我编辑了上一篇文章)之后,我想我已经让它正常工作了。 现在的问题是,我的自定义项目注册似乎不起作用(它没有失败,只是似乎没有效果)。我没有找到如何在Forge 1.14.4版本上正确执行此操作的示例,因此非常感谢任何帮助或想法 如果我在单机模式下(从Eclipse环境)测试它,它工作得很好,但在运行forge服务器时就不行了(同样,在任何地方都没有错误或调试输出) 编辑: 我更改为其他注册方法(使用DeferredRegister和RegistryObject)。。。同样的结果:(它在单人游戏中非常有效,但在服务器端没有效果 这是我的主类中的新register方法:Java Can';t在多人游戏机上注册自定义剑,java,minecraft,minecraft-forge,Java,Minecraft,Minecraft Forge,在客户端和服务器端出现了一些大的“nooby”错误(我编辑了上一篇文章)之后,我想我已经让它正常工作了。 现在的问题是,我的自定义项目注册似乎不起作用(它没有失败,只是似乎没有效果)。我没有找到如何在Forge 1.14.4版本上正确执行此操作的示例,因此非常感谢任何帮助或想法 如果我在单机模式下(从Eclipse环境)测试它,它工作得很好,但在运行forge服务器时就不行了(同样,在任何地方都没有错误或调试输出) 编辑: 我更改为其他注册方法(使用DeferredRegister和Regist
@Mod("simpleclock")
public class SimpleClock {
public static final String MODID = "simpleclock";
public static final String NAME = "alef's Simple Clock";
public static final String VERSION = "1.5.5";
private static final Logger LOGGER = LogManager.getLogger();
public static World WORLD;
public static PlayerEntity PLAYER;
public static final Item TIMESWORD = new SwordItem(TimeSwordTier.time_sword, 0, -2, new Item.Properties().group(ItemGroup.COMBAT));
public static final DeferredRegister<Item> CONTAINER = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
public static final RegistryObject<Item> ITEM = CONTAINER.register("time_sword", () -> TIMESWORD);
public SimpleClock() {
// Register the setup method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
// Register the doClientStuff method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff);
// Register the enqueueIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC);
// Register the processIMC method for modloading
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
// Register items and other stuff
CONTAINER.register(FMLJavaModLoadingContext.get().getModEventBus());
// Load config file
ModLoadingContext.get().registerConfig(net.minecraftforge.fml.config.ModConfig.Type.COMMON, ConfigFile.spec);
}
解决:只要从每个地方删除“静态”,请考虑把你的评论作为一个正确的答案,这样别人就会看到它已经被回答了。
public enum TimeSwordTier implements IItemTier {
time_sword(5.0f, 9.0f, 5000, 3, 25, null);
private float attackDamage, efficiency;
private int durability, harvestLevel, enchantability;
private Item repairMaterial;
private static double knockback = 1.5;
private TimeSwordTier(float attackDamage, float efficiency, int durability, int harvestLevel, int enchantability, Item repairMaterial) {
this.attackDamage = attackDamage;
this.efficiency = efficiency;
this.durability = durability;
this.harvestLevel = harvestLevel;
this.enchantability = enchantability;
this.repairMaterial = repairMaterial;
}
@Override
public float getAttackDamage()
{
return this.attackDamage;
}
@Override
public float getEfficiency()
{
return this.efficiency;
}
@Override
public int getEnchantability()
{
return this.enchantability;
}
@Override
public int getHarvestLevel()
{
return this.harvestLevel;
}
@Override
public int getMaxUses()
{
return this.durability;
}
@Override
public Ingredient getRepairMaterial()
{
return Ingredient.fromItems(this.repairMaterial);
}
public static double getKnockback()
{
return TimeSwordTier.knockback;
}
}