Skip to content

Commit

Permalink
Merge branch 'architectury-1.20' into architectury-1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Nov 5, 2023
2 parents 5ee3121 + ca9f2b4 commit 30edecf
Show file tree
Hide file tree
Showing 23 changed files with 1,005 additions and 97 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ out/
.gradle/
output/
bin/
libs/

.classpath
.project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void commonInit() {
if (getModList().contains("farmersdelight"))
pfmModCompatibilities.add(PFMFarmersDelight.getInstance());
if (getModList().contains("imm_ptl_core"))
pfmModCompatibilities.add(new PFMImmersivePortals());
pfmModCompatibilities.add(PFMImmersivePortals.getInstance());
}

@ExpectPlatform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ public static Identifier getLogId(Block block, String postFix) {
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
id = new Identifier(namespace, "block/alpha_oak_log");
if (idExists(id, ResourceType.CLIENT_RESOURCES, IdLocation.TEXTURES)) {
return id;
}
}
return new Identifier(namespace, "block/" + path);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
package com.unlikepaladin.pfm.compat.imm_ptl;

import com.unlikepaladin.pfm.compat.PFMClientModCompatibility;
import com.unlikepaladin.pfm.compat.PFMModCompatibility;
import com.unlikepaladin.pfm.compat.imm_ptl.client.PFMImmersivePortalsClient;
import com.unlikepaladin.pfm.compat.imm_ptl.entity.PFMMirrorEntity;
import com.unlikepaladin.pfm.registry.EntityRegistry;
import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.MapColor;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import dev.architectury.injectables.annotations.ExpectPlatform;

import java.util.Optional;

public class PFMImmersivePortals implements PFMModCompatibility {
private PFMClientModCompatibility clientModCompatibility;
public PFMImmersivePortals(){
}
public static final EntityType<PFMMirrorEntity> MIRROR = EntityType.Builder.create(PFMMirrorEntity::new, SpawnGroup.MISC).setDimensions(0.0F, 0.0F).makeFireImmune().disableSummon().build("mirror_entity");

@Override
public void registerEntityTypes() {
EntityRegistry.registerEntityType("mirror_entity", MIRROR);
}

@Override
public void createBlocks() {
PaladinFurnitureModBlocksItems.WHITE_MIRROR = new PFMMirrorBlockIP(AbstractBlock.Settings.create().mapColor(MapColor.WHITE).nonOpaque());
PaladinFurnitureModBlocksItems.GRAY_MIRROR = new PFMMirrorBlockIP(AbstractBlock.Settings.create().mapColor(MapColor.GRAY).nonOpaque());
}

@Override
public String getModId() {
return "immersive_portals";
}

@Override
public Optional<PFMClientModCompatibility> getClientModCompatiblity() {
if (clientModCompatibility == null)
clientModCompatibility = new PFMImmersivePortalsClient(this);
return Optional.of(clientModCompatibility);
public class PFMImmersivePortals {
@ExpectPlatform
public static PFMModCompatibility getInstance() {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Optional<WoodVariant> getVariantFromBlock(Block baseBlock, Identifier blo
}
String namespace = blockId.getNamespace();
if (name != null && !namespace.equals("securitycraft") &&
!namespace.equals("absentbydesign") && !(namespace.equals("terrestria") && path.contains("sakura")) && !(namespace.equals("betternether") && path.contains("nether_mushroom")) && !namespace.equals("chipped")) {
!namespace.equals("absentbydesign") && !(namespace.equals("terrestria") && path.contains("sakura")) && !(namespace.equals("betternether") && path.contains("nether_mushroom")) && !namespace.equals("chipped") && !(namespace.equals("regions_unexplored") && path.contains("alpha"))) {

BlockState state = baseBlock.getDefaultState();
//can't check if the block is a full one, so I do this. Adding some checks here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public static void registerBlocks() throws InvocationTargetException, Instantiat
this.addBlock(registerLateBlock(color.getName() + "_shower_towel", () -> new ShowerTowelBlock(color, AbstractBlock.Settings.create().burnable().strength(2.0f).resistance(2.0f).nonOpaque().sounds(BlockSoundGroup.WOOL).mapColor(color.getMapColor())), true, PaladinFurnitureMod.FURNITURE_GROUP));
}
}});
if (!BlockItemRegistry.isModLoaded("imm_ptl_core")) {
if (!BlockItemRegistry.isModLoaded("imm_ptl_core") && PaladinFurnitureMod.getLoader() == PaladinFurnitureMod.Loader.FABRIC_LIKE) {
PaladinFurnitureModBlocksItems.WHITE_MIRROR = new MirrorBlock(AbstractBlock.Settings.create().mapColor(MapColor.WHITE).nonOpaque());
PaladinFurnitureModBlocksItems.GRAY_MIRROR = new MirrorBlock(AbstractBlock.Settings.create().mapColor(MapColor.GRAY).nonOpaque());
}
Expand Down
13 changes: 11 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ else {

if (rootProject.immersive_portals_compatibility_fabric == "true"){
dependencies {
modRuntimeOnly ("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version_fabric}"){
modImplementation ("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version_fabric}"){
exclude(group: "net.fabricmc.fabric-api")
transitive(false)
}
modRuntimeOnly("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:${rootProject.immersive_portals_version_fabric}"){
modImplementation("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:${rootProject.immersive_portals_version_fabric}"){
exclude(group: "net.fabricmc.fabric-api")
transitive(false)
}
Expand Down Expand Up @@ -183,6 +183,15 @@ dependencies {

modCompileOnly "curse.maven:balm-fabric-500525:${rootProject.balm_version_fabric}"
modCompileOnly "curse.maven:cooking-for-blockheads-fabric-634546:${rootProject.cookingforblockheads_version_fabric}"

modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version_fabric}"){
exclude(group: "net.fabricmc.fabric-api")
transitive(false)
}
modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:${rootProject.immersive_portals_version_fabric}"){
exclude(group: "net.fabricmc.fabric-api")
transitive(false)
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.unlikepaladin.pfm.compat.imm_ptl.fabric;

import com.unlikepaladin.pfm.compat.PFMClientModCompatibility;
import com.unlikepaladin.pfm.compat.PFMModCompatibility;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.client.PFMImmersivePortalsClient;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.entity.PFMMirrorEntity;
import com.unlikepaladin.pfm.registry.EntityRegistry;
import com.unlikepaladin.pfm.registry.PaladinFurnitureModBlocksItems;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.MapColor;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;

import java.util.Optional;

public class PFMImmersivePortalsImpl implements PFMModCompatibility {
private PFMClientModCompatibility clientModCompatibility;
public static final EntityType<PFMMirrorEntity> MIRROR = EntityType.Builder.create(PFMMirrorEntity::new, SpawnGroup.MISC).setDimensions(0.0F, 0.0F).makeFireImmune().disableSummon().build("mirror_entity");

@Override
public void registerEntityTypes() {
EntityRegistry.registerEntityType("mirror_entity", MIRROR);
}

@Override
public void createBlocks() {
PaladinFurnitureModBlocksItems.WHITE_MIRROR = new PFMMirrorBlockIP(AbstractBlock.Settings.create().mapColor(MapColor.WHITE).nonOpaque());
PaladinFurnitureModBlocksItems.GRAY_MIRROR = new PFMMirrorBlockIP(AbstractBlock.Settings.create().mapColor(MapColor.GRAY).nonOpaque());
}

@Override
public String getModId() {
return "immersive_portals";
}

@Override
public Optional<PFMClientModCompatibility> getClientModCompatiblity() {
if (clientModCompatibility == null)
clientModCompatibility = new PFMImmersivePortalsClient(this);
return Optional.of(clientModCompatibility);
}
public static PFMModCompatibility getInstance() {
return new PFMImmersivePortalsImpl();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.unlikepaladin.pfm.compat.imm_ptl;
package com.unlikepaladin.pfm.compat.imm_ptl.fabric;

import com.unlikepaladin.pfm.PaladinFurnitureMod;
import com.unlikepaladin.pfm.blocks.MirrorBlock;
import com.unlikepaladin.pfm.compat.imm_ptl.entity.PFMMirrorEntity;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.entity.PFMMirrorEntity;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
Expand Down Expand Up @@ -41,7 +41,7 @@ public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity pl
List<PFMMirrorEntity> mirrorBlockEntities;
if (!world.isClient && !(mirrorBlockEntities = world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos))).isEmpty()) {
mirrorBlockEntities.forEach(pfmMirrorEntity -> {
pfmMirrorEntity.remove(Entity.RemovalReason.KILLED);
((PFMMirrorEntity)pfmMirrorEntity).remove(Entity.RemovalReason.KILLED);
});
world.updateNeighbors(pos, state.getBlock());
}
Expand All @@ -58,7 +58,7 @@ public BlockState getStateForNeighborUpdate(BlockState state, Direction directio
if (!(world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos)).isEmpty())) {
mirrorBlockEntities.addAll(world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos)));
mirrorBlockEntities.forEach(pfmMirrorEntity -> {
pfmMirrorEntity.remove(Entity.RemovalReason.KILLED);
((Entity)pfmMirrorEntity).remove(Entity.RemovalReason.KILLED);
});
}
PFMMirrorEntity.createMirror((ServerWorld) world, pos, state.get(FACING).getOpposite());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.unlikepaladin.pfm.compat.imm_ptl.client;
package com.unlikepaladin.pfm.compat.imm_ptl.fabric.client;

import com.unlikepaladin.pfm.client.EntityRenderRegistry;
import com.unlikepaladin.pfm.compat.PFMClientModCompatibility;
import com.unlikepaladin.pfm.compat.PFMModCompatibility;
import com.unlikepaladin.pfm.compat.imm_ptl.PFMImmersivePortals;
import qouteall.imm_ptl.core.render.PortalEntityRenderer;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.PFMImmersivePortalsImpl;

public class PFMImmersivePortalsClient implements PFMClientModCompatibility {
private final PFMImmersivePortals parent;
public PFMImmersivePortalsClient(PFMImmersivePortals parent) {
private final PFMImmersivePortalsImpl parent;
public PFMImmersivePortalsClient(PFMImmersivePortalsImpl parent) {
this.parent = parent;
}
@Override
Expand All @@ -18,6 +17,6 @@ public PFMModCompatibility getCompatiblity() {

@Override
public void registerEntityRenderer() {
EntityRenderRegistry.registerEntityRender(PFMImmersivePortals.MIRROR, PFMMirrorEntityRenderer::new);
EntityRenderRegistry.registerEntityRender(PFMImmersivePortalsImpl.MIRROR, PFMMirrorEntityRenderer::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.unlikepaladin.pfm.compat.imm_ptl.client;
package com.unlikepaladin.pfm.compat.imm_ptl.fabric.client;

import com.unlikepaladin.pfm.PaladinFurnitureMod;
import net.minecraft.client.render.VertexConsumerProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.unlikepaladin.pfm.compat.imm_ptl.entity;
package com.unlikepaladin.pfm.compat.imm_ptl.fabric.entity;


import com.unlikepaladin.pfm.compat.imm_ptl.PFMImmersivePortals;
import com.unlikepaladin.pfm.compat.imm_ptl.PFMMirrorBlockIP;
import com.unlikepaladin.pfm.compat.imm_ptl.shape.BlockPortalShape;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.PFMImmersivePortalsImpl;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.PFMMirrorBlockIP;
import com.unlikepaladin.pfm.compat.imm_ptl.fabric.shape.BlockPortalShape;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.world.ServerWorld;
Expand All @@ -15,15 +16,15 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import qouteall.imm_ptl.core.portal.Mirror;
import qouteall.q_misc_util.my_util.IntBox;
import qouteall.q_misc_util.Helper;
import qouteall.q_misc_util.my_util.IntBox;

import org.jetbrains.annotations.Nullable;
import java.util.stream.Stream;

public class PFMMirrorEntity extends Mirror {
public static EntityType<PFMMirrorEntity> entityType = PFMImmersivePortals.MIRROR;
public static EntityType<PFMMirrorEntity> entityType = PFMImmersivePortalsImpl.MIRROR;
@Nullable
public IntBox wallArea;
@Nullable
Expand Down Expand Up @@ -123,7 +124,7 @@ else if (blockPortalShape != null) {
wallValid = false;
}
if (!wallValid) {
remove(RemovalReason.DISCARDED);
((Entity)this).remove(RemovalReason.DISCARDED);
}
}

Expand All @@ -135,13 +136,9 @@ public static boolean isMirrorBlock(World world, BlockPos blockPos, Direction fa
return false;
}

public static PFMMirrorEntity createMirror(
ServerWorld world,
BlockPos glassPos,
Direction facing
) {
public static void createMirror(ServerWorld world, BlockPos glassPos, Direction facing) {
if (!isMirrorBlock(world, glassPos, facing.getOpposite())) {
return null;
return;
}

BlockPortalShape shape = BlockPortalShape.findArea(
Expand All @@ -151,15 +148,15 @@ public static PFMMirrorEntity createMirror(
);

if (shape == null) {
return null;
return;
}

PFMMirrorEntity pfmMirrorEntity = PFMMirrorEntity.entityType.create(world);
double distanceToCenter = -0.452;

Box wallBox = getWallBox(world, shape.area.stream());
if (wallBox == null) {
return null;
return;
}
pfmMirrorEntity.facing = facing;
Vec3d pos = Helper.getBoxSurfaceInversed(wallBox, facing.getOpposite()).getCenter();
Expand All @@ -172,7 +169,7 @@ public static PFMMirrorEntity createMirror(
facing.getAxis()
)
);
pfmMirrorEntity.setPosition(pos);
((Entity)pfmMirrorEntity).setPos(pos.x, pos.y, pos.z);
pfmMirrorEntity.setDestination(pos);
pfmMirrorEntity.dimensionTo = world.getRegistryKey();

Expand All @@ -181,7 +178,6 @@ public static PFMMirrorEntity createMirror(
pfmMirrorEntity.blockPortalShape = shape;
world.spawnEntity(pfmMirrorEntity);

return pfmMirrorEntity;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.unlikepaladin.pfm.compat.imm_ptl.shape;
package com.unlikepaladin.pfm.compat.imm_ptl.fabric.shape;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtInt;
Expand All @@ -9,12 +9,11 @@
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import org.apache.commons.lang3.Validate;
import org.jetbrains.annotations.Nullable;
import qouteall.imm_ptl.core.portal.GeometryPortalShape;
import qouteall.imm_ptl.core.portal.Portal;
import qouteall.q_misc_util.Helper;
import qouteall.q_misc_util.my_util.IntBox;

import org.jetbrains.annotations.Nullable;
import qouteall.q_misc_util.my_util.Mesh2D;

import java.util.ArrayDeque;
Expand Down Expand Up @@ -399,18 +398,18 @@ public void initPortalAxisShape(Portal portal, Vec3d center, Direction facing) {
}
else {
GeometryPortalShape shape = new GeometryPortalShape(new Mesh2D());

IntBox rectanglePart = Helper.expandRectangle(
anchor,
blockPos -> area.contains(blockPos),
axis
anchor,
blockPos -> area.contains(blockPos),
axis
);

Stream.concat(
area.stream()
.filter(blockPos -> !rectanglePart.contains(blockPos))
.map(blockPos -> new IntBox(blockPos, blockPos)),
Stream.of(rectanglePart)
area.stream()
.filter(blockPos -> !rectanglePart.contains(blockPos))
.map(blockPos -> new IntBox(blockPos, blockPos)),
Stream.of(rectanglePart)
).forEach(part -> {
Vec3d p1 = Vec3d.of(part.l).add(offset);
Vec3d p2 = Vec3d.of(part.h).add(1, 1, 1).add(offset);
Expand All @@ -419,13 +418,13 @@ public void initPortalAxisShape(Portal portal, Vec3d center, Direction facing) {
double p2LocalX = p2.subtract(center).dotProduct(portal.axisW);
double p2LocalY = p2.subtract(center).dotProduct(portal.axisH);
shape.addTriangleForRectangle(
p1LocalX, p1LocalY,
p2LocalX, p2LocalY
p1LocalX, p1LocalY,
p2LocalX, p2LocalY
);
});

portal.specialShape = shape;

Vec3d p1 = Vec3d.of(rectanglePart.l).add(offset);
Vec3d p2 = Vec3d.of(rectanglePart.h).add(1, 1, 1).add(offset);
double p1LocalX = p1.subtract(center).dotProduct(portal.axisW);
Expand Down
Loading

0 comments on commit 30edecf

Please sign in to comment.