everything but one

This commit is contained in:
Mysticpasta1 2022-06-24 07:48:31 -05:00
parent e6a5d38f55
commit 1cfbb02d6e
17 changed files with 136 additions and 106 deletions

View File

@ -22,6 +22,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
@ -112,12 +113,12 @@ public class BlockPeripheral extends BaseEntityBlock {
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
Class<? extends BlockEntity> cls = state.getValue(type).getTEClass();
BlockEntityType.BlockEntitySupplier<? extends BlockEntity> cls = state.getValue(type).getTEClass();
if(cls == null)
return null;
try {
return cls.newInstance();
return cls.create(pos, state); //TODO does this even work!
} catch(Throwable t) {
Log.errorEx("Couldn't instantiate peripheral TileEntity:", t);
}

View File

@ -5,17 +5,12 @@
package net.montoyo.wd.block;
import net.minecraft.ChatFormatting;
import net.minecraft.block.state.IBlockState;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.Explosion;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.World;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
@ -33,6 +28,7 @@ import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Material;
import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.phys.BlockHitResult;
@ -45,6 +41,7 @@ import net.montoyo.wd.entity.TileEntityScreen;
import net.montoyo.wd.init.BlockInit;
import net.montoyo.wd.item.WDItem;
import net.montoyo.wd.utilities.*;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -98,7 +95,7 @@ public class BlockScreen extends BaseEntityBlock {
return super.updateShape(state, direction, neighborState, level, currentPos, neighborPos);
}
@Override
/* @Override
@Nonnull
public BlockState getExtendedState(@Nonnull BlockState ret, Level world, BlockPos bpos) {
Vector3i pos = new Vector3i(bpos);
@ -114,7 +111,7 @@ public class BlockScreen extends BaseEntityBlock {
}
return ret;
}
}*/
// @Override
// @Nonnull
@ -328,28 +325,23 @@ public class BlockScreen extends BaseEntityBlock {
private void destroySide(Level world, Vector3i pos, BlockSide side, Multiblock.BlockOverride override, Player source) {
Multiblock.findOrigin(world, pos, side, override);
BlockPos bp = pos.toBlock();
TileEntity te = world.getTileEntity(bp);
BlockEntity te = world.getBlockEntity(bp);
if(te != null && te instanceof TileEntityScreen) {
((TileEntityScreen) te).onDestroy(source);
world.setBlockState(bp, world.getBlockState(bp).withProperty(hasTE, false)); //Destroy tile entity.
world.setBlock(bp, world.getBlockState(bp).setValue(hasTE, false), Block.UPDATE_ALL_IMMEDIATE); //Destroy tile entity.
}
}
@Override
public boolean removedByPlayer(@Nonnull IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull EntityPlayer ply, boolean willHarvest) {
onDestroy(world, pos, ply);
return super.removedByPlayer(state, world, pos, ply, willHarvest);
public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, Player player, boolean willHarvest, FluidState fluid) {
onDestroy(level, pos, player);
return super.onDestroyedByPlayer(state, level, pos, player, willHarvest, fluid);
}
@Override
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion) {
onDestroy(world, pos, null);
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase whoDidThisShit, ItemStack stack) {
if(world.isRemote)
public void setPlacedBy(Level world, @NotNull BlockPos pos, @NotNull BlockState state, @org.jetbrains.annotations.Nullable LivingEntity whoDidThisShit, @NotNull ItemStack stack) {
if(world.isClientSide)
return;
Multiblock.BlockOverride override = new Multiblock.BlockOverride(new Vector3i(pos), Multiblock.OverrideAction.IGNORE);
@ -365,13 +357,13 @@ public class BlockScreen extends BaseEntityBlock {
for(Vector3i neighbor: neighbors) {
if(world.getBlockState(neighbor.toBlock()).getBlock() instanceof BlockScreen) {
for(BlockSide bs: BlockSide.values())
destroySide(world, neighbor.clone(), bs, override, (whoDidThisShit instanceof EntityPlayer) ? ((EntityPlayer) whoDidThisShit) : null);
destroySide(world, neighbor.clone(), bs, override, (whoDidThisShit instanceof Player) ? ((Player) whoDidThisShit) : null);
}
}
}
@Override
public PushReaction getPistonPushReaction(BlockState state) {
public @NotNull PushReaction getPistonPushReaction(BlockState state) {
return PushReaction.IGNORE;
}

View File

@ -5,9 +5,11 @@
package net.montoyo.wd.client.gui;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.loading.FMLPaths;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.client.gui.controls.Button;
import net.montoyo.wd.client.gui.controls.Control;
@ -20,7 +22,7 @@ import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Log;
import net.montoyo.wd.utilities.TypeData;
import net.montoyo.wd.utilities.Util;
import org.lwjgl.system.CallbackI;
import org.lwjgl.glfw.GLFW;
import java.io.*;
import java.util.ArrayList;
@ -44,9 +46,11 @@ public class GuiKeyboard extends WDScreen {
private Button btnOk;
public GuiKeyboard() {
super(Component.nullToEmpty(null));
}
public GuiKeyboard(TileEntityScreen tes, BlockSide side, BlockPos kbPos) {
this();
this.tes = tes;
this.side = side;
this.kbPos = kbPos;
@ -61,20 +65,20 @@ public class GuiKeyboard extends WDScreen {
public void init() {
super.init();
if(minecraft.getSingleplayerServer() != null && !minecraft.getSingleplayerServer().isPublished())
if (minecraft.getSingleplayerServer() != null && !minecraft.getSingleplayerServer().isPublished())
showWarning = false; //NO NEED
else
showWarning = !hasUserReadWarning();
loadFrom(new ResourceLocation("webdisplays", "gui/keyboard.json"));
if(showWarning) {
if (showWarning) {
int maxLabelW = 0;
int totalH = 0;
for(Control ctrl : controls) {
if(ctrl != lblInfo && ctrl instanceof Label) {
if(ctrl.getWidth() > maxLabelW)
for (Control ctrl : controls) {
if (ctrl != lblInfo && ctrl instanceof Label) {
if (ctrl.getWidth() > maxLabelW)
maxLabelW = ctrl.getWidth();
totalH += ctrl.getHeight();
@ -87,8 +91,8 @@ public class GuiKeyboard extends WDScreen {
totalH += btnOk.getHeight();
int y = (height - totalH) / 2;
for(Control ctrl : controls) {
if(ctrl != lblInfo) {
for (Control ctrl : controls) {
if (ctrl != lblInfo) {
ctrl.setPos(ctrl.getX(), y);
y += ctrl.getHeight();
}
@ -103,39 +107,45 @@ public class GuiKeyboard extends WDScreen {
}
@Override
public void handleKeyboardInput() throws IOException {
if(showWarning) {
try {
super.handleKeyboardInput();
} catch(IOException ex) {
Log.warningEx("Caught exception while handling screen input", ex);
}
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
key(keyCode, scanCode, true);
return super.keyPressed(keyCode, scanCode, modifiers);
}
return;
@Override
public boolean keyReleased(int keyCode, int scanCode, int modifiers) {
key(keyCode, scanCode, false);
return super.keyPressed(keyCode, scanCode, modifiers);
}
public void key(int keyCode, int scanCode, boolean pressed) {
char chr = getChar(keyCode, scanCode);
if (pressed) {
int kc = keyCode;
evStack.add(new TypeData(TypeData.Action.PRESS, kc, chr));
evStack.add(new TypeData(TypeData.Action.RELEASE, kc, chr));
}
if(Keyboard.isCreated()) {
while(Keyboard.next()) {
if(Keyboard.getEventKey() == Keyboard.KEY_ESCAPE)
mc.displayGuiScreen(null);
else {
char chr = Keyboard.getEventCharacter();
if (chr != 0)
evStack.add(new TypeData(TypeData.Action.TYPE, 0, chr));
if(Keyboard.getEventKeyState()) {
int kc = Keyboard.getEventKey();
if (!evStack.isEmpty() && !syncRequested())
requestSync();
}
evStack.add(new TypeData(TypeData.Action.PRESS, kc, chr));
evStack.add(new TypeData(TypeData.Action.RELEASE, kc, chr));
}
if(chr != 0)
evStack.add(new TypeData(TypeData.Action.TYPE, 0, chr));
}
}
if(!evStack.isEmpty() && !syncRequested())
requestSync();
public char getChar(int keyCode, int scanCode) {
String keystr = GLFW.glfwGetKeyName(keyCode, scanCode);
if(keystr == null){
keystr = "\0";
}
if(keyCode == GLFW.GLFW_KEY_ENTER){
keystr = "\n";
}
if(keystr.length() == 0){
return (char) -1;
}
return keystr.charAt(keystr.length() - 1);
}
@Override
@ -162,14 +172,14 @@ public class GuiKeyboard extends WDScreen {
btnOk.setVisible(false);
showWarning = false;
defaultBackground = false;
mc.inGameHasFocus = true;
mc.mouseHelper.grabMouseCursor();
minecraft.setWindowActive(true);
minecraft.mouseHandler.grabMouse();
}
}
private boolean hasUserReadWarning() {
try {
File f = new File(mc.mcDataDir, WARNING_FNAME);
File f = new File(FMLPaths.GAMEDIR.name(), WARNING_FNAME);
if(f.exists()) {
BufferedReader br = new BufferedReader(new FileReader(f));
@ -187,7 +197,7 @@ public class GuiKeyboard extends WDScreen {
private void writeUserAcknowledge() {
try {
File f = new File(mc.mcDataDir, WARNING_FNAME);
File f = new File(FMLPaths.GAMEDIR.name(), WARNING_FNAME);
BufferedWriter bw = new BufferedWriter(new FileWriter(f));
bw.write("read\n");
@ -199,7 +209,7 @@ public class GuiKeyboard extends WDScreen {
@Override
public boolean isForBlock(BlockPos bp, BlockSide side) {
return bp.equals(kbPos) || (bp.equals(tes.getPos()) && side == this.side);
return bp.equals(kbPos) || (bp.equals(tes.getBlockPos()) && side == this.side);
}
}

View File

@ -36,7 +36,7 @@ public final class LaserPointerRenderer implements IItemRenderer {
}
@Override
public final void render(ItemStack is, float handSideSign, float swingProgress, float equipProgress) {
public void render(PoseStack poseStack, ItemStack is, float handSideSign, float swingProgress, float equipProgress) {
//This whole method is a fucking hack
float sqrtSwingProg = (float) Math.sqrt(swingProgress);
float sinSqrtSwingProg1 = (float) Math.sin(sqrtSwingProg * PI);

View File

@ -20,6 +20,7 @@ public final class ModelMinePad extends Model {
private final ModelPart right;
public ModelMinePad() {
super();
textureWidth = 64;
textureHeight = 32;

View File

@ -6,6 +6,7 @@ package net.montoyo.wd.core;
import net.minecraft.world.item.ItemStack;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.init.ItemInit;
public enum CraftComponent {
@ -33,7 +34,7 @@ public enum CraftComponent {
}
public ItemStack makeItemStack() {
return new ItemStack(WebDisplays.INSTANCE.itemCraftComp, 1);
return new ItemStack(ItemInit.itemCraftComp.get(), 1);
}
}

View File

@ -5,26 +5,31 @@
package net.montoyo.wd.core;
import net.minecraft.util.StringRepresentable;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.montoyo.wd.entity.*;
import java.util.function.Consumer;
import java.util.function.Supplier;
public enum DefaultPeripheral implements StringRepresentable {
KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard.class), //WITH FACING (< 3)
KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard::new), //WITH FACING (< 3)
// CC_INTERFACE("ccinterface", "ComputerCraft_Interface", TileEntityCCInterface.class),
// OC_INTERFACE("cointerface", "OpenComputers_Interface", TileEntityOCInterface.class),
REMOTE_CONTROLLER("remotectrl", "Remote_Controller", TileEntityRCtrl.class), //WITHOUT FACING (>= 3)
REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl.class),
SERVER("server", "Server", TileEntityServer.class);
REMOTE_CONTROLLER("remotectrl", "Remote_Controller", TileEntityRCtrl::new), //WITHOUT FACING (>= 3)
REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl::new),
SERVER("server", "Server", TileEntityServer::new);
private final String name;
private final String wikiName;
private final Class<? extends BlockEntity> teClass;
private final BlockEntityType.BlockEntitySupplier<? extends BlockEntity> teClass;
DefaultPeripheral(String name, String wname, Class<? extends BlockEntity> te) {
DefaultPeripheral(String name, String wname, BlockEntityType.BlockEntitySupplier<? extends BlockEntity> factory) {
this.name = name;
wikiName = wname;
teClass = te;
teClass = factory;
}
public static DefaultPeripheral fromMetadata(int meta) {
@ -34,7 +39,7 @@ public enum DefaultPeripheral implements StringRepresentable {
return values()[meta & 3]; //With facing
}
public Class<? extends BlockEntity> getTEClass() {
public BlockEntityType.BlockEntitySupplier<? extends BlockEntity> getTEClass() {
return teClass;
}

View File

@ -6,6 +6,8 @@ package net.montoyo.wd.core;
import net.minecraft.world.item.ItemStack;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.config.ModConfig;
import net.montoyo.wd.init.ItemInit;
public enum DefaultUpgrade {
@ -28,6 +30,6 @@ public enum DefaultUpgrade {
}
public boolean matches(ItemStack is) {
return is.getItem() == WebDisplays.INSTANCE.itemUpgrade;
return is.getItem() == ItemInit.itemUpgrade.get();
}
}

View File

@ -4,8 +4,10 @@
package net.montoyo.wd.data;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
@ -33,7 +35,7 @@ public class RedstoneCtrlData extends GuiData {
@OnlyIn(Dist.CLIENT)
@Override
public Screen createGui(Screen old, Level world) {
return new GuiRedstoneCtrl(dimension, pos, risingEdgeURL, fallingEdgeURL);
return new GuiRedstoneCtrl(old.getTitle(), dimension, pos, risingEdgeURL, fallingEdgeURL); //TODO is getTitle() correct?
}
@Override

View File

@ -16,6 +16,7 @@ import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.KeyboardData;
import net.montoyo.wd.init.TileInit;
import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Util;
@ -23,8 +24,8 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
private static final String RANDOM_CHARS = "AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn0123456789"; //Yes I have an AZERTY keyboard, u care?
public TileEntityKeyboard(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
super(arg, arg2, arg3);
public TileEntityKeyboard(BlockPos arg2, BlockState arg3) {
super(TileInit.PERIPHERAL.get(), arg2, arg3);
}
@Override

View File

@ -7,44 +7,46 @@ package net.montoyo.wd.entity;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.SetURLData;
import net.montoyo.wd.init.TileInit;
import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Util;
public class TileEntityRCtrl extends TileEntityPeripheralBase {
public TileEntityRCtrl(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
super(arg, arg2, arg3);
public TileEntityRCtrl(BlockPos arg2, BlockState arg3) {
super(TileInit.PERIPHERAL.get(), arg2, arg3);
}
@Override
public boolean onRightClick(Player player, InteractionHand hand, BlockSide side) {
public InteractionResult onRightClick(Player player, InteractionHand hand) {
if(level.isClientSide)
return true;
return InteractionResult.SUCCESS;
if(!isScreenChunkLoaded()) {
Util.toast(player, "chunkUnloaded");
return true;
return InteractionResult.SUCCESS;
}
TileEntityScreen tes = getConnectedScreen();
if(tes == null) {
Util.toast(player, "notLinked");
return true;
return InteractionResult.SUCCESS;
}
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
if((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
Util.toast(player, "restrictions");
return true;
return InteractionResult.SUCCESS;
}
(new SetURLData(screenPos, screenSide, scr.url, getBlockPos())).sendTo((ServerPlayer) player);
return true;
return InteractionResult.SUCCESS;
}
}

View File

@ -8,12 +8,15 @@ import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.RedstoneCtrlData;
import net.montoyo.wd.init.TileInit;
import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Util;
@ -25,8 +28,8 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
private String fallingEdgeURL = "";
private boolean state = false;
public TileEntityRedCtrl(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
super(arg, arg2, arg3);
public TileEntityRedCtrl(BlockPos arg2, BlockState arg3) {
super(TileInit.PERIPHERAL.get(), arg2, arg3);
}
@Override
@ -51,29 +54,29 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
}
@Override
public boolean onRightClick(Player player, InteractionHand hand, BlockSide side) {
public InteractionResult onRightClick(Player player, InteractionHand hand) {
if(level.isClientSide)
return true;
return InteractionResult.SUCCESS;
if(!isScreenChunkLoaded()) {
Util.toast(player, "chunkUnloaded");
return true;
return InteractionResult.SUCCESS;
}
TileEntityScreen tes = getConnectedScreen();
if(tes == null) {
Util.toast(player, "notLinked");
return true;
return InteractionResult.SUCCESS;
}
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
if((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
Util.toast(player, "restrictions");
return true;
return InteractionResult.SUCCESS;
}
(new RedstoneCtrlData(level.dimension().location(), getBlockPos(), risingEdgeURL, fallingEdgeURL)).sendTo((ServerPlayer) player);
return true;
return InteractionResult.SUCCESS;
}
@Override

View File

@ -34,6 +34,7 @@ import net.montoyo.wd.core.ScreenRights;
import net.montoyo.wd.data.ScreenConfigData;
import net.montoyo.wd.init.BlockInit;
import net.montoyo.wd.init.ItemInit;
import net.montoyo.wd.init.TileInit;
import net.montoyo.wd.net.Messages;
import net.montoyo.wd.net.client.CMessageAddScreen;
import net.montoyo.wd.net.client.CMessageCloseGui;
@ -54,7 +55,7 @@ import static net.montoyo.wd.block.BlockPeripheral.point;
public class TileEntityScreen extends BlockEntity{
public TileEntityScreen(BlockPos arg2, BlockState arg3) {
super(null /*TODO: add blockEnityTYpe */ , arg2, arg3);
super(TileInit.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
}
public static class Screen {

View File

@ -13,6 +13,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.montoyo.wd.WebDisplays;
import net.montoyo.wd.data.ServerData;
import net.montoyo.wd.init.TileInit;
import net.montoyo.wd.utilities.NameUUIDPair;
import net.montoyo.wd.utilities.Util;
@ -22,8 +23,8 @@ public class TileEntityServer extends BlockEntity {
private NameUUIDPair owner;
public TileEntityServer(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
super(arg, arg2, arg3);
public TileEntityServer(BlockPos arg2, BlockState arg3) {
super(TileInit.PERIPHERAL.get(), arg2, arg3);
}
@Override

View File

@ -34,7 +34,7 @@ public class BlockInit {
public static final RegistryObject<Block> blockScreen = registerBlock("screen_block", BlockScreen::new);
public static final RegistryObject<Block> blockPeripheral = registerBlock("peripheral_block", () -> new BlockPeripheral());
public static final RegistryObject<Block> blockPeripheral = registerBlock("peripheral_block", BlockPeripheral::new);
public static final RegistryObject<Block> blockKbRight = registerBlock("kb_right_block", () -> new BlockKeyboardRight());
public static final RegistryObject<Block> blockKbRight = registerBlock("kb_right_block", BlockKeyboardRight::new);
}

View File

@ -1,13 +1,9 @@
package net.montoyo.wd.init;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraftforge.common.extensions.IForgeBlockEntity;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.montoyo.wd.core.DefaultPeripheral;
import net.montoyo.wd.entity.TileEntityScreen;
@ -16,13 +12,19 @@ public class TileInit {
public static final DeferredRegister<BlockEntityType<?>> TILE_TYPES = DeferredRegister
.create(ForgeRegistries.BLOCK_ENTITIES, "webdisplays");
public static RegistryObject<BlockEntityType<?>> PERIPHERAL;
//Register tile entities
public static final BlockEntityType<TileEntityScreen> SCREEN_BLOCK_ENTITY = TILE_TYPES.register("screen", () -> BlockEntityType.Builder.of(TileEntityScreen::new, BlockInit.blockScreen).build(null));
public static final RegistryObject<BlockEntityType<TileEntityScreen>> SCREEN_BLOCK_ENTITY = TILE_TYPES
.register("screen", () -> BlockEntityType.Builder
.of(TileEntityScreen::new, BlockInit.blockScreen.get()).build(null));
public static void registerPeripherals() {
for (DefaultPeripheral dp : DefaultPeripheral.values()) {
if (dp.getTEClass() != null)
TILE_TYPES.register(dp.name(), () -> BlockEntityType.Builder.of(dp.getTEClass(), BlockInit.blockPeripheral.get()).build(null));
PERIPHERAL = TILE_TYPES.register(dp.name(), () -> BlockEntityType.Builder
.of(dp.getTEClass(), BlockInit.blockPeripheral.get()).build(null));
}
}
}

View File

@ -8,6 +8,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.montoyo.wd.WebDisplays;
@ -18,6 +19,7 @@ import net.montoyo.wd.utilities.BlockSide;
import net.montoyo.wd.utilities.Multiblock;
import net.montoyo.wd.utilities.Util;
import net.montoyo.wd.utilities.Vector3i;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.system.CallbackI;
import javax.annotation.Nonnull;
@ -59,4 +61,8 @@ public class ItemScreenConfigurator extends Item implements WDItem {
return InteractionResult.SUCCESS;
}
@Override
public String getWikiName(@NotNull ItemStack is) {
return is.getItem().getName(is).getString();
}
}