mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-01-18 16:37:23 +01:00
added structure config generator block with functionality
This commit is contained in:
11
build.gradle
11
build.gradle
@@ -20,10 +20,9 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.16.5-0.1.32-T' + System.currentTimeMillis()
|
||||
version = '1.16.5-0.1.33-T' + System.currentTimeMillis()
|
||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'MasterfulMachinery'
|
||||
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
|
||||
|
||||
configurations {
|
||||
@@ -156,10 +155,10 @@ dependencies {
|
||||
|
||||
shade 'com.github.marschall:memoryfilesystem:2.1.0'
|
||||
|
||||
compileOnly fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
|
||||
// runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:additions")// Mekanism: Additions
|
||||
// runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")// Mekanism: Generators
|
||||
// runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")// Mekanism: Tools
|
||||
implementation fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
|
||||
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:additions")// Mekanism: Additions
|
||||
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")// Mekanism: Generators
|
||||
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")// Mekanism: Tools
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api")
|
||||
// at runtime, use the full JEI jar
|
||||
|
||||
@@ -6,9 +6,11 @@ import com.ticticboooom.mods.mm.block.ControllerBlock;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
|
||||
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
|
||||
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
|
||||
import com.ticticboooom.mods.mm.client.screen.ControllerBlockContainerScreen;
|
||||
import com.ticticboooom.mods.mm.client.screen.PortBlockContainerScreen;
|
||||
import com.ticticboooom.mods.mm.client.screen.StructureGenBlockContainerScreen;
|
||||
import com.ticticboooom.mods.mm.client.ter.StructureGenTileEntityRenderer;
|
||||
import com.ticticboooom.mods.mm.datagen.MMPackFinder;
|
||||
import com.ticticboooom.mods.mm.datagen.MemoryDataGeneratorFactory;
|
||||
import com.ticticboooom.mods.mm.datagen.PackType;
|
||||
@@ -24,6 +26,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -31,6 +34,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
@@ -103,6 +107,7 @@ public class MM {
|
||||
for (RegistryObject<ContainerType<ControllerBlockContainer>> container : MMLoader.CONTAINERS) {
|
||||
ScreenManager.registerFactory(container.get(), ControllerBlockContainerScreen::new);
|
||||
}
|
||||
|
||||
for (RegistryObject<ContainerType<?>> container : MMLoader.PORT_CONTAINERS) {
|
||||
ScreenManager.registerFactory((ContainerType<PortBlockContainer>) container.get(), PortBlockContainerScreen::new);
|
||||
}
|
||||
@@ -118,7 +123,10 @@ public class MM {
|
||||
for (RegistryObject<MachinePortBlock> block : MMLoader.OPORT_BLOCKS) {
|
||||
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.getSolid() || layer == RenderType.getTranslucent());
|
||||
}
|
||||
|
||||
|
||||
RenderTypeLookup.setRenderLayer(MMSetup.PROJECTOR_BLOCK.get(), RenderType.getTranslucent());
|
||||
ScreenManager.registerFactory(MMSetup.STRUCTURE_CONTAINER.get(), StructureGenBlockContainerScreen::new);
|
||||
ClientRegistry.bindTileEntityRenderer(MMSetup.STRUCTURE_TILE.get(), StructureGenTileEntityRenderer::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,42 +29,101 @@ public class ProjectorBlock extends Block {
|
||||
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
private static final VoxelShape SHAPE_N = Stream.of(
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
|
||||
Block.makeCuboidShape(0, 8, 0, 4, 10, 16),
|
||||
Block.makeCuboidShape(4, 8, 8, 16, 12, 16),
|
||||
Block.makeCuboidShape(12, 8, 0, 16, 10, 8),
|
||||
Block.makeCuboidShape(5, 8, 1, 11, 12, 7),
|
||||
Block.makeCuboidShape(5, 12, 9, 11, 16, 15)
|
||||
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
|
||||
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
|
||||
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
|
||||
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
|
||||
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
|
||||
Block.makeCuboidShape(0.75, 2.5, 6.75, 2.25, 4.75, 9.25),
|
||||
Block.makeCuboidShape(13.75, 2.5, 6.75, 15.25, 4.75, 9.25),
|
||||
Block.makeCuboidShape(6, 3.5, 14, 7, 12.75, 15),
|
||||
Block.makeCuboidShape(5.75, 11.25, 13.75, 7.25, 13.5, 15.25),
|
||||
Block.makeCuboidShape(5.75, 2.5, 13.75, 7.25, 4.75, 15.25),
|
||||
Block.makeCuboidShape(8.75, 11.25, 13.75, 10.25, 13.5, 15.25),
|
||||
Block.makeCuboidShape(8.75, 2.5, 13.75, 10.25, 4.75, 15.25),
|
||||
Block.makeCuboidShape(9, 3.5, 14, 10, 12.75, 15),
|
||||
Block.makeCuboidShape(1.25, 6.25, 7.5, 2.25, 7.25, 8.5),
|
||||
Block.makeCuboidShape(13.75, 6.25, 7.5, 14.75, 7.25, 8.5),
|
||||
Block.makeCuboidShape(14, 3.5, 7, 15, 7.75, 9),
|
||||
Block.makeCuboidShape(1, 3.5, 7, 2, 7.75, 9),
|
||||
Block.makeCuboidShape(11, 2, 6, 15, 4, 10),
|
||||
Block.makeCuboidShape(1, 2, 6, 5, 4, 10),
|
||||
Block.makeCuboidShape(6, 2, 11, 10, 4, 15),
|
||||
Block.makeCuboidShape(6, 12, 9, 10, 15, 15)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
private static final VoxelShape SHAPE_E = Stream.of(
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
|
||||
Block.makeCuboidShape(0, 8, 0, 16, 10, 4),
|
||||
Block.makeCuboidShape(0, 8, 4, 8, 12, 16),
|
||||
Block.makeCuboidShape(8, 8, 12, 16, 10, 16),
|
||||
Block.makeCuboidShape(9, 8, 5, 15, 12, 11),
|
||||
Block.makeCuboidShape(1, 12, 5, 7, 16, 11)
|
||||
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
|
||||
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
|
||||
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
|
||||
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
|
||||
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
|
||||
Block.makeCuboidShape(6.75, 2.5, 0.75, 9.25, 4.75, 2.25),
|
||||
Block.makeCuboidShape(6.75, 2.5, 13.75, 9.25, 4.75, 15.25),
|
||||
Block.makeCuboidShape(1, 3.5, 6, 2, 12.75, 7),
|
||||
Block.makeCuboidShape(0.75, 11.25, 5.75, 2.25, 13.5, 7.25),
|
||||
Block.makeCuboidShape(0.75, 2.5, 5.75, 2.25, 4.75, 7.25),
|
||||
Block.makeCuboidShape(0.75, 11.25, 8.75, 2.25, 13.5, 10.25),
|
||||
Block.makeCuboidShape(0.75, 2.5, 8.75, 2.25, 4.75, 10.25),
|
||||
Block.makeCuboidShape(1, 3.5, 9, 2, 12.75, 10),
|
||||
Block.makeCuboidShape(7.5, 6.25, 1.25, 8.5, 7.25, 2.25),
|
||||
Block.makeCuboidShape(7.5, 6.25, 13.75, 8.5, 7.25, 14.75),
|
||||
Block.makeCuboidShape(7, 3.5, 14, 9, 7.75, 15),
|
||||
Block.makeCuboidShape(7, 3.5, 1, 9, 7.75, 2),
|
||||
Block.makeCuboidShape(6, 2, 11, 10, 4, 15),
|
||||
Block.makeCuboidShape(6, 2, 1, 10, 4, 5),
|
||||
Block.makeCuboidShape(1, 2, 6, 5, 4, 10),
|
||||
Block.makeCuboidShape(1, 12, 6, 7, 15, 10)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
private static final VoxelShape SHAPE_S = Stream.of(
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
|
||||
Block.makeCuboidShape(12, 8, 0, 16, 10, 16),
|
||||
Block.makeCuboidShape(0, 8, 0, 12, 12, 8),
|
||||
Block.makeCuboidShape(0, 8, 8, 4, 10, 16),
|
||||
Block.makeCuboidShape(5, 8, 9, 11, 12, 15),
|
||||
Block.makeCuboidShape(5, 12, 1, 11, 16, 7)
|
||||
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
|
||||
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
|
||||
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
|
||||
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
|
||||
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
|
||||
Block.makeCuboidShape(13.75, 2.5, 6.75, 15.25, 4.75, 9.25),
|
||||
Block.makeCuboidShape(0.75, 2.5, 6.75, 2.25, 4.75, 9.25),
|
||||
Block.makeCuboidShape(9, 3.5, 1, 10, 12.75, 2),
|
||||
Block.makeCuboidShape(8.75, 11.25, 0.75, 10.25, 13.5, 2.25),
|
||||
Block.makeCuboidShape(8.75, 2.5, 0.75, 10.25, 4.75, 2.25),
|
||||
Block.makeCuboidShape(5.75, 11.25, 0.75, 7.25, 13.5, 2.25),
|
||||
Block.makeCuboidShape(5.75, 2.5, 0.75, 7.25, 4.75, 2.25),
|
||||
Block.makeCuboidShape(6, 3.5, 1, 7, 12.75, 2),
|
||||
Block.makeCuboidShape(13.75, 6.25, 7.5, 14.75, 7.25, 8.5),
|
||||
Block.makeCuboidShape(1.25, 6.25, 7.5, 2.25, 7.25, 8.5),
|
||||
Block.makeCuboidShape(1, 3.5, 7, 2, 7.75, 9),
|
||||
Block.makeCuboidShape(14, 3.5, 7, 15, 7.75, 9),
|
||||
Block.makeCuboidShape(1, 2, 6, 5, 4, 10),
|
||||
Block.makeCuboidShape(11, 2, 6, 15, 4, 10),
|
||||
Block.makeCuboidShape(6, 2, 1, 10, 4, 5),
|
||||
Block.makeCuboidShape(6, 12, 1, 10, 15, 7)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
private static final VoxelShape SHAPE_W = Stream.of(
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 8, 16),
|
||||
Block.makeCuboidShape(0, 8, 12, 16, 10, 16),
|
||||
Block.makeCuboidShape(8, 8, 0, 16, 12, 12),
|
||||
Block.makeCuboidShape(0, 8, 0, 8, 10, 4),
|
||||
Block.makeCuboidShape(1, 8, 5, 7, 12, 11),
|
||||
Block.makeCuboidShape(9, 12, 5, 15, 16, 11)
|
||||
Block.makeCuboidShape(4, 2, 4, 12, 3, 12),
|
||||
Block.makeCuboidShape(4, 0, 4, 12, 1, 12),
|
||||
Block.makeCuboidShape(6, 2.5, 6, 10, 3.5, 10),
|
||||
Block.makeCuboidShape(5, 1, 5, 11, 2, 11),
|
||||
Block.makeCuboidShape(5, 6, 5, 11, 12, 11),
|
||||
Block.makeCuboidShape(6.75, 2.5, 13.75, 9.25, 4.75, 15.25),
|
||||
Block.makeCuboidShape(6.75, 2.5, 0.75, 9.25, 4.75, 2.25),
|
||||
Block.makeCuboidShape(14, 3.5, 9, 15, 12.75, 10),
|
||||
Block.makeCuboidShape(13.75, 11.25, 8.75, 15.25, 13.5, 10.25),
|
||||
Block.makeCuboidShape(13.75, 2.5, 8.75, 15.25, 4.75, 10.25),
|
||||
Block.makeCuboidShape(13.75, 11.25, 5.75, 15.25, 13.5, 7.25),
|
||||
Block.makeCuboidShape(13.75, 2.5, 5.75, 15.25, 4.75, 7.25),
|
||||
Block.makeCuboidShape(14, 3.5, 6, 15, 12.75, 7),
|
||||
Block.makeCuboidShape(7.5, 6.25, 13.75, 8.5, 7.25, 14.75),
|
||||
Block.makeCuboidShape(7.5, 6.25, 1.25, 8.5, 7.25, 2.25),
|
||||
Block.makeCuboidShape(7, 3.5, 1, 9, 7.75, 2),
|
||||
Block.makeCuboidShape(7, 3.5, 14, 9, 7.75, 15),
|
||||
Block.makeCuboidShape(6, 2, 1, 10, 4, 5),
|
||||
Block.makeCuboidShape(6, 2, 11, 10, 4, 15),
|
||||
Block.makeCuboidShape(11, 2, 6, 15, 4, 10),
|
||||
Block.makeCuboidShape(9, 12, 6, 15, 15, 10)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder.add(FACING));
|
||||
|
||||
@@ -5,25 +5,110 @@ import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.item.BlockItemUseContext;
|
||||
import net.minecraft.state.DirectionProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.shapes.IBooleanFunction;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class StructureGenBlock extends Block {
|
||||
public StructureGenBlock() {
|
||||
super(Properties.create(Material.IRON));
|
||||
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
|
||||
}
|
||||
|
||||
private static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
|
||||
|
||||
private static final VoxelShape SHAPE_N = Stream.of(
|
||||
Block.makeCuboidShape(1, 2, 1, 15, 5, 6),
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
|
||||
Block.makeCuboidShape(0.5, 2, 6.5, 15.5, 5, 15.5),
|
||||
Block.makeCuboidShape(0, 5, 6, 16, 6, 16),
|
||||
Block.makeCuboidShape(4, 6, 7, 15, 14, 13),
|
||||
Block.makeCuboidShape(1, 5.5, 7, 3, 6.5, 9),
|
||||
Block.makeCuboidShape(1.25, 11, 7.25, 2.75, 11.25, 8.75),
|
||||
Block.makeCuboidShape(1, 6, 11, 3, 12.25, 14),
|
||||
Block.makeCuboidShape(1, 11.25, 6.75, 3, 12.25, 11.25),
|
||||
Block.makeCuboidShape(0, 2, 0, 1, 3, 6),
|
||||
Block.makeCuboidShape(15, 2, 0, 16, 3, 6),
|
||||
Block.makeCuboidShape(0, 2, 6, 1, 5, 7),
|
||||
Block.makeCuboidShape(15, 2, 6, 16, 5, 7),
|
||||
Block.makeCuboidShape(15, 2, 15, 16, 5, 16),
|
||||
Block.makeCuboidShape(0, 2, 15, 1, 5, 16)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
private static final VoxelShape SHAPE_E = Stream.of(
|
||||
Block.makeCuboidShape(10, 2, 1, 15, 5, 15),
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
|
||||
Block.makeCuboidShape(0.5, 2, 0.5, 9.5, 5, 15.5),
|
||||
Block.makeCuboidShape(0, 5, 0, 10, 6, 16),
|
||||
Block.makeCuboidShape(3, 6, 4, 9, 14, 15),
|
||||
Block.makeCuboidShape(7, 5.5, 1, 9, 6.5, 3),
|
||||
Block.makeCuboidShape(7.25, 11, 1.25, 8.75, 11.25, 2.75),
|
||||
Block.makeCuboidShape(2, 6, 1, 5, 12.25, 3),
|
||||
Block.makeCuboidShape(4.75, 11.25, 1, 9.25, 12.25, 3),
|
||||
Block.makeCuboidShape(10, 2, 0, 16, 3, 1),
|
||||
Block.makeCuboidShape(10, 2, 15, 16, 3, 16),
|
||||
Block.makeCuboidShape(9, 2, 0, 10, 5, 1),
|
||||
Block.makeCuboidShape(9, 2, 15, 10, 5, 16),
|
||||
Block.makeCuboidShape(0, 2, 15, 1, 5, 16),
|
||||
Block.makeCuboidShape(0, 2, 0, 1, 5, 1)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
private static final VoxelShape SHAPE_S = Stream.of(
|
||||
Block.makeCuboidShape(1, 2, 10, 15, 5, 15),
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
|
||||
Block.makeCuboidShape(0.5, 2, 0.5, 15.5, 5, 9.5),
|
||||
Block.makeCuboidShape(0, 5, 0, 16, 6, 10),
|
||||
Block.makeCuboidShape(1, 6, 3, 12, 14, 9),
|
||||
Block.makeCuboidShape(13, 5.5, 7, 15, 6.5, 9),
|
||||
Block.makeCuboidShape(13.25, 11, 7.25, 14.75, 11.25, 8.75),
|
||||
Block.makeCuboidShape(13, 6, 2, 15, 12.25, 5),
|
||||
Block.makeCuboidShape(13, 11.25, 4.75, 15, 12.25, 9.25),
|
||||
Block.makeCuboidShape(15, 2, 10, 16, 3, 16),
|
||||
Block.makeCuboidShape(0, 2, 10, 1, 3, 16),
|
||||
Block.makeCuboidShape(15, 2, 9, 16, 5, 10),
|
||||
Block.makeCuboidShape(0, 2, 9, 1, 5, 10),
|
||||
Block.makeCuboidShape(0, 2, 0, 1, 5, 1),
|
||||
Block.makeCuboidShape(15, 2, 0, 16, 5, 1)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
private static final VoxelShape SHAPE_W = Stream.of(
|
||||
Block.makeCuboidShape(1, 2, 1, 6, 5, 15),
|
||||
Block.makeCuboidShape(0, 0, 0, 16, 2, 16),
|
||||
Block.makeCuboidShape(6.5, 2, 0.5, 15.5, 5, 15.5),
|
||||
Block.makeCuboidShape(6, 5, 0, 16, 6, 16),
|
||||
Block.makeCuboidShape(7, 6, 1, 13, 14, 12),
|
||||
Block.makeCuboidShape(7, 5.5, 13, 9, 6.5, 15),
|
||||
Block.makeCuboidShape(7.25, 11, 13.25, 8.75, 11.25, 14.75),
|
||||
Block.makeCuboidShape(11, 6, 13, 14, 12.25, 15),
|
||||
Block.makeCuboidShape(6.75, 11.25, 13, 11.25, 12.25, 15),
|
||||
Block.makeCuboidShape(0, 2, 15, 6, 3, 16),
|
||||
Block.makeCuboidShape(0, 2, 0, 6, 3, 1),
|
||||
Block.makeCuboidShape(6, 2, 15, 7, 5, 16),
|
||||
Block.makeCuboidShape(6, 2, 0, 7, 5, 1),
|
||||
Block.makeCuboidShape(15, 2, 0, 16, 5, 1),
|
||||
Block.makeCuboidShape(15, 2, 15, 16, 5, 16)
|
||||
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(BlockState state) {
|
||||
return true;
|
||||
@@ -39,10 +124,37 @@ public class StructureGenBlock extends Block {
|
||||
public ActionResultType onBlockActivated(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
|
||||
if (!level.isRemote()) {
|
||||
TileEntity blockEntity = level.getTileEntity(pos);
|
||||
if (blockEntity instanceof ControllerBlockEntity) {
|
||||
if (blockEntity instanceof StructureGenBlockEntity) {
|
||||
NetworkHooks.openGui(((ServerPlayerEntity) player), (StructureGenBlockEntity)blockEntity, pos);
|
||||
}
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder.add(FACING));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState getStateForPlacement(BlockItemUseContext ctx) {
|
||||
return this.getDefaultState().with(FACING, ctx.getPlacementHorizontalFacing().getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VoxelShape getShape(BlockState state, IBlockReader p_220053_2_, BlockPos p_220053_3_, ISelectionContext p_220053_4_) {
|
||||
switch (state.get(FACING)) {
|
||||
case NORTH:
|
||||
return SHAPE_N;
|
||||
case EAST:
|
||||
return SHAPE_E;
|
||||
case SOUTH:
|
||||
return SHAPE_S;
|
||||
case WEST:
|
||||
return SHAPE_W;
|
||||
default:
|
||||
throw new IllegalStateException("Invalid State");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,40 @@
|
||||
package com.ticticboooom.mods.mm.block.container;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.container.slot.StructureDeviceSlot;
|
||||
import com.ticticboooom.mods.mm.block.tile.ProjectorBlockEntity;
|
||||
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class StructureGenBlockContainer extends Container {
|
||||
@Getter
|
||||
private StructureGenBlockEntity tile;
|
||||
|
||||
public StructureGenBlockContainer(int windowId, StructureGenBlockEntity tile) {
|
||||
public StructureGenBlockContainer(int windowId, PlayerInventory inv, StructureGenBlockEntity tile) {
|
||||
super(MMSetup.STRUCTURE_CONTAINER.get(), windowId);
|
||||
this.tile = tile;
|
||||
|
||||
this.addSlot(new StructureDeviceSlot(tile.getInv(), 0, 151, -14));
|
||||
|
||||
this.tile = tile;
|
||||
int playerOffsetX = 8;
|
||||
int playerOffsetY = 121;
|
||||
for (int j = 0; j < 3; j++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
this.addSlot(new Slot(inv, 9 + (j * 9 + i), i * 18 + playerOffsetX, j * 18 + playerOffsetY));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
this.addSlot(new Slot(inv, i, 8 + (i * 18), 179));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,6 +43,30 @@ public class StructureGenBlockContainer extends Container {
|
||||
}
|
||||
|
||||
public StructureGenBlockContainer(int w, PlayerInventory inv, PacketBuffer buf) {
|
||||
this(w, (StructureGenBlockEntity) inv.player.world.getTileEntity(buf.readBlockPos()));
|
||||
this(w, inv, (StructureGenBlockEntity) inv.player.world.getTileEntity(buf.readBlockPos()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(PlayerEntity p_82846_1_, int index) {
|
||||
ItemStack itemStack = ItemStack.EMPTY;
|
||||
Slot slot = this.getSlot(index);
|
||||
if (slot.getHasStack()) {
|
||||
ItemStack itemStack1 = slot.getStack();
|
||||
itemStack = itemStack1.copy();
|
||||
if (index < 1) {
|
||||
if (!this.mergeItemStack(itemStack1, 1, this.inventorySlots.size(), true)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (!this.mergeItemStack(itemStack1, 0, 1, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
if (itemStack1.isEmpty()) {
|
||||
slot.putStack(ItemStack.EMPTY);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
}
|
||||
return itemStack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.ticticboooom.mods.mm.block.container.slot;
|
||||
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class StructureDeviceSlot extends Slot {
|
||||
public StructureDeviceSlot(IInventory inventoryIn, int index, int xPosition, int yPosition) {
|
||||
super(inventoryIn, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() == MMSetup.STRUCTURE_DEVICE.get();
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.ticticboooom.mods.mm.block.tile;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.container.StructureGenBlockContainer;
|
||||
import com.ticticboooom.mods.mm.inventory.ItemStackInventory;
|
||||
import com.ticticboooom.mods.mm.model.ProcessUpdate;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
@@ -16,6 +18,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -24,6 +27,11 @@ public class StructureGenBlockEntity extends UpdatableTile implements ITickableT
|
||||
super(MMSetup.STRUCTURE_TILE.get());
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
private ItemStackHandler handler = new ItemStackHandler(1);
|
||||
@Getter
|
||||
private ItemStackInventory inv = new ItemStackInventory(handler);
|
||||
private ItemStack device = ItemStack.EMPTY;
|
||||
|
||||
@Override
|
||||
@@ -55,6 +63,6 @@ public class StructureGenBlockEntity extends UpdatableTile implements ITickableT
|
||||
@Nullable
|
||||
@Override
|
||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
|
||||
return new StructureGenBlockContainer(p_createMenu_1_, this);
|
||||
return new StructureGenBlockContainer(p_createMenu_1_, p_createMenu_2_, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.ticticboooom.mods.mm.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderState;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
|
||||
public class MMRenderTypes extends RenderType {
|
||||
private static final RenderState.LineState THICK_LINES = new RenderState.LineState(OptionalDouble.of(3.0D));
|
||||
|
||||
|
||||
public static final RenderType OUTLINE = makeType("MMOutline",
|
||||
DefaultVertexFormats.POSITION_COLOR, GL11.GL_QUADS, 256,
|
||||
RenderType.State.getBuilder()
|
||||
.line(THICK_LINES)
|
||||
.layer(RenderState.NO_LAYERING)
|
||||
.transparency(RenderState.TRANSLUCENT_TRANSPARENCY)
|
||||
.texture(NO_TEXTURE)
|
||||
.depthTest(DEPTH_LEQUAL)
|
||||
.cull(CULL_DISABLED)
|
||||
.lightmap(LIGHTMAP_DISABLED)
|
||||
.writeMask(COLOR_WRITE)
|
||||
.build(false));
|
||||
|
||||
public MMRenderTypes(String nameIn, VertexFormat formatIn, int drawModeIn, int bufferSizeIn, boolean useDelegateIn, boolean needsSortingIn, Runnable setupTaskIn, Runnable clearTaskIn) {
|
||||
super(nameIn, formatIn, drawModeIn, bufferSizeIn, useDelegateIn, needsSortingIn, setupTaskIn, clearTaskIn);
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,12 @@ import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.helpers.IJeiHelpers;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.java.games.input.Mouse;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DirectionalBlock;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
@@ -50,10 +52,13 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
private double xLastMousePosition = 0;
|
||||
private float yRotation = 0;
|
||||
private double yLastMousePosition = 0;
|
||||
private int scrollLastPos = 0;
|
||||
|
||||
private int sliceY = 0;
|
||||
private boolean slicingActive = false;
|
||||
private Map<Integer, Integer> tagIndexes = new HashMap<>();
|
||||
private Map<Integer, Integer> tagIndexCounter = new HashMap<>();
|
||||
private float scaleFactor = 12F;
|
||||
public MachineStructureRecipeCategory(IJeiHelpers helpers, ControllerBlock controller) {
|
||||
this.helpers = helpers;
|
||||
this.controller = controller;
|
||||
@@ -139,8 +144,13 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
topY = Math.max(part.getPos().getY(), topY);
|
||||
bottomY = Math.min(part.getPos().getY(), bottomY);
|
||||
}
|
||||
int scaleFactor = Math.abs(furthestX) + Math.abs(nearestX) + Math.abs(furthestZ) + Math.abs(nearestZ);
|
||||
scaleFactor = scaleFactor / 4;
|
||||
if (GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != 0){
|
||||
if (scrollLastPos == 0){
|
||||
scrollLastPos = (int) mouseY;
|
||||
}
|
||||
scaleFactor += (mouseY - yLastMousePosition) * 0.05;
|
||||
scaleFactor = Math.max(0.003f, scaleFactor);
|
||||
}
|
||||
nearestX++;
|
||||
nearestZ++;
|
||||
float centreX = ((float) nearestX - furthestX) / 2f;
|
||||
@@ -170,7 +180,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
.withPrePosition(new Vector3f(6.5f, -5, 10))
|
||||
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))
|
||||
.withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true))
|
||||
.withScale(new Vector3f(12f, -12, 12))
|
||||
.withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor))
|
||||
.finalize(matrixStack);
|
||||
}
|
||||
} else if (!part.getTag().equals("")){
|
||||
@@ -185,7 +195,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
tagIndexCounter.put(i, 0);
|
||||
index++;
|
||||
}
|
||||
if (index >= tag.getAllElements().size()){
|
||||
if (index >= tag.getAllElements().size()) {
|
||||
index = 0;
|
||||
}
|
||||
tagIndexes.put(i, index);
|
||||
@@ -195,7 +205,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
.withPrePosition(new Vector3f(6.5f, -5, 10))
|
||||
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))
|
||||
.withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true))
|
||||
.withScale(new Vector3f(12f, -12, 12))
|
||||
.withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor))
|
||||
.finalize(matrixStack);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +224,7 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
.withPrePosition(new Vector3f(6.5f, -5, 10))
|
||||
.withRotation(new Quaternion(new Vector3f(1, 0, 0), 15 + yRotation, true))
|
||||
.withRotation(new Quaternion(new Vector3f(0, -1, 0), 225 - xRotation, true))
|
||||
.withScale(new Vector3f(12f, -12f, 12f))
|
||||
.withScale(new Vector3f(scaleFactor, -scaleFactor, scaleFactor))
|
||||
.finalize(matrixStack);
|
||||
|
||||
}
|
||||
@@ -256,4 +266,5 @@ public class MachineStructureRecipeCategory implements IRecipeCategory<MachineSt
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,28 +3,55 @@ package com.ticticboooom.mods.mm.client.screen;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.container.StructureGenBlockContainer;
|
||||
import com.ticticboooom.mods.mm.helper.StructureHelper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
public class StructureGenBlockContainerScreen extends ContainerScreen<StructureGenBlockContainer> {
|
||||
public StructureGenBlockContainerScreen(StructureGenBlockContainer p_i51105_1_, PlayerInventory p_i51105_2_, ITextComponent p_i51105_3_) {
|
||||
super(p_i51105_1_, p_i51105_2_, p_i51105_3_);
|
||||
}
|
||||
private final StructureGenBlockContainer cont;
|
||||
|
||||
public StructureGenBlockContainerScreen(StructureGenBlockContainer cont, PlayerInventory p_i51105_2_, ITextComponent p_i51105_3_) {
|
||||
super(cont, p_i51105_2_, p_i51105_3_);
|
||||
this.cont = cont;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack ms, int p_230430_2_, int p_230430_3_, float p_230430_4_) {
|
||||
super.render(ms, p_230430_2_, p_230430_3_, p_230430_4_);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(MatrixStack ms, int x, int y) {
|
||||
this.minecraft.fontRenderer.func_238418_a_(new StringTextComponent("Structure Generator"), 10, -10, 176, 0xfefefe);
|
||||
drawString(ms, this.minecraft.fontRenderer, "Inventory", 7, 107, 0xfefefe);
|
||||
drawCenteredString(ms, this.minecraft.fontRenderer, "COPY TO CLIPBOARD", 80, 50, 0xfefefe);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(MatrixStack ms, float partialTicks, int x, int y) {
|
||||
this.renderBackground(ms);
|
||||
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
|
||||
blit(ms, guiLeft, guiTop, 0, 0, 175, 256);
|
||||
blit(ms, guiLeft, guiTop - 20, 0, 0, 175, 256);
|
||||
|
||||
Minecraft.getInstance().textureManager.bindTexture(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"));
|
||||
blit(ms, guiLeft + 150, guiTop - 15, 0, 26, 18, 18);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
int x = (int)mouseX - guiLeft;
|
||||
int y = (int)mouseY - guiTop;
|
||||
|
||||
if (x > 0 && x < 176 && y > 40 && y < 60){
|
||||
StructureHelper.copyToClickBoard(cont.getTile().getInv().getStackInSlot(0).getTag(), cont.getTile().getWorld());
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.ticticboooom.mods.mm.client.ter;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
|
||||
import com.ticticboooom.mods.mm.client.MMRenderTypes;
|
||||
import com.ticticboooom.mods.mm.helper.NBTHelper;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
|
||||
public class StructureGenTileEntityRenderer extends TileEntityRenderer<StructureGenBlockEntity> {
|
||||
public StructureGenTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(StructureGenBlockEntity tileEntityIn, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
|
||||
ItemStack stackInSlot = tileEntityIn.getHandler().getStackInSlot(0);
|
||||
if (stackInSlot.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stackInSlot.getItem() != MMSetup.STRUCTURE_DEVICE.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stackInSlot.getTag() == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if (stackInSlot.getTag().contains("pos1") && stackInSlot.getTag().contains("pos2")) {
|
||||
CompoundNBT pos1c = stackInSlot.getTag().getCompound("pos1");
|
||||
CompoundNBT pos2c = stackInSlot.getTag().getCompound("pos2");
|
||||
|
||||
BlockPos pos1 = NBTHelper.fromCompound(pos1c);
|
||||
BlockPos pos2 = NBTHelper.fromCompound(pos2c);
|
||||
BlockPos tilePos = tileEntityIn.getPos();
|
||||
|
||||
pos1 = pos1.subtract(tilePos);
|
||||
pos2 = pos2.subtract(tilePos);
|
||||
|
||||
IVertexBuilder builder = bufferIn.getBuffer(MMRenderTypes.OUTLINE);
|
||||
matrixStackIn.push();
|
||||
Matrix4f mat = matrixStackIn.getLast().getMatrix();
|
||||
|
||||
int x = Math.min(pos1.getX(), pos2.getX());
|
||||
int y = Math.min(pos1.getY(), pos2.getY());
|
||||
int z = Math.min(pos1.getZ(), pos2.getZ());
|
||||
int dx = Math.max(pos1.getX(), pos2.getX()) + 1;
|
||||
int dy = Math.max(pos1.getY(), pos2.getY()) + 1;
|
||||
int dz = Math.max(pos1.getZ(), pos2.getZ()) + 1;
|
||||
|
||||
int R = 255, G = 255, B = 255, A = 70;
|
||||
builder.pos(mat, x , y, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, y, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, y, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, y, dz).color(R, G, B, A).endVertex();
|
||||
|
||||
builder.pos(mat, x , dy, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, dy, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, dy, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, dy, z).color(R, G, B, A).endVertex();
|
||||
|
||||
builder.pos(mat, x , y, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, dy, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, dy, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, y, z).color(R, G, B, A).endVertex();
|
||||
|
||||
builder.pos(mat, x , y, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, y, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, dy, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, dy, dz).color(R, G, B, A).endVertex();
|
||||
|
||||
builder.pos(mat, dx , y, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, y, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, dy, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, dx, dy, z).color(R, G, B, A).endVertex();
|
||||
|
||||
builder.pos(mat, x , y, z).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, y, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, dy, dz).color(R, G, B, A).endVertex();
|
||||
builder.pos(mat, x, dy, z).color(R, G, B, A).endVertex();
|
||||
|
||||
matrixStackIn.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Matrix4f;
|
||||
import net.minecraft.util.math.vector.Quaternion;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
@@ -97,11 +98,12 @@ public class GuiBlockRenderBuilder {
|
||||
}
|
||||
|
||||
private void transformMatrix(MatrixStack ms) {
|
||||
ms.scale(scale.getX(), scale.getY(), scale.getZ());
|
||||
ms.scale(12, -12, 12);
|
||||
ms.translate(prePosition.getX(), prePosition.getY(), prePosition.getZ());
|
||||
for (Quaternion quaternion : orderedRotation) {
|
||||
ms.rotate(quaternion);
|
||||
}
|
||||
ms.scale(scale.getX(), -scale.getY(), scale.getZ());
|
||||
ms.translate(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
|
||||
for (MachineStructureRecipeKeyModel model : models) {
|
||||
if (!model.getBlock().equals("")) {
|
||||
if (RLUtils.isRL(model.getBlock())) {
|
||||
if (!ForgeRegistries.ITEMS.containsKey(RLUtils.toRL(model.getBlock()))) {
|
||||
if (!ForgeRegistries.BLOCKS.containsKey(RLUtils.toRL(model.getBlock()))) {
|
||||
throw new InvalidStructureDefinitionException("Block: " + model.getBlock() + " is not an existing block in the game");
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,9 @@ import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.helper.RLUtils;
|
||||
import com.ticticboooom.mods.mm.registration.MMLoader;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.DirectionalBlock;
|
||||
import net.minecraft.block.HorizontalBlock;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -50,8 +52,9 @@ public class MMBlockStateProvider extends BlockStateProvider {
|
||||
simpleBlock(port.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + port.getId().getPath())));
|
||||
}
|
||||
|
||||
simpleBlock(MMSetup.PROJECTOR_BLOCK.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/projector")));
|
||||
simpleBlock(MMSetup.STRUCTURE_BLOCK.get(), new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/config_generator")));
|
||||
directionalState(MMSetup.PROJECTOR_BLOCK.get());
|
||||
|
||||
directionalState(MMSetup.STRUCTURE_BLOCK.get());
|
||||
}
|
||||
|
||||
public void dynamicBlockNorthOverlay(ResourceLocation loc, ResourceLocation baseTexture, ResourceLocation overlayTexture) {
|
||||
@@ -127,4 +130,13 @@ public class MMBlockStateProvider extends BlockStateProvider {
|
||||
)
|
||||
.end();
|
||||
}
|
||||
|
||||
private void directionalState(Block block){
|
||||
VariantBlockStateBuilder variantBuilder = getVariantBuilder(block);
|
||||
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.NORTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(0).addModel();
|
||||
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.SOUTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(180).addModel();
|
||||
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.EAST).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(90).addModel();
|
||||
variantBuilder.partialState().with(HorizontalBlock.HORIZONTAL_FACING, Direction.WEST).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + block.getRegistryName().getPath()))).rotationY(270).addModel();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MMItemModelProvider extends ItemModelProvider {
|
||||
|
||||
this.getBuilder(MMSetup.BLUEPRINT.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "item/blueprint");
|
||||
this.getBuilder(MMSetup.STRUCTURE_DEVICE.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "item/scanning_tool");
|
||||
this.getBuilder(MMSetup.STRUCTURE_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/config_generator")));
|
||||
this.getBuilder(MMSetup.STRUCTURE_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/structure_generator")));
|
||||
this.getBuilder(MMSetup.PROJECTOR_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/" + MMSetup.PROJECTOR_BLOCK.getId().getPath())));
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,11 @@ public class NBTHelper {
|
||||
result.putInt("z", pos.getZ());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static BlockPos fromCompound(CompoundNBT nbt) {
|
||||
int x = nbt.getInt("x");
|
||||
int y = nbt.getInt("y");
|
||||
int z = nbt.getInt("z");
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ticticboooom.mods.mm.helper;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.block.ControllerBlock;
|
||||
import com.ticticboooom.mods.mm.registration.MMLoader;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3i;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class StructureHelper {
|
||||
static String allChars;
|
||||
|
||||
static {
|
||||
int[] codePoints = new int[0x110000];
|
||||
for (int i = 0; i < codePoints.length; i++) {
|
||||
|
||||
codePoints[i] = i;
|
||||
}
|
||||
|
||||
allChars = new String(codePoints, 0, codePoints.length);
|
||||
}
|
||||
|
||||
private static Gson GSON = null;
|
||||
|
||||
public static void copyToClickBoard(CompoundNBT tag, World world) {
|
||||
if (tag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tag.contains("pos1") || !tag.contains("pos2")) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos pos1 = NBTHelper.fromCompound(tag.getCompound("pos1"));
|
||||
BlockPos pos2 = NBTHelper.fromCompound(tag.getCompound("pos2"));
|
||||
|
||||
int x = Math.min(pos1.getX(), pos2.getX());
|
||||
int y = Math.min(pos1.getY(), pos2.getY());
|
||||
int z = Math.min(pos1.getZ(), pos2.getZ());
|
||||
int dx = Math.max(pos1.getX(), pos2.getX());
|
||||
int dy = Math.max(pos1.getY(), pos2.getY());
|
||||
int dz = Math.max(pos1.getZ(), pos2.getZ());
|
||||
|
||||
BlockPos minPos = new BlockPos(x, y, z);
|
||||
BlockPos maxPos = new BlockPos(dx, dy, dz);
|
||||
|
||||
List<List<String>> layout = new ArrayList<>();
|
||||
Map<Character, ResourceLocation> legend = new HashMap<>();
|
||||
Map<ResourceLocation, Character> legendLookup = new HashMap<>();
|
||||
|
||||
char index = 33;
|
||||
|
||||
for (int yi = minPos.getY(); yi <= maxPos.getY(); yi++) {
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
for (int zi = minPos.getZ(); zi <= maxPos.getZ(); zi++) {
|
||||
StringBuilder row = new StringBuilder();
|
||||
for (int xi = minPos.getX(); xi <= maxPos.getX(); xi++) {
|
||||
BlockState state = world.getBlockState(new BlockPos(xi, yi, zi));
|
||||
ResourceLocation registryName = state.getBlock().getRegistryName();
|
||||
|
||||
if (state.isAir()) {
|
||||
row.append(" ");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state.getBlock() instanceof ControllerBlock) {
|
||||
row.append('C');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!legendLookup.containsKey(registryName)) {
|
||||
legend.put(index, registryName);
|
||||
legendLookup.put(registryName, index);
|
||||
index++;
|
||||
}
|
||||
row.append(legendLookup.get(registryName));
|
||||
}
|
||||
strings.add(row.toString());
|
||||
}
|
||||
layout.add(strings);
|
||||
}
|
||||
|
||||
JsonObject jsonObject = toJson(legend, layout);
|
||||
String s = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.disableHtmlEscaping()
|
||||
.create().toJson(jsonObject);
|
||||
Minecraft.getInstance().keyboardListener.setClipboardString(s);
|
||||
}
|
||||
|
||||
private static JsonObject toJson(Map<Character, ResourceLocation> legend, List<List<String>> layout) {
|
||||
JsonObject result = new JsonObject();
|
||||
result.addProperty("type", "masterfulmachinery:machine_structure");
|
||||
result.addProperty("id", "chance_this");
|
||||
result.addProperty("controllerId", "chance_this");
|
||||
result.addProperty("name", "Change This");
|
||||
|
||||
DataResult<JsonElement> apply = JsonOps.INSTANCE.withEncoder(Codec.list(Codec.list(Codec.STRING))).apply(layout);
|
||||
JsonArray layoutJson = apply.result().get().getAsJsonArray();
|
||||
|
||||
result.add("layout", layoutJson);
|
||||
JsonObject legendJson = new JsonObject();
|
||||
for (Map.Entry<Character, ResourceLocation> entry : legend.entrySet()) {
|
||||
JsonObject inner = new JsonObject();
|
||||
inner.addProperty("block", entry.getValue().toString());
|
||||
legendJson.add(entry.getKey().toString(), inner);
|
||||
}
|
||||
|
||||
result.add("legend", legendJson);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,21 @@
|
||||
package com.ticticboooom.mods.mm.inventory.astral;
|
||||
|
||||
import hellfirepvp.astralsorcery.common.starlight.IStarlightReceiver;
|
||||
import hellfirepvp.astralsorcery.common.starlight.IStarlightTransmission;
|
||||
import hellfirepvp.astralsorcery.common.starlight.transmission.ITransmissionReceiver;
|
||||
import hellfirepvp.astralsorcery.common.starlight.transmission.base.SimplePrismTransmissionNode;
|
||||
import hellfirepvp.astralsorcery.common.starlight.transmission.base.SimpleTransmissionReceiver;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class MMStarlightTransmission implements IStarlightTransmission<SimplePrismTransmissionNode> {
|
||||
public class MMStarlightReceiver implements IStarlightReceiver<ITransmissionReceiver> {
|
||||
|
||||
private final World world;
|
||||
private final BlockPos pos;
|
||||
|
||||
public MMStarlightTransmission(World world, BlockPos pos) {
|
||||
public MMStarlightReceiver(World world, BlockPos pos) {
|
||||
this.world = world;
|
||||
this.pos = pos;
|
||||
}
|
||||
@@ -31,7 +34,7 @@ public class MMStarlightTransmission implements IStarlightTransmission<SimplePri
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public SimplePrismTransmissionNode provideTransmissionNode(BlockPos blockPos) {
|
||||
return new SimplePrismTransmissionNode(blockPos);
|
||||
public ITransmissionReceiver provideEndpoint(BlockPos blockPos) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.ticticboooom.mods.mm.inventory.astral;
|
||||
|
||||
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
|
||||
import hellfirepvp.astralsorcery.common.starlight.transmission.ITransmissionReceiver;
|
||||
import hellfirepvp.astralsorcery.common.starlight.transmission.registry.TransmissionProvider;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class MMTransmissionReceiver implements ITransmissionReceiver {
|
||||
|
||||
private BlockPos pos;
|
||||
private final Set<BlockPos> sourcesToThis = new HashSet<>();
|
||||
|
||||
public MMTransmissionReceiver(BlockPos pos) {
|
||||
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStarlightReceive(World world, IWeakConstellation iWeakConstellation, double v) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getLocationPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySourceLink(World world, BlockPos blockPos) {
|
||||
sourcesToThis.add(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySourceUnlink(World world, BlockPos blockPos) {
|
||||
sourcesToThis.remove(blockPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean notifyBlockChange(World world, BlockPos blockPos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPos> getSources() {
|
||||
return new LinkedList<>(sourcesToThis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransmissionProvider getProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(CompoundNBT compoundNBT) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(CompoundNBT compoundNBT) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class StructureGenSelectionDevice extends Item {
|
||||
@@ -29,14 +30,18 @@ public class StructureGenSelectionDevice extends Item {
|
||||
}
|
||||
if (!tag.contains("pos1") && !tag.contains("pos2")) {
|
||||
tag.put("pos1", NBTHelper.toCompound(clickedPos));
|
||||
ctx.getPlayer().sendStatusMessage(new StringTextComponent("Set Pos 1"), true);
|
||||
} else if (tag.contains("pos1") && !tag.contains("pos2")) {
|
||||
tag.put("pos2", NBTHelper.toCompound(clickedPos));
|
||||
ctx.getPlayer().sendStatusMessage(new StringTextComponent("Set Pos 2"), true);
|
||||
} else {
|
||||
if (tag.contains("pos2")) {
|
||||
tag.remove("pos2");
|
||||
}
|
||||
tag.put("pos1", NBTHelper.toCompound(clickedPos));
|
||||
ctx.getPlayer().sendStatusMessage(new StringTextComponent("Set Pos 1"), true);
|
||||
}
|
||||
iih.setTag(tag);
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class MMSetup {
|
||||
public static final RegistryObject<Item> PROJECTOR_ITEM = ITEMS_REG.register("projector", () -> new BlockItem(PROJECTOR_BLOCK.get(), new Item.Properties().group(MMLoader.MASTERFUL_ITEM_GROUP)));
|
||||
|
||||
|
||||
public static final RegistryObject<TileEntityType<?>> STRUCTURE_TILE = TILES_REG.register("structure_generator", () -> TileEntityType.Builder.create(StructureGenBlockEntity::new).build(null));
|
||||
public static final RegistryObject<Block> STRUCTURE_BLOCK = BLOCKS_REG.register("structure_generator", StructureGenBlock::new);
|
||||
public static final RegistryObject<TileEntityType<StructureGenBlockEntity>> STRUCTURE_TILE = TILES_REG.register("structure_generator", () -> TileEntityType.Builder.create(StructureGenBlockEntity::new, STRUCTURE_BLOCK.get()).build(null));
|
||||
public static final RegistryObject<ContainerType<StructureGenBlockContainer>> STRUCTURE_CONTAINER = CONTAINER_REG.register("structure_generator", () -> IForgeContainerType.create(StructureGenBlockContainer::new));
|
||||
public static final RegistryObject<Item> STRUCTURE_ITEM = ITEMS_REG.register("structure_generator", () -> new BlockItem(STRUCTURE_BLOCK.get(), new Item.Properties().group(MMLoader.MASTERFUL_ITEM_GROUP)));
|
||||
public static final RegistryObject<Item> STRUCTURE_DEVICE = ITEMS_REG.register("structure_gen_device", StructureGenSelectionDevice::new);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Reference in New Issue
Block a user