Skip to content

Commit

Permalink
Actually fixed Immptl, blame loom
Browse files Browse the repository at this point in the history
  • Loading branch information
UnlikePaladin committed Nov 5, 2023
1 parent a56882e commit daf3b5b
Show file tree
Hide file tree
Showing 16 changed files with 966 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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());
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +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.block.Material;
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.of(Material.STONE, MapColor.WHITE).nonOpaque());
PaladinFurnitureModBlocksItems.GRAY_MIRROR = new PFMMirrorBlockIP(AbstractBlock.Settings.of(Material.STONE, 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();
}
}
13 changes: 11 additions & 2 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ else {

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

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

modCompileOnly("com.github.qouteall.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version_fabric}"){
exclude(group: "net.fabricmc.fabric-api")
transitive(false)
}
modCompileOnly("com.github.qouteall.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,46 @@
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.block.Material;
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.of(Material.STONE, MapColor.WHITE).nonOpaque());
PaladinFurnitureModBlocksItems.GRAY_MIRROR = new PFMMirrorBlockIP(AbstractBlock.Settings.of(Material.STONE, 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
@@ -0,0 +1,69 @@
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.fabric.entity.PFMMirrorEntity;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class PFMMirrorBlockIP extends MirrorBlock {
protected PFMMirrorBlockIP(Settings settings) {
super(settings);
}

@Override
public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack itemStack) {
super.onPlaced(world, pos, state, placer, itemStack);
if (PaladinFurnitureMod.getPFMConfig().doImmersivePortalsMirrorsSpawn()) {
if (!world.isClient && world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos)).isEmpty()) {
PFMMirrorEntity.createMirror((ServerWorld) world, pos, state.get(FACING).getOpposite());
}
}
}

@Override
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
super.onBreak(world, pos, state, player);
if (PaladinFurnitureMod.getPFMConfig().doImmersivePortalsMirrorsSpawn()) {
List<PFMMirrorEntity> mirrorBlockEntities;
if (!world.isClient && !(mirrorBlockEntities = world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos))).isEmpty()) {
mirrorBlockEntities.forEach(pfmMirrorEntity -> {
((PFMMirrorEntity)pfmMirrorEntity).remove(Entity.RemovalReason.KILLED);
});
world.updateNeighbors(pos, state.getBlock());
}
}
}

@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
if (PaladinFurnitureMod.getPFMConfig().doImmersivePortalsMirrorsSpawn() && !world.isClient()) {
List<PFMMirrorEntity> mirrorBlockEntities = new ArrayList<>();
if (canConnect(neighborState, state)) {
mirrorBlockEntities.addAll(world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(neighborPos)));
}
if (!(world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos)).isEmpty())) {
mirrorBlockEntities.addAll(world.getNonSpectatingEntities(PFMMirrorEntity.class, new Box(pos)));
mirrorBlockEntities.forEach(pfmMirrorEntity -> {
((Entity)pfmMirrorEntity).remove(Entity.RemovalReason.KILLED);
});
}
PFMMirrorEntity.createMirror((ServerWorld) world, pos, state.get(FACING).getOpposite());
world.updateNeighbors(pos, state.getBlock());
}
return super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
}
}
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
@@ -0,0 +1,20 @@
package com.unlikepaladin.pfm.compat.imm_ptl.fabric.client;

import com.unlikepaladin.pfm.PaladinFurnitureMod;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.util.math.MatrixStack;
import qouteall.imm_ptl.core.portal.Portal;
import qouteall.imm_ptl.core.render.PortalEntityRenderer;

public class PFMMirrorEntityRenderer extends PortalEntityRenderer {
public PFMMirrorEntityRenderer(EntityRendererFactory.Context context) {
super(context);
}

@Override
public void render(Portal portal, float yaw, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light) {
if (PaladinFurnitureMod.getPFMConfig().doImmersivePortalsMirrorsRender())
super.render(portal, yaw, tickDelta, matrixStack, vertexConsumerProvider, light);
}
}
Loading

0 comments on commit daf3b5b

Please sign in to comment.