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