From 3e0bfec88286b73d37ba295ae13092dd7edca07a Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 22 Jun 2020 01:28:44 +0200 Subject: [PATCH] Added CTM back in (???) May need to be tweaked --- gradle.properties | 1 + gradle/scripts/dependencies.gradle | 1 + .../block/networking/BlockCableBus.java | 87 +++++++++---------- .../integration/abstraction/IAEFacade.java | 54 ++++++++++++ .../java/team/chisel/ctm/api/IFacade.java | 44 ++++++++++ 5 files changed, 142 insertions(+), 45 deletions(-) create mode 100644 src/main/java/appeng/integration/abstraction/IAEFacade.java create mode 100644 src/main/java/team/chisel/ctm/api/IFacade.java diff --git a/gradle.properties b/gradle.properties index f14180c72..aee000602 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,6 +19,7 @@ forge_version=31.2.20 jei_version=6.0.0.4 top_version=2.0.4-5 hwyla_version=1.10.8-B72_1.15.2 +ctm_version=MC1.15.2-1.1.0.9 ######################################################### # Deployment # diff --git a/gradle/scripts/dependencies.gradle b/gradle/scripts/dependencies.gradle index af49744d6..b24a7ea5d 100644 --- a/gradle/scripts/dependencies.gradle +++ b/gradle/scripts/dependencies.gradle @@ -80,6 +80,7 @@ dependencies { // Runtime, Mods runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") runtimeOnly fg.deobf("mcjty.theoneprobe:TheOneProbe-${minecraft_release}:${minecraft_release}-${top_version}") + runtimeOnly fg.deobf("team.chisel.ctm:CTM:${ctm_version}") // unit test dependencies testCompile "junit:junit:4.13" diff --git a/src/main/java/appeng/block/networking/BlockCableBus.java b/src/main/java/appeng/block/networking/BlockCableBus.java index dfbdcc721..530391f70 100644 --- a/src/main/java/appeng/block/networking/BlockCableBus.java +++ b/src/main/java/appeng/block/networking/BlockCableBus.java @@ -18,12 +18,25 @@ package appeng.block.networking; -import java.util.EnumSet; -import java.util.List; -import java.util.Random; - -import javax.annotation.Nullable; - +import appeng.api.parts.IFacadeContainer; +import appeng.api.parts.IFacadePart; +import appeng.api.parts.PartItemStack; +import appeng.api.parts.SelectedPart; +import appeng.api.util.AEColor; +import appeng.api.util.AEPartLocation; +import appeng.block.AEBaseTileBlock; +import appeng.client.render.cablebus.CableBusBakedModel; +import appeng.client.render.cablebus.CableBusBreakingParticle; +import appeng.client.render.cablebus.CableBusRenderState; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketClick; +import appeng.helpers.AEGlassMaterial; +import appeng.integration.abstraction.IAEFacade; +import appeng.parts.ICableBusContainer; +import appeng.parts.NullCableBusContainer; +import appeng.tile.AEBaseTile; +import appeng.tile.networking.TileCableBus; +import appeng.util.Platform; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.Minecraft; @@ -44,12 +57,8 @@ import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.NonNullList; -import net.minecraft.util.math.AxisAlignedBB; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.*; import net.minecraft.util.math.RayTraceResult.Type; -import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; @@ -60,24 +69,12 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import appeng.api.parts.IFacadeContainer; -import appeng.api.parts.PartItemStack; -import appeng.api.parts.SelectedPart; -import appeng.api.util.AEColor; -import appeng.block.AEBaseTileBlock; -import appeng.client.render.cablebus.CableBusBakedModel; -import appeng.client.render.cablebus.CableBusBreakingParticle; -import appeng.client.render.cablebus.CableBusRenderState; -import appeng.core.sync.network.NetworkHandler; -import appeng.core.sync.packets.PacketClick; -import appeng.helpers.AEGlassMaterial; -import appeng.parts.ICableBusContainer; -import appeng.parts.NullCableBusContainer; -import appeng.tile.AEBaseTile; -import appeng.tile.networking.TileCableBus; -import appeng.util.Platform; +import javax.annotation.Nullable; +import java.util.EnumSet; +import java.util.List; +import java.util.Random; -public class BlockCableBus extends AEBaseTileBlock /* FIXME implements IAEFacade */ { +public class BlockCableBus extends AEBaseTileBlock implements IAEFacade { private static final ICableBusContainer NULL_CABLE_BUS = new NullCableBusContainer(); @@ -355,23 +352,23 @@ public class BlockCableBus extends AEBaseTileBlock /* FIXME implem // do nothing } -// FIXME FACADES @Override -// FIXME FACADES public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side ) -// FIXME FACADES { -// FIXME FACADES if( side != null ) -// FIXME FACADES { -// FIXME FACADES IFacadeContainer container = this.fc( world, pos ); -// FIXME FACADES if( container != null ) -// FIXME FACADES { -// FIXME FACADES IFacadePart facade = container.getFacade( AEPartLocation.fromFacing( side ) ); -// FIXME FACADES if( facade != null ) -// FIXME FACADES { -// FIXME FACADES return facade.getBlockState(); -// FIXME FACADES } -// FIXME FACADES } -// FIXME FACADES } -// FIXME FACADES return world.getBlockState( pos ); -// FIXME FACADES } + @Override + public BlockState getFacadeState( IBlockReader world, BlockPos pos, Direction side ) + { + if( side != null ) + { + IFacadeContainer container = this.fc( world, pos ); + if( container != null ) + { + IFacadePart facade = container.getFacade( AEPartLocation.fromFacing( side ) ); + if( facade != null ) + { + return facade.getBlockState(); + } + } + } + return world.getBlockState( pos ); + } @Override public VoxelShape getShape(BlockState state, IBlockReader w, BlockPos pos, ISelectionContext context) { diff --git a/src/main/java/appeng/integration/abstraction/IAEFacade.java b/src/main/java/appeng/integration/abstraction/IAEFacade.java new file mode 100644 index 000000000..722224d29 --- /dev/null +++ b/src/main/java/appeng/integration/abstraction/IAEFacade.java @@ -0,0 +1,54 @@ +/* + * This file is part of Applied Energistics 2. + * Copyright (c) 2013 - 2018, AlgorithmX2, All rights reserved. + * + * Applied Energistics 2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Applied Energistics 2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Applied Energistics 2. If not, see . + */ + +package appeng.integration.abstraction; + + +import net.minecraft.block.BlockState; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; +import team.chisel.ctm.api.IFacade; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + + +/** + * Neat abstraction class for All the IFacade interfaces. + * + * @author covers1624 + */ +public interface IAEFacade extends IFacade +{ + + BlockState getFacadeState( IBlockReader world, BlockPos pos, @Nullable Direction side ); + + @Nonnull + @Override + default BlockState getFacade(@Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nullable Direction side) { + return getFacadeState(world, pos, side); + } + + @Nonnull + @Override + default BlockState getFacade(@Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nullable Direction side, @Nonnull BlockPos connection) { + return getFacadeState(world, pos, side); + } + +} diff --git a/src/main/java/team/chisel/ctm/api/IFacade.java b/src/main/java/team/chisel/ctm/api/IFacade.java new file mode 100644 index 000000000..6b31f30d1 --- /dev/null +++ b/src/main/java/team/chisel/ctm/api/IFacade.java @@ -0,0 +1,44 @@ +package team.chisel.ctm.api; + +import net.minecraft.block.BlockState; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * To be implemented on blocks that "hide" another block inside, so connected textures can still be accomplished. + */ +public interface IFacade { + + /** + * @deprecated Use {@link #getFacade(IBlockReader, BlockPos, Direction, BlockPos)} + */ + @Nonnull + @Deprecated + BlockState getFacade(@Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nullable Direction side); + + /** + * Gets the blockstate this facade appears as. + * + * @param world + * {@link World} + * @param pos + * The Blocks position + * @param side + * The side being rendered, NOT the side being connected from. + *

+ * This value can be null if no side is specified. Please handle this appropriately. + * @param connection + * The position of the block being connected to. + * @return The blockstate which your block appears as. + */ + @Nonnull + default BlockState getFacade(@Nonnull IBlockReader world, @Nonnull BlockPos pos, @Nullable Direction side, @Nonnull BlockPos connection) { + return getFacade(world, pos, side); + } + +}