From db3a6f2c7e3e1f3ebfe4111da18e8ea6fe4fc22f Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Sat, 23 Feb 2019 23:51:37 +0000 Subject: [PATCH] Enough to get the game running --- build.gradle | 5 ++++ src/main/java/techreborn/TechReborn.java | 19 ++++++++++-- .../techreborn/blocks/cable/BlockCable.java | 14 +++++---- .../blocks/tier1/BlockPlayerDetector.java | 3 +- .../events/RegistryEventHandler.java | 30 +++++++++---------- .../java/techreborn/init/TRTileEntities.java | 21 ++++++++++++- src/main/resources/META-INF/mods.toml | 10 ++++++- 7 files changed, 76 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index ce665a787..f8cf7fdcd 100644 --- a/build.gradle +++ b/build.gradle @@ -77,6 +77,11 @@ minecraft { techreborn { source sourceSets.main } + if (findProject(':reborncore') != null) { + reborncore { + source project(":reborncore").sourceSets.main + } + } } } diff --git a/src/main/java/techreborn/TechReborn.java b/src/main/java/techreborn/TechReborn.java index 3d815741a..143d06179 100644 --- a/src/main/java/techreborn/TechReborn.java +++ b/src/main/java/techreborn/TechReborn.java @@ -29,11 +29,15 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.registry.VillagerRegistry; +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 reborncore.RebornCore; import reborncore.api.recipe.RecipeHandler; import reborncore.common.multiblock.MultiblockEventHandler; import reborncore.common.multiblock.MultiblockServerTickHandler; @@ -60,7 +64,7 @@ public class TechReborn { public static final String MOD_ID = "techreborn"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); // @SidedProxy(clientSide = TechReborn.CLIENT_PROXY_CLASS, serverSide = TechReborn.SERVER_PROXY_CLASS) - public static CommonProxy proxy; + public static CommonProxy proxy = new CommonProxy(); public static TechReborn INSTANCE; public static final ItemGroup ITEMGROUP = new ItemGroup(-1, MOD_ID) { @@ -72,6 +76,16 @@ public class TechReborn { public TechReborn() { + IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus(); + eventBus.addListener(this::setup); + } + + private void setup(FMLCommonSetupEvent event) { +// if(!RebornCore.LOADED){ +// throw new RuntimeException("RebornCore has not loaded!"); +// } else { +// System.out.println("Hello Reborn Core, I see you are loaded and ready."); +// } MinecraftForge.EVENT_BUS.register(this); INSTANCE = this; @@ -95,7 +109,8 @@ public class TechReborn { ModLoot.init(); MinecraftForge.EVENT_BUS.register(new ModLoot()); // Sounds - ModSounds.init(); + //TODO 1.13 registry events + //ModSounds.init(); // Client only init, needs to be done before parts system proxy.init(); // WorldGen diff --git a/src/main/java/techreborn/blocks/cable/BlockCable.java b/src/main/java/techreborn/blocks/cable/BlockCable.java index bcd232ade..ca7127433 100644 --- a/src/main/java/techreborn/blocks/cable/BlockCable.java +++ b/src/main/java/techreborn/blocks/cable/BlockCable.java @@ -32,6 +32,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.state.AbstractProperty; import net.minecraft.state.BooleanProperty; +import net.minecraft.state.StateContainer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; @@ -40,6 +41,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.World; +import net.minecraft.world.chunk.BlockStateContainer; import reborncore.api.ToolManager; import reborncore.common.blocks.BlockWrenchEventHandler; import reborncore.common.registration.RebornRegister; @@ -78,7 +80,7 @@ public class BlockCable extends BlockContainer { public BlockCable(TRContent.Cables type) { super(Block.Properties.create(Material.ROCK).hardnessAndResistance(1f, 8f)); this.type = type; - setDefaultState(getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false).with(SOUTH, false).with(UP, false).with(DOWN, false)); + setDefaultState(this.stateContainer.getBaseState().with(EAST, false).with(WEST, false).with(NORTH, false).with(SOUTH, false).with(UP, false).with(DOWN, false)); BlockWrenchEventHandler.wrenableBlocks.add(this); } @@ -141,6 +143,11 @@ public class BlockCable extends BlockContainer { return super.onBlockActivated(state, worldIn, pos, playerIn, hand, side, hitX, hitY, hitZ); } + @Override + protected void fillStateContainer(StateContainer.Builder builder) { + builder.add(EAST, WEST, NORTH, SOUTH, UP, DOWN); + } + /* @Override @@ -166,11 +173,6 @@ public class BlockCable extends BlockContainer { return false; } - @Override - protected BlockStateContainer createBlockState() { - return new BlockStateContainer(this, EAST, WEST, NORTH, SOUTH, UP, DOWN); - } - @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return getStateFromMeta(meta); diff --git a/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java b/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java index f87a913f1..825f7e386 100644 --- a/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java +++ b/src/main/java/techreborn/blocks/tier1/BlockPlayerDetector.java @@ -26,6 +26,7 @@ package techreborn.blocks.tier1; import com.google.common.collect.Lists; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.resources.I18n; import net.minecraft.entity.EntityLivingBase; @@ -65,7 +66,7 @@ public class BlockPlayerDetector extends BlockMachineBase { public static PropertyString TYPE; public BlockPlayerDetector() { - super(); + super(Block.Properties.create(Material.IRON), true); this.setDefaultState(this.stateContainer.getBaseState().with(TYPE, types[0])); for (int i = 0; i < types.length; i++) { RebornModelRegistry.registerModel(new ModelCompound(TechReborn.MOD_ID, this, i, "machines/tier1_machines").setInvVariant("type=" + types[i])); diff --git a/src/main/java/techreborn/events/RegistryEventHandler.java b/src/main/java/techreborn/events/RegistryEventHandler.java index 06b36e763..477a6415e 100644 --- a/src/main/java/techreborn/events/RegistryEventHandler.java +++ b/src/main/java/techreborn/events/RegistryEventHandler.java @@ -56,29 +56,29 @@ import java.util.Arrays; * */ -@Mod.EventBusSubscriber(modid = TechReborn.MOD_ID) +@Mod.EventBusSubscriber(modid = TechReborn.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD) public class RegistryEventHandler { @SubscribeEvent public static void registerBlocks(RegistryEvent.Register event) { - Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties())); - Arrays.stream(StorageBlocks.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties())); + Arrays.stream(Ores.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); + Arrays.stream(StorageBlocks.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); Arrays.stream(MachineBlocks.values()).forEach(value -> { - RebornRegistry.registerBlock(value.frame, new Item.Properties()); - RebornRegistry.registerBlock(value.casing, new Item.Properties()); + RebornRegistry.registerBlock(value.frame, new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(value.casing, new Item.Properties().group(TechReborn.ITEMGROUP)); }); - Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties())); - Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties())); - Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties())); + Arrays.stream(SolarPanels.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); + Arrays.stream(Cables.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); + Arrays.stream(Machine.values()).forEach(value -> RebornRegistry.registerBlock(value.block, new Item.Properties().group(TechReborn.ITEMGROUP))); // Misc. blocks - RebornRegistry.registerBlock(TRContent.COMPUTER_CUBE = InitUtils.setup(new BlockComputerCube(), "computer_cube"), new Item.Properties()); - RebornRegistry.registerBlock(TRContent.NUKE = InitUtils.setup(new BlockNuke(), "nuke"), new Item.Properties()); - RebornRegistry.registerBlock(TRContent.REFINED_IRON_FENCE = InitUtils.setup(new BlockRefinedIronFence(), "refined_iron_fence"), new Item.Properties()); - RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), new Item.Properties()); - RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), new Item.Properties()); - RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), new Item.Properties()); - RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), new Item.Properties()); + RebornRegistry.registerBlock(TRContent.COMPUTER_CUBE = InitUtils.setup(new BlockComputerCube(), "computer_cube"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.NUKE = InitUtils.setup(new BlockNuke(), "nuke"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.REFINED_IRON_FENCE = InitUtils.setup(new BlockRefinedIronFence(), "refined_iron_fence"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), new Item.Properties().group(TechReborn.ITEMGROUP)); + RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), new Item.Properties().group(TechReborn.ITEMGROUP)); RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"), ItemBlockRubberSapling.class, "rubber_sapling"); diff --git a/src/main/java/techreborn/init/TRTileEntities.java b/src/main/java/techreborn/init/TRTileEntities.java index b7fd76de3..dce6bc636 100644 --- a/src/main/java/techreborn/init/TRTileEntities.java +++ b/src/main/java/techreborn/init/TRTileEntities.java @@ -24,8 +24,13 @@ package techreborn.init; +import com.mojang.datafixers.DataFixUtils; +import com.mojang.datafixers.types.Type; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityType; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.datafix.DataFixesManager; +import net.minecraft.util.datafix.TypeReferences; import reborncore.common.tile.TileMachineBase; import techreborn.tiles.*; import techreborn.tiles.cable.TileCable; @@ -53,6 +58,8 @@ import techreborn.tiles.transformers.TileHVTransformer; import techreborn.tiles.transformers.TileLVTransformer; import techreborn.tiles.transformers.TileMVTransformer; +import java.util.function.Supplier; + public class TRTileEntities { public static final TileEntityType THERMAL_GEN = register(TileThermalGenerator.class, "thermal_generator"); @@ -115,7 +122,19 @@ public class TRTileEntities { public static final TileEntityType FLUID_REPLICATOR = register(TileFluidReplicator.class, "fluid_replicator"); public static TileEntityType register(Class tClass, String name) { - return null; + return register(new ResourceLocation("techrebonr", name).toString(), TileEntityType.Builder.create(() -> { + //TODO clean this up + try { + return tClass.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + throw new RuntimeException("Failed to create tile", e); + } + })); + } + + public static TileEntityType register(String id, TileEntityType.Builder builder) { + TileEntityType tileEntityType = builder.build(null); + return tileEntityType; } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 28119f2d3..52ab04c31 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,8 +1,16 @@ modLoader="javafml" loaderVersion="[13,)" +version="1" [[mods]] modId="techreborn" version="${version}" displayName="Tech Reborn" - description="Tech Reborn" \ No newline at end of file + description="Tech Reborn" + +[[dependencies.techreborn]] + modId="reborncore" + mandatory=true + ordering="AFTER" + side="BOTH" + versionRange="[4.0.0,)" \ No newline at end of file