Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zeta 1.20 minor porting (#1) #4416

Merged
merged 6 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ public VoxelShape getCollisionShape(@NotNull BlockState state, @NotNull BlockGet
return tile != null ? tile.getCollisionShape(worldIn, pos) : Shapes.empty();
}

@Nullable
private MagnetizedBlockBlockEntity getMagnetTileEntity(BlockGetter world, Vec3 origin) {
BlockPos pos = new BlockPos(origin);
return getMagnetTileEntity(world, pos);
}

@Nullable
private MagnetizedBlockBlockEntity getMagnetTileEntity(BlockGetter world, BlockPos pos) {
BlockEntity tile = world.getBlockEntity(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -305,7 +306,7 @@ public void tick() {
public void load(@NotNull CompoundTag compound) {
super.load(compound);

this.magnetState = NbtUtils.readBlockState(compound.getCompound("blockState"));
this.magnetState = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), compound.getCompound("blockState"));
this.magnetFacing = Direction.from3DDataValue(compound.getInt("facing"));
this.progress = compound.getFloat("progress");
this.lastProgress = this.progress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.common.collect.ImmutableList;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Vector3f;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
Expand Down Expand Up @@ -124,7 +123,7 @@ public void render(@NotNull TinyPotatoBlockEntity potato, float partialTicks, @N
rotY = 270F;
break;
}
ms.mulPose(Vector3f.YN.rotationDegrees(rotY));
ms.mulPose(com.mojang.math.Axis.YN.rotationDegrees(rotY));

float jump = potato.jumpTicks;
if (jump > 0) {
Expand All @@ -136,7 +135,7 @@ public void render(@NotNull TinyPotatoBlockEntity potato, float partialTicks, @N
float wiggle = (float) Math.sin(jump / 10 * Math.PI) * 0.05F;

ms.translate(wiggle, up, 0F);
ms.mulPose(Vector3f.ZP.rotationDegrees(rotZ));
ms.mulPose(com.mojang.math.Axis.ZP.rotationDegrees(rotZ));

boolean render = !(info.name().equals("mami") || info.name().equals("soaryn") || info.name().equals("eloraam") && jump != 0);
if (render) {
Expand All @@ -155,12 +154,12 @@ public void render(@NotNull TinyPotatoBlockEntity potato, float partialTicks, @N

ms.translate(0F, 1.5F, 0F);
ms.pushPose();
ms.mulPose(Vector3f.ZP.rotationDegrees(180F));
ms.mulPose(com.mojang.math.Axis.ZP.rotationDegrees(180F));
renderItems(potato, potatoFacing, ms, buffers, light, overlay);
ms.popPose();

ms.mulPose(Vector3f.ZP.rotationDegrees(-rotZ));
ms.mulPose(Vector3f.YN.rotationDegrees(-rotY));
ms.mulPose(com.mojang.math.Axis.ZP.rotationDegrees(-rotZ));
ms.mulPose(com.mojang.math.Axis.YN.rotationDegrees(-rotY));

renderName(potato, info.name(), ms, buffers, light);
ms.popPose();
Expand Down Expand Up @@ -198,7 +197,7 @@ private void renderName(TinyPotatoBlockEntity potato, String name, PoseStack ms,

private void renderItems(TinyPotatoBlockEntity potato, Direction facing, PoseStack ms, MultiBufferSource buffers, int light, int overlay) {
ms.pushPose();
ms.mulPose(Vector3f.ZP.rotationDegrees(180F));
ms.mulPose(com.mojang.math.Axis.ZP.rotationDegrees(180F));
ms.translate(0F, -1F, 0F);
float s = 1F / 3.5F;
ms.scale(s, s, s);
Expand Down Expand Up @@ -258,7 +257,7 @@ private void renderItems(TinyPotatoBlockEntity potato, Direction facing, PoseSta
} else if (block) {
ms.translate(-0.4F, 0.8F, 0F);
} else {
ms.mulPose(Vector3f.YP.rotationDegrees(-90F));
ms.mulPose(com.mojang.math.Axis.YP.rotationDegrees(-90F));
}
ms.translate(-0.3F, -1.9F, 0.04F);
}
Expand All @@ -274,7 +273,7 @@ private void renderItems(TinyPotatoBlockEntity potato, Direction facing, PoseSta
} else if (block) {
ms.translate(1F, 0.8F, 1F);
} else {
ms.mulPose(Vector3f.YP.rotationDegrees(-90F));
ms.mulPose(com.mojang.math.Axis.YP.rotationDegrees(-90F));
}
ms.translate(-0.3F, -1.9F, -0.92F);
}
Expand All @@ -286,7 +285,7 @@ private void renderItems(TinyPotatoBlockEntity potato, Direction facing, PoseSta
ms.scale(0.5F, 0.5F, 0.5F);
}
if (block && side == Direction.NORTH) {
ms.mulPose(Vector3f.YP.rotationDegrees(180F));
ms.mulPose(com.mojang.math.Axis.YP.rotationDegrees(180F));
}
renderItem(ms, buffers, light, overlay, stack);
ms.popPose();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.violetmoon.quark.addons.oddities.client.render.entity;

import com.mojang.math.Axis;
import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.addons.oddities.entity.TotemOfHoldingEntity;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.base.QuarkClient;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
Expand Down Expand Up @@ -46,7 +46,7 @@ public void render(TotemOfHoldingEntity entity, float entityYaw, float partialTi
ModelManager modelManager = mc.getModelManager();

matrixStackIn.pushPose();
matrixStackIn.mulPose(Vector3f.YP.rotationDegrees(rotation));
matrixStackIn.mulPose(Axis.YP.rotationDegrees(rotation));
matrixStackIn.translate(0, translation, 0);
matrixStackIn.scale(scale, scale, scale);
matrixStackIn.translate(-0.5, 0, -0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.LinkedList;
import java.util.List;

import net.minecraft.network.protocol.game.ClientGamePacketListener;
import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.addons.oddities.item.BackpackItem;
Expand Down Expand Up @@ -62,7 +63,7 @@ public void setOwner(Player player) {
}

private Player getOwnerEntity() {
for(Player player : level.players()) {
for(Player player : level().players()) {
String uuid = player.getUUID().toString();
if(uuid.equals(owner))
return player;
Expand All @@ -73,21 +74,21 @@ private Player getOwnerEntity() {

@Override
public boolean skipAttackInteraction(@NotNull Entity e) {
if(!level.isClientSide && e instanceof Player player) {
if(!level().isClientSide && e instanceof Player player) {

if(!TotemOfHoldingModule.allowAnyoneToCollect && !player.getAbilities().instabuild) {
Player owner = getOwnerEntity();
if(e != owner)
return false;
}

int drops = Math.min(storedItems.size(), 3 + level.random.nextInt(4));
int drops = Math.min(storedItems.size(), 3 + level().random.nextInt(4));

for(int i = 0; i < drops; i++) {
ItemStack stack = storedItems.remove(0);

if(stack.getItem() instanceof ArmorItem armor) {
EquipmentSlot slot = armor.getSlot();
EquipmentSlot slot = armor.getEquipmentSlot();
ItemStack curr = player.getItemBySlot(slot);

if(curr.isEmpty()) {
Expand All @@ -112,7 +113,7 @@ public boolean skipAttackInteraction(@NotNull Entity e) {
spawnAtLocation(stack, 0);
}

if(level instanceof ServerLevel serverLevel) {
if(level() instanceof ServerLevel serverLevel) {
serverLevel.sendParticles(ParticleTypes.DAMAGE_INDICATOR, getX(), getY() + 0.5, getZ(), drops, 0.1, 0.5, 0.1, 0);
serverLevel.sendParticles(ParticleTypes.ENCHANTED_HIT, getX(), getY() + 0.5, getZ(), drops, 0.4, 0.5, 0.4, 0);
}
Expand All @@ -135,14 +136,14 @@ public void tick() {

if(TotemOfHoldingModule.darkSoulsMode) {
Player owner = getOwnerEntity();
if(owner != null && !level.isClientSide) {
if(owner != null && !level().isClientSide) {
String ownerTotem = TotemOfHoldingModule.getTotemUUID(owner);
if(!getUUID().toString().equals(ownerTotem))
dropEverythingAndDie();
}
}

if(storedItems.isEmpty() && !level.isClientSide)
if(storedItems.isEmpty() && !level().isClientSide)
entityData.set(DYING, true);

if(isDying()) {
Expand All @@ -151,8 +152,8 @@ public void tick() {
else deathTicks++;
}

else if(level.isClientSide)
level.addParticle(ParticleTypes.PORTAL, getX(), getY() + (Math.random() - 0.5) * 0.2, getZ(), Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
else if(level().isClientSide)
level().addParticle(ParticleTypes.PORTAL, getX(), getY() + (Math.random() - 0.5) * 0.2, getZ(), Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5);
}

private void dropEverythingAndDie() {
Expand Down Expand Up @@ -205,7 +206,7 @@ protected void addAdditionalSaveData(@NotNull CompoundTag compound) {

@NotNull
@Override
public Packet<?> getAddEntityPacket() {
public Packet<ClientGamePacketListener> getAddEntityPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
Expand Down Expand Up @@ -47,7 +48,7 @@ public final void register(ZRegister event) {
tiny_potato = new TinyPotatoBlock(this);

blockEntityType = BlockEntityType.Builder.of(TinyPotatoBlockEntity::new, tiny_potato).build(null);
Quark.ZETA.registry.register(blockEntityType, "tiny_potato", Registry.BLOCK_ENTITY_TYPE_REGISTRY);
Quark.ZETA.registry.register(blockEntityType, "tiny_potato", Registries.BLOCK_ENTITY_TYPE);

patPotatoTrigger = event.getAdvancementModifierRegistry().registerManualTrigger("pat_potato");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -65,7 +66,7 @@ public final void register(ZRegister event) {
.setShouldReceiveVelocityUpdates(false)
.setCustomClientFactory((spawnEntity, world) -> new TotemOfHoldingEntity(totemType, world))
.build("totem");
Quark.ZETA.registry.register(totemType, "totem", Registry.ENTITY_TYPE_REGISTRY);
Quark.ZETA.registry.register(totemType, "totem", Registries.ENTITY_TYPE);
}

@PlayEvent
Expand All @@ -81,17 +82,17 @@ public void onPlayerDrops(ZLivingDrops.Lowest event) {
CompoundTag persistent = data.getCompound(Player.PERSISTED_NBT_TAG);

if(!drops.isEmpty()) {
TotemOfHoldingEntity totem = new TotemOfHoldingEntity(totemType, player.level);
totem.setPos(player.getX(), Math.max(player.level.getMinBuildHeight() + 3, player.getY() + 1), player.getZ());
TotemOfHoldingEntity totem = new TotemOfHoldingEntity(totemType, player.level());
totem.setPos(player.getX(), Math.max(player.level().getMinBuildHeight() + 3, player.getY() + 1), player.getZ());
totem.setOwner(player);
totem.setCustomName(player.getDisplayName());
drops.stream()
.filter(Objects::nonNull)
.map(ItemEntity::getItem)
.filter(stack -> !stack.isEmpty())
.forEach(totem::addItem);
if (!player.level.isClientSide)
player.level.addFreshEntity(totem);
if (!player.level().isClientSide)
player.level().addFreshEntity(totem);

persistent.putString(TAG_LAST_TOTEM, totem.getUUID().toString());

Expand All @@ -101,7 +102,7 @@ public void onPlayerDrops(ZLivingDrops.Lowest event) {
BlockPos pos = player.blockPosition(); // getPosition
persistent.putInt(TAG_DEATH_X, pos.getX());
persistent.putInt(TAG_DEATH_Z, pos.getZ());
persistent.putString(TAG_DEATH_DIM, player.level.dimension().location().toString());
persistent.putString(TAG_DEATH_DIM, player.level().dimension().location().toString());

if(!data.contains(Player.PERSISTED_NBT_TAG))
data.put(Player.PERSISTED_NBT_TAG, persistent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.minecraft.client.model.BoatModel;
import net.minecraft.client.model.ChestBoatModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderer;
Expand Down Expand Up @@ -39,7 +40,8 @@ private static Map<String, BoatModelTuple> computeBoatResources(boolean chest, E
return WoodSetHandler.boatTypes().collect(ImmutableMap.toImmutableMap(Functions.identity(), name -> {
String folder = chest ? "chest_boat" : "boat";
ResourceLocation texture = new ResourceLocation(Quark.MOD_ID, "textures/model/entity/" + folder + "/" + name + ".png");
BoatModel model = new BoatModel(context.bakeLayer(chest ? ModelHandler.quark_boat_chest : ModelHandler.quark_boat), chest);
BoatModel model = (chest) ? new ChestBoatModel(context.bakeLayer(ModelHandler.quark_boat_chest)) :
new BoatModel(context.bakeLayer(ModelHandler.quark_boat));

return new BoatModelTuple(texture, model);
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.*;
import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.*;
Expand Down Expand Up @@ -140,9 +141,9 @@ private static void digest(Recipe<?> recipe) {
*/

public static void recursivelyFindCraftedItemsFromStrings(@Nullable Collection<String> derivationList, @Nullable Collection<String> whitelist, @Nullable Collection<String> blacklist, Consumer<Item> callback) {
List<Item> parsedDerivationList = derivationList == null ? null : RegistryUtil.massRegistryGet(derivationList, Registry.ITEM);
List<Item> parsedWhitelist = whitelist == null ? null : RegistryUtil.massRegistryGet(whitelist, Registry.ITEM);
List<Item> parsedBlacklist = blacklist == null ? null : RegistryUtil.massRegistryGet(blacklist, Registry.ITEM);
List<Item> parsedDerivationList = derivationList == null ? null : RegistryUtil.massRegistryGet(derivationList, BuiltInRegistries.ITEM);
List<Item> parsedWhitelist = whitelist == null ? null : RegistryUtil.massRegistryGet(whitelist, BuiltInRegistries.ITEM);
List<Item> parsedBlacklist = blacklist == null ? null : RegistryUtil.massRegistryGet(blacklist, BuiltInRegistries.ITEM);

recursivelyFindCraftedItems(parsedDerivationList, parsedWhitelist, parsedBlacklist, callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public Item getDropItem() {

@NotNull
@Override
public Type getBoatType() {
public Type getVariant() {
return Boat.Type.OAK;
}

@Override
public void setType(@NotNull Type type) {
public void setVariant(@NotNull Type type) {
// NO-OP
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.violetmoon.quark.base.item.boat;

import net.minecraft.core.registries.BuiltInRegistries;
import org.jetbrains.annotations.NotNull;

import org.violetmoon.quark.base.handler.WoodSetHandler;
Expand Down Expand Up @@ -64,7 +65,7 @@ protected void readAdditionalSaveData(@NotNull CompoundTag tag) {

@Override
public ItemEntity spawnAtLocation(ItemLike itemLike) {
if(Registry.ITEM.getKey(itemLike.asItem()).getPath().contains("_planks"))
if(BuiltInRegistries.ITEM.getKey(itemLike.asItem()).getPath().contains("_planks"))
return super.spawnAtLocation(getQuarkBoatTypeObj().planks());
return super.spawnAtLocation(itemLike);
}
Expand All @@ -77,12 +78,12 @@ public Item getDropItem() {

@NotNull
@Override
public Type getBoatType() {
public Type getVariant() {
return Boat.Type.OAK;
}

@Override
public void setType(@NotNull Type type) {
public void setVariant(@NotNull Type type) {
// NO-OP
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import net.minecraft.core.BlockSource;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Registry;
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
import net.minecraft.core.dispenser.DispenseItemBehavior;
import net.minecraft.core.dispenser.OptionalDispenseItemBehavior;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -54,8 +54,8 @@ public void setup(ZCommonSetup e) {
e.enqueueWork(() -> {
Map<Item, DispenseItemBehavior> registry = DispenserBlock.DISPENSER_REGISTRY;

for(Block b : Registry.BLOCK) {
ResourceLocation res = Registry.BLOCK.getKey(b);
for(Block b : BuiltInRegistries.BLOCK) {
ResourceLocation res = BuiltInRegistries.BLOCK.getKey(b);
if(!blacklist.contains(Objects.toString(res))) {
Item item = b.asItem();
if(item instanceof BlockItem) {
Expand Down
Loading
Loading