Skip to content

Commit

Permalink
More Porting again
Browse files Browse the repository at this point in the history
  • Loading branch information
IThundxr committed Nov 16, 2023
1 parent 921ee23 commit b541b14
Show file tree
Hide file tree
Showing 28 changed files with 231 additions and 269 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.violetmoon.quark.addons.oddities.inventory;

import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -13,12 +13,10 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentInstance;

import javax.annotation.Nonnull;

import org.violetmoon.quark.addons.oddities.module.MatrixEnchantingModule;
import org.violetmoon.quark.content.experimental.module.EnchantmentsBegoneModule;

import javax.annotation.Nonnull;
import java.awt.*;
import java.util.List;
import java.util.*;
Expand Down Expand Up @@ -145,8 +143,8 @@ private EnchantmentDataWrapper generateRandomEnchantment(Map<Enchantment, Intege
List<Piece> marked = pieces.values().stream().filter(p -> p.marked).collect(Collectors.toList());

List<EnchantmentDataWrapper> validEnchants = new ArrayList<>();
Registry.ENCHANTMENT.forEach(enchantment -> {
String id = Registry.ENCHANTMENT.getKey(enchantment).toString();
BuiltInRegistries.ENCHANTMENT.forEach(enchantment -> {
String id = BuiltInRegistries.ENCHANTMENT.getKey(enchantment).toString();
boolean isValid = true;
if(enchantment.isTreasureOnly()){
isValid = MatrixEnchantingModule.allowTreasures ||
Expand Down Expand Up @@ -414,7 +412,7 @@ public Piece(EnchantmentDataWrapper wrapper, int type) {
this.influence = wrapper.influence;
this.type = type;

Random rng = new Random(Objects.toString(Registry.ENCHANTMENT.getKey(enchant)).hashCode());
Random rng = new Random(Objects.toString(BuiltInRegistries.ENCHANTMENT.getKey(enchant)).hashCode());
float h = rng.nextFloat();
float s = rng.nextFloat() * 0.2F + 0.8F;
float b = rng.nextFloat() * 0.25F + 0.75F;
Expand Down Expand Up @@ -457,7 +455,7 @@ public void writeToNBT(CompoundTag cmp) {
cmp.putInt(TAG_COLOR, color);
cmp.putInt(TAG_TYPE, type);
if (enchant != null)
cmp.putString(TAG_ENCHANTMENT, Objects.toString(Registry.ENCHANTMENT.getKey(enchant)));
cmp.putString(TAG_ENCHANTMENT, Objects.toString(BuiltInRegistries.ENCHANTMENT.getKey(enchant)));
cmp.putInt(TAG_LEVEL, level);
cmp.putInt(TAG_X, x);
cmp.putInt(TAG_Y, y);
Expand All @@ -473,7 +471,7 @@ public void writeToNBT(CompoundTag cmp) {
public void readFromNBT(CompoundTag cmp) {
color = cmp.getInt(TAG_COLOR);
type = cmp.getInt(TAG_TYPE);
enchant = Registry.ENCHANTMENT.get(new ResourceLocation(cmp.getString(TAG_ENCHANTMENT)));
enchant = BuiltInRegistries.ENCHANTMENT.get(new ResourceLocation(cmp.getString(TAG_ENCHANTMENT)));
level = cmp.getInt(TAG_LEVEL);
x = cmp.getInt(TAG_X);
y = cmp.getInt(TAG_Y);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;

import java.io.Serial;

import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.tweaks.module.DoubleDoorOpeningModule;
import org.violetmoon.zeta.network.IZetaMessage;
import org.violetmoon.zeta.network.IZetaNetworkEventContext;

import java.io.Serial;

public class DoubleDoorMessage implements IZetaMessage {

@Serial
Expand All @@ -25,7 +24,7 @@ public DoubleDoorMessage(BlockPos pos) {
}

private Level extractWorld(ServerPlayer entity) {
return entity == null ? null : entity.level;
return entity == null ? null : entity.getCommandSenderWorld();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package org.violetmoon.quark.content.automation.block;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.player.Player;
Expand All @@ -28,17 +24,16 @@
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.*;
import net.minecraftforge.common.util.ForgeSoundType;
import org.violetmoon.quark.content.automation.block.be.FeedingTroughBlockEntity;
import org.violetmoon.quark.content.automation.module.FeedingTroughModule;
import org.violetmoon.zeta.block.ZetaBlock;
import org.violetmoon.zeta.module.ZetaModule;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
* @author WireSegal
* Created at 9:39 AM on 9/20/19.
Expand Down Expand Up @@ -94,11 +89,11 @@ public SoundType getSoundTypeZeta(BlockState state, LevelReader world, BlockPos
}

@Override
public void fallOn(Level world, @Nonnull BlockState state, @Nonnull BlockPos pos, @Nonnull Entity entity, float distance) {
if (world.getBlockState(pos).getValue(FULL))
entity.causeFallDamage(distance, 0.2F, DamageSource.FALL);
public void fallOn(Level level, @Nonnull BlockState state, @Nonnull BlockPos pos, @Nonnull Entity entity, float distance) {
if (level.getBlockState(pos).getValue(FULL))
entity.causeFallDamage(distance, 0.2F, level.damageSources().fall());
else
super.fallOn(world, state, pos, entity, distance);
super.fallOn(level, state, pos, entity, distance);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.violetmoon.quark.content.automation.block.be;

import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.DustParticleOptions;
Expand All @@ -18,14 +17,14 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;

import java.util.List;

import org.joml.Vector3f;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.automation.block.EnderWatcherBlock;
import org.violetmoon.quark.content.automation.module.EnderWatcherModule;
import org.violetmoon.zeta.block.be.ZetaBlockEntity;

import java.util.List;

public class EnderWatcherBlockEntity extends ZetaBlockEntity {

public EnderWatcherBlockEntity(BlockPos pos, BlockState state) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
package org.violetmoon.quark.content.automation.block.be;

import java.util.List;
import java.util.Random;
import java.util.UUID;

import javax.annotation.Nonnull;

import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.quark.content.automation.block.FeedingTroughBlock;
import org.violetmoon.quark.content.automation.module.FeedingTroughModule;

import com.mojang.authlib.GameProfile;

import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.core.particles.ItemParticleOption;
Expand All @@ -36,6 +25,14 @@
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.FakePlayerFactory;
import org.violetmoon.quark.base.handler.MiscUtil;
import org.violetmoon.quark.content.automation.block.FeedingTroughBlock;
import org.violetmoon.quark.content.automation.module.FeedingTroughModule;

import javax.annotation.Nonnull;
import java.util.List;
import java.util.Random;
import java.util.UUID;

/**
* @author WireSegal
Expand Down Expand Up @@ -140,11 +137,11 @@ public void setChanged() {

private void addItemParticles(Entity entity, ItemStack stack, int count) {
for(int i = 0; i < count; ++i) {
Vec3 direction = new Vec3((entity.level.random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
Vec3 direction = new Vec3((entity.getCommandSenderWorld().random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
direction = direction.xRot(-entity.getXRot() * ((float)Math.PI / 180F));
direction = direction.yRot(-entity.getYRot() * ((float)Math.PI / 180F));
double yVelocity = (-entity.level.random.nextFloat()) * 0.6D - 0.3D;
Vec3 position = new Vec3((entity.level.random.nextFloat() - 0.5D) * 0.3D, yVelocity, 0.6D);
double yVelocity = (-entity.getCommandSenderWorld().random.nextFloat()) * 0.6D - 0.3D;
Vec3 position = new Vec3((entity.getCommandSenderWorld().random.nextFloat() - 0.5D) * 0.3D, yVelocity, 0.6D);
Vec3 entityPos = entity.position();
position = position.xRot(-entity.getXRot() * ((float)Math.PI / 180F));
position = position.yRot(-entity.getYRot() * ((float)Math.PI / 180F));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package org.violetmoon.quark.content.automation.module;

import net.minecraft.core.registries.Registries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.zeta.advancement.ManualTrigger;
import org.violetmoon.quark.content.automation.block.EnderWatcherBlock;
import org.violetmoon.quark.content.automation.block.be.EnderWatcherBlockEntity;
import org.violetmoon.zeta.advancement.ManualTrigger;
import org.violetmoon.zeta.event.bus.LoadEvent;
import org.violetmoon.zeta.event.load.ZRegister;
import org.violetmoon.zeta.module.ZetaLoadModule;
import org.violetmoon.zeta.module.ZetaModule;
import org.violetmoon.zeta.util.Hint;

import net.minecraft.core.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;

@ZetaLoadModule(category = "automation")
public class EnderWatcherModule extends ZetaModule {

Expand All @@ -26,7 +25,7 @@ public class EnderWatcherModule extends ZetaModule {
public final void register(ZRegister event) {
ender_watcher = new EnderWatcherBlock(this);
blockEntityType = BlockEntityType.Builder.of(EnderWatcherBlockEntity::new, ender_watcher).build(null);
Quark.ZETA.registry.register(blockEntityType, "ender_watcher", Registry.BLOCK_ENTITY_TYPE_REGISTRY);
Quark.ZETA.registry.register(blockEntityType, "ender_watcher", Registries.BLOCK_ENTITY_TYPE);

watcherCenterTrigger = event.getAdvancementModifierRegistry().registerManualTrigger("watcher_center");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
package org.violetmoon.quark.content.building.client.render.entity;

import java.util.List;

import javax.annotation.Nonnull;

import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.building.entity.GlassItemFrame;
import org.violetmoon.quark.content.building.module.GlassItemFrameModule;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.datafixers.util.Pair;
import com.mojang.math.Vector3f;

import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.blockentity.BannerRenderer;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
Expand All @@ -35,18 +25,20 @@
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.BannerItem;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.MapItem;
import net.minecraft.world.item.ShieldItem;
import net.minecraft.world.item.*;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BannerBlockEntity;
import net.minecraft.world.level.block.entity.BannerPattern;
import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.event.RenderItemInFrameEvent;
import net.minecraftforge.common.MinecraftForge;
import org.violetmoon.quark.base.Quark;
import org.violetmoon.quark.content.building.entity.GlassItemFrame;
import org.violetmoon.quark.content.building.module.GlassItemFrameModule;

import javax.annotation.Nonnull;
import java.util.List;

/**
* @author WireSegal
Expand Down Expand Up @@ -85,8 +77,8 @@ public void render(@Nonnull GlassItemFrame frame, float yaw, float partialTicks,
Vec3 Vector3d = this.getRenderOffset(frame, partialTicks);
matrix.translate(-Vector3d.x(), -Vector3d.y(), -Vector3d.z());
matrix.translate((double)direction.getStepX() * 0.46875D, (double)direction.getStepY() * 0.46875D, (double)direction.getStepZ() * 0.46875D);
matrix.mulPose(Vector3f.XP.rotationDegrees(frame.getXRot()));
matrix.mulPose(Vector3f.YP.rotationDegrees(180.0F - frame.getYRot()));
matrix.mulPose(Axis.XP.rotationDegrees(frame.getXRot()));
matrix.mulPose(Axis.YP.rotationDegrees(180.0F - frame.getYRot()));
BlockRenderDispatcher blockrendererdispatcher = this.mc.getBlockRenderer();
ModelManager modelmanager = blockrendererdispatcher.getBlockModelShaper().getModelManager();

Expand Down Expand Up @@ -138,7 +130,7 @@ protected void renderNameTag(@Nonnull GlassItemFrame frame, @Nonnull Component t
protected void renderItemStack(GlassItemFrame itemFrame, PoseStack matrix, MultiBufferSource buff, int light, ItemStack stack) {
if (!stack.isEmpty()) {
matrix.pushPose();
MapItemSavedData mapdata = MapItem.getSavedData(stack, itemFrame.level);
MapItemSavedData mapdata = MapItem.getSavedData(stack, itemFrame.getCommandSenderWorld());

sign: if(itemFrame.isOnSign()) {

Expand All @@ -156,17 +148,17 @@ protected void renderItemStack(GlassItemFrame itemFrame, PoseStack matrix, Multi
matrix.translate(0, 0.35, 0.8);
matrix.scale(0.4F, 0.4F, 0.4F);
matrix.translate(0, 0, 0.5);
matrix.mulPose(Vector3f.YP.rotationDegrees(angle));
matrix.mulPose(Axis.YP.rotationDegrees(angle));
matrix.translate(0, 0, -0.5);
matrix.translate(0, 0, -0.085);
}

int rotation = mapdata != null ? itemFrame.getRotation() % 4 * 2 : itemFrame.getRotation();
matrix.mulPose(Vector3f.ZP.rotationDegrees((float) rotation * 360.0F / 8.0F));
matrix.mulPose(Axis.ZP.rotationDegrees((float) rotation * 360.0F / 8.0F));

if (!MinecraftForge.EVENT_BUS.post(new RenderItemInFrameEvent(itemFrame, defaultRenderer, matrix, buff, light))) {
if (mapdata != null) {
matrix.mulPose(Vector3f.ZP.rotationDegrees(180.0F));
matrix.mulPose(Axis.ZP.rotationDegrees(180.0F));
matrix.scale(0.0078125F, 0.0078125F, 0.0078125F);
matrix.translate(-64.0F, -64.0F, 62.5F); // <- Use 62.5 instead of 64 to prevent z-fighting

Expand Down Expand Up @@ -194,7 +186,7 @@ protected void renderItemStack(GlassItemFrame itemFrame, PoseStack matrix, Multi
matrix.scale(s, s, s);
}
matrix.scale(0.5F, 0.5F, 0.5F);
this.itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, light, OverlayTexture.NO_OVERLAY, matrix, buff, 0);
this.itemRenderer.renderStatic(stack, ItemDisplayContext.FIXED, light, OverlayTexture.NO_OVERLAY, matrix, buff, mc.level, 0);
}
}
}
Expand Down
Loading

0 comments on commit b541b14

Please sign in to comment.