mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Misc other tidying up
This commit is contained in:
parent
a36f6580bb
commit
54a4309825
30 changed files with 156 additions and 196 deletions
|
@ -1,60 +1,30 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import com.minelittlepony.common.util.settings.JsonConfig;
|
||||
|
||||
public class Config {
|
||||
|
||||
private static Config INSTANCE = new Config();
|
||||
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
public class Config extends JsonConfig {
|
||||
|
||||
@Deprecated
|
||||
public static Config getInstance() {
|
||||
return INSTANCE;
|
||||
return Unicopia.getConfig();
|
||||
}
|
||||
|
||||
static void init(Path directory) {
|
||||
Path file = directory.resolve("unicopia.json");
|
||||
|
||||
try {
|
||||
if (Files.exists(file)) {
|
||||
try(JsonReader reader = new JsonReader(Files.newBufferedReader(file))) {
|
||||
INSTANCE = GSON.fromJson(reader, Config.class);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new Config();
|
||||
}
|
||||
}
|
||||
|
||||
INSTANCE.file = file;
|
||||
INSTANCE.save();
|
||||
public Config() {
|
||||
super(GamePaths.getConfigDirectory().resolve("unicopia.json"));
|
||||
}
|
||||
|
||||
private Path file;
|
||||
|
||||
@Expose(deserialize = false)
|
||||
private final String speciesWhiteListComment =
|
||||
"A whitelist of races permitted on the server. " +
|
||||
"Races added to this list can be used by anyone, whilst any ones left off are not permitted. " +
|
||||
"An empty list disables whitelisting entirely.";
|
||||
@Expose
|
||||
private final List<Race> speciesWhiteList = Lists.newArrayList();
|
||||
private final Set<Race> speciesWhiteList = new HashSet<>();
|
||||
|
||||
@Expose(deserialize = false)
|
||||
private final String preferredRaceComment =
|
||||
|
@ -71,7 +41,7 @@ public class Config {
|
|||
@Expose
|
||||
private boolean ignoreMineLP = false;
|
||||
|
||||
public List<Race> getSpeciesWhiteList() {
|
||||
public Set<Race> getSpeciesWhiteList() {
|
||||
return speciesWhiteList;
|
||||
}
|
||||
|
||||
|
@ -100,20 +70,4 @@ public class Config {
|
|||
|
||||
return preferredRace;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
Files.deleteIfExists(file);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
try (JsonWriter writer = new JsonWriter(Files.newBufferedWriter(file))) {
|
||||
writer.setIndent(" ");
|
||||
|
||||
GSON.toJson(this, Config.class, writer);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,10 @@ public class InteractionManager {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public Race getPreferredRace() {
|
||||
return Unicopia.getConfig().getPrefferedRace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Side-independent method to create a new player.
|
||||
*
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.minelittlepony.unicopia;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -71,7 +72,11 @@ public enum Race {
|
|||
return false;
|
||||
}
|
||||
|
||||
return isDefault() || Config.getInstance().getSpeciesWhiteList().isEmpty() || Config.getInstance().getSpeciesWhiteList().contains(this);
|
||||
Set<Race> whitelist = Unicopia.getConfig().getSpeciesWhiteList();
|
||||
|
||||
return isDefault()
|
||||
|| whitelist.isEmpty()
|
||||
|| whitelist.contains(this);
|
||||
}
|
||||
|
||||
public Race validate(PlayerEntity sender) {
|
||||
|
|
|
@ -21,7 +21,7 @@ public interface USounds {
|
|||
SoundEvent RECORD_FUNK = register("record.funk");
|
||||
|
||||
static SoundEvent register(String name) {
|
||||
Identifier id = new Identifier(Unicopia.MODID, name);
|
||||
Identifier id = new Identifier("unicopia", name);
|
||||
return Registry.register(Registry.SOUND_EVENT, id, new SoundEvent(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import net.minecraft.tag.Tag;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public interface UTags {
|
||||
Tag<Item> CURSED_ARTEFACTS = TagRegistry.item(new Identifier(Unicopia.MODID, "cursed_artefacts"));
|
||||
Tag<Item> HAMMERPACE_IMMUNE = TagRegistry.item(new Identifier(Unicopia.MODID, "hammerspace_immune"));
|
||||
Tag<Item> CURSED_ARTEFACTS = TagRegistry.item(new Identifier("unicopia", "cursed_artefacts"));
|
||||
Tag<Item> HAMMERPACE_IMMUNE = TagRegistry.item(new Identifier("unicopia", "hammerspace_immune"));
|
||||
|
||||
static void bootstrap() { }
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.minecraft.resource.ResourceType;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.minelittlepony.common.util.GamePaths;
|
||||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
import com.minelittlepony.unicopia.advancement.BOHDeathCriterion;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
|
@ -22,13 +21,24 @@ import com.minelittlepony.unicopia.network.Channel;
|
|||
import com.minelittlepony.unicopia.structure.UStructures;
|
||||
|
||||
public class Unicopia implements ModInitializer {
|
||||
public static final String MODID = "unicopia";
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private static Config CONFIG;
|
||||
|
||||
public static Config getConfig() {
|
||||
if (CONFIG == null) {
|
||||
CONFIG = new Config();
|
||||
}
|
||||
return CONFIG;
|
||||
}
|
||||
|
||||
public Unicopia() {
|
||||
getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Config.init(GamePaths.getConfigDirectory());
|
||||
|
||||
Channel.bootstrap();
|
||||
UTags.bootstrap();
|
||||
Commands.bootstrap();
|
||||
|
@ -41,6 +51,6 @@ public class Unicopia implements ModInitializer {
|
|||
|
||||
CriterionsRegistry.register(BOHDeathCriterion.INSTANCE);
|
||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance());
|
||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(AffineIngredients.instance());
|
||||
ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(AffineIngredients.getInstance());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia.block;
|
||||
|
||||
import com.minelittlepony.unicopia.TreeType;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.gas.CloudAnvilBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudBlock;
|
||||
import com.minelittlepony.unicopia.gas.CloudDoorBlock;
|
||||
|
@ -72,7 +71,7 @@ public interface UBlocks {
|
|||
|
||||
|
||||
static <T extends Block> T register(T block, String name) {
|
||||
return Registry.BLOCK.add(new Identifier(Unicopia.MODID, name), block);
|
||||
return Registry.BLOCK.add(new Identifier("unicopia", name), block);
|
||||
}
|
||||
|
||||
static void bootstrap() { }
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
public class ClientInteractionManager extends InteractionManager {
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
||||
if (observer.world instanceof ClientWorld) {
|
||||
return new DummyClientPlayerEntity((ClientWorld)observer.world, profile);
|
||||
}
|
||||
return super.createPlayer(observer, profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientPlayer(@Nullable PlayerEntity player) {
|
||||
if (MinecraftClient.getInstance().player == player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MinecraftClient.getInstance().player == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Pony.equal(MinecraftClient.getInstance().player, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Race getPreferredRace() {
|
||||
if (!Unicopia.getConfig().ignoresMineLittlePony()
|
||||
&& MinecraftClient.getInstance().player != null) {
|
||||
Race race = MineLPConnector.getPlayerPonyRace();
|
||||
|
||||
if (!race.isDefault()) {
|
||||
return race;
|
||||
}
|
||||
}
|
||||
|
||||
return Unicopia.getConfig().getPrefferedRace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewMode() {
|
||||
return MinecraftClient.getInstance().options.perspective;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import com.minelittlepony.unicopia.KeyBind;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
|
@ -15,7 +14,6 @@ import net.minecraft.client.options.KeyBinding;
|
|||
import net.minecraft.client.util.InputUtil;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
|
||||
class KeyBindingsHandler {
|
||||
private final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
|
@ -27,7 +25,7 @@ class KeyBindingsHandler {
|
|||
public void addKeybind(KeyBind p) {
|
||||
KeyBindingRegistry.INSTANCE.addCategory(p.getKeyCategory());
|
||||
|
||||
FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier(Unicopia.MODID, p.getKeyName()), InputUtil.Type.KEYSYM, p.getKeyCode(), p.getKeyCategory()).build();
|
||||
FabricKeyBinding b = FabricKeyBinding.Builder.create(new Identifier("unicopia", p.getKeyName()), InputUtil.Type.KEYSYM, p.getKeyCode(), p.getKeyCategory()).build();
|
||||
KeyBindingRegistry.INSTANCE.register(b);
|
||||
|
||||
bindings.add(b);
|
||||
|
|
|
@ -2,25 +2,20 @@ package com.minelittlepony.unicopia.client;
|
|||
|
||||
import static com.minelittlepony.unicopia.EquinePredicates.MAGI;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.common.event.ClientReadyCallback;
|
||||
import com.minelittlepony.unicopia.Config;
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.ability.Abilities;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.container.SpellbookResultSlot;
|
||||
import com.minelittlepony.unicopia.ducks.Colourful;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
import com.minelittlepony.unicopia.mixin.client.DefaultTexturesRegistry;
|
||||
import com.minelittlepony.unicopia.network.Channel;
|
||||
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
||||
import com.minelittlepony.unicopia.util.dummy.DummyClientPlayerEntity;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
|
||||
|
@ -31,31 +26,21 @@ import net.minecraft.client.color.world.BiomeColors;
|
|||
import net.minecraft.client.color.world.GrassColors;
|
||||
import net.minecraft.client.texture.SpriteAtlasTexture;
|
||||
import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
|
||||
public class UnicopiaClient extends InteractionManager implements ClientModInitializer {
|
||||
public class UnicopiaClient implements ClientModInitializer {
|
||||
|
||||
private final KeyBindingsHandler keyboard = new KeyBindingsHandler();
|
||||
|
||||
/**
|
||||
* The race preferred by the client - as determined by mine little pony.
|
||||
* Human if minelp was not installed.
|
||||
*
|
||||
* This is not neccessarily the _actual_ race used for the player,
|
||||
* as the server may not allow certain race types, or the player may override
|
||||
* this option in-game themselves.
|
||||
*/
|
||||
private static Race clientPlayerRace = getclientPlayerRace();
|
||||
private Race lastPreferredRace = InteractionManager.instance().getPreferredRace();
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
clientPlayerRace = getclientPlayerRace();
|
||||
InteractionManager.INSTANCE = this;
|
||||
lastPreferredRace = InteractionManager.instance().getPreferredRace();
|
||||
InteractionManager.INSTANCE = new ClientInteractionManager();
|
||||
|
||||
URenderers.bootstrap();
|
||||
|
||||
|
@ -80,58 +65,18 @@ public class UnicopiaClient extends InteractionManager implements ClientModIniti
|
|||
PlayerEntity player = client.player;
|
||||
|
||||
if (player != null && !player.removed) {
|
||||
Race newRace = getclientPlayerRace();
|
||||
Race newRace = InteractionManager.instance().getPreferredRace();
|
||||
|
||||
if (newRace != clientPlayerRace) {
|
||||
clientPlayerRace = newRace;
|
||||
if (newRace != lastPreferredRace) {
|
||||
lastPreferredRace = newRace;
|
||||
|
||||
Channel.REQUEST_CAPABILITIES.send(new MsgRequestCapabilities(player, clientPlayerRace));
|
||||
Channel.REQUEST_CAPABILITIES.send(new MsgRequestCapabilities(lastPreferredRace));
|
||||
}
|
||||
}
|
||||
|
||||
keyboard.onKeyInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nonnull
|
||||
public PlayerEntity createPlayer(Entity observer, GameProfile profile) {
|
||||
if (observer.world instanceof ClientWorld) {
|
||||
return new DummyClientPlayerEntity((ClientWorld)observer.world, profile);
|
||||
}
|
||||
return super.createPlayer(observer, profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClientPlayer(@Nullable PlayerEntity player) {
|
||||
if (MinecraftClient.getInstance().player == player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (MinecraftClient.getInstance().player == null || player == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Pony.equal(MinecraftClient.getInstance().player, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewMode() {
|
||||
return MinecraftClient.getInstance().options.perspective;
|
||||
}
|
||||
|
||||
private static Race getclientPlayerRace() {
|
||||
if (!Config.getInstance().ignoresMineLittlePony()
|
||||
&& MinecraftClient.getInstance().player != null) {
|
||||
Race race = MineLPConnector.getPlayerPonyRace();
|
||||
|
||||
if (!race.isDefault()) {
|
||||
return race;
|
||||
}
|
||||
}
|
||||
|
||||
return Config.getInstance().getPrefferedRace();
|
||||
}
|
||||
|
||||
private static int getLeavesColor(BlockState state, @Nullable BlockRenderView world, @Nullable BlockPos pos, int tint) {
|
||||
Block block = state.getBlock();
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MagicParticle extends SpriteBillboardParticle {
|
|||
|
||||
@Override
|
||||
public ParticleTextureSheet getType() {
|
||||
return ParticleTextureSheet.PARTICLE_SHEET_OPAQUE;
|
||||
return ParticleTextureSheet.TERRAIN_SHEET;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.unicopia.client.render;
|
||||
|
||||
import com.minelittlepony.unicopia.InteractionManager;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.client.render.model.CuccoonEntityModel;
|
||||
import com.minelittlepony.unicopia.entity.CuccoonEntity;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
@ -17,7 +16,7 @@ import net.minecraft.util.Identifier;
|
|||
|
||||
public class CuccoonEntityRenderer extends LivingEntityRenderer<CuccoonEntity, CuccoonEntityModel> {
|
||||
|
||||
private static final Identifier TEXTURE = new Identifier(Unicopia.MODID, "textures/entity/cuccoon.png");
|
||||
private static final Identifier TEXTURE = new Identifier("unicopia", "textures/entity/cuccoon.png");
|
||||
|
||||
public CuccoonEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager, new CuccoonEntityModel(), 1);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.client.render;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.entity.SpearEntity;
|
||||
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
|
||||
|
@ -9,7 +8,7 @@ import net.minecraft.client.render.entity.ProjectileEntityRenderer;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SpearEntityRenderer extends ProjectileEntityRenderer<SpearEntity> {
|
||||
public static final Identifier TEXTURE = new Identifier(Unicopia.MODID, "textures/entity/projectiles/spear.png");
|
||||
public static final Identifier TEXTURE = new Identifier("unicopia", "textures/entity/projectiles/spear.png");
|
||||
|
||||
public SpearEntityRenderer(EntityRenderDispatcher manager, EntityRendererRegistry.Context context) {
|
||||
super(manager);
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.minelittlepony.unicopia.command;
|
|||
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.minelittlepony.unicopia.Config;
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
|
||||
|
@ -22,9 +22,9 @@ class RacelistCommand {
|
|||
builder.then(CommandManager.literal("allow")
|
||||
.then(CommandManager.argument("race", new RaceArgument())
|
||||
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "allowed", race -> {
|
||||
boolean result = Config.getInstance().getSpeciesWhiteList().remove(race);
|
||||
boolean result = Unicopia.getConfig().getSpeciesWhiteList().remove(race);
|
||||
|
||||
Config.getInstance().save();
|
||||
Unicopia.getConfig().save();
|
||||
|
||||
return result;
|
||||
}))
|
||||
|
@ -32,9 +32,9 @@ class RacelistCommand {
|
|||
builder.then(CommandManager.literal("disallow")
|
||||
.then(CommandManager.argument("race", new RaceArgument())
|
||||
.executes(context -> toggle(context.getSource(), context.getSource().getPlayer(), context.getArgument("race", Race.class), "disallowed", race -> {
|
||||
boolean result = Config.getInstance().getSpeciesWhiteList().add(race);
|
||||
boolean result = Unicopia.getConfig().getSpeciesWhiteList().add(race);
|
||||
|
||||
Config.getInstance().save();
|
||||
Unicopia.getConfig().save();
|
||||
|
||||
return result;
|
||||
}))
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.util.DefaultedList;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class SpellbookResultSlot extends SpellBookContainer.SpellbookSlot {
|
||||
public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "empty_slot_gem");
|
||||
public static final Identifier EMPTY_GEM_SLOT = new Identifier("unicopia", "item/empty_gem_slot");
|
||||
|
||||
private final Pony player;
|
||||
private final SpellBookInventory craftMatrix;
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
package com.minelittlepony.unicopia.container;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.fabricmc.fabric.api.container.ContainerFactory;
|
||||
import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
||||
import net.minecraft.container.Container;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public interface UContainers {
|
||||
|
||||
Identifier BAG_OF_HOLDING = new Identifier(Unicopia.MODID, "bag_of_holding");
|
||||
Identifier SPELL_BOOK = new Identifier(Unicopia.MODID, "spell_book");
|
||||
Identifier BAG_OF_HOLDING = register("bag_of_holding", BagOfHoldingContainer::new);
|
||||
Identifier SPELL_BOOK = register("spell_book", SpellBookContainer::new);
|
||||
|
||||
static void bootstrap() {
|
||||
ContainerProviderRegistry.INSTANCE.registerFactory(BAG_OF_HOLDING, BagOfHoldingContainer::new);
|
||||
ContainerProviderRegistry.INSTANCE.registerFactory(SPELL_BOOK, SpellBookContainer::new);
|
||||
static Identifier register(String name, ContainerFactory<Container> factory) {
|
||||
Identifier id = new Identifier("unicopia", name);
|
||||
ContainerProviderRegistry.INSTANCE.registerFactory(BAG_OF_HOLDING, factory);
|
||||
return id;
|
||||
}
|
||||
|
||||
static void bootstrap() { }
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ import com.google.common.collect.Maps;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.minecraft.resource.JsonDataLoader;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
|
@ -23,7 +21,7 @@ import net.minecraft.util.Util;
|
|||
import net.minecraft.util.profiler.Profiler;
|
||||
|
||||
public class Pages extends JsonDataLoader implements IdentifiableResourceReloadListener {
|
||||
private static final Identifier ID = new Identifier(Unicopia.MODID, "pages");
|
||||
private static final Identifier ID = new Identifier("unicopia", "pages");
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
|
|
|
@ -37,17 +37,17 @@ class AffineIngredient implements SpellIngredient {
|
|||
|
||||
@Override
|
||||
public ItemStack getStack() {
|
||||
return AffineIngredients.instance().getIngredient(res).getStack();
|
||||
return AffineIngredients.getInstance().getIngredient(res).getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<ItemStack> getStacks() {
|
||||
return AffineIngredients.instance().getIngredient(res).getStacks();
|
||||
return AffineIngredients.getInstance().getIngredient(res).getStacks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack other, int materialMult) {
|
||||
return AffineIngredients.instance().getIngredient(res).matches(other, materialMult);
|
||||
return AffineIngredients.getInstance().getIngredient(res).matches(other, materialMult);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -5,8 +5,6 @@ import com.google.common.collect.Maps;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener;
|
||||
import net.minecraft.resource.JsonDataLoader;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
|
@ -14,16 +12,16 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.profiler.Profiler;
|
||||
|
||||
public class AffineIngredients extends JsonDataLoader implements IdentifiableResourceReloadListener {
|
||||
private static final Identifier ID = new Identifier(Unicopia.MODID, "ingredients");
|
||||
private static final Identifier ID = new Identifier("unicopia", "ingredients");
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.create();
|
||||
|
||||
private static final AffineIngredients instance = new AffineIngredients();
|
||||
private static final AffineIngredients INSTANCE = new AffineIngredients();
|
||||
|
||||
public static AffineIngredients instance() {
|
||||
return instance;
|
||||
public static AffineIngredients getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private final Map<Identifier, SpellIngredient> storedIngredients = Maps.newHashMap();
|
||||
|
|
|
@ -4,8 +4,6 @@ import java.util.Random;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
|
@ -227,7 +225,7 @@ public class ButterflyEntity extends AmbientEntity {
|
|||
WHITE_MONARCH,
|
||||
BRIMSTONE;
|
||||
|
||||
private final Identifier skin = new Identifier(Unicopia.MODID, "textures/entity/butterfly/" + name().toLowerCase() + ".png");
|
||||
private final Identifier skin = new Identifier("unicopia", "textures/entity/butterfly/" + name().toLowerCase() + ".png");
|
||||
|
||||
public Identifier getSkin() {
|
||||
return skin;
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.minelittlepony.unicopia.entity;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
|
@ -37,7 +35,7 @@ public interface UEntities {
|
|||
EntityType<SpearEntity> THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.<SpearEntity>create(EntityCategory.MISC, SpearEntity::new).trackable(100, 10));
|
||||
|
||||
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
|
||||
return Registry.register(Registry.ENTITY_TYPE, new Identifier(Unicopia.MODID, name), builder.build());
|
||||
return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build());
|
||||
}
|
||||
|
||||
static void bootstrap() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.minelittlepony.unicopia.item;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.util.CustomStatusEffect;
|
||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||
|
||||
|
@ -12,7 +11,7 @@ import net.minecraft.util.Identifier;
|
|||
|
||||
public interface UEffects {
|
||||
|
||||
StatusEffect FOOD_POISONING = new CustomStatusEffect(new Identifier(Unicopia.MODID, "food_poisoning"), StatusEffectType.BENEFICIAL, 3484199)
|
||||
StatusEffect FOOD_POISONING = new CustomStatusEffect(new Identifier("unicopia", "food_poisoning"), StatusEffectType.BENEFICIAL, 3484199)
|
||||
.setSilent()
|
||||
.direct((p, e, i) -> {
|
||||
StatusEffectInstance nausea = e.getStatusEffect(StatusEffects.NAUSEA);
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.unicopia.item;
|
|||
import static com.minelittlepony.unicopia.EquinePredicates.*;
|
||||
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.entity.UEntities;
|
||||
import com.minelittlepony.unicopia.magic.spell.ScorchSpell;
|
||||
|
@ -71,7 +70,7 @@ public interface UItems {
|
|||
Item SLIME_DROP = register(new BlockItem(UBlocks.SLIME_DROP, new Item.Settings().group(ItemGroup.MATERIALS)), "slime_drop");
|
||||
Item SLIME_LAYER = register(new BlockItem(UBlocks.SLIME_LAYER, new Item.Settings().group(ItemGroup.DECORATIONS)), "slime_layer");
|
||||
|
||||
Item MISTED_DOOR = register(new TallBlockItem(UBlocks.MISTED_GLASS_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "misted_door");
|
||||
Item MISTED_GLASS_DOOR = register(new TallBlockItem(UBlocks.MISTED_GLASS_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "misted_glass_door");
|
||||
Item LIBRARY_DOOR = register(new TallBlockItem(UBlocks.LIBRARY_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "library_door");
|
||||
Item BAKERY_DOOR = register(new TallBlockItem(UBlocks.BAKERY_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "bakery_door");
|
||||
Item DIAMOND_DOOR = register(new TallBlockItem(UBlocks.DIAMOND_DOOR, new Item.Settings().group(ItemGroup.REDSTONE)), "diamond_door");
|
||||
|
@ -154,7 +153,7 @@ public interface UItems {
|
|||
Item BUTTERFLY_SPAWN_EGG = register(new SpawnEggItem(UEntities.BUTTERFLY, 0x222200, 0xaaeeff, new Item.Settings().group(ItemGroup.MISC)), "butterfly_spawn_egg");
|
||||
|
||||
static <T extends Item> T register(T item, String name) {
|
||||
return Registry.ITEM.add(new Identifier(Unicopia.MODID, name), item);
|
||||
return Registry.ITEM.add(new Identifier("unicopia", name), item);
|
||||
}
|
||||
|
||||
static MusicDiscItem createRecord(SoundEvent sound) {
|
||||
|
|
|
@ -19,7 +19,7 @@ public class MsgPlayerAbility implements Channel.Packet {
|
|||
|
||||
private final String abilityJson;
|
||||
|
||||
public MsgPlayerAbility(Ability<?> power, Ability.IData data) {
|
||||
MsgPlayerAbility(Ability<?> power, Ability.IData data) {
|
||||
powerIdentifier = power.getKeyName();
|
||||
abilityJson = gson.toJson(data, power.getPackageType());
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public class MsgPlayerCapabilities implements Channel.Packet {
|
|||
|
||||
private final CompoundTag compoundTag;
|
||||
|
||||
public MsgPlayerCapabilities(PacketByteBuf buffer) {
|
||||
MsgPlayerCapabilities(PacketByteBuf buffer) {
|
||||
newRace = Race.values()[buffer.readInt()];
|
||||
try (InputStream in = new ByteBufInputStream(buffer)) {
|
||||
compoundTag = NbtIo.readCompressed(in);
|
||||
|
|
|
@ -4,18 +4,17 @@ import com.minelittlepony.unicopia.Race;
|
|||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
|
||||
import net.fabricmc.fabric.api.network.PacketContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
public class MsgRequestCapabilities implements Channel.Packet {
|
||||
|
||||
private final Race race;
|
||||
|
||||
public MsgRequestCapabilities(PacketByteBuf buffer) {
|
||||
MsgRequestCapabilities(PacketByteBuf buffer) {
|
||||
race = Race.values()[buffer.readInt()];
|
||||
}
|
||||
|
||||
public MsgRequestCapabilities(PlayerEntity player, Race preferredRace) {
|
||||
public MsgRequestCapabilities(Race preferredRace) {
|
||||
race = preferredRace;
|
||||
}
|
||||
|
||||
|
@ -34,5 +33,4 @@ public class MsgRequestCapabilities implements Channel.Packet {
|
|||
|
||||
Channel.PLAYER_CAPABILITIES.send(context.getPlayer(), new MsgPlayerCapabilities(true, player));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class MsgSpawnRainbow implements Channel.Packet {
|
|||
z = entity.getZ();
|
||||
}
|
||||
|
||||
public MsgSpawnRainbow(PacketByteBuf buffer) {
|
||||
MsgSpawnRainbow(PacketByteBuf buffer) {
|
||||
id = buffer.readVarInt();
|
||||
x = buffer.readDouble();
|
||||
y = buffer.readDouble();
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Arrays;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -33,9 +32,9 @@ import net.minecraft.world.gen.feature.StructureFeature;
|
|||
class CloudDungeonFeature extends AbstractTempleFeature<DefaultFeatureConfig> {
|
||||
private static final BlockPos POS = new BlockPos(4, 0, 15);
|
||||
private static final Identifier[] VARIANTS = new Identifier[] {
|
||||
new Identifier(Unicopia.MODID, "cloud/temple_small"),
|
||||
new Identifier(Unicopia.MODID, "cloud/house_small"),
|
||||
new Identifier(Unicopia.MODID, "cloud/island_small")
|
||||
new Identifier("unicopia", "cloud/temple_small"),
|
||||
new Identifier("unicopia", "cloud/house_small"),
|
||||
new Identifier("unicopia", "cloud/island_small")
|
||||
};
|
||||
|
||||
public CloudDungeonFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> func) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.util.Arrays;
|
|||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -33,11 +32,11 @@ import net.minecraft.world.gen.feature.StructureFeature;
|
|||
class RuinFeature extends AbstractTempleFeature<DefaultFeatureConfig> {
|
||||
private static final BlockPos POS = new BlockPos(4, 0, 15);
|
||||
private static final Identifier[] VARIANTS = new Identifier[] {
|
||||
new Identifier(Unicopia.MODID, "ground/tower"),
|
||||
new Identifier(Unicopia.MODID, "ground/temple_with_book"),
|
||||
new Identifier(Unicopia.MODID, "ground/temple_without_book"),
|
||||
new Identifier(Unicopia.MODID, "ground/wizard_tower_red"),
|
||||
new Identifier(Unicopia.MODID, "ground/wizard_tower_blue")
|
||||
new Identifier("unicopia", "ground/tower"),
|
||||
new Identifier("unicopia", "ground/temple_with_book"),
|
||||
new Identifier("unicopia", "ground/temple_without_book"),
|
||||
new Identifier("unicopia", "ground/wizard_tower_red"),
|
||||
new Identifier("unicopia", "ground/wizard_tower_blue")
|
||||
};
|
||||
|
||||
public RuinFeature(Function<Dynamic<?>, ? extends DefaultFeatureConfig> func) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.minelittlepony.unicopia.structure;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
|
||||
import net.minecraft.structure.StructurePieceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
@ -18,11 +16,11 @@ public interface UStructures {
|
|||
StructureFeature<DefaultFeatureConfig> RUIN = feature("ruin", new RuinFeature(DefaultFeatureConfig::deserialize));
|
||||
|
||||
static StructurePieceType part(String id, StructurePieceType type) {
|
||||
return Registry.register(Registry.STRUCTURE_PIECE, new Identifier(Unicopia.MODID, id), type);
|
||||
return Registry.register(Registry.STRUCTURE_PIECE, new Identifier("unicopia", id), type);
|
||||
}
|
||||
|
||||
static <C extends FeatureConfig, F extends Feature<C>> F feature(String id, F feature) {
|
||||
return Registry.register(Registry.FEATURE, new Identifier(Unicopia.MODID, id), feature);
|
||||
return Registry.register(Registry.FEATURE, new Identifier("unicopia", id), feature);
|
||||
}
|
||||
|
||||
static void bootstrap() { }
|
||||
|
|
Loading…
Reference in a new issue