did stuff
This commit is contained in:
parent
5793d88028
commit
fb3c6be715
|
|
@ -11,7 +11,6 @@ import me.shedaniel.autoconfig.serializer.Toml4jConfigSerializer;
|
|||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
|
@ -21,10 +20,8 @@ import net.minecraft.sounds.SoundEvents;
|
|||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraftforge.client.event.ClientChatEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.AttachCapabilitiesEvent;
|
||||
|
|
@ -34,24 +31,17 @@ import net.minecraftforge.event.entity.item.ItemTossEvent;
|
|||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.server.ServerStoppingEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
import net.montoyo.wd.block.BlockKeyboardRight;
|
||||
import net.montoyo.wd.block.BlockPeripheral;
|
||||
import net.montoyo.wd.block.BlockScreen;
|
||||
import net.montoyo.wd.client.ClientProxy;
|
||||
import net.montoyo.wd.config.ModConfig;
|
||||
import net.montoyo.wd.core.*;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
import net.montoyo.wd.init.BlockInit;
|
||||
import net.montoyo.wd.init.ItemInit;
|
||||
import net.montoyo.wd.init.TileInit;
|
||||
import net.montoyo.wd.item.*;
|
||||
import net.montoyo.wd.miniserv.server.Server;
|
||||
import net.montoyo.wd.net.Messages;
|
||||
import net.montoyo.wd.net.client.CMessageServerInfo;
|
||||
|
|
@ -154,17 +144,14 @@ public class WebDisplays {
|
|||
padResY = config.main.padHeight;
|
||||
padResX = padResY * PAD_RATIO;
|
||||
|
||||
IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
ItemInit.init(bus);
|
||||
BlockInit.init(bus);
|
||||
ItemInit.init();
|
||||
BlockInit.init();
|
||||
PROXY.preInit();
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
//Other things
|
||||
PROXY.init();
|
||||
|
||||
TileInit.registerPeripherals();
|
||||
|
||||
PROXY.postInit();
|
||||
hasOC = ModList.get().isLoaded("opencomputers");
|
||||
hasCC = ModList.get().isLoaded("computercraft");
|
||||
|
|
@ -293,7 +280,7 @@ public class WebDisplays {
|
|||
public void onLogIn(PlayerEvent.PlayerLoggedInEvent ev) {
|
||||
if(!ev.getPlayer().getLevel().isClientSide && ev.getPlayer() instanceof ServerPlayer) {
|
||||
Messages.INSTANCE.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) ev.getPlayer()), new CMessageServerInfo(miniservPort));
|
||||
IWDDCapability cap = (IWDDCapability) ev.getPlayer().getCapability(WDDCapability.Provider.cap, null);
|
||||
IWDDCapability cap = ev.getPlayer().getCapability(WDDCapability.Provider.cap, null).orElseThrow(RuntimeException::new);
|
||||
|
||||
if(cap == null)
|
||||
Log.warning("Player %s (%s) has null IWDDCapability!", ev.getPlayer().getName(), ev.getPlayer().getGameProfile().getId().toString());
|
||||
|
|
@ -321,8 +308,8 @@ public class WebDisplays {
|
|||
|
||||
@SubscribeEvent
|
||||
public void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone ev) {
|
||||
IWDDCapability src = (IWDDCapability) ev.getOriginal().getCapability(WDDCapability.Provider.cap, null);
|
||||
IWDDCapability dst = (IWDDCapability) ev.getPlayer().getCapability(WDDCapability.Provider.cap, null);
|
||||
IWDDCapability src = ev.getOriginal().getCapability(WDDCapability.Provider.cap, null).orElseThrow(RuntimeException::new);
|
||||
IWDDCapability dst = ev.getPlayer().getCapability(WDDCapability.Provider.cap, null).orElseThrow(RuntimeException::new);
|
||||
|
||||
if(src == null) {
|
||||
Log.error("src is null");
|
||||
|
|
|
|||
|
|
@ -13,16 +13,13 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
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;
|
||||
|
|
@ -45,12 +42,9 @@ import net.montoyo.wd.init.BlockInit;
|
|||
import net.montoyo.wd.item.ItemLinker;
|
||||
import net.montoyo.wd.net.Messages;
|
||||
import net.montoyo.wd.net.client.CMessageCloseGui;
|
||||
import net.montoyo.wd.utilities.Log;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BlockPeripheral extends BaseEntityBlock {
|
||||
public class BlockPeripheral extends Block {
|
||||
|
||||
public static final EnumProperty<DefaultPeripheral> type = EnumProperty.create("type", DefaultPeripheral.class);
|
||||
public static final DirectionProperty facing = DirectionProperty.create("facing", Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST);
|
||||
|
|
@ -59,7 +53,6 @@ public class BlockPeripheral extends BaseEntityBlock {
|
|||
public BlockPeripheral() {
|
||||
super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f));
|
||||
// setName("peripheral");
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
|
@ -110,7 +103,7 @@ public class BlockPeripheral extends BaseEntityBlock {
|
|||
// }
|
||||
|
||||
|
||||
@Nullable
|
||||
/*@Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
BlockEntityType.BlockEntitySupplier<? extends BlockEntity> cls = state.getValue(type).getTEClass();
|
||||
|
|
@ -118,13 +111,13 @@ public class BlockPeripheral extends BaseEntityBlock {
|
|||
return null;
|
||||
|
||||
try {
|
||||
return cls.create(pos, state); //TODO does this even work!
|
||||
return cls.create(pos, state);
|
||||
} catch(Throwable t) {
|
||||
Log.errorEx("Couldn't instantiate peripheral TileEntity:", t);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
} */
|
||||
|
||||
@Override
|
||||
public RenderShape getRenderShape(BlockState state) {
|
||||
|
|
|
|||
|
|
@ -18,18 +18,16 @@ import net.minecraft.world.item.context.BlockPlaceContext;
|
|||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.RenderShape;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||
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.DirectionProperty;
|
||||
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;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
|
|
@ -46,32 +44,28 @@ import org.jetbrains.annotations.NotNull;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class BlockScreen extends BaseEntityBlock {
|
||||
public class BlockScreen extends Block {
|
||||
|
||||
public static final BooleanProperty hasTE = BooleanProperty.create("haste");
|
||||
public static final BooleanProperty emitting = BooleanProperty.create("emitting");
|
||||
private static final Property<?>[] properties = new Property<?>[] { hasTE, emitting };
|
||||
public static final IntegerProperty[] sideFlags = new IntegerProperty[6];
|
||||
static {
|
||||
for(int i = 0; i < sideFlags.length; i++)
|
||||
sideFlags[i] = IntegerProperty.create("neighbor" + i, 0, 15);
|
||||
}
|
||||
public static final DirectionProperty FACING = BlockStateProperties.FACING;
|
||||
|
||||
private static final int BAR_BOT = 1;
|
||||
private static final int BAR_RIGHT = 2;
|
||||
private static final int BAR_TOP = 4;
|
||||
private static final int BAR_LEFT = 8;
|
||||
|
||||
public BlockScreen() {
|
||||
super(BlockBehaviour.Properties.of(Material.STONE).strength(1.5f, 10.f));
|
||||
public BlockScreen(Properties properties) {
|
||||
super(properties.strength(1.5f, 10.f));
|
||||
// setCreativeTab(WebDisplays.CREATIVE_TAB);
|
||||
// setName("screen");
|
||||
registerDefaultState(getStateDefinition().any().setValue(hasTE, false).setValue(emitting, false));
|
||||
this.registerDefaultState(this.defaultBlockState().setValue(hasTE, false).setValue(emitting, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
||||
builder.add(properties).add(sideFlags);
|
||||
builder.add(properties).add(FACING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -299,7 +293,7 @@ public class BlockScreen extends BaseEntityBlock {
|
|||
return false;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable
|
||||
/* @org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||
int meta = getMetaFromState(state);
|
||||
|
|
@ -308,7 +302,7 @@ public class BlockScreen extends BaseEntityBlock {
|
|||
return null;
|
||||
|
||||
return ((meta & 1) == 0) ? null : new TileEntityScreen(pos, state);
|
||||
}
|
||||
}*/
|
||||
|
||||
/************************************************* DESTRUCTION HANDLING *************************************************/
|
||||
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
|||
//Laser pointer raycast
|
||||
boolean raycastHit = false;
|
||||
|
||||
if(mc.player != null && mc.level != null && mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.itemLaserPointer.get())
|
||||
if(mc.player != null && mc.level != null && ItemInit.itemLaserPointer.isPresent() && mc.player.getItemInHand(InteractionHand.MAIN_HAND).getItem().equals(ItemInit.itemLaserPointer.get())
|
||||
&& mc.options.keyUse.isDown()
|
||||
&& (mc.hitResult == null || mc.hitResult.getType() != HitResult.Type.BLOCK)) {
|
||||
laserPointerRenderer.isOn = true;
|
||||
|
|
@ -628,19 +628,20 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
|||
Item item = ev.getItemStack().getItem();
|
||||
IItemRenderer renderer;
|
||||
|
||||
if(item == ItemInit.itemMinePad.get())
|
||||
renderer = minePadRenderer;
|
||||
else if(item == ItemInit.itemLaserPointer.get())
|
||||
renderer = laserPointerRenderer;
|
||||
else
|
||||
return;
|
||||
if(ItemInit.itemMinePad.isPresent() && ItemInit.itemLaserPointer.isPresent()) {
|
||||
if (item == ItemInit.itemMinePad.get())
|
||||
renderer = minePadRenderer;
|
||||
else if (item == ItemInit.itemLaserPointer.get())
|
||||
renderer = laserPointerRenderer;
|
||||
else
|
||||
return;
|
||||
HumanoidArm handSide = mc.player.getMainArm();
|
||||
if (ev.getHand() == InteractionHand.OFF_HAND)
|
||||
handSide = handSide.getOpposite();
|
||||
|
||||
HumanoidArm handSide = mc.player.getMainArm();
|
||||
if(ev.getHand() == InteractionHand.OFF_HAND)
|
||||
handSide = handSide.getOpposite();
|
||||
|
||||
renderer.render(ev.getPoseStack(), ev.getItemStack(), (handSide == HumanoidArm.RIGHT) ? 1.0f : -1.0f, ev.getSwingProgress(), ev.getEquipProgress(), ev.getMultiBufferSource(), ev.getPackedLight());
|
||||
ev.setCanceled(true);
|
||||
renderer.render(ev.getPoseStack(), ev.getItemStack(), (handSide == HumanoidArm.RIGHT) ? 1.0f : -1.0f, ev.getSwingProgress(), ev.getEquipProgress(), ev.getMultiBufferSource(), ev.getPackedLight());
|
||||
ev.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
@ -693,11 +694,13 @@ public class ClientProxy extends SharedProxy implements IDisplayHandler, IJSQuer
|
|||
for(int i = 0; i < cnt; i++) {
|
||||
ItemStack item = inv.get(i);
|
||||
|
||||
if(item.getItem() == ItemInit.itemMinePad.get()) {
|
||||
CompoundTag tag = item.getTag();
|
||||
if(ItemInit.itemMinePad.isPresent()) {
|
||||
if (item.getItem() == ItemInit.itemMinePad.get()) {
|
||||
CompoundTag tag = item.getTag();
|
||||
|
||||
if(tag != null && tag.contains("PadID"))
|
||||
updatePad(tag.getInt("PadID"), tag, item == heldStack);
|
||||
if (tag != null && tag.contains("PadID"))
|
||||
updatePad(tag.getInt("PadID"), tag, item == heldStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ import net.minecraft.client.renderer.texture.TextureAtlas;
|
|||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.level.block.state.properties.IntegerProperty;
|
||||
import net.montoyo.wd.block.BlockScreen;
|
||||
import net.montoyo.wd.utilities.BlockSide;
|
||||
import net.montoyo.wd.utilities.Vector3f;
|
||||
|
|
@ -98,9 +101,12 @@ public class ScreenBaker implements IModelBaker {
|
|||
int sid = BlockSide.reverse(side.ordinal());
|
||||
BlockSide s = blockSides[sid];
|
||||
TextureAtlasSprite tex = texs[15];
|
||||
if(bs != null)
|
||||
tex = texs[bs.getValue(BlockScreen.sideFlags[sid])];
|
||||
|
||||
if(bs != null) {
|
||||
IntegerProperty[] sideFlags = new IntegerProperty[6];
|
||||
for(int i = 0; i < sideFlags.length; i++)
|
||||
sideFlags[i] = IntegerProperty.create("neighbor" + i, 0, 15);
|
||||
tex = texs[bs.getValue(sideFlags[sid])];
|
||||
}
|
||||
ret.add(bakeSide(s, tex));
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,6 @@ public enum DefaultPeripheral implements StringRepresentable {
|
|||
|
||||
@Override
|
||||
public String getSerializedName() {
|
||||
return "DefaultPeripheral";
|
||||
return "default_peripheral_" + name;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ public class WDDCapability implements IWDDCapability {
|
|||
|
||||
public static class Provider implements ICapabilitySerializable<CompoundTag> {
|
||||
|
||||
public static Capability<IWDDCapability> cap = CapabilityManager.get(new CapabilityToken<>(){});
|
||||
public static Capability<IWDDCapability> cap = CapabilityManager.get(new CapabilityToken<>() {
|
||||
});
|
||||
private WDDCapability wddCap = null;
|
||||
private final LazyOptional<IWDDCapability> INSTANCE = LazyOptional.of(this::createWDDCapability);
|
||||
|
||||
@NotNull
|
||||
|
|
@ -58,7 +60,7 @@ public class WDDCapability implements IWDDCapability {
|
|||
|
||||
@Nonnull
|
||||
private IWDDCapability createWDDCapability() {
|
||||
return cap == null ? new WDDCapability() : (IWDDCapability) cap;
|
||||
return wddCap == null ? new WDDCapability() : wddCap;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
|
|||
private static final String RANDOM_CHARS = "AZERTYUIOPQSDFGHJKLMWXCVBNazertyuiopqsdfghjklmwxcvbn0123456789"; //Yes I have an AZERTY keyboard, u care?
|
||||
|
||||
public TileEntityKeyboard(BlockPos arg2, BlockState arg3) {
|
||||
super(TileInit.PERIPHERAL.get(), arg2, arg3);
|
||||
super(TileInit.KEYBOARD.get(), arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import net.montoyo.wd.utilities.Util;
|
|||
public class TileEntityRCtrl extends TileEntityPeripheralBase {
|
||||
|
||||
public TileEntityRCtrl(BlockPos arg2, BlockState arg3) {
|
||||
super(TileInit.PERIPHERAL.get(), arg2, arg3);
|
||||
super(TileInit.REMOTE_CONTROLLER.get(), arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
|||
private boolean state = false;
|
||||
|
||||
public TileEntityRedCtrl(BlockPos arg2, BlockState arg3) {
|
||||
super(TileInit.PERIPHERAL.get(), arg2, arg3);
|
||||
super(TileInit.REDSTONE_CONTROLLER.get(), arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class TileEntityServer extends BlockEntity {
|
|||
private NameUUIDPair owner;
|
||||
|
||||
public TileEntityServer(BlockPos arg2, BlockState arg3) {
|
||||
super(TileInit.PERIPHERAL.get(), arg2, arg3);
|
||||
super(TileInit.SERVER.get(), arg2, arg3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
package net.montoyo.wd.init;
|
||||
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.montoyo.wd.block.BlockKeyboardRight;
|
||||
import net.montoyo.wd.block.BlockPeripheral;
|
||||
|
|
@ -18,25 +19,13 @@ import java.util.function.Supplier;
|
|||
|
||||
public class BlockInit {
|
||||
|
||||
public static DeferredRegister<Block> BLOCKS = DeferredRegister.create(Registry.BLOCK_REGISTRY, "webdisplays");
|
||||
public static void init() {}
|
||||
|
||||
public static void init(IEventBus bus) {
|
||||
BLOCKS.register(bus);
|
||||
}
|
||||
public static DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, "webdisplays");
|
||||
|
||||
private static RegistryObject<Block> registerBlock(String name, Supplier<Block> blockSupplier) {
|
||||
return registerBlock(name, blockSupplier, b -> () -> new BlockItem(blockSupplier.get(), new Item.Properties().tab(WDCreativeTab.TAB_REDSTONE)));
|
||||
}
|
||||
public static final RegistryObject<Block> blockScreen = BLOCKS.register("screen_block", () -> new BlockScreen(BlockBehaviour.Properties.of(Material.STONE)));
|
||||
|
||||
private static RegistryObject<Block> registerBlock(String name, Supplier<Block> block, Function<RegistryObject<Block>, Supplier<? extends BlockItem>> item) {
|
||||
var reg = BLOCKS.register(name, block);
|
||||
ItemInit.ITEMS.register(name, () -> item.apply(reg).get());
|
||||
return reg;
|
||||
}
|
||||
public static final RegistryObject<Block> blockPeripheral = BLOCKS.register("peripheral_block", BlockPeripheral::new);
|
||||
|
||||
public static final RegistryObject<Block> blockScreen = registerBlock("screen_block", BlockScreen::new);
|
||||
|
||||
public static final RegistryObject<Block> blockPeripheral = registerBlock("peripheral_block", BlockPeripheral::new);
|
||||
|
||||
public static final RegistryObject<Block> blockKbRight = registerBlock("kb_right_block", BlockKeyboardRight::new);
|
||||
public static final RegistryObject<Block> blockKbRight = BLOCKS.register("kb_right_block", BlockKeyboardRight::new);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package net.montoyo.wd.init;
|
|||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import net.montoyo.wd.item.*;
|
||||
|
||||
|
|
@ -10,26 +11,16 @@ import java.util.function.Supplier;
|
|||
|
||||
public class ItemInit {
|
||||
|
||||
public static DeferredRegister<Item> ITEMS = DeferredRegister.create(Item.class, "webdisplays");
|
||||
public static void init() {}
|
||||
|
||||
public static void init(IEventBus bus) {
|
||||
ITEMS.register(bus);
|
||||
}
|
||||
public static DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, "webdisplays");
|
||||
|
||||
public static <T extends Item> RegistryObject<T> register(String name, Supplier<T> item) {
|
||||
return ITEMS.register(name, item);
|
||||
}
|
||||
|
||||
static <T extends Item> RegistryObject<T> register(Supplier<T> c, String id) {
|
||||
return register(id, c);
|
||||
}
|
||||
|
||||
public static final RegistryObject<Item> itemScreenCfg = register("item_screen_config", () -> new ItemScreenConfigurator(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemOwnerThief = register("item_owner_thief", () -> new ItemOwnershipThief(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemLinker = register("item_linker", () -> new ItemLinker(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemMinePad = register("item_mine_pad", () -> new ItemMinePad2(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemUpgrade = register("item_upgrade", ItemUpgrade::new);
|
||||
public static final RegistryObject<Item> itemCraftComp = register("item_craftcomp", () -> new ItemCraftComponent(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemLaserPointer = register("item_laserpointer", () -> new ItemLaserPointer(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemScreenCfg = ITEMS.register("screen_config", () -> new ItemScreenConfigurator(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemOwnerThief = ITEMS.register("owner_thief", () -> new ItemOwnershipThief(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemLinker = ITEMS.register("linker", () -> new ItemLinker(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemMinePad = ITEMS.register("mine_pad", () -> new ItemMinePad2(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemUpgrade = ITEMS.register("upgrade", ItemUpgrade::new);
|
||||
public static final RegistryObject<Item> itemCraftComp = ITEMS.register("craftcomp", () -> new ItemCraftComponent(new Item.Properties()));
|
||||
public static final RegistryObject<Item> itemLaserPointer = ITEMS.register("laserpointer", () -> new ItemLaserPointer(new Item.Properties()));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ 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;
|
||||
import net.montoyo.wd.entity.*;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
|
@ -14,19 +14,21 @@ 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 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)
|
||||
PERIPHERAL = TILE_TYPES.register(dp.name().toLowerCase(Locale.ROOT), () -> BlockEntityType.Builder
|
||||
.of(dp.getTEClass(), BlockInit.blockPeripheral.get()).build(null));
|
||||
public static final RegistryObject<BlockEntityType<?>> KEYBOARD = TILE_TYPES.register("keyboard", () -> BlockEntityType.Builder
|
||||
.of(TileEntityKeyboard::new, BlockInit.blockPeripheral.get()).build(null));
|
||||
|
||||
public static final RegistryObject<BlockEntityType<?>> REMOTE_CONTROLLER = TILE_TYPES.register("remotectrl",
|
||||
() -> BlockEntityType.Builder.of(TileEntityRCtrl::new, BlockInit.blockPeripheral.get()).build(null)); //WITHOUT FACING (>= 3)
|
||||
|
||||
public static final RegistryObject<BlockEntityType<?>> REDSTONE_CONTROLLER = TILE_TYPES.register("redstonectrl",
|
||||
() -> BlockEntityType.Builder.of(TileEntityRedCtrl::new, BlockInit.blockPeripheral.get()).build(null));
|
||||
|
||||
public static final RegistryObject<BlockEntityType<?>> SERVER = TILE_TYPES.register("server" ,
|
||||
() -> BlockEntityType.Builder.of(TileEntityServer::new, BlockInit.blockPeripheral.get()).build(null));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package net.montoyo.wd.item;
|
|||
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.montoyo.wd.WebDisplays;
|
||||
import net.montoyo.wd.core.DefaultUpgrade;
|
||||
import net.montoyo.wd.core.IUpgrade;
|
||||
import net.montoyo.wd.entity.TileEntityScreen;
|
||||
|
|
@ -18,9 +19,7 @@ import javax.annotation.Nullable;
|
|||
public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
||||
|
||||
public ItemUpgrade() {
|
||||
super(DefaultUpgrade.class, new Properties());
|
||||
setRegistryName("upgrade");
|
||||
//TODO set creative tab to WebDisplays.CREATIVE_TAB
|
||||
super(DefaultUpgrade.class, new Properties().tab(WebDisplays.CREATIVE_TAB));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
|
|
@ -15,6 +16,7 @@ import net.minecraftforge.network.simple.SimpleChannel;
|
|||
import net.montoyo.wd.net.client.*;
|
||||
import net.montoyo.wd.net.server.*;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class Messages {
|
||||
|
||||
private static final String PROTOCOL_VERSION = "1";
|
||||
|
|
@ -26,11 +28,6 @@ public class Messages {
|
|||
PROTOCOL_VERSION::equals
|
||||
);
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@SubscribeEvent
|
||||
public static void registryNetworkPackets (FMLClientSetupEvent event) {
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registryNetworkPackets (FMLCommonSetupEvent event) {
|
||||
INSTANCE.registerMessage(index++, CMessageACResult.class, CMessageACResult::encode, CMessageACResult::decode, CMessageACResult::handle);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"keyboardType": {
|
||||
"keyboard_type": {
|
||||
"category": "block",
|
||||
"sounds": [
|
||||
"webdisplays:keyboard1",
|
||||
|
|
@ -12,19 +12,19 @@
|
|||
"webdisplays:keyboard8"
|
||||
]
|
||||
},
|
||||
"upgradeAdd": {
|
||||
"upgrade_add": {
|
||||
"category": "block",
|
||||
"sounds": [
|
||||
"webdisplays:upgrade_add"
|
||||
]
|
||||
},
|
||||
"upgradeDel": {
|
||||
"upgrade_del": {
|
||||
"category": "block",
|
||||
"sounds": [
|
||||
"webdisplays:upgrade_del"
|
||||
]
|
||||
},
|
||||
"screencfgOpen": {
|
||||
"screencfg_open": {
|
||||
"category": "master",
|
||||
"sounds": [
|
||||
"webdisplays:screencfg_open"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user