diff --git a/build.gradle b/build.gradle index 67b903c..43e25b4 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ minecraft { // stable_# Stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. - mappings channel: 'snapshot', version: '20190719-1.14.3' + mappings channel: 'snapshot', version: '20200229-1.15.1' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') @@ -74,10 +74,10 @@ minecraft { // Recommended logging level for the console property 'forge.logging.console.level', 'debug' - args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/') + args '--mod', 'engage', '--all', '--output', file('src/generated/resources/') mods { - examplemod { + examplemod {Q source sourceSets.main } } diff --git a/src/main/java/uk/gemwire/engage/Engage.java b/src/main/java/uk/gemwire/engage/Engage.java index acf9cfd..43567bc 100644 --- a/src/main/java/uk/gemwire/engage/Engage.java +++ b/src/main/java/uk/gemwire/engage/Engage.java @@ -5,6 +5,7 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; +import net.minecraft.tileentity.TileEntityType; import net.minecraft.world.chunk.IChunk; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -18,10 +19,16 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import uk.gemwire.engage.api.multiblocks.bts.MultiblockRegistry; import uk.gemwire.engage.blocks.Blocks; +import uk.gemwire.engage.blocks.tileEntities.EngageTETypes; import uk.gemwire.engage.blocks.util.WCoreStruct; import uk.gemwire.engage.items.ItemProperties; -import uk.gemwire.engage.multiblocks.bts.MultiblockRegistry; +import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockPort; +import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockType; +import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockWall; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity; @Mod("engage") @@ -48,11 +55,26 @@ public class Engage { @SubscribeEvent public static void onBlockRegistry(final RegistryEvent.Register e) { e.getRegistry().register(new WCoreStruct()); + e.getRegistry().register(new WarpCoreBlockWall().setRegistryName("warpcorewall")); + e.getRegistry().register(new WarpCoreBlockPort(WarpCoreBlockType.Power).setRegistryName("warpcorepower")); + e.getRegistry().register(new WarpCoreBlockPort(WarpCoreBlockType.Input).setRegistryName("warpcoreinput")); + e.getRegistry().register(new WarpCoreBlockPort(WarpCoreBlockType.Output).setRegistryName("warpcoreoutput")); } @SubscribeEvent public static void onItemRegistry(final RegistryEvent.Register e) { e.getRegistry().register(new BlockItem(Blocks.WCORESTRUCT, ItemProperties.BlockItemProperties).setRegistryName("wcoreextern")); + e.getRegistry().register(new BlockItem(Blocks.WCOREWALL, ItemProperties.BlockItemProperties).setRegistryName("warpcorewall")); + e.getRegistry().register(new BlockItem(Blocks.WCOREPOWER, ItemProperties.BlockItemProperties).setRegistryName("warpcorepower")); + e.getRegistry().register(new BlockItem(Blocks.WCOREINPUT, ItemProperties.BlockItemProperties).setRegistryName("warpcoreinput")); + e.getRegistry().register(new BlockItem(Blocks.WCOREOUTPUT, ItemProperties.BlockItemProperties).setRegistryName("warpcoreoutput")); + } + + @SubscribeEvent + public static void onTileRegistry(final RegistryEvent.Register> e) { + e.getRegistry().registerAll(TileEntityType.Builder.create(() -> new WarpCoreTileEntity(EngageTETypes.WarpCoreBaseType), Blocks.WCOREWALL).build(null).setRegistryName("warpcorebase"), + TileEntityType.Builder.create(() -> new WarpCorePowerTileEntity(EngageTETypes.WarpCorePowerType), Blocks.WCOREPOWER).build(null).setRegistryName("warpcorepower"), + TileEntityType.Builder.create(() -> new WarpCoreTileEntity(EngageTETypes.WarpCorePortType), Blocks.WCOREINPUT, Blocks.WCOREOUTPUT).build(null).setRegistryName("warpcoreport")); } diff --git a/src/main/java/uk/gemwire/engage/multiblocks/bts/BlockFacing.java b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/BlockFacing.java similarity index 99% rename from src/main/java/uk/gemwire/engage/multiblocks/bts/BlockFacing.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/bts/BlockFacing.java index 3d86bc0..56e7d46 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/bts/BlockFacing.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/BlockFacing.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.bts; +package uk.gemwire.engage.api.multiblocks.bts; import net.minecraft.block.BlockState; import net.minecraft.state.BooleanProperty; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/bts/BlockFacingProperty.java b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/BlockFacingProperty.java similarity index 99% rename from src/main/java/uk/gemwire/engage/multiblocks/bts/BlockFacingProperty.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/bts/BlockFacingProperty.java index 3f043d6..e64f949 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/bts/BlockFacingProperty.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/BlockFacingProperty.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.bts; +package uk.gemwire.engage.api.multiblocks.bts; import net.minecraft.state.EnumProperty; import net.minecraft.util.IStringSerializable; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/bts/MultiblockRegistry.java b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/MultiblockRegistry.java similarity index 90% rename from src/main/java/uk/gemwire/engage/multiblocks/bts/MultiblockRegistry.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/bts/MultiblockRegistry.java index 713fc7b..46368a7 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/bts/MultiblockRegistry.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/MultiblockRegistry.java @@ -1,10 +1,10 @@ -package uk.gemwire.engage.multiblocks.bts; +package uk.gemwire.engage.api.multiblocks.bts; import net.minecraft.world.World; import uk.gemwire.engage.Engage; -import uk.gemwire.engage.multiblocks.iface.IMultiblockPart; -import uk.gemwire.engage.multiblocks.iface.IMultiblockRegistry; -import uk.gemwire.engage.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockRegistry; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; import java.util.HashMap; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/bts/MultiblockWorldRegistry.java b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/MultiblockWorldRegistry.java similarity index 98% rename from src/main/java/uk/gemwire/engage/multiblocks/bts/MultiblockWorldRegistry.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/bts/MultiblockWorldRegistry.java index 19d822f..b3e22bc 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/bts/MultiblockWorldRegistry.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/MultiblockWorldRegistry.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.bts; +package uk.gemwire.engage.api.multiblocks.bts; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; @@ -6,9 +6,9 @@ import net.minecraft.util.math.ChunkPos; import net.minecraft.world.World; import net.minecraft.world.chunk.AbstractChunkProvider; import uk.gemwire.engage.Engage; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; import uk.gemwire.engage.misc.Helper; -import uk.gemwire.engage.multiblocks.iface.IMultiblockPart; -import uk.gemwire.engage.multiblocks.te.MultiblockControllerBase; import java.util.*; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/bts/PartPosition.java b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/PartPosition.java similarity index 96% rename from src/main/java/uk/gemwire/engage/multiblocks/bts/PartPosition.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/bts/PartPosition.java index cc19d47..aaf8c2f 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/bts/PartPosition.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/bts/PartPosition.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.bts; +package uk.gemwire.engage.api.multiblocks.bts; import net.minecraft.state.EnumProperty; import net.minecraft.util.Direction; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/iface/IMultiblockPart.java b/src/main/java/uk/gemwire/engage/api/multiblocks/iface/IMultiblockPart.java similarity index 91% rename from src/main/java/uk/gemwire/engage/multiblocks/iface/IMultiblockPart.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/iface/IMultiblockPart.java index b28c90b..ed53471 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/iface/IMultiblockPart.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/iface/IMultiblockPart.java @@ -1,8 +1,8 @@ -package uk.gemwire.engage.multiblocks.iface; +package uk.gemwire.engage.api.multiblocks.iface; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.math.BlockPos; -import uk.gemwire.engage.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; import java.util.Set; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/iface/IMultiblockRegistry.java b/src/main/java/uk/gemwire/engage/api/multiblocks/iface/IMultiblockRegistry.java similarity index 74% rename from src/main/java/uk/gemwire/engage/multiblocks/iface/IMultiblockRegistry.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/iface/IMultiblockRegistry.java index c036bf8..5fa4abe 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/iface/IMultiblockRegistry.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/iface/IMultiblockRegistry.java @@ -1,7 +1,7 @@ -package uk.gemwire.engage.multiblocks.iface; +package uk.gemwire.engage.api.multiblocks.iface; import net.minecraft.world.World; -import uk.gemwire.engage.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; public interface IMultiblockRegistry { diff --git a/src/main/java/uk/gemwire/engage/multiblocks/te/MultiblockControllerBase.java b/src/main/java/uk/gemwire/engage/api/multiblocks/te/MultiblockControllerBase.java similarity index 98% rename from src/main/java/uk/gemwire/engage/multiblocks/te/MultiblockControllerBase.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/te/MultiblockControllerBase.java index af8721f..3f4f045 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/te/MultiblockControllerBase.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/te/MultiblockControllerBase.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.te; +package uk.gemwire.engage.api.multiblocks.te; import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompoundNBT; @@ -10,13 +10,13 @@ import net.minecraft.world.chunk.Chunk; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import uk.gemwire.engage.Engage; +import uk.gemwire.engage.api.multiblocks.bts.MultiblockRegistry; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockRegistry; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; +import uk.gemwire.engage.api.multiblocks.validation.ValidationError; import uk.gemwire.engage.blocks.ModTileEntity; import uk.gemwire.engage.misc.Helper; -import uk.gemwire.engage.multiblocks.bts.MultiblockRegistry; -import uk.gemwire.engage.multiblocks.iface.IMultiblockPart; -import uk.gemwire.engage.multiblocks.iface.IMultiblockRegistry; -import uk.gemwire.engage.multiblocks.validation.IMultiblockValidator; -import uk.gemwire.engage.multiblocks.validation.ValidationError; import java.util.HashSet; import java.util.LinkedList; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/te/MultiblockTileEntityBase.java b/src/main/java/uk/gemwire/engage/api/multiblocks/te/MultiblockTileEntityBase.java similarity index 97% rename from src/main/java/uk/gemwire/engage/multiblocks/te/MultiblockTileEntityBase.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/te/MultiblockTileEntityBase.java index 53a52da..04d61a1 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/te/MultiblockTileEntityBase.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/te/MultiblockTileEntityBase.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.te; +package uk.gemwire.engage.api.multiblocks.te; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.TileEntity; @@ -6,9 +6,9 @@ import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import uk.gemwire.engage.Engage; +import uk.gemwire.engage.api.multiblocks.bts.MultiblockRegistry; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart; import uk.gemwire.engage.blocks.ModTileEntity; -import uk.gemwire.engage.multiblocks.bts.MultiblockRegistry; -import uk.gemwire.engage.multiblocks.iface.IMultiblockPart; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/te/rectangular/RectangularMultiblockControllerBase.java b/src/main/java/uk/gemwire/engage/api/multiblocks/te/rectangular/RectangularMultiblockControllerBase.java similarity index 95% rename from src/main/java/uk/gemwire/engage/multiblocks/te/rectangular/RectangularMultiblockControllerBase.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/te/rectangular/RectangularMultiblockControllerBase.java index 499e26c..2d99ebc 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/te/rectangular/RectangularMultiblockControllerBase.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/te/rectangular/RectangularMultiblockControllerBase.java @@ -1,11 +1,11 @@ -package uk.gemwire.engage.multiblocks.te.rectangular; +package uk.gemwire.engage.api.multiblocks.te.rectangular; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; -import uk.gemwire.engage.multiblocks.te.MultiblockControllerBase; -import uk.gemwire.engage.multiblocks.validation.IMultiblockValidator; -import uk.gemwire.engage.multiblocks.validation.ValidationError; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; +import uk.gemwire.engage.api.multiblocks.validation.ValidationError; public abstract class RectangularMultiblockControllerBase extends MultiblockControllerBase { diff --git a/src/main/java/uk/gemwire/engage/multiblocks/te/rectangular/RectangularMultiblockTileEntityBase.java b/src/main/java/uk/gemwire/engage/api/multiblocks/te/rectangular/RectangularMultiblockTileEntityBase.java similarity index 92% rename from src/main/java/uk/gemwire/engage/multiblocks/te/rectangular/RectangularMultiblockTileEntityBase.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/te/rectangular/RectangularMultiblockTileEntityBase.java index 3f0c22a..31836a1 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/te/rectangular/RectangularMultiblockTileEntityBase.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/te/rectangular/RectangularMultiblockTileEntityBase.java @@ -1,13 +1,13 @@ -package uk.gemwire.engage.multiblocks.te.rectangular; +package uk.gemwire.engage.api.multiblocks.te.rectangular; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; -import uk.gemwire.engage.multiblocks.bts.BlockFacing; -import uk.gemwire.engage.multiblocks.bts.PartPosition; -import uk.gemwire.engage.multiblocks.te.MultiblockControllerBase; -import uk.gemwire.engage.multiblocks.te.MultiblockTileEntityBase; -import uk.gemwire.engage.multiblocks.validation.IMultiblockValidator; +import uk.gemwire.engage.api.multiblocks.bts.BlockFacing; +import uk.gemwire.engage.api.multiblocks.bts.PartPosition; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.te.MultiblockTileEntityBase; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; import javax.annotation.Nonnull; import javax.annotation.Nullable; diff --git a/src/main/java/uk/gemwire/engage/multiblocks/validation/IMultiblockValidator.java b/src/main/java/uk/gemwire/engage/api/multiblocks/validation/IMultiblockValidator.java similarity index 77% rename from src/main/java/uk/gemwire/engage/multiblocks/validation/IMultiblockValidator.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/validation/IMultiblockValidator.java index dfc72a6..8569e08 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/validation/IMultiblockValidator.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/validation/IMultiblockValidator.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.validation; +package uk.gemwire.engage.api.multiblocks.validation; public interface IMultiblockValidator { diff --git a/src/main/java/uk/gemwire/engage/multiblocks/validation/ValidationError.java b/src/main/java/uk/gemwire/engage/api/multiblocks/validation/ValidationError.java similarity index 92% rename from src/main/java/uk/gemwire/engage/multiblocks/validation/ValidationError.java rename to src/main/java/uk/gemwire/engage/api/multiblocks/validation/ValidationError.java index e1c4b26..52626b1 100644 --- a/src/main/java/uk/gemwire/engage/multiblocks/validation/ValidationError.java +++ b/src/main/java/uk/gemwire/engage/api/multiblocks/validation/ValidationError.java @@ -1,4 +1,4 @@ -package uk.gemwire.engage.multiblocks.validation; +package uk.gemwire.engage.api.multiblocks.validation; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; diff --git a/src/main/java/uk/gemwire/engage/blocks/Blocks.java b/src/main/java/uk/gemwire/engage/blocks/Blocks.java index 13fe7f1..c49f0c7 100644 --- a/src/main/java/uk/gemwire/engage/blocks/Blocks.java +++ b/src/main/java/uk/gemwire/engage/blocks/Blocks.java @@ -2,10 +2,26 @@ package uk.gemwire.engage.blocks; import net.minecraftforge.registries.ObjectHolder; import uk.gemwire.engage.blocks.util.WCoreStruct; +import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockPort; +import uk.gemwire.engage.multiblock.warpcore.block.WarpCoreBlockWall; public class Blocks { @ObjectHolder("engage:wcoreextern") public static WCoreStruct WCORESTRUCT; + @ObjectHolder("engage:warpcorewall") + public static WarpCoreBlockWall WCOREWALL; + + @ObjectHolder("engage:warpcorepower") + public static WarpCoreBlockPort WCOREPOWER; + + @ObjectHolder("engage:warpcoreinput") + public static WarpCoreBlockPort WCOREINPUT; + + @ObjectHolder("engage:warpcoreoutput") + public static WarpCoreBlockPort WCOREOUTPUT; + + + } diff --git a/src/main/java/uk/gemwire/engage/blocks/tileEntities/EngageTETypes.java b/src/main/java/uk/gemwire/engage/blocks/tileEntities/EngageTETypes.java new file mode 100644 index 0000000..45d2def --- /dev/null +++ b/src/main/java/uk/gemwire/engage/blocks/tileEntities/EngageTETypes.java @@ -0,0 +1,19 @@ +package uk.gemwire.engage.blocks.tileEntities; + +import net.minecraft.tileentity.TileEntityType; +import net.minecraftforge.registries.ObjectHolder; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreIOPortTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity; + +public class EngageTETypes { + + @ObjectHolder("engage:warpcorebase") + public static TileEntityType WarpCoreBaseType; + + @ObjectHolder("engage:warpcorepower") + public static TileEntityType WarpCorePowerType; + + @ObjectHolder("engage:warpcoreport") + public static TileEntityType WarpCorePortType; +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/WarpCoreController.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/WarpCoreController.java new file mode 100644 index 0000000..751c130 --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/WarpCoreController.java @@ -0,0 +1,289 @@ +package uk.gemwire.engage.multiblock.warpcore; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.world.World; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.te.rectangular.RectangularMultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; +import uk.gemwire.engage.blocks.ModTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreIOPortTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity; + +public class WarpCoreController extends RectangularMultiblockControllerBase { + + private static final int MACHINE_SIZE = 3; + + private WarpCoreIOPortTileEntity inputPort; + private WarpCoreIOPortTileEntity outputPort; + private WarpCorePowerTileEntity powerPort; + private boolean active; + + public WarpCoreController(World world) { + super(world); + + this.inputPort = this.outputPort = null; + this.powerPort = null; + this.active = false; + } + + public boolean isActive() { + return active; + } + + public void toggleActive() { + this.setActive(!this.active); + } + + public void setActive(boolean active) { + + if (this.active == active) + return; + + this.active = active; + + if (!this.WORLD.isRemote) { + this.markReferenceCoordForUpdate(); + this.markReferenceCoordDirty(); + } else + this.markMultiblockForRenderUpdate(); + + } + + @Override + protected boolean isBlockGoodForFrame(World world, int x, int y, int z, IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z); + return false; + } + + @Override + protected boolean isBlockGoodForBottom(World world, int x, int y, int z, IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z); + return false; + } + + @Override + protected boolean isBlockGoodForInterior(World world, int x, int y, int z, IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z); + return false; + } + + @Override + protected boolean isBlockGoodForSides(World world, int x, int y, int z, IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z); + return false; + } + + @Override + protected boolean isBlockGoodForTop(World world, int x, int y, int z, IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.invalid_block", x, y, z); + return false; + } + + @Override + protected void onBlockAdded(IMultiblockPart part) { + + } + + @Override + protected void onBlockRemoved(IMultiblockPart part) { + if (part instanceof WarpCoreTileEntity) { + WarpCoreTileEntity tile = (WarpCoreTileEntity) part; + + if (tile == this.powerPort) + this.powerPort = null; + } else if (part instanceof WarpCoreIOPortTileEntity) { + WarpCoreIOPortTileEntity tile = (WarpCoreIOPortTileEntity) part; + + if (tile == this.outputPort) { + this.outputPort = null; + } else if (tile == this.inputPort) { + this.inputPort = null; + } + } + } + + @Override + protected boolean isMachineWhole(IMultiblockValidator validatorCallback) { + WarpCorePowerTileEntity powerPort = null; + WarpCoreIOPortTileEntity inputPort = null; + WarpCoreIOPortTileEntity outputPort = null; + + if (!super.isMachineWhole(validatorCallback)) + return false; + + + for (IMultiblockPart part : this.connectedParts) { + if (part instanceof WarpCorePowerTileEntity) { + if (powerPort != null) { + validatorCallback.setLastError("engage:multiblock.error.powerport_already_present"); + return false; + } + + powerPort = (WarpCorePowerTileEntity) part; + } else if (part instanceof WarpCoreIOPortTileEntity) { + WarpCoreIOPortTileEntity io = (WarpCoreIOPortTileEntity) part; + + boolean isInput = io.isInput(); + + if (isInput) { + if (inputPort != null) { + validatorCallback.setLastError("engage:multiblock.error.inputport_already_present"); + return false; + } + inputPort = io; + } else { + if (outputPort != null) { + validatorCallback.setLastError("engage:multiblock.error.outputport_already_present"); + return false; + } + + outputPort = io; + } + } + + } + + + if (powerPort == null) { + validatorCallback.setLastError("engage:multiblock.error.powerport_missing"); + return false; + } + + + if (inputPort == null) { + validatorCallback.setLastError("engage:multiblock.error.inputport_missing"); + return false; + } + + if (outputPort == null) { + validatorCallback.setLastError("engage:multiblock.error.outputport_missing"); + return false; + } + + return true; + } + + @Override + protected void onMachineAssembled() { + this.lookupPorts(); + + if (this.WORLD.isRemote) + this.markMultiblockForRenderUpdate(); + + + } + + @Override + protected void onMachineRestored() { + this.onMachineAssembled(); + } + + @Override + protected void onMachinePaused() { + if (this.WORLD.isRemote) + this.markMultiblockForRenderUpdate(); + } + + @Override + protected void onMachineDisassembled() { + if (this.WORLD.isRemote) + this.markMultiblockForRenderUpdate(); + } + + @Override + public void onAttachedPartWithMultiblockData(IMultiblockPart part, CompoundNBT data) { + + } + + @Override + protected void onAssimilate(MultiblockControllerBase assimilatedController) { + + } + + @Override + protected void onAssimilated(MultiblockControllerBase asssimilatorController) { + + } + + @Override + protected int getMinBlocksInFullMachine() { + return 27; + } + + @Override + protected int getMaxXSize() { + return MACHINE_SIZE; + } + + @Override + protected int getMaxYSize() { + return MACHINE_SIZE; + } + + @Override + protected int getMaxZSize() { + return MACHINE_SIZE; + } + + @Override + protected int getMinXSize() { + return MACHINE_SIZE; + } + + @Override + protected int getMinYSize() { + return MACHINE_SIZE; + } + + @Override + protected int getMinZSize() { + return MACHINE_SIZE; + } + + @Override + protected boolean updateServer() { + return false; + } + + @Override + protected void updateClient() { + + } + + @Override + public void syncDataFrom(CompoundNBT data, ModTileEntity.SyncReason syncReason) { + if (data.contains("isActive")) + this.setActive(data.getBoolean("isActive")); + } + + @Override + public void syncDataTo(CompoundNBT data, ModTileEntity.SyncReason syncReason) { + data.putBoolean("isActive", this.isActive()); + } + + private void lookupPorts() { + + this.outputPort = null; + this.inputPort = null; + this.powerPort = null; + + for (IMultiblockPart part : this.connectedParts) { + if (part instanceof WarpCorePowerTileEntity) + this.powerPort = (WarpCorePowerTileEntity) part; + + if (part instanceof WarpCoreIOPortTileEntity) { + + WarpCoreIOPortTileEntity io = (WarpCoreIOPortTileEntity) part; + + if (io.isInput()) + this.inputPort = io; + else + this.outputPort = io; + + } + } + + } +} \ No newline at end of file diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockBase.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockBase.java new file mode 100644 index 0000000..27e23fb --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockBase.java @@ -0,0 +1,92 @@ +package uk.gemwire.engage.multiblock.warpcore.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.world.IBlockReader; +import net.minecraft.world.World; +import uk.gemwire.engage.api.multiblocks.iface.IMultiblockPart; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.validation.ValidationError; +import uk.gemwire.engage.blocks.tileEntities.EngageTETypes; +import uk.gemwire.engage.multiblock.warpcore.WarpCoreController; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreIOPortTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCorePowerTileEntity; +import uk.gemwire.engage.multiblock.warpcore.tile.WarpCoreTileEntity; + +import javax.annotation.Nullable; + +public class WarpCoreBlockBase extends Block { + + private WarpCoreBlockType myType; + + protected WarpCoreBlockBase(WarpCoreBlockType blockType) { + super(Properties.create(Material.IRON).hardnessAndResistance(1.5F, 10.0F).sound(SoundType.METAL)); + + this.myType = blockType; + + } + + + @Override + public boolean hasTileEntity(BlockState state) { + return true; + } + + @Nullable + @Override + public TileEntity createTileEntity(BlockState state, IBlockReader world) { + switch(this.myType) { + default: + return new WarpCoreTileEntity(EngageTETypes.WarpCoreBaseType); + case Power: + return new WarpCorePowerTileEntity(EngageTETypes.WarpCorePowerType); + case Input: + return new WarpCoreIOPortTileEntity(EngageTETypes.WarpCorePortType, true); + case Output: + return new WarpCoreIOPortTileEntity(EngageTETypes.WarpCorePortType, false); + } + } + + @Override + public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult ray) { + if(world.isRemote || (hand != Hand.OFF_HAND || (player.getHeldItem(hand) == ItemStack.EMPTY))) + return ActionResultType.FAIL; + + WarpCoreController controller = this.getWarpController(world, pos); + + if(controller != null) { + if(player.isCrouching()) { + controller.toggleActive(); + return ActionResultType.SUCCESS; + } else { + ValidationError status = controller.getLastError(); + + if(status != null) { + player.sendMessage(status.getChatMessage()); + } + } + } + return ActionResultType.FAIL; + } + + protected IMultiblockPart getMultiblockPartAt(World world, BlockPos pos) { + TileEntity te = world.getTileEntity(pos); + + return te instanceof IMultiblockPart ? (IMultiblockPart) te : null; + } + + protected WarpCoreController getWarpController(World world, BlockPos pos) { + MultiblockControllerBase controller = this.getMultiblockPartAt(world, pos).getMultiblockController(); + + return controller instanceof WarpCoreController ? (WarpCoreController) controller : null; + } +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockPort.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockPort.java new file mode 100644 index 0000000..1a16b73 --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockPort.java @@ -0,0 +1,86 @@ +package uk.gemwire.engage.multiblock.warpcore.block; + +import net.minecraft.block.BlockState; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.state.BooleanProperty; +import net.minecraft.state.DirectionProperty; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class WarpCoreBlockPort extends WarpCoreBlockBase { + + public static final BooleanProperty ASSEMBLED = BooleanProperty.create("assembled"); + public static final DirectionProperty HFACING = DirectionProperty.create("hfacing", Direction.Plane.HORIZONTAL); + + public WarpCoreBlockPort(WarpCoreBlockType type) { + super(type); + + if(type == WarpCoreBlockType.Wall) + throw new IllegalArgumentException("Invalid port type on warp core!"); + + this.setDefaultState(this.getDefaultState().with(HFACING, Direction.NORTH).with(ASSEMBLED, false)); + } + + @Override + public BlockState getStateForPlacement(BlockItemUseContext c) { + PlayerEntity player = c.getPlayer(); + Direction facing = (player != null) ? player.getHorizontalFacing().getOpposite() : Direction.NORTH; + + return this.getDefaultState().with(HFACING, facing); + } + + @Override + public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState newstate, boolean moving) { + Direction dir = this.suggestDefaultFacing(world, pos, state.get(HFACING)); + world.setBlockState(pos, state.with(HFACING, dir), 2); + } + + protected Direction suggestDefaultFacing(World world, BlockPos pos, Direction currentDir) { + + Direction oppositeDir = currentDir.getOpposite(); + BlockState facingBlockState = world.getBlockState(pos.offset(currentDir)); + BlockState oppositeBlockState = world.getBlockState(pos.offset(oppositeDir)); + + return facingBlockState.isSolid() && !oppositeBlockState.isSolid() ? oppositeDir : currentDir; + } + + /* + + IMultiblockPart part = this.getMultiblockPartAt(world.getWorld(), pos1); + + if(part instanceof WarpCoreTileEntity) { + WarpCoreTileEntity wallTile = (WarpCoreTileEntity) part; + + boolean assembled = wallTile.isConnected() && wallTile.getMultiblockController().isAssembled(); + + state = state.with(ASSEMBLED, assembled); + + if(assembled) { + switch(wallTile.getPartPosition()) { + case NorthFace: + state = state.with(HFACING, Direction.NORTH); + break; + + case SouthFace: + state = state.with(HFACING, Direction.SOUTH); + break; + + case WestFace: + state = state.with(HFACING, Direction.WEST); + break; + + case EastFace: + state = state.with(HFACING, Direction.EAST); + break; + } + } + } + + return state; + + */ + + +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockType.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockType.java new file mode 100644 index 0000000..bd397ff --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockType.java @@ -0,0 +1,17 @@ +package uk.gemwire.engage.multiblock.warpcore.block; + + +import net.minecraft.util.IStringSerializable; + +public enum WarpCoreBlockType implements IStringSerializable { + + Wall, + Power, + Input, + Output; + + @Override + public String getName() { + return super.toString(); + } +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockWall.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockWall.java new file mode 100644 index 0000000..a60cb4f --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/block/WarpCoreBlockWall.java @@ -0,0 +1,33 @@ +package uk.gemwire.engage.multiblock.warpcore.block; + +import com.google.common.collect.Lists; +import net.minecraft.state.EnumProperty; +import uk.gemwire.engage.api.multiblocks.bts.BlockFacingProperty; + +import java.util.ArrayList; + +public class WarpCoreBlockWall extends WarpCoreBlockBase { + + private final static EnumProperty FACES; + + + public WarpCoreBlockWall() { + super(WarpCoreBlockType.Wall); + this.setDefaultState(this.getDefaultState().with(FACES, BlockFacingProperty.All)); + } + + + + static { + + ArrayList values = Lists.newArrayList(); + + values.addAll(BlockFacingProperty.ALL_AND_NONE); + values.addAll(BlockFacingProperty.FACES); + values.addAll(BlockFacingProperty.ANGLES); + values.addAll(BlockFacingProperty.CORNERS); + values.add(BlockFacingProperty.Opposite_EW); + + FACES = EnumProperty.create("faces", BlockFacingProperty.class, values); + } +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCoreIOPortTileEntity.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCoreIOPortTileEntity.java new file mode 100644 index 0000000..b92b563 --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCoreIOPortTileEntity.java @@ -0,0 +1,59 @@ +package uk.gemwire.engage.multiblock.warpcore.tile; + +import net.minecraft.nbt.CompoundNBT; +import net.minecraft.tileentity.TileEntityType; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; + +public class WarpCoreIOPortTileEntity extends WarpCoreTileEntity { + + protected boolean isInput; + + public WarpCoreIOPortTileEntity(TileEntityType type, boolean isInput) { + super(type); + isInput = false; + } + + public WarpCoreIOPortTileEntity(TileEntityType type) { + this(type, false); + } + + @Override + public boolean isGoodForTop(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.ioport_invalid_position"); + return false; + } + @Override + public boolean isGoodForBottom(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.ioport_invalid_position"); + return false; + } + @Override + public boolean isGoodForFrame(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.ioport_invalid_position"); + return false; + } + @Override + public boolean isGoodForInterior(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.ioport_invalid_position"); + return false; + } + + public boolean isInput() { + return isInput; + } + + @Override + protected void syncDataFrom(CompoundNBT data, SyncReason reason) { + super.syncDataFrom(data, reason); + + if(data.contains("IODir")) + this.isInput = data.getBoolean("IODir"); + } + + @Override + protected void syncDataTo(CompoundNBT data, SyncReason reason) { + super.syncDataTo(data, reason); + + data.putBoolean("IODir", this.isInput); + } +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCorePowerTileEntity.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCorePowerTileEntity.java new file mode 100644 index 0000000..fc5d09d --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCorePowerTileEntity.java @@ -0,0 +1,32 @@ +package uk.gemwire.engage.multiblock.warpcore.tile; + +import net.minecraft.tileentity.TileEntityType; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; + +public class WarpCorePowerTileEntity extends WarpCoreTileEntity { + + public WarpCorePowerTileEntity(TileEntityType type) { + super(type); + } + + @Override + public boolean isGoodForInterior(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.powerport_invalid_position"); + return false; + } + @Override + public boolean isGoodForTop(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.powerport_invalid_position"); + return false; + } + @Override + public boolean isGoodForBottom(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.powerport_invalid_position"); + return false; + } + @Override + public boolean isGoodForFrame(IMultiblockValidator validatorCallback) { + validatorCallback.setLastError("engage:multiblock.error.powerport_invalid_position"); + return false; + } +} diff --git a/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCoreTileEntity.java b/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCoreTileEntity.java new file mode 100644 index 0000000..a77c2ef --- /dev/null +++ b/src/main/java/uk/gemwire/engage/multiblock/warpcore/tile/WarpCoreTileEntity.java @@ -0,0 +1,63 @@ +package uk.gemwire.engage.multiblock.warpcore.tile; + +import net.minecraft.tileentity.TileEntityType; +import uk.gemwire.engage.api.multiblocks.te.MultiblockControllerBase; +import uk.gemwire.engage.api.multiblocks.te.rectangular.RectangularMultiblockTileEntityBase; +import uk.gemwire.engage.api.multiblocks.validation.IMultiblockValidator; +import uk.gemwire.engage.multiblock.warpcore.WarpCoreController; + +public class WarpCoreTileEntity extends RectangularMultiblockTileEntityBase { + + public WarpCoreTileEntity(TileEntityType type) { + super(type); + } + + @Override + public boolean isGoodForSides(IMultiblockValidator validatorCallback) { + return true; + } + + @Override + public boolean isGoodForFrame(IMultiblockValidator validatorCallback) { + return true; + } + + @Override + public boolean isGoodForTop(IMultiblockValidator validatorCallback) { + return true; + } + + @Override + public boolean isGoodForBottom(IMultiblockValidator validatorCallback) { + return true; + } + + @Override + public boolean isGoodForInterior(IMultiblockValidator validatorCallback) { + return true; + } + + @Override + public void onMachineActivated() { + + } + + @Override + public void onMachineDeactivated() { + + } + + @Override + public MultiblockControllerBase createNewMultiblock() { + return new WarpCoreController(this.world); + } + + @Override + public Class getMultiblockControllerType() { + return WarpCoreController.class; + } + + public WarpCoreController getCoreController() { + return (WarpCoreController)this.getMultiblockController(); + } +}