Skip to content

Commit

Permalink
Bump version, update to 1.19.4-pre3, add virtual entity submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Mar 4, 2023
1 parent 5f4523e commit 767ced8
Show file tree
Hide file tree
Showing 82 changed files with 2,807 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mkdocs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
git config --global user.name Docs deploy
git config --global user.email docs@dummy.bot.com
mike set-default latest
mike deploy --push --update-aliases 0.3.x latest
mike deploy --push --update-aliases 0.4.x latest
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Polymer
It's a library for creating server side content, that work for player's without mods or (required) resource packs!
You can create blocks, items and entities, that not only will work fully on server side (and singleplayer), but also
are represented on server the same as normal (vanilla/modded) ones (unlike bukkit/spigot ones, that are stored as vanilla block).
You can create blocks, items and entities, that not only will work fully server side (and singleplayer), but also
are still real custom ones, allowing for better integration with data packs and other mods (servers still see it as
`mymod:custom` and not `minecraft:player_head`, unlike bukkit/spigot ones, that only emulate them).

This library also should work correctly with other, non-polymer mods and PolyMC!
This library also works correctly with other, non-polymer mods and [PolyMc](https://github.com/TheEpicBlock/PolyMc)!

## For players:
This library/mod includes few small utilities that can be useful for playing on servers using Polymer.

Few things it does on the client:

- Added compatibility to multiple client side mods ([EMI](https://modrinth.com/mod/emi),
- Added compatibility for multiple client side mods ([EMI](https://modrinth.com/mod/emi),
[Just Enough Items](https://www.curseforge.com/minecraft/mc-mods/jei),
[Roughly Enough Items](https://modrinth.com/mod/roughly-enough-items), [WTHIT](https://modrinth.com/mod/wthit),
[Jade](https://www.curseforge.com/minecraft/mc-mods/jade), [AppleSkin](https://modrinth.com/mod/appleskin))
Expand All @@ -25,8 +26,8 @@ Any mod using this library shouldn't be required on the client side! However, as
are few small quality of life things added with it. So you might want to recommend it or include with
your mod pack.

If you have a server and polymer based mods you are using include a resource pack, you might want since version 0.2.5
"packed/all" version of polymer contains AutoHost module, allowing you to setup automatic building and sending of packs
If you have a server and polymer based mods you are using include a resource pack, you might want to install
"bundled/packed/all" version of polymer contains AutoHost module, allowing you to set up automatic building and sending of packs
to clients.

If you use 1.18.x or older, use this instead: https://github.com/aws404/polypack-host
Expand All @@ -36,7 +37,7 @@ All information about usage can be found at https://polymer.pb4.eu!

## What this library/mod doesn't do
This mod doesn't convert existing mods to server side ones. While it's possible to do so with manual coding,
for that you might want to use [PolyMC](https://github.com/TheEpicBlock/PolyMc) as long as you don't
for that you might want to use [PolyMc](https://github.com/TheEpicBlock/PolyMc) as long as you don't
need to use regular mods on the client (for example with a modpack).

## Commands
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ dependencies {
api include(project(":polymer-common"))
api include(project(":polymer-resource-pack"))
api include(project(":polymer-blocks"))
api include(project(":polymer-virtual-entity"))
//include(project(":polymer-client-extensions"))
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.4-pre1
yarn_mappings=1.19.4-pre1+build.1
minecraft_version=1.19.4-pre3
yarn_mappings=1.19.4-pre3+build.1
loader_version=0.14.14

#Fabric api
fabric_version=0.74.2+1.19.4

maven_group = eu.pb4

mod_version = 0.3.13
mod_version = 0.4.0-beta.1

minecraft_version_supported = ">=1.19.3-beta.3"
minecraft_version_supported = ">=1.19.4-"

packet_tweaker_version = 0.3.1+23w06a

is_stable = true
is_stable = false
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Mixin(MinecraftServer.class)
public class MinecraftServerMixin {
@Inject(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V"))
@Inject(method = "runServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;createMetadata()Lnet/minecraft/server/ServerMetadata;"))
private void polymer_autohost_init(CallbackInfo ci) {
AutoHost.init((MinecraftServer) (Object) this);
}
Expand Down
1 change: 1 addition & 0 deletions polymer-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ loom {
dependencies {
modCompileOnly ("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
modApi include("xyz.nucleoid:packet-tweaker:${packet_tweaker_version}")
modCompileOnly "xyz.nucleoid:disguiselib-fabric:1.2.2"
}

afterEvaluate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ public class CommonConfig {
public boolean enableDevTools = false;
public String _c3 = "Uses simpler about display for /polymer command";
public boolean minimalisticAbout = false;
public String _c4 = "Logs warnings while creating template/filter entities";
public boolean enableTemplateEntityWarnings = true;
public String _c5 = "Enables logging of more exceptions. Useful when debugging";
public boolean logAllExceptions = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public final class CommonImpl {
public static final FabricLoader LOADER = FabricLoader.getInstance();
public static final boolean DEV_ENV = LOADER.isDevelopmentEnvironment();
public static final boolean IS_CLIENT = LOADER.getEnvironmentType() == EnvType.CLIENT;
public static final boolean LOG_MORE_ERRORS;
public static final boolean ENABLE_TEMPLATE_ENTITY_WARNINGS;

private static final ModContainer CONTAINER = FabricLoader.getInstance().getModContainer("polymer-common").get();
public static final List<String> CONTRIBUTORS = new ArrayList<>();
Expand All @@ -59,6 +61,8 @@ public static void addContributor(Person person) {
CORE_COMMAND_MINIMAL_OP = config.coreCommandOperatorLevel;
DEVELOPER_MODE = config.enableDevTools || DEV_ENV;
MINIMAL_ABOUT = config.minimalisticAbout;
LOG_MORE_ERRORS = config.logAllExceptions || CommonImpl.DEVELOPER_MODE;
ENABLE_TEMPLATE_ENTITY_WARNINGS = config.enableTemplateEntityWarnings;

CONTAINER.getMetadata().getAuthors().forEach(CommonImpl::addContributor);
CONTAINER.getMetadata().getContributors().forEach(CommonImpl::addContributor);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package eu.pb4.polymer.core.impl.entity;
package eu.pb4.polymer.common.impl.entity;

import eu.pb4.polymer.common.impl.CommonImpl;
import eu.pb4.polymer.common.impl.FakeWorld;
import eu.pb4.polymer.core.impl.PolymerImpl;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.NbtCompound;
Expand Down Expand Up @@ -40,11 +40,11 @@ public Packet<ClientPlayPacketListener> createSpawnPacket() {
try {
entity = new FakeEntity(EntityType.PIG, FakeWorld.INSTANCE_UNSAFE);
} catch (Throwable e1) {
PolymerImpl.LOGGER.error("Couldn't initiate base template entity... trying again with a different method.", e1);
CommonImpl.LOGGER.error("Couldn't initiate base template entity... trying again with a different method.", e1);
try {
entity = new FakeEntity(EntityType.PIG, FakeWorld.INSTANCE_REGULAR);
} catch (Throwable e2) {
PolymerImpl.LOGGER.error("Couldn't initiate base template entity! It's super bad and it might crash soon!", e2);
CommonImpl.LOGGER.error("Couldn't initiate base template entity! It's super bad and it might crash soon!", e2);
entity = null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package eu.pb4.polymer.core.impl.entity;
package eu.pb4.polymer.common.impl.entity;

import com.mojang.authlib.GameProfile;
import eu.pb4.polymer.common.impl.CommonImpl;
import eu.pb4.polymer.common.impl.CompatStatus;
import eu.pb4.polymer.common.impl.FakeWorld;
import eu.pb4.polymer.core.impl.PolymerImpl;
import eu.pb4.polymer.core.mixin.entity.DataTrackerAccessor;
import eu.pb4.polymer.common.mixin.DataTrackerAccessor;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -44,8 +44,8 @@ public boolean isCreative() {
}
});
} catch (Throwable e) {
if (PolymerImpl.LOG_MORE_ERRORS) {
PolymerImpl.LOGGER.error("Failed add player like entity! Trying with alternative method", e);
if (CommonImpl.LOG_MORE_ERRORS) {
CommonImpl.LOGGER.error("Failed add player like entity! Trying with alternative method", e);
}
try {
EXAMPLE_ENTITIES.put(EntityType.PLAYER, new PlayerEntity(FakeWorld.INSTANCE_REGULAR, BlockPos.ORIGIN, 0, new GameProfile(Util.NIL_UUID, "TinyPotato")) {
Expand All @@ -60,8 +60,8 @@ public boolean isCreative() {
}
});
} catch (Throwable e2) {
if (PolymerImpl.LOG_MORE_ERRORS) {
PolymerImpl.LOGGER.error("Failed add player like entity!", e2);
if (CommonImpl.LOG_MORE_ERRORS) {
CommonImpl.LOGGER.error("Failed add player like entity!", e2);
}
}
}
Expand Down Expand Up @@ -113,17 +113,17 @@ public static Entity getEntity(EntityType<?> type) {
entity = type.create(FakeWorld.INSTANCE_REGULAR);
} catch (Throwable e2) {
var id = Registries.ENTITY_TYPE.getId(type);
if (PolymerImpl.ENABLE_TEMPLATE_ENTITY_WARNINGS) {
PolymerImpl.LOGGER.warn(String.format(
if (CommonImpl.ENABLE_TEMPLATE_ENTITY_WARNINGS) {
CommonImpl.LOGGER.warn(String.format(
"Couldn't create template entity of %s... Defaulting to empty. %s",
id,
id != null && id.getNamespace().equals("minecraft") ? "This might cause problems!" : "Don't worry, this shouldn't cause problems!"
));

if (id != null && id.getNamespace().equals("minecraft")) {
PolymerImpl.LOGGER.warn("First error:");
CommonImpl.LOGGER.warn("First error:");
e.printStackTrace();
PolymerImpl.LOGGER.warn("Second error:");
CommonImpl.LOGGER.warn("Second error:");
e2.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package eu.pb4.polymer.common.mixin;

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import net.minecraft.entity.data.DataTracker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(DataTracker.class)
public interface DataTrackerAccessor {
@Accessor
Int2ObjectMap<DataTracker.Entry<?>> getEntries();
}
2 changes: 1 addition & 1 deletion polymer-common/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"icon": "assets/icon.png",
"environment": "*",
"depends": {
"minecraft": "1.19.4-beta.1",
"minecraft": ">=1.19.4-beta.1",
"fabricloader": ">=0.14.4"
},
"custom": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"compatibilityLevel": "JAVA_17",
"mixins": [
"CommandManagerMixin",
"DataTrackerAccessor",
"ReferenceAccessor",
"ServerPlayerEntityMixin",
"ServerPlayNetworkHandlerMixin",
Expand Down
7 changes: 5 additions & 2 deletions polymer-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ dependencies {
exclude(group: "net.fabricmc")
}

modCompileOnly("fr.catcore:server-translations-api:1.4.19+1.19.3")
//modLocalRuntime("fr.catcore:server-translations-api:1.4.19+1.19.3")
modCompileOnly("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")
modLocalRuntime("xyz.nucleoid:server-translations-api:2.0.0-beta.2+1.19.4-pre2")

modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v2.5.1-mc1.19.3'
modCompileOnly 'com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v2.5.1-mc1.19.3'
Expand All @@ -95,6 +95,9 @@ dependencies {

compileOnly (project(path: ':polymer-resource-pack', configuration: 'namedElements'))
localRuntime (project(path: ':polymer-resource-pack', configuration: 'namedElements'))

compileOnly (project(path: ':polymer-virtual-entity', configuration: 'namedElements'))
localRuntime (project(path: ':polymer-virtual-entity', configuration: 'namedElements'))
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ default void beforeEntityTrackerTick(Set<EntityTrackingListener> listeners) {}
default boolean canSynchronizeToPolymerClient(ServerPlayerEntity player) {
return true;
}

default boolean sendEmptyTrackerUpdates() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package eu.pb4.polymer.core.api.entity;

import eu.pb4.polymer.core.impl.entity.InternalEntityHelpers;
import eu.pb4.polymer.common.impl.entity.InternalEntityHelpers;
import eu.pb4.polymer.core.impl.interfaces.EntityAttachedPacket;
import eu.pb4.polymer.core.impl.networking.PolymerServerProtocol;
import eu.pb4.polymer.core.mixin.entity.EntityAccessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.packet.Packet;
Expand Down Expand Up @@ -192,6 +194,12 @@ public static NbtCompound createSkullOwner(String value) {
return skullOwner;
}

public static ItemStack createPlayerHead(String value) {
var stack = new ItemStack(Items.PLAYER_HEAD);
stack.getOrCreateNbt().put("SkullOwner", createSkullOwner(value));
return stack;
}

/**
* Allows to execute code with selected player being returned for {@link PolymerUtils#getPlayerContext()}
* calls. Useful for custom packets using writeItemStack and similar methods.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import eu.pb4.polymer.core.api.item.PolymerItemGroupUtils;
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
import eu.pb4.polymer.core.api.other.PolymerStat;
import eu.pb4.polymer.core.api.utils.PolymerObject;
import eu.pb4.polymer.core.api.utils.PolymerSyncUtils;
import eu.pb4.polymer.core.api.utils.PolymerUtils;
import eu.pb4.polymer.core.impl.compat.ServerTranslationUtils;
import eu.pb4.polymer.core.impl.networking.PolymerServerProtocol;
import eu.pb4.polymer.core.impl.ui.CreativeTabListUi;
import eu.pb4.polymer.core.impl.ui.CreativeTabUi;
Expand Down Expand Up @@ -51,6 +51,7 @@
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -403,7 +404,7 @@ private static int displayClientItem(CommandContext<ServerCommandSource> context
stack.getOrCreateNbt().remove(PolymerItemUtils.POLYMER_ITEM_ID);
stack.getOrCreateNbt().remove(PolymerItemUtils.REAL_TAG);

context.getSource().sendFeedback((new NbtTextFormatter("", 3)).apply(stack.writeNbt(new NbtCompound())), false);
context.getSource().sendFeedback((new NbtTextFormatter("", 3)).apply(ServerTranslationUtils.parseFor(player.networkHandler, stack).writeNbt(new NbtCompound())), false);

return 1;
}
Expand All @@ -414,7 +415,7 @@ private static int getClientItem(CommandContext<ServerCommandSource> context) th
var stack = PolymerItemUtils.getPolymerItemStack(player.getMainHandStack(), player);
stack.getOrCreateNbt().remove(PolymerItemUtils.POLYMER_ITEM_ID);
stack.getOrCreateNbt().remove(PolymerItemUtils.REAL_TAG);
player.giveItemStack(stack.copy());
player.giveItemStack(ServerTranslationUtils.parseFor(player.networkHandler, stack));
context.getSource().sendFeedback(Text.literal("Given client representation to player"), true);

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public final class PolymerImpl {
public static final boolean IS_CLIENT = CommonImpl.IS_CLIENT;

public static final boolean USE_ALT_ARMOR_HANDLER;
public static final boolean ENABLE_TEMPLATE_ENTITY_WARNINGS;
public static final boolean DISPLAY_DEBUG_INFO_CLIENT;
public static final boolean ADD_NON_POLYMER_CREATIVE_TABS;
public static final boolean RESEND_BLOCKS_AROUND_CLICK;
Expand All @@ -30,12 +29,11 @@ public final class PolymerImpl {
static {
var serverConfig = CommonImpl.loadConfig("server", ServerConfig.class);

ENABLE_TEMPLATE_ENTITY_WARNINGS = serverConfig.enableTemplateEntityWarnings;
ADD_NON_POLYMER_CREATIVE_TABS = serverConfig.displayNonPolymerCreativeTabs;
RESEND_BLOCKS_AROUND_CLICK = serverConfig.sendBlocksAroundClicked;
LOG_SYNC_TIME = CommonImpl.DEVELOPER_MODE || serverConfig.logHandshakeTime;
LOG_BLOCKSTATE_REBUILDS = serverConfig.logBlockStateRebuilds;
LOG_MORE_ERRORS = serverConfig.logAllExceptions || CommonImpl.DEVELOPER_MODE;
LOG_MORE_ERRORS = CommonImpl.LOG_MORE_ERRORS;
SYNC_MODDED_ENTRIES_POLYMC = serverConfig.polyMcSyncModdedEntries && CompatStatus.POLYMC;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package eu.pb4.polymer.core.impl;

public class ServerConfig {
public String _c5 = "Logs warnings while creating template/filter entities";
public boolean enableTemplateEntityWarnings = true;
public String _c7 = "Displays vanilla/modded creatives tabs in /polymer creative";
public boolean displayNonPolymerCreativeTabs = true;
public String _c9 = "Makes server send additional block updates around clicked area";
Expand All @@ -11,8 +9,6 @@ public class ServerConfig {
public boolean logHandshakeTime = false;
public String _c12 = "Enables logging of BlockState ids rebuilds";
public boolean logBlockStateRebuilds = true;
public String _c13 = "Enables logging of more exceptions. Useful when debugging";
public boolean logAllExceptions = false;
public String _c1 = "Enables syncing of non-polymer entries as polymer ones, when PolyMc is present";
public boolean polyMcSyncModdedEntries = true;
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package eu.pb4.polymer.core.impl.client.compat;

import eu.pb4.polymer.common.impl.client.ClientUtils;
import eu.pb4.polymer.core.api.client.ClientPolymerBlock;
import eu.pb4.polymer.core.api.client.PolymerClientUtils;
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
import eu.pb4.polymer.core.impl.client.InternalClientRegistry;
import eu.pb4.polymer.core.impl.entity.InternalEntityHelpers;
import eu.pb4.polymer.common.impl.entity.InternalEntityHelpers;
import mcp.mobius.waila.api.*;
import mcp.mobius.waila.api.component.EmptyComponent;
import mcp.mobius.waila.api.component.ItemComponent;
import mcp.mobius.waila.api.component.PairComponent;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.ItemEntity;
import net.minecraft.item.ItemStack;
Expand Down
Loading

0 comments on commit 767ced8

Please sign in to comment.