mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-03-18 21:40:34 +01:00
further started on structure builder
This commit is contained in:
@@ -8,6 +8,7 @@ import com.ticticboooom.mods.mm.block.container.ControllerBlockContainer;
|
||||
import com.ticticboooom.mods.mm.block.container.PortBlockContainer;
|
||||
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.datagen.MMPackFinder;
|
||||
import com.ticticboooom.mods.mm.datagen.MemoryDataGeneratorFactory;
|
||||
import com.ticticboooom.mods.mm.datagen.PackType;
|
||||
@@ -117,5 +118,7 @@ public class MM {
|
||||
for (RegistryObject<MachinePortBlock> block : MMLoader.OPORT_BLOCKS) {
|
||||
RenderTypeLookup.setRenderLayer(block.get(), layer -> layer == RenderType.solid() || layer == RenderType.translucent());
|
||||
}
|
||||
|
||||
ScreenManager.register(MMSetup.STRUCTURE_CONTAINER.get(), StructureGenBlockContainerScreen::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
package com.ticticboooom.mods.mm.block;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
|
||||
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.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
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 net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -24,4 +34,15 @@ public class StructureGenBlock extends Block {
|
||||
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||
return MMSetup.STRUCTURE_TILE.get().create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType use(BlockState state, World level, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult traceResult) {
|
||||
if (!level.isClientSide()) {
|
||||
TileEntity blockEntity = level.getBlockEntity(pos);
|
||||
if (blockEntity instanceof ControllerBlockEntity) {
|
||||
NetworkHooks.openGui(((ServerPlayerEntity) player), (StructureGenBlockEntity)blockEntity, pos);
|
||||
}
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
package com.ticticboooom.mods.mm.block.tile;
|
||||
|
||||
import com.ticticboooom.mods.mm.block.container.StructureGenBlockContainer;
|
||||
import com.ticticboooom.mods.mm.model.ProcessUpdate;
|
||||
import com.ticticboooom.mods.mm.registration.MMSetup;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.inventory.ItemStackHelper;
|
||||
import net.minecraft.inventory.container.Container;
|
||||
import net.minecraft.inventory.container.INamedContainerProvider;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
public class StructureGenBlockEntity extends UpdatableTile implements ITickableTileEntity {
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class StructureGenBlockEntity extends UpdatableTile implements ITickableTileEntity, INamedContainerProvider {
|
||||
public StructureGenBlockEntity() {
|
||||
super(MMSetup.STRUCTURE_TILE.get());
|
||||
}
|
||||
@@ -37,4 +46,15 @@ public class StructureGenBlockEntity extends UpdatableTile implements ITickableT
|
||||
public void tick() {
|
||||
update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName() {
|
||||
return new StringTextComponent("Structure Generator");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Container createMenu(int p_createMenu_1_, PlayerInventory p_createMenu_2_, PlayerEntity p_createMenu_3_) {
|
||||
return new StructureGenBlockContainer(p_createMenu_1_, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
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 net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class StructureGenBlockContainerScreen extends ContainerScreen<StructureGenBlockContainer> {
|
||||
@@ -12,7 +15,15 @@ public class StructureGenBlockContainerScreen extends ContainerScreen<StructureG
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) {
|
||||
protected void renderBg(MatrixStack ms, float p_230450_2_, int p_230450_3_, int p_230450_4_) {
|
||||
Minecraft.getInstance().textureManager.bind(new ResourceLocation(MM.ID, "textures/gui/port_gui.png"));
|
||||
blit(ms, leftPos, topPos, 0, 0, 175, 256);
|
||||
}
|
||||
|
||||
@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_);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ticticboooom.mods.mm.datagen.gen;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.ControllerBlock;
|
||||
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.data.DataGenerator;
|
||||
@@ -33,5 +34,7 @@ public class MMItemModelProvider extends ItemModelProvider {
|
||||
|
||||
this.getBuilder(MMSetup.BLUEPRINT.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "items/blueprint");
|
||||
this.getBuilder(MMSetup.STRUCTURE_DEVICE.getId().getPath()).parent(new ModelFile.UncheckedModelFile("item/generated")).texture("layer0", "items/scanning_tool");
|
||||
this.getBuilder(MMSetup.STRUCTURE_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/" + MMSetup.STRUCTURE_BLOCK.getId().getPath())));
|
||||
this.getBuilder(MMSetup.PROJECTOR_ITEM.getId().getPath()).parent(new ModelFile.UncheckedModelFile(RLUtils.toRL(MM.ID + ":block/" + MMSetup.PROJECTOR_BLOCK.getId().getPath())));
|
||||
}
|
||||
}
|
||||
@@ -34,5 +34,7 @@ public class MMLangProvider extends LanguageProvider {
|
||||
}
|
||||
this.add(MMSetup.BLUEPRINT.get(), "Blueprint");
|
||||
this.add(MMSetup.STRUCTURE_DEVICE.get(), "Structure Scanner");
|
||||
this.add(MMSetup.PROJECTOR_BLOCK.get(), "Structure Projector");
|
||||
this.add(MMSetup.STRUCTURE_BLOCK.get(), "Structure Scanner");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
|
||||
import com.ticticboooom.mods.mm.item.StructureGenSelectionDevice;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraftforge.common.extensions.IForgeContainerType;
|
||||
@@ -28,11 +29,13 @@ public class MMSetup {
|
||||
|
||||
public static final RegistryObject<TileEntityType<?>> PROJECTOR_TILE = TILES_REG.register("projector", () -> TileEntityType.Builder.of(ProjectorBlockEntity::new).build(null));
|
||||
public static final RegistryObject<Block> PROJECTOR_BLOCK = BLOCKS_REG.register("projector", ProjectorBlock::new);
|
||||
public static final RegistryObject<ContainerType<?>> PROJECTOR_CONTAINER = CONTAINER_REG.register("projector", () -> IForgeContainerType.create(ProjectorBlockContainer::new));
|
||||
public static final RegistryObject<ContainerType<ProjectorBlockContainer>> PROJECTOR_CONTAINER = CONTAINER_REG.register("projector", () -> IForgeContainerType.create(ProjectorBlockContainer::new));
|
||||
public static final RegistryObject<Item> PROJECTOR_ITEM = ITEMS_REG.register("projector", () -> new BlockItem(PROJECTOR_BLOCK.get(), new Item.Properties().tab(MMLoader.MASTERFUL_ITEM_GROUP)));
|
||||
|
||||
|
||||
public static final RegistryObject<TileEntityType<?>> STRUCTURE_TILE = TILES_REG.register("structure_generator", () -> TileEntityType.Builder.of(StructureGenBlockEntity::new).build(null));
|
||||
public static final RegistryObject<Block> STRUCTURE_BLOCK = BLOCKS_REG.register("structure_generator", StructureGenBlock::new);
|
||||
public static final RegistryObject<ContainerType<?>> STRUCTURE_CONTAINER = CONTAINER_REG.register("structure_generator", () -> IForgeContainerType.create(StructureGenBlockContainer::new));
|
||||
|
||||
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().tab(MMLoader.MASTERFUL_ITEM_GROUP)));
|
||||
public static final RegistryObject<Item> STRUCTURE_DEVICE = ITEMS_REG.register("structure_gen_device", StructureGenSelectionDevice::new);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user