调整worlddata命名
This commit is contained in:
parent
0b33c1578f
commit
762a997dac
2 changed files with 7 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
package net.mcreator.superbwarfare;
|
package net.mcreator.superbwarfare;
|
||||||
|
|
||||||
import net.mcreator.superbwarfare.init.*;
|
import net.mcreator.superbwarfare.init.*;
|
||||||
|
import net.mcreator.superbwarfare.network.ModVariables;
|
||||||
import net.mcreator.superbwarfare.network.message.*;
|
import net.mcreator.superbwarfare.network.message.*;
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
@ -112,6 +113,9 @@ public class ModUtils {
|
||||||
addNetworkMessage(GunReforgeMessage.class, GunReforgeMessage::encode, GunReforgeMessage::decode, GunReforgeMessage::handler);
|
addNetworkMessage(GunReforgeMessage.class, GunReforgeMessage::encode, GunReforgeMessage::decode, GunReforgeMessage::handler);
|
||||||
addNetworkMessage(SetPerkLevelMessage.class, SetPerkLevelMessage::encode, SetPerkLevelMessage::decode, SetPerkLevelMessage::handler);
|
addNetworkMessage(SetPerkLevelMessage.class, SetPerkLevelMessage::encode, SetPerkLevelMessage::decode, SetPerkLevelMessage::handler);
|
||||||
addNetworkMessage(BreathMessage.class, BreathMessage::encode, BreathMessage::decode, BreathMessage::handler);
|
addNetworkMessage(BreathMessage.class, BreathMessage::encode, BreathMessage::decode, BreathMessage::handler);
|
||||||
|
addNetworkMessage(ModVariables.SavedDataSyncMessage.class, ModVariables.SavedDataSyncMessage::buffer, ModVariables.SavedDataSyncMessage::new, ModVariables.SavedDataSyncMessage::handler);
|
||||||
|
addNetworkMessage(ModVariables.PlayerVariablesSyncMessage.class, ModVariables.PlayerVariablesSyncMessage::buffer, ModVariables.PlayerVariablesSyncMessage::new, ModVariables.PlayerVariablesSyncMessage::handler);
|
||||||
|
addNetworkMessage(ModVariables.PlayerVariablesSyncMessage.class, ModVariables.PlayerVariablesSyncMessage::buffer, ModVariables.PlayerVariablesSyncMessage::new, ModVariables.PlayerVariablesSyncMessage::handler);
|
||||||
|
|
||||||
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
event.enqueueWork(() -> BrewingRecipeRegistry.addRecipe(Ingredient.of(PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)),
|
||||||
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
Ingredient.of(Items.LIGHTNING_ROD), PotionUtils.setPotion(new ItemStack(Items.POTION), ModPotion.SHOCK.get())));
|
||||||
|
|
|
@ -22,7 +22,6 @@ import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
|
|
||||||
|
@ -31,11 +30,6 @@ import java.util.function.Supplier;
|
||||||
|
|
||||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||||
public class ModVariables {
|
public class ModVariables {
|
||||||
@SubscribeEvent
|
|
||||||
public static void init(FMLCommonSetupEvent event) {
|
|
||||||
ModUtils.addNetworkMessage(SavedDataSyncMessage.class, SavedDataSyncMessage::buffer, SavedDataSyncMessage::new, SavedDataSyncMessage::handler);
|
|
||||||
ModUtils.addNetworkMessage(PlayerVariablesSyncMessage.class, PlayerVariablesSyncMessage::buffer, PlayerVariablesSyncMessage::new, PlayerVariablesSyncMessage::handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void init(RegisterCapabilitiesEvent event) {
|
public static void init(RegisterCapabilitiesEvent event) {
|
||||||
|
@ -126,7 +120,7 @@ public class ModVariables {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WorldVariables extends SavedData {
|
public static class WorldVariables extends SavedData {
|
||||||
public static final String DATA_NAME = "target_world_variables";
|
public static final String DATA_NAME = ModUtils.MODID + "_world_variables";
|
||||||
|
|
||||||
public static WorldVariables load(CompoundTag tag) {
|
public static WorldVariables load(CompoundTag tag) {
|
||||||
WorldVariables data = new WorldVariables();
|
WorldVariables data = new WorldVariables();
|
||||||
|
@ -158,7 +152,7 @@ public class ModVariables {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MapVariables extends SavedData {
|
public static class MapVariables extends SavedData {
|
||||||
public static final String DATA_NAME = "target_map_variables";
|
public static final String DATA_NAME = ModUtils.MODID + "_map_variables";
|
||||||
public boolean pvpMode = false;
|
public boolean pvpMode = false;
|
||||||
|
|
||||||
public static MapVariables load(CompoundTag tag) {
|
public static MapVariables load(CompoundTag tag) {
|
||||||
|
@ -245,7 +239,7 @@ public class ModVariables {
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
public static void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) {
|
||||||
if (event.getObject() instanceof Player && !(event.getObject() instanceof FakePlayer))
|
if (event.getObject() instanceof Player && !(event.getObject() instanceof FakePlayer))
|
||||||
event.addCapability(new ResourceLocation("target", "player_variables"), new PlayerVariablesProvider());
|
event.addCapability(new ResourceLocation(ModUtils.MODID, "player_variables"), new PlayerVariablesProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PlayerVariables playerVariables = new PlayerVariables();
|
private final PlayerVariables playerVariables = new PlayerVariables();
|
||||||
|
@ -347,11 +341,6 @@ public class ModVariables {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void registerMessage(FMLCommonSetupEvent event) {
|
|
||||||
ModUtils.addNetworkMessage(PlayerVariablesSyncMessage.class, PlayerVariablesSyncMessage::buffer, PlayerVariablesSyncMessage::new, PlayerVariablesSyncMessage::handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PlayerVariablesSyncMessage {
|
public static class PlayerVariablesSyncMessage {
|
||||||
private final int target;
|
private final int target;
|
||||||
private final PlayerVariables data;
|
private final PlayerVariables data;
|
||||||
|
|
Loading…
Add table
Reference in a new issue