Skip to content

Commit

Permalink
Merge remote-tracking branch 'glitch/entity-refactor' into 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
OroArmor committed Sep 25, 2023
2 parents 2d137bb + 4bc7ed9 commit 97613ea
Show file tree
Hide file tree
Showing 57 changed files with 163 additions and 342 deletions.
17 changes: 0 additions & 17 deletions library/entity/entity/build.gradle

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions library/entity/entity/src/main/resources/quilt_entity.mixins.json

This file was deleted.

18 changes: 0 additions & 18 deletions library/entity/entity/src/testmod/resources/quilt.mod.json

This file was deleted.

22 changes: 22 additions & 0 deletions library/entity/entity_extensions/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id("qsl.module")
}

qslModule {
name = "Quilt Entity Extensions"
moduleName = "entity_extensions"
id = "quilt_entity_extensions"
description = "Extensions for creating and working with entities."
moduleDependencies {
core {
api("resource_loader")
api("registry")
api("networking")
testmodOnly("qsl_base")
}
}
accessWidener()
injectedInterface("net/minecraft/class_1688") {
values = ["org/quiltmc/qsl/entity/extensions/api/MinecartComparatorLogic"]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.vehicle.api;
package org.quiltmc.qsl.entity.extensions.api;

import net.minecraft.block.BlockState;
import net.minecraft.entity.vehicle.AbstractMinecartEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.poi.api;
package org.quiltmc.qsl.entity.extensions.api;

import java.util.Arrays;
import java.util.Collection;
Expand All @@ -35,8 +35,8 @@
import net.minecraft.world.poi.PointOfInterest;
import net.minecraft.world.poi.PointOfInterestType;
import net.minecraft.world.poi.PointOfInterestTypes;

import org.quiltmc.qsl.poi.impl.PointOfInterestTypeExtensions;
import org.quiltmc.qsl.entity.extensions.impl.PointOfInterestTypeExtensions;
import org.quiltmc.qsl.entity.extensions.mixin.PointOfInterestTypesAccessor;

/**
* This class provides utilities to create a {@link PointOfInterestType}.
Expand Down Expand Up @@ -116,7 +116,7 @@ public static RegistryKey<PointOfInterestType> register(Identifier id, PointOfIn
var key = RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE, id);
Registry.register(Registries.POINT_OF_INTEREST_TYPE, key, poiType);
poiType.blockStates().forEach(state -> {
Holder<PointOfInterestType> replaced = PointOfInterestTypes.STATE_TO_TYPE.put(state, Registries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(key));
Holder<PointOfInterestType> replaced = PointOfInterestTypesAccessor.getStateToTypeMap().put(state, Registries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(key));
if (replaced != null) {
throw Util.throwOrPause(new IllegalStateException(String.format("%s is defined in too many tags", state)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.api;
package org.quiltmc.qsl.entity.extensions.api;

import java.util.Objects;

Expand All @@ -39,7 +39,7 @@
import net.minecraft.world.Heightmap;
import net.minecraft.world.World;

import org.quiltmc.qsl.entity.impl.QuiltEntityType;
import org.quiltmc.qsl.entity.extensions.impl.QuiltEntityType;

/**
* Extended version of {@link EntityType.Builder} with added registration for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
* limitations under the License.
*/

package org.quiltmc.qsl.villager.api;
package org.quiltmc.qsl.entity.extensions.api;

import java.util.List;
import java.util.function.Consumer;

import net.minecraft.village.TradeOffers;
import net.minecraft.village.VillagerProfession;
import org.quiltmc.qsl.entity.extensions.impl.TradeOfferInternals;

import org.quiltmc.qsl.villager.impl.TradeOfferInternals;

/**
* Utilities to help with registration of trade offers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.networking.api.extended_spawn_data;
package org.quiltmc.qsl.entity.extensions.api.networking;

import java.util.List;

Expand All @@ -24,8 +24,7 @@
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.PacketBundleS2CPacket;
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;

import org.quiltmc.qsl.entity.networking.impl.QuiltEntityNetworkingInitializer;
import org.quiltmc.qsl.entity.extensions.impl.networking.QuiltEntityNetworkingInitializer;
import org.quiltmc.qsl.networking.api.PacketByteBufs;
import org.quiltmc.qsl.networking.api.ServerPlayNetworking;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.networking.api.tracked_data;
package org.quiltmc.qsl.entity.extensions.api.networking;

import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import net.minecraft.entity.data.TrackedDataHandler;
import net.minecraft.util.Identifier;

import org.quiltmc.qsl.entity.networking.impl.QuiltEntityNetworkingInitializer;
import org.quiltmc.qsl.entity.extensions.impl.networking.QuiltEntityNetworkingInitializer;

public final class QuiltTrackedDataHandlerRegistry {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.poi.impl;
package org.quiltmc.qsl.entity.extensions.impl;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.impl;
package org.quiltmc.qsl.entity.extensions.impl;

import com.google.common.collect.ImmutableSet;
import org.jetbrains.annotations.ApiStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.villager.impl;
package org.quiltmc.qsl.entity.extensions.impl;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.networking.impl;
package org.quiltmc.qsl.entity.extensions.impl.networking;

import com.mojang.logging.LogUtils;
import org.jetbrains.annotations.ApiStatus;
import org.quiltmc.qsl.entity.extensions.api.networking.QuiltExtendedSpawnDataEntity;
import org.slf4j.Logger;

import net.minecraft.registry.Registries;

import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;
import org.quiltmc.qsl.entity.networking.api.extended_spawn_data.QuiltExtendedSpawnDataEntity;
import org.quiltmc.qsl.networking.api.client.ClientPlayNetworking;

@ApiStatus.Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.networking.impl;
package org.quiltmc.qsl.entity.extensions.impl.networking;

import com.mojang.serialization.Lifecycle;
import org.jetbrains.annotations.ApiStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* limitations under the License.
*/

package org.quiltmc.qsl.vehicle.mixin;
package org.quiltmc.qsl.entity.extensions.mixin;

import org.spongepowered.asm.mixin.Mixin;

import net.minecraft.entity.vehicle.AbstractMinecartEntity;

import org.quiltmc.qsl.vehicle.api.MinecartComparatorLogic;
import org.quiltmc.qsl.entity.extensions.api.MinecartComparatorLogic;

@Mixin(AbstractMinecartEntity.class)
public abstract class AbstractMinecartEntityMixin implements MinecartComparatorLogic {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.mixin;
package org.quiltmc.qsl.entity.extensions.mixin;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.vehicle.mixin;
package org.quiltmc.qsl.entity.extensions.mixin;

import java.util.List;
import java.util.function.Predicate;
Expand All @@ -34,7 +34,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;

import org.quiltmc.qsl.vehicle.api.MinecartComparatorLogic;
import org.quiltmc.qsl.entity.extensions.api.MinecartComparatorLogic;

@Mixin(DetectorRailBlock.class)
public abstract class DetectorRailBlockMixin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
* limitations under the License.
*/

package org.quiltmc.qsl.poi.mixin;

import static net.minecraft.world.poi.PointOfInterestTypes.STATE_TO_TYPE;
package org.quiltmc.qsl.entity.extensions.mixin;

import java.util.Collection;
import java.util.Set;

import com.google.common.collect.ImmutableSet;
import org.quiltmc.qsl.entity.extensions.impl.PointOfInterestTypeExtensions;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
Expand All @@ -36,7 +35,6 @@
import net.minecraft.util.Util;
import net.minecraft.world.poi.PointOfInterestType;

import org.quiltmc.qsl.poi.impl.PointOfInterestTypeExtensions;

@Mixin(PointOfInterestType.class)
public class PointOfInterestTypeMixin implements PointOfInterestTypeExtensions {
Expand Down Expand Up @@ -85,12 +83,12 @@ public class PointOfInterestTypeMixin implements PointOfInterestTypeExtensions {
private void quilt$setBlockStates(RegistryKey<PointOfInterestType> key, Collection<BlockState> states, boolean added) {
if (!added) {
for (BlockState state : this.blockStates) {
STATE_TO_TYPE.remove(state);
PointOfInterestTypesAccessor.getStateToTypeMap().remove(state);
}
}

for (BlockState state : states) {
Holder<PointOfInterestType> replaced = STATE_TO_TYPE.put(state, Registries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(key));
Holder<PointOfInterestType> replaced = PointOfInterestTypesAccessor.getStateToTypeMap().put(state, Registries.POINT_OF_INTEREST_TYPE.getHolderOrThrow(key));
if (replaced != null) {
throw Util.throwOrPause(new IllegalStateException(String.format("%s is defined in too many tags", state)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2023 The Quilt Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.quiltmc.qsl.entity.extensions.mixin;

import net.minecraft.block.BlockState;
import net.minecraft.registry.Holder;
import net.minecraft.world.poi.PointOfInterestType;
import net.minecraft.world.poi.PointOfInterestTypes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

import java.util.Map;

@Mixin(PointOfInterestTypes.class)
public interface PointOfInterestTypesAccessor {
@Accessor("STATE_TO_TYPE")
static Map<BlockState, Holder<PointOfInterestType>> getStateToTypeMap() {
throw new IllegalStateException("Mixin injection failed");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.quiltmc.qsl.villager.mixin;
package org.quiltmc.qsl.entity.extensions.mixin;

import java.util.stream.Stream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
* limitations under the License.
*/

package org.quiltmc.qsl.entity.networking.mixin;
package org.quiltmc.qsl.entity.extensions.mixin.networking;

import org.quiltmc.qsl.entity.extensions.api.networking.QuiltExtendedSpawnDataEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -25,8 +26,6 @@
import net.minecraft.network.listener.ClientPlayPacketListener;
import net.minecraft.network.packet.Packet;

import org.quiltmc.qsl.entity.networking.api.extended_spawn_data.QuiltExtendedSpawnDataEntity;

@Mixin(Entity.class)
public abstract class EntityMixin {
@Inject(method = "createSpawnPacket", at = @At("RETURN"), cancellable = true)
Expand Down
Loading

0 comments on commit 97613ea

Please sign in to comment.