Skip to content

Commit

Permalink
Deprecation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Oct 12, 2024
1 parent 7adbca7 commit f932352
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 93 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ org.gradle.jvmargs=-Xmx4G
# Fabric Properties
# check these on https://fabricmc.net/use

minecraft_version=1.21.2-pre2
yarn_mappings=1.21.2-pre2+build.2
minecraft_version=1.21.2-pre3
yarn_mappings=1.21.2-pre3+build.2
loader_version=0.16.7

# Fabric API
fabric_version=0.105.3+1.21.2
fabric_version=0.105.4+1.21.2

maven_group = eu.pb4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ static ResourcePackDataProvider getActive() {
static <T> void register(Identifier identifier, Supplier<ResourcePackDataProvider> providerCreator) {
AutoHost.TYPES.put(identifier, providerCreator);
};
default Collection<MinecraftServer.ServerResourcePackProperties> getProperties(ClientConnection connection) {
return getProperties();
};

@Deprecated
default Collection<MinecraftServer.ServerResourcePackProperties> getProperties() {
return List.of();
};
Collection<MinecraftServer.ServerResourcePackProperties> getProperties(ClientConnection connection);

static MinecraftServer.ServerResourcePackProperties createProperties(@Nullable UUID uuid, String address, @Nullable String hash) {
return new MinecraftServer.ServerResourcePackProperties(uuid != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,6 @@ public static void end(MinecraftServer server) {
provider.serverStopped(server);
}

@Deprecated(forRemoval = true)
public static void generateAndCall(MinecraftServer server, Consumer<Text> messageConsumer, Runnable runnable) {
PolymerResourcePackMod.generateAndCall(server, true, messageConsumer, runnable);
}

public static File getFile(String path) {
var x = getPath(path);
return x != null ? x.toFile() : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import eu.pb4.polymer.autohost.api.ResourcePackDataProvider;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.Util;

Expand All @@ -29,11 +30,6 @@ public void loadSettings(JsonElement settings) {

}

@Override
public Collection<MinecraftServer.ServerResourcePackProperties> getProperties() {
return List.of();
}

@Override
public void serverStarted(MinecraftServer server) {

Expand All @@ -43,4 +39,9 @@ public void serverStarted(MinecraftServer server) {
public void serverStopped(MinecraftServer server) {

}

@Override
public Collection<MinecraftServer.ServerResourcePackProperties> getProperties(ClientConnection connection) {
return List.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,19 +217,4 @@ public static boolean isServerNetworkingThreadWithContext() {
public interface ResourcePackChangeCallback {
void onResourcePackChange(ServerCommonNetworkHandler handler, UUID uuid, boolean oldStatus, boolean newStatus);
}

/**
* Use PolymerCommonUtils#executeWithNetworkingLogic
*/
@Deprecated
public static void executeWithPlayerContext(ServerPlayerEntity player, Runnable runnable) {
executeWithNetworkingLogic(player.networkHandler, runnable);
}
/**
* Use PolymerCommonUtils#executeWithNetworkingLogic
*/
@Deprecated
public static void executeWithPlayerContext(ServerPlayerEntity player, Runnable runnable, Consumer<Runnable> runnableConsumer) {
executeWithNetworkingLogic(player.networkHandler, () -> runnableConsumer.accept(runnable));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,5 @@ public static Entity getEntityContext(Packet<?> packet) {
public static void sendEntityType(ServerPlayerEntity player, int entityId, EntityType<?> entityType) {
PolymerServerProtocol.sendEntityInfo(player.networkHandler, entityId, entityType);
}

@Deprecated
public static boolean isRegisteredEntityType(EntityType<?> type) {
return ENTITY_TYPES.contains(type);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -509,22 +509,6 @@ public static ItemWithMetadata getItemSafely(PolymerItem item, ItemStack stack,
return getItemSafely(item, stack, context, PolymerBlockUtils.NESTED_DEFAULT_DISTANCE);
}

/**
* @deprecated Use {@link PolymerComponent#registerDataComponent(ComponentType[])} instead
*/
@Deprecated
public static void markAsPolymer(ComponentType<?>... types) {
PolymerComponent.registerDataComponent(types);
}

/**
* @deprecated Use {@link PolymerComponent#isPolymerComponent(ComponentType)} instead
*/
@Deprecated
public static boolean isPolymerComponent(ComponentType<?> type) {
return PolymerComponent.isPolymerComponent(type);
}

public static ItemStack getClientItemStack(ItemStack stack, PacketContext context) {
var out = getPolymerItemStack(stack, context);
if (CompatStatus.POLYMC) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ public static void reloadWorld(ServerPlayerEntity player) {
PolymerImplUtils.IS_RELOADING_WORLD.remove();
});
}
/**
* @deprecated Use {@link PolymerComponent#registerDataComponent(ComponentType[])} instead
*/
@Deprecated
public static void markAsPolymer(ComponentType<?>... types) {
PolymerItemUtils.markAsPolymer(types);
}

/**
* Resends inventory to player
Expand Down Expand Up @@ -194,12 +187,4 @@ public static Packet<?> replacePacket(ServerCommonNetworkHandler handler, Packet
public static boolean shouldPreventPacket(ServerCommonNetworkHandler handler, Packet<?> packet) {
return PacketPatcher.prevent(handler, packet);
}

/**
* Use PolymerCommonUtils.executeWithNetworkingLogic
*/
@Deprecated
public static void executeWithPlayerContext(ServerPlayerEntity player, Runnable runnable) {
PolymerCommonUtils.executeWithPlayerContext(player, runnable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import eu.pb4.polymer.virtualentity.api.BlockWithElementHolder;
import eu.pb4.polymer.virtualentity.api.BlockWithMovingElementHolder;
import eu.pb4.polymer.virtualentity.api.ElementHolder;
import eu.pb4.polymer.virtualentity.api.attachment.BlockAwareAttachment;
import eu.pb4.polymer.virtualentity.api.attachment.ChunkAttachment;
import eu.pb4.polymer.virtualentity.api.attachment.HolderAttachment;
import eu.pb4.polymer.virtualentity.api.elements.EntityElement;
Expand All @@ -15,16 +16,16 @@
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.passive.SheepEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.Items;
import net.minecraft.item.ModelTransformationMode;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ColorHelper;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.*;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.biome.source.BiomeCoords;
Expand All @@ -35,15 +36,23 @@

public class AnimatedBlock extends FallingBlock implements PolymerBlock, BlockWithMovingElementHolder {
public static final BooleanProperty CAN_FALL = BooleanProperty.of("can_fall");
public static final EnumProperty<Direction> FACING = Properties.FACING;

public AnimatedBlock(Settings settings) {
super(settings);
setDefaultState(this.getDefaultState().with(CAN_FALL, false));
}


@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(CAN_FALL);
builder.add(CAN_FALL, FACING);
}

@Nullable
@Override
public BlockState getPlacementState(ItemPlacementContext ctx) {
return super.getPlacementState(ctx).with(FACING, ctx.getSide());
}

@Override
Expand All @@ -70,7 +79,7 @@ public boolean tickElementHolder(ServerWorld world, BlockPos pos, BlockState ini

@Override
public @Nullable ElementHolder createElementHolder(ServerWorld world, BlockPos pos, BlockState initialBlockState) {
return new CustomHolder(world);
return new CustomHolder(world, initialBlockState);
}

public static class CustomHolder extends ElementHolder {
Expand All @@ -80,7 +89,7 @@ public static class CustomHolder extends ElementHolder {
private final ItemDisplayElement moonElement;
private int tick = 0;

public CustomHolder(ServerWorld world) {
public CustomHolder(ServerWorld world, BlockState state) {
this.planetElement = this.addElement(new ItemDisplayElement(Items.LIGHT_BLUE_WOOL));
this.moonElement = this.addElement(new ItemDisplayElement(Items.DECORATED_POT));
this.centralElement = this.addElement(new ItemDisplayElement(TestMod.TATER_BLOCK_ITEM));
Expand All @@ -94,13 +103,39 @@ public CustomHolder(ServerWorld world) {
this.moonElement.setTeleportDuration(1);
this.planetElement.setTeleportDuration(1);
this.entity = this.addElement(new EntityElement<>(EntityType.SHEEP, world));
this.updateRotation(state);
entity.entity().setColor(DyeColor.PINK);
entity.setOffset(new Vec3d(0, 1, 0));
this.centralElement.setGlowing(true);
this.centralElement.setGlowColorOverride(0x000000);
this.animate();
}

private void updateRotation(BlockState state) {
var yaw = 0f;
var pitch = 0f;
var dir = state.get(FACING);

if (dir.getAxis() == Direction.Axis.Y) {
pitch = dir == Direction.DOWN ? 180 : 0;
} else {
pitch = 90;
yaw = dir.asRotation();
}

this.planetElement.setRotation(pitch, yaw);
this.moonElement.setRotation(pitch, yaw);
this.centralElement.setRotation(pitch, yaw);
}

@Override
public void notifyUpdate(HolderAttachment.UpdateType updateType) {
super.notifyUpdate(updateType);
if (updateType == BlockAwareAttachment.BLOCK_STATE_UPDATE) {
updateRotation(BlockAwareAttachment.get(this).getBlockState());
}
}

@Override
protected void onTick() {
this.animate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public List<RecipeDisplay> getDisplays() {
}

@Override
public RecipeBookCategory getRecipeBookTab() {
public RecipeBookCategory getRecipeBookCategory() {
return RecipeBookCategories.CAMPFIRE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,4 @@ public interface TempPlayerLoginAttachments {

void polymerNet$setForceRespawnPacket();
boolean polymerNet$getForceRespawnPacket();

@Deprecated(forRemoval = true)
default boolean polymer$getWorldReload() {
return polymerNet$getWorldReload();
}

@Deprecated(forRemoval = true)
default void polymer$setWorldReload(boolean b) {
polymerNet$setWorldReload(b);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;

import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Consumer;
Expand All @@ -35,6 +34,7 @@ public abstract class GenericEntityElement extends AbstractElement {
private float yaw;
private boolean isRotationDirty;
private boolean sendPositionUpdates = true;
private boolean instantPositionUpdates = false;
protected DataTrackerLike createDataTracker() {
return new SimpleDataTracker(this.getEntityType());
}
Expand All @@ -50,6 +50,13 @@ public boolean isRotationDirty() {
public void ignorePositionUpdates() {
setSendPositionUpdates(false);
}
public void instantPositionUpdates() {
setInstantPositionUpdates(true);
}

public void setInstantPositionUpdates(boolean value) {
this.instantPositionUpdates = value;
}

public void setSendPositionUpdates(boolean b) {
this.sendPositionUpdates = b;
Expand Down Expand Up @@ -120,7 +127,7 @@ protected void sendChangedTrackerEntries(ServerPlayerEntity player, Consumer<Pac

@Override
public void notifyMove(Vec3d oldPos, Vec3d newPos, Vec3d delta) {
if (this.sendPositionUpdates) {
if (this.sendPositionUpdates && this.instantPositionUpdates) {
this.sendPositionUpdates();
}
}
Expand Down Expand Up @@ -292,4 +299,9 @@ public boolean hasNoGravity() {
public void setNoGravity(boolean noGravity) {
this.dataTracker.set(EntityTrackedData.NO_GRAVITY, noGravity);
}

public void setRotation(float pitch, float yaw) {
this.setPitch(pitch);
this.setYaw(yaw);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public class EntityPassengersSetS2CPacketMixin {

@ModifyArg(method = "write", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/PacketByteBuf;writeIntArray([I)Lnet/minecraft/network/PacketByteBuf;"))
private int[] addDynamicPassengers(int[] a) {
if (this.virtualPassengers.isEmpty()) {
// This can be null due to Unsafe!
//noinspection ConstantValue
if (this.virtualPassengers == null || this.virtualPassengers.isEmpty()) {
return a;
}
var player = PacketContext.get();
Expand Down

0 comments on commit f932352

Please sign in to comment.