modernize naming pt0
This commit is contained in:
parent
a9d9dcfecf
commit
a2f81aeeac
|
|
@ -14,13 +14,12 @@ import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
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.minecraftforge.common.MinecraftForge;
|
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
import net.montoyo.wd.core.HasAdvancement;
|
import net.montoyo.wd.core.HasAdvancement;
|
||||||
import net.montoyo.wd.core.JSServerRequest;
|
import net.montoyo.wd.core.JSServerRequest;
|
||||||
import net.montoyo.wd.data.GuiData;
|
import net.montoyo.wd.data.GuiData;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
@ -58,7 +57,7 @@ public class SharedProxy {
|
||||||
Log.error("Called SharedProxy.displayGui() on server side...");
|
Log.error("Called SharedProxy.displayGui() on server side...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trackScreen(TileEntityScreen tes, boolean track) {
|
public void trackScreen(ScreenBlockEntity tes, boolean track) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onAutocompleteResult(NameUUIDPair pairs[]) {
|
public void onAutocompleteResult(NameUUIDPair pairs[]) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.montoyo.wd.core.DefaultPeripheral;
|
import net.montoyo.wd.core.DefaultPeripheral;
|
||||||
import net.montoyo.wd.entity.TileEntityKeyboard;
|
import net.montoyo.wd.entity.KeyboardBlockEntity;
|
||||||
import net.montoyo.wd.item.ItemLinker;
|
import net.montoyo.wd.item.ItemLinker;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
||||||
|
|
@ -51,11 +51,11 @@ public class BlockKeyboardLeft extends BlockPeripheral {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make non static (for extensibility purposes)
|
// TODO: make non static (for extensibility purposes)
|
||||||
public static TileEntityKeyboard getTileEntity(BlockState state, Level world, BlockPos pos) {
|
public static KeyboardBlockEntity getTileEntity(BlockState state, Level world, BlockPos pos) {
|
||||||
if (state.getBlock() instanceof BlockKeyboardLeft) {
|
if (state.getBlock() instanceof BlockKeyboardLeft) {
|
||||||
BlockEntity te = world.getBlockEntity(pos); // TODO: check?
|
BlockEntity te = world.getBlockEntity(pos); // TODO: check?
|
||||||
if (te instanceof TileEntityKeyboard)
|
if (te instanceof KeyboardBlockEntity)
|
||||||
return (TileEntityKeyboard) te;
|
return (KeyboardBlockEntity) te;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING).getOpposite()));
|
BlockPos relative = pos.relative(BlockKeyboardLeft.mapDirection(state.getValue(FACING).getOpposite()));
|
||||||
|
|
@ -63,8 +63,8 @@ public class BlockKeyboardLeft extends BlockPeripheral {
|
||||||
|
|
||||||
if (ns.getBlock() instanceof BlockPeripheral) {
|
if (ns.getBlock() instanceof BlockPeripheral) {
|
||||||
BlockEntity te = world.getBlockEntity(relative); // TODO: check?
|
BlockEntity te = world.getBlockEntity(relative); // TODO: check?
|
||||||
if (te instanceof TileEntityKeyboard)
|
if (te instanceof KeyboardBlockEntity)
|
||||||
return (TileEntityKeyboard) te;
|
return (KeyboardBlockEntity) te;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -89,7 +89,7 @@ public class BlockKeyboardLeft extends BlockPeripheral {
|
||||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
double rpos = (entity.getY() - ((double) pos.getY())) * 16.0;
|
double rpos = (entity.getY() - ((double) pos.getY())) * 16.0;
|
||||||
if (!world.isClientSide && rpos >= 1.0 && rpos <= 2.0 && Math.random() < 0.25) {
|
if (!world.isClientSide && rpos >= 1.0 && rpos <= 2.0 && Math.random() < 0.25) {
|
||||||
TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, world, pos);
|
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, world, pos);
|
||||||
|
|
||||||
if (tek != null)
|
if (tek != null)
|
||||||
tek.simulateCat(entity);
|
tek.simulateCat(entity);
|
||||||
|
|
@ -101,7 +101,7 @@ public class BlockKeyboardLeft extends BlockPeripheral {
|
||||||
if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
|
if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
||||||
TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, level, pos);
|
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, level, pos);
|
||||||
if (tek != null)
|
if (tek != null)
|
||||||
return tek.onRightClick(player, hand);
|
return tek.onRightClick(player, hand);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.montoyo.wd.core.IPeripheral;
|
import net.montoyo.wd.core.IPeripheral;
|
||||||
import net.montoyo.wd.entity.TileEntityKeyboard;
|
import net.montoyo.wd.entity.KeyboardBlockEntity;
|
||||||
import net.montoyo.wd.item.ItemLinker;
|
import net.montoyo.wd.item.ItemLinker;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
||||||
|
|
@ -82,7 +82,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean connect(Level world, BlockPos pos, BlockState state, Vector3i scrPos, BlockSide scrSide) {
|
public boolean connect(Level world, BlockPos pos, BlockState state, Vector3i scrPos, BlockSide scrSide) {
|
||||||
TileEntityKeyboard keyboard = BlockKeyboardLeft.getTileEntity(state, world, pos);
|
KeyboardBlockEntity keyboard = BlockKeyboardLeft.getTileEntity(state, world, pos);
|
||||||
return keyboard != null && keyboard.connect(world, pos, state, scrPos, scrSide);
|
return keyboard != null && keyboard.connect(world, pos, state, scrPos, scrSide);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
|
||||||
double rpos = (entity.getY() - ((double) pos.getY())) * 16.0;
|
double rpos = (entity.getY() - ((double) pos.getY())) * 16.0;
|
||||||
if (!world.isClientSide && rpos >= 1.0 && rpos <= 2.0 && Math.random() < 0.25) {
|
if (!world.isClientSide && rpos >= 1.0 && rpos <= 2.0 && Math.random() < 0.25) {
|
||||||
TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, world, pos);
|
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, world, pos);
|
||||||
|
|
||||||
if (tek != null)
|
if (tek != null)
|
||||||
tek.simulateCat(entity);
|
tek.simulateCat(entity);
|
||||||
|
|
@ -102,7 +102,7 @@ public class BlockKeyboardRight extends Block implements IPeripheral {
|
||||||
if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
|
if (player.getItemInHand(hand).getItem() instanceof ItemLinker)
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
|
|
||||||
TileEntityKeyboard tek = BlockKeyboardLeft.getTileEntity(state, level, pos);
|
KeyboardBlockEntity tek = BlockKeyboardLeft.getTileEntity(state, level, pos);
|
||||||
if (tek != null)
|
if (tek != null)
|
||||||
return tek.onRightClick(player, hand);
|
return tek.onRightClick(player, hand);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.montoyo.wd.core.DefaultPeripheral;
|
import net.montoyo.wd.core.DefaultPeripheral;
|
||||||
import net.montoyo.wd.entity.TileEntityInterfaceBase;
|
import net.montoyo.wd.entity.AbstractInterfaceBlockEntity;
|
||||||
import net.montoyo.wd.entity.TileEntityPeripheralBase;
|
import net.montoyo.wd.entity.AbstractPeripheralBlockEntity;
|
||||||
import net.montoyo.wd.entity.TileEntityServer;
|
import net.montoyo.wd.entity.ServerBlockEntity;
|
||||||
import net.montoyo.wd.item.ItemLinker;
|
import net.montoyo.wd.item.ItemLinker;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
import net.montoyo.wd.net.client_bound.S2CMessageCloseGui;
|
||||||
|
|
@ -76,10 +76,10 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
|
|
||||||
BlockEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
|
|
||||||
if (te instanceof TileEntityPeripheralBase)
|
if (te instanceof AbstractPeripheralBlockEntity)
|
||||||
return ((TileEntityPeripheralBase) te).onRightClick(player, hand);
|
return ((AbstractPeripheralBlockEntity) te).onRightClick(player, hand);
|
||||||
else if (te instanceof TileEntityServer) {
|
else if (te instanceof ServerBlockEntity) {
|
||||||
((TileEntityServer) te).onPlayerRightClick(player);
|
((ServerBlockEntity) te).onPlayerRightClick(player);
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
} else
|
} else
|
||||||
return InteractionResult.FAIL;
|
return InteractionResult.FAIL;
|
||||||
|
|
@ -98,10 +98,10 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
if (placer instanceof Player) {
|
if (placer instanceof Player) {
|
||||||
BlockEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
|
|
||||||
if (te instanceof TileEntityServer)
|
if (te instanceof ServerBlockEntity)
|
||||||
((TileEntityServer) te).setOwner((Player) placer);
|
((ServerBlockEntity) te).setOwner((Player) placer);
|
||||||
else if (te instanceof TileEntityInterfaceBase)
|
else if (te instanceof AbstractInterfaceBlockEntity)
|
||||||
((TileEntityInterfaceBase) te).setOwner((Player) placer);
|
((AbstractInterfaceBlockEntity) te).setOwner((Player) placer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,8 +113,8 @@ public class BlockPeripheral extends WDBlockContainer {
|
||||||
@Override
|
@Override
|
||||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block neighborType, BlockPos neighbor, boolean isMoving) {
|
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block neighborType, BlockPos neighbor, boolean isMoving) {
|
||||||
BlockEntity te = world.getBlockEntity(pos);
|
BlockEntity te = world.getBlockEntity(pos);
|
||||||
if (te instanceof TileEntityPeripheralBase)
|
if (te instanceof AbstractPeripheralBlockEntity)
|
||||||
((TileEntityPeripheralBase) te).onNeighborChange(neighborType, neighbor);
|
((AbstractPeripheralBlockEntity) te).onNeighborChange(neighborType, neighbor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import net.montoyo.wd.core.DefaultUpgrade;
|
||||||
import net.montoyo.wd.core.IUpgrade;
|
import net.montoyo.wd.core.IUpgrade;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.data.SetURLData;
|
import net.montoyo.wd.data.SetURLData;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.item.ItemLaserPointer;
|
import net.montoyo.wd.item.ItemLaserPointer;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
@ -92,10 +92,10 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
BlockSide side = BlockSide.values()[hit.getDirection().ordinal()];
|
BlockSide side = BlockSide.values()[hit.getDirection().ordinal()];
|
||||||
|
|
||||||
Multiblock.findOrigin(world, pos, side, null);
|
Multiblock.findOrigin(world, pos, side, null);
|
||||||
TileEntityScreen te = (TileEntityScreen) world.getBlockEntity(pos.toBlock());
|
ScreenBlockEntity te = (ScreenBlockEntity) world.getBlockEntity(pos.toBlock());
|
||||||
|
|
||||||
if (te != null && te.getScreen(side) != null) {
|
if (te != null && te.getScreen(side) != null) {
|
||||||
TileEntityScreen.Screen scr = te.getScreen(side);
|
ScreenBlockEntity.Screen scr = te.getScreen(side);
|
||||||
|
|
||||||
if (sneaking) { //Right Click
|
if (sneaking) { //Right Click
|
||||||
if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0)
|
if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0)
|
||||||
|
|
@ -168,7 +168,7 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
if (te == null) {
|
if (te == null) {
|
||||||
BlockPos bp = pos.toBlock();
|
BlockPos bp = pos.toBlock();
|
||||||
world.setBlockAndUpdate(bp, world.getBlockState(bp).setValue(hasTE, true));
|
world.setBlockAndUpdate(bp, world.getBlockState(bp).setValue(hasTE, true));
|
||||||
te = (TileEntityScreen) world.getBlockEntity(bp);
|
te = (ScreenBlockEntity) world.getBlockEntity(bp);
|
||||||
created = true;
|
created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,7 +184,7 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
Vector3i vec = new Vector3i(pos);
|
Vector3i vec = new Vector3i(pos);
|
||||||
Multiblock.findOrigin(world, vec, side, null);
|
Multiblock.findOrigin(world, vec, side, null);
|
||||||
|
|
||||||
TileEntityScreen tes = (TileEntityScreen) world.getBlockEntity(vec.toBlock());
|
ScreenBlockEntity tes = (ScreenBlockEntity) world.getBlockEntity(vec.toBlock());
|
||||||
if (tes != null && tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
if (tes != null && tes.hasUpgrade(side, DefaultUpgrade.REDINPUT)) {
|
||||||
Direction facing = Direction.from2DDataValue(side.reverse().ordinal()); //Opposite face
|
Direction facing = Direction.from2DDataValue(side.reverse().ordinal()); //Opposite face
|
||||||
vec.sub(pos.getX(), pos.getY(), pos.getZ()).neg();
|
vec.sub(pos.getX(), pos.getY(), pos.getZ()).neg();
|
||||||
|
|
@ -194,7 +194,7 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, TileEntityScreen.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) {
|
public static boolean hit2pixels(BlockSide side, BlockPos bpos, Vector3i pos, ScreenBlockEntity.Screen scr, float hitX, float hitY, float hitZ, Vector2i dst) {
|
||||||
Vector3f rel = new Vector3f(hitX, hitY, hitZ);
|
Vector3f rel = new Vector3f(hitX, hitY, hitZ);
|
||||||
|
|
||||||
// how these dot products come in is beyond me
|
// how these dot products come in is beyond me
|
||||||
|
|
@ -259,8 +259,8 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
BlockPos bp = pos.toBlock();
|
BlockPos bp = pos.toBlock();
|
||||||
BlockEntity te = world.getBlockEntity(bp);
|
BlockEntity te = world.getBlockEntity(bp);
|
||||||
|
|
||||||
if (te instanceof TileEntityScreen) {
|
if (te instanceof ScreenBlockEntity) {
|
||||||
((TileEntityScreen) te).onDestroy(source);
|
((ScreenBlockEntity) te).onDestroy(source);
|
||||||
world.setBlock(bp, world.getBlockState(bp).setValue(hasTE, false), Block.UPDATE_ALL_IMMEDIATE); //Destroy tile entity.
|
world.setBlock(bp, world.getBlockState(bp).setValue(hasTE, false), Block.UPDATE_ALL_IMMEDIATE); //Destroy tile entity.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -315,7 +315,7 @@ public class BlockScreen extends BaseEntityBlock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
|
||||||
return state.getValue(hasTE) ? new TileEntityScreen(pos, state) : null;
|
return state.getValue(hasTE) ? new ScreenBlockEntity(pos, state) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ import net.montoyo.wd.client.gui.loading.GuiLoader;
|
||||||
import net.montoyo.wd.client.renderers.*;
|
import net.montoyo.wd.client.renderers.*;
|
||||||
import net.montoyo.wd.core.HasAdvancement;
|
import net.montoyo.wd.core.HasAdvancement;
|
||||||
import net.montoyo.wd.data.GuiData;
|
import net.montoyo.wd.data.GuiData;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.registry.BlockRegistry;
|
import net.montoyo.wd.registry.BlockRegistry;
|
||||||
import net.montoyo.wd.registry.ItemRegistry;
|
import net.montoyo.wd.registry.ItemRegistry;
|
||||||
import net.montoyo.wd.registry.TileRegistry;
|
import net.montoyo.wd.registry.TileRegistry;
|
||||||
|
|
@ -157,9 +157,9 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
||||||
|
|
||||||
Multiblock.findOrigin(mc.level, pos, side, null);
|
Multiblock.findOrigin(mc.level, pos, side, null);
|
||||||
TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock());
|
ScreenBlockEntity te = (ScreenBlockEntity) mc.level.getBlockEntity(pos.toBlock());
|
||||||
|
|
||||||
TileEntityScreen.Screen sc = te.getScreen(side);
|
ScreenBlockEntity.Screen sc = te.getScreen(side);
|
||||||
|
|
||||||
if (sc == null) return;
|
if (sc == null) return;
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
private PadData(String url, UUID id) {
|
private PadData(String url, UUID id) {
|
||||||
String webUrl;
|
String webUrl;
|
||||||
try {
|
try {
|
||||||
webUrl = TileEntityScreen.url(url);
|
webUrl = ScreenBlockEntity.url(url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +224,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
private Map advancementToProgress;
|
private Map advancementToProgress;
|
||||||
|
|
||||||
//Tracking
|
//Tracking
|
||||||
private final ArrayList<TileEntityScreen> screenTracking = new ArrayList<>();
|
private final ArrayList<ScreenBlockEntity> screenTracking = new ArrayList<>();
|
||||||
private int lastTracked = 0;
|
private int lastTracked = 0;
|
||||||
|
|
||||||
//MinePads Management
|
//MinePads Management
|
||||||
|
|
@ -313,7 +313,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void trackScreen(TileEntityScreen tes, boolean track) {
|
public void trackScreen(ScreenBlockEntity tes, boolean track) {
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
for (int i = 0; i < screenTracking.size(); i++) {
|
for (int i = 0; i < screenTracking.size(); i++) {
|
||||||
if (screenTracking.get(i) == tes) {
|
if (screenTracking.get(i) == tes) {
|
||||||
|
|
@ -534,7 +534,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TileEntityScreen tes : screenTracking)
|
for (ScreenBlockEntity tes : screenTracking)
|
||||||
tes.updateClientSideURL(browser, url);
|
tes.updateClientSideURL(browser, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -644,7 +644,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
|
|
||||||
int id = lastTracked % screenTracking.size();
|
int id = lastTracked % screenTracking.size();
|
||||||
|
|
||||||
TileEntityScreen tes = screenTracking.get(id);
|
ScreenBlockEntity tes = screenTracking.get(id);
|
||||||
|
|
||||||
if (!tes.getLevel().equals(ev.level))
|
if (!tes.getLevel().equals(ev.level))
|
||||||
return;
|
return;
|
||||||
|
|
@ -658,7 +658,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
} else {
|
} else {
|
||||||
double dist = Double.POSITIVE_INFINITY;
|
double dist = Double.POSITIVE_INFINITY;
|
||||||
for (int i = 0; i < tes.screenCount(); i++) {
|
for (int i = 0; i < tes.screenCount(); i++) {
|
||||||
TileEntityScreen.Screen scrn = tes.getScreen(i);
|
ScreenBlockEntity.Screen scrn = tes.getScreen(i);
|
||||||
|
|
||||||
Vector3d pos = new Vector3d(
|
Vector3d pos = new Vector3d(
|
||||||
scrn.side.right.x * scrn.size.x + scrn.size.y * scrn.side.up.x,
|
scrn.side.right.x * scrn.size.x + scrn.size.y * scrn.side.up.x,
|
||||||
|
|
@ -849,15 +849,15 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
|
|
||||||
public static final class ScreenSidePair {
|
public static final class ScreenSidePair {
|
||||||
|
|
||||||
public TileEntityScreen tes;
|
public ScreenBlockEntity tes;
|
||||||
public BlockSide side;
|
public BlockSide side;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean findScreenFromBrowser(CefBrowser browser, ScreenSidePair pair) {
|
public boolean findScreenFromBrowser(CefBrowser browser, ScreenSidePair pair) {
|
||||||
for (TileEntityScreen tes : screenTracking) {
|
for (ScreenBlockEntity tes : screenTracking) {
|
||||||
for (int i = 0; i < tes.screenCount(); i++) {
|
for (int i = 0; i < tes.screenCount(); i++) {
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(i);
|
ScreenBlockEntity.Screen scr = tes.getScreen(i);
|
||||||
|
|
||||||
if (scr.browser == browser) {
|
if (scr.browser == browser) {
|
||||||
pair.tes = tes;
|
pair.tes = tes;
|
||||||
|
|
@ -910,7 +910,7 @@ public class ClientProxy extends SharedProxy implements CefDisplayHandler/*, IJS
|
||||||
BlockEntity be = Minecraft.getInstance().level.getBlockEntity(
|
BlockEntity be = Minecraft.getInstance().level.getBlockEntity(
|
||||||
pos
|
pos
|
||||||
);
|
);
|
||||||
if (be instanceof TileEntityScreen tes) {
|
if (be instanceof ScreenBlockEntity tes) {
|
||||||
if (tes.getScreen(side) != null) {
|
if (tes.getScreen(side) != null) {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import net.montoyo.wd.client.gui.controls.Button;
|
||||||
import net.montoyo.wd.client.gui.controls.Control;
|
import net.montoyo.wd.client.gui.controls.Control;
|
||||||
import net.montoyo.wd.client.gui.controls.Label;
|
import net.montoyo.wd.client.gui.controls.Label;
|
||||||
import net.montoyo.wd.client.gui.loading.FillControl;
|
import net.montoyo.wd.client.gui.loading.FillControl;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
@ -40,7 +40,7 @@ public class GuiKeyboard extends WDScreen {
|
||||||
|
|
||||||
private static final String WARNING_FNAME = "wd_keyboard_warning.txt";
|
private static final String WARNING_FNAME = "wd_keyboard_warning.txt";
|
||||||
|
|
||||||
private TileEntityScreen tes;
|
private ScreenBlockEntity tes;
|
||||||
private BlockSide side;
|
private BlockSide side;
|
||||||
private final ArrayList<TypeData> evStack = new ArrayList<>();
|
private final ArrayList<TypeData> evStack = new ArrayList<>();
|
||||||
private BlockPos kbPos;
|
private BlockPos kbPos;
|
||||||
|
|
@ -56,7 +56,7 @@ public class GuiKeyboard extends WDScreen {
|
||||||
super(Component.nullToEmpty(null));
|
super(Component.nullToEmpty(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiKeyboard(TileEntityScreen tes, BlockSide side, BlockPos kbPos) {
|
public GuiKeyboard(ScreenBlockEntity tes, BlockSide side, BlockPos kbPos) {
|
||||||
this();
|
this();
|
||||||
this.tes = tes;
|
this.tes = tes;
|
||||||
this.side = side;
|
this.side = side;
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.client.gui.controls.*;
|
import net.montoyo.wd.client.gui.controls.*;
|
||||||
import net.montoyo.wd.client.gui.loading.FillControl;
|
import net.montoyo.wd.client.gui.loading.FillControl;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.item.WDItem;
|
import net.montoyo.wd.item.WDItem;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.UUID;
|
||||||
public class GuiScreenConfig extends WDScreen {
|
public class GuiScreenConfig extends WDScreen {
|
||||||
|
|
||||||
//Screen data
|
//Screen data
|
||||||
private final TileEntityScreen tes;
|
private final ScreenBlockEntity tes;
|
||||||
private final BlockSide side;
|
private final BlockSide side;
|
||||||
private NameUUIDPair owner;
|
private NameUUIDPair owner;
|
||||||
private NameUUIDPair[] friends;
|
private NameUUIDPair[] friends;
|
||||||
|
|
@ -119,7 +119,7 @@ public class GuiScreenConfig extends WDScreen {
|
||||||
private CheckBox[] friendBoxes;
|
private CheckBox[] friendBoxes;
|
||||||
private CheckBox[] otherBoxes;
|
private CheckBox[] otherBoxes;
|
||||||
|
|
||||||
public GuiScreenConfig(Component component, TileEntityScreen tes, BlockSide side, NameUUIDPair[] friends, int fr, int or) {
|
public GuiScreenConfig(Component component, ScreenBlockEntity tes, BlockSide side, NameUUIDPair[] friends, int fr, int or) {
|
||||||
super(component);
|
super(component);
|
||||||
this.tes = tes;
|
this.tes = tes;
|
||||||
this.side = side;
|
this.side = side;
|
||||||
|
|
@ -147,7 +147,7 @@ public class GuiScreenConfig extends WDScreen {
|
||||||
boxOClick.setUserdata(ScreenRights.INTERACT);
|
boxOClick.setUserdata(ScreenRights.INTERACT);
|
||||||
boxOSetUrl.setUserdata(ScreenRights.CHANGE_URL);
|
boxOSetUrl.setUserdata(ScreenRights.CHANGE_URL);
|
||||||
|
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
ScreenBlockEntity.Screen scr = tes.getScreen(side);
|
||||||
if(scr != null) {
|
if(scr != null) {
|
||||||
owner = scr.owner;
|
owner = scr.owner;
|
||||||
rotation = scr.rotation;
|
rotation = scr.rotation;
|
||||||
|
|
@ -191,7 +191,7 @@ public class GuiScreenConfig extends WDScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clickSetRes() {
|
private void clickSetRes() {
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
ScreenBlockEntity.Screen scr = tes.getScreen(side);
|
||||||
if(scr == null)
|
if(scr == null)
|
||||||
return; //WHATDAFUQ?
|
return; //WHATDAFUQ?
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import net.montoyo.wd.client.ClientProxy;
|
||||||
import net.montoyo.wd.client.gui.controls.Button;
|
import net.montoyo.wd.client.gui.controls.Button;
|
||||||
import net.montoyo.wd.client.gui.controls.TextField;
|
import net.montoyo.wd.client.gui.controls.TextField;
|
||||||
import net.montoyo.wd.client.gui.loading.FillControl;
|
import net.montoyo.wd.client.gui.loading.FillControl;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.item.ItemMinePad2;
|
import net.montoyo.wd.item.ItemMinePad2;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.server_bound.C2SMessageMinepadUrl;
|
import net.montoyo.wd.net.server_bound.C2SMessageMinepadUrl;
|
||||||
|
|
@ -32,7 +32,7 @@ import java.util.UUID;
|
||||||
public class GuiSetURL2 extends WDScreen {
|
public class GuiSetURL2 extends WDScreen {
|
||||||
|
|
||||||
//Screen data
|
//Screen data
|
||||||
private TileEntityScreen tileEntity;
|
private ScreenBlockEntity tileEntity;
|
||||||
private BlockSide screenSide;
|
private BlockSide screenSide;
|
||||||
private Vector3i remoteLocation;
|
private Vector3i remoteLocation;
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class GuiSetURL2 extends WDScreen {
|
||||||
@FillControl
|
@FillControl
|
||||||
private Button btnOk;
|
private Button btnOk;
|
||||||
|
|
||||||
public GuiSetURL2(TileEntityScreen tes, BlockSide side, String url, Vector3i rl) {
|
public GuiSetURL2(ScreenBlockEntity tes, BlockSide side, String url, Vector3i rl) {
|
||||||
super(Component.nullToEmpty(null));
|
super(Component.nullToEmpty(null));
|
||||||
tileEntity = tes;
|
tileEntity = tes;
|
||||||
screenSide = side;
|
screenSide = side;
|
||||||
|
|
@ -120,7 +120,7 @@ public class GuiSetURL2 extends WDScreen {
|
||||||
if (!url.isEmpty()) {
|
if (!url.isEmpty()) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TileEntityScreen.url(url);
|
ScreenBlockEntity.url(url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,21 +11,20 @@ import net.minecraft.client.renderer.GameRenderer;
|
||||||
import net.minecraft.client.renderer.MultiBufferSource;
|
import net.minecraft.client.renderer.MultiBufferSource;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.Vector3f;
|
import net.montoyo.wd.utilities.Vector3f;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import static com.mojang.math.Axis.*;
|
import static com.mojang.math.Axis.*;
|
||||||
|
|
||||||
public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
|
public class ScreenRenderer implements BlockEntityRenderer<ScreenBlockEntity> {
|
||||||
public ScreenRenderer() {
|
public ScreenRenderer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ScreenRendererProvider implements BlockEntityRendererProvider<TileEntityScreen> {
|
public static class ScreenRendererProvider implements BlockEntityRendererProvider<ScreenBlockEntity> {
|
||||||
@Override
|
@Override
|
||||||
public @NotNull BlockEntityRenderer<TileEntityScreen> create(@NotNull Context arg) {
|
public @NotNull BlockEntityRenderer<ScreenBlockEntity> create(@NotNull Context arg) {
|
||||||
return new ScreenRenderer();
|
return new ScreenRenderer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +34,7 @@ public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
|
||||||
private final Vector3f tmpf = new Vector3f();
|
private final Vector3f tmpf = new Vector3f();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(TileEntityScreen te, float partialTick, @NotNull PoseStack poseStack, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) {
|
public void render(ScreenBlockEntity te, float partialTick, @NotNull PoseStack poseStack, @NotNull MultiBufferSource bufferSource, int packedLight, int packedOverlay) {
|
||||||
if (!te.isLoaded())
|
if (!te.isLoaded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -45,7 +44,7 @@ public class ScreenRenderer implements BlockEntityRenderer<TileEntityScreen> {
|
||||||
RenderSystem.disableBlend();
|
RenderSystem.disableBlend();
|
||||||
|
|
||||||
for (int i = 0; i < te.screenCount(); i++) {
|
for (int i = 0; i < te.screenCount(); i++) {
|
||||||
TileEntityScreen.Screen scr = te.getScreen(i);
|
ScreenBlockEntity.Screen scr = te.getScreen(i);
|
||||||
if (scr.browser == null) {
|
if (scr.browser == null) {
|
||||||
scr.createBrowser(true);
|
scr.createBrowser(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
@ -22,9 +22,9 @@ public abstract class ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void write(FriendlyByteBuf buf);
|
public abstract void write(FriendlyByteBuf buf);
|
||||||
public abstract void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException;
|
public abstract void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException;
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public abstract void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx);
|
public abstract void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx);
|
||||||
|
|
||||||
public void checkPerms(int perms, Function<Integer, Boolean> checker, ServerPlayer player) throws MissingPermissionException {
|
public void checkPerms(int perms, Function<Integer, Boolean> checker, ServerPlayer player) throws MissingPermissionException {
|
||||||
if (!checker.apply(perms)) {
|
if (!checker.apply(perms)) {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.builtin.*;
|
import net.montoyo.wd.controls.builtin.*;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ public class ScreenControlRegistry {
|
||||||
if (FMLEnvironment.dist.isClient()) {
|
if (FMLEnvironment.dist.isClient()) {
|
||||||
boolean shouldThrow = false;
|
boolean shouldThrow = false;
|
||||||
try {
|
try {
|
||||||
Method m = type.clazz.getMethod("handleClient", BlockPos.class, BlockSide.class, TileEntityScreen.class, NetworkEvent.Context.class);
|
Method m = type.clazz.getMethod("handleClient", BlockPos.class, BlockSide.class, ScreenBlockEntity.class, NetworkEvent.Context.class);
|
||||||
OnlyIn onlyIn = m.getAnnotation(OnlyIn.class);
|
OnlyIn onlyIn = m.getAnnotation(OnlyIn.class);
|
||||||
if (onlyIn == null) shouldThrow = true;
|
if (onlyIn == null) shouldThrow = true;
|
||||||
Dist d = onlyIn.value(); // idc if this throws, lol
|
Dist d = onlyIn.value(); // idc if this throws, lol
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
@ -35,7 +35,7 @@ public class AutoVolumeControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
// I feel like there's probably a better permission category
|
// I feel like there's probably a better permission category
|
||||||
checkPerms(ScreenRights.MANAGE_UPGRADES, permissionChecker, ctx.getSender());
|
checkPerms(ScreenRights.MANAGE_UPGRADES, permissionChecker, ctx.getSender());
|
||||||
tes.setAutoVolume(side, autoVol);
|
tes.setAutoVolume(side, autoVol);
|
||||||
|
|
@ -43,7 +43,7 @@ public class AutoVolumeControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
tes.setAutoVolume(side, autoVol);
|
tes.setAutoVolume(side, autoVol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Vector2i;
|
import net.montoyo.wd.utilities.Vector2i;
|
||||||
|
|
||||||
|
|
@ -47,13 +47,13 @@ public class ClickControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
throw new RuntimeException("Cannot call click control on server");
|
throw new RuntimeException("Cannot call click control on server");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
if (coord != null)
|
if (coord != null)
|
||||||
tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, coord, -1);
|
tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, coord, -1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.JSServerRequest;
|
import net.montoyo.wd.core.JSServerRequest;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Log;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
|
@ -49,7 +48,7 @@ public class JSRequestControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
ServerPlayer player = ctx.getSender();
|
ServerPlayer player = ctx.getSender();
|
||||||
// if (reqType == null || data == null) Log.warning("Caught invalid JS request from player %s (UUID %s)", player.getName(), player.getGameProfile().getId().toString());
|
// if (reqType == null || data == null) Log.warning("Caught invalid JS request from player %s (UUID %s)", player.getName(), player.getGameProfile().getId().toString());
|
||||||
// else tes.handleJSRequest(player, side, reqId, reqType, data);
|
// else tes.handleJSRequest(player, side, reqId, reqType, data);
|
||||||
|
|
@ -57,7 +56,7 @@ public class JSRequestControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
throw new RuntimeException("TODO");
|
throw new RuntimeException("TODO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
@ -39,14 +39,14 @@ public class KeyTypedControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
checkPerms(ScreenRights.INTERACT, permissionChecker, ctx.getSender());
|
checkPerms(ScreenRights.INTERACT, permissionChecker, ctx.getSender());
|
||||||
tes.type(side, text, soundPos, ctx.getSender());
|
tes.type(side, text, soundPos, ctx.getSender());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
tes.type(side, text, soundPos);
|
tes.type(side, text, soundPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Vector2i;
|
import net.montoyo.wd.utilities.Vector2i;
|
||||||
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class LaserControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
// feel like this makes sense, but I wanna get opinions first
|
// feel like this makes sense, but I wanna get opinions first
|
||||||
// checkPerms(ScreenRights.INTERACT, permissionChecker, ctx.getSender());
|
// checkPerms(ScreenRights.INTERACT, permissionChecker, ctx.getSender());
|
||||||
ServerPlayer sender = ctx.getSender();
|
ServerPlayer sender = ctx.getSender();
|
||||||
|
|
@ -67,7 +67,7 @@ public class LaserControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
if (coord != null)
|
if (coord != null)
|
||||||
tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, coord, -1);
|
tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, coord, -1);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
@ -79,7 +79,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
ServerPlayer player = ctx.getSender();
|
ServerPlayer player = ctx.getSender();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case UPGRADES -> {
|
case UPGRADES -> {
|
||||||
|
|
@ -89,7 +89,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl {
|
||||||
else tes.removeUpgrade(side, toRemove, player);
|
else tes.removeUpgrade(side, toRemove, player);
|
||||||
}
|
}
|
||||||
case RIGHTS -> {
|
case RIGHTS -> {
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
ScreenBlockEntity.Screen scr = tes.getScreen(side);
|
||||||
|
|
||||||
int fr = scr.owner.uuid.equals(player.getGameProfile().getId()) ? friendRights : scr.friendRights;
|
int fr = scr.owner.uuid.equals(player.getGameProfile().getId()) ? friendRights : scr.friendRights;
|
||||||
int or = (scr.rightsFor(player) & ScreenRights.MANAGE_OTHER_RIGHTS) == 0 ? scr.otherRights : otherRights;
|
int or = (scr.rightsFor(player) & ScreenRights.MANAGE_OTHER_RIGHTS) == 0 ? scr.otherRights : otherRights;
|
||||||
|
|
@ -102,7 +102,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
ServerPlayer player = ctx.getSender();
|
ServerPlayer player = ctx.getSender();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case UPGRADES -> {
|
case UPGRADES -> {
|
||||||
|
|
@ -111,7 +111,7 @@ public class ManageRightsAndUpdgradesControl extends ScreenControl {
|
||||||
else tes.removeUpgrade(side, toRemove, player);
|
else tes.removeUpgrade(side, toRemove, player);
|
||||||
}
|
}
|
||||||
case RIGHTS -> {
|
case RIGHTS -> {
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
ScreenBlockEntity.Screen scr = tes.getScreen(side);
|
||||||
|
|
||||||
int fr = friendRights;
|
int fr = friendRights;
|
||||||
int or = otherRights;
|
int or = otherRights;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class ModifyFriendListControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
ServerPlayer player = ctx.getSender();
|
ServerPlayer player = ctx.getSender();
|
||||||
checkPerms(ScreenRights.MANAGE_FRIEND_LIST, permissionChecker, ctx.getSender());
|
checkPerms(ScreenRights.MANAGE_FRIEND_LIST, permissionChecker, ctx.getSender());
|
||||||
if (adding) tes.addFriend(player, side, friend);
|
if (adding) tes.addFriend(player, side, friend);
|
||||||
|
|
@ -50,7 +50,7 @@ public class ModifyFriendListControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
throw new RuntimeException("TODO");
|
throw new RuntimeException("TODO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||||
|
|
||||||
|
|
@ -35,13 +35,13 @@ public class OwnerControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
throw new RuntimeException("Cannot handle ownership theft packet from server");
|
throw new RuntimeException("Cannot handle ownership theft packet from server");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
tes.getScreen(side).owner = owner;
|
tes.getScreen(side).owner = owner;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Rotation;
|
import net.montoyo.wd.utilities.Rotation;
|
||||||
import net.montoyo.wd.utilities.Vector2i;
|
import net.montoyo.wd.utilities.Vector2i;
|
||||||
|
|
@ -55,7 +55,7 @@ public class ScreenModifyControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
checkPerms(ScreenRights.MODIFY_SCREEN, permissionChecker, ctx.getSender());
|
checkPerms(ScreenRights.MODIFY_SCREEN, permissionChecker, ctx.getSender());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RESOLUTION -> tes.setResolution(side, res);
|
case RESOLUTION -> tes.setResolution(side, res);
|
||||||
|
|
@ -65,7 +65,7 @@ public class ScreenModifyControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RESOLUTION -> tes.setResolution(side, res);
|
case RESOLUTION -> tes.setResolution(side, res);
|
||||||
case ROTATION -> tes.setRotation(side, rotation);
|
case ROTATION -> tes.setRotation(side, rotation);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class SetURLControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
// TODO: deal with remote
|
// TODO: deal with remote
|
||||||
checkPerms(ScreenRights.CHANGE_URL, permissionChecker, ctx.getSender());
|
checkPerms(ScreenRights.CHANGE_URL, permissionChecker, ctx.getSender());
|
||||||
try {
|
try {
|
||||||
|
|
@ -53,7 +53,7 @@ public class SetURLControl extends ScreenControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
try {
|
try {
|
||||||
tes.setScreenURL(side, url);
|
tes.setScreenURL(side, url);
|
||||||
} catch (Throwable err) {
|
} catch (Throwable err) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,8 @@ import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
|
@ -29,13 +28,13 @@ public class TurnOffControl extends ScreenControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleServer(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
public void handleServer(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx, Function<Integer, Boolean> permissionChecker) throws MissingPermissionException {
|
||||||
throw new RuntimeException("Cannot handle deactivation packet from server");
|
throw new RuntimeException("Cannot handle deactivation packet from server");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public void handleClient(BlockPos pos, BlockSide side, TileEntityScreen tes, NetworkEvent.Context ctx) {
|
public void handleClient(BlockPos pos, BlockSide side, ScreenBlockEntity tes, NetworkEvent.Context ctx) {
|
||||||
if (side != null) {
|
if (side != null) {
|
||||||
WebDisplays.PROXY.closeGui(pos, side);
|
WebDisplays.PROXY.closeGui(pos, side);
|
||||||
tes.disableScreen(side);
|
tes.disableScreen(side);
|
||||||
|
|
|
||||||
|
|
@ -8,22 +8,22 @@ import net.minecraft.util.StringRepresentable;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
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.entity.BlockEntityType;
|
||||||
import net.montoyo.wd.entity.TileEntityKeyboard;
|
import net.montoyo.wd.entity.KeyboardBlockEntity;
|
||||||
import net.montoyo.wd.entity.TileEntityRCtrl;
|
import net.montoyo.wd.entity.RemoteControlBlockEntity;
|
||||||
import net.montoyo.wd.entity.TileEntityRedCtrl;
|
import net.montoyo.wd.entity.RedstoneControlBlockEntity;
|
||||||
import net.montoyo.wd.entity.TileEntityServer;
|
import net.montoyo.wd.entity.ServerBlockEntity;
|
||||||
import net.montoyo.wd.registry.BlockRegistry;
|
import net.montoyo.wd.registry.BlockRegistry;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public enum DefaultPeripheral implements StringRepresentable {
|
public enum DefaultPeripheral implements StringRepresentable {
|
||||||
KEYBOARD("keyboard", "Keyboard", TileEntityKeyboard::new, BlockRegistry.KEYBOARD_BLOCK), //WITH FACING (< 3)
|
KEYBOARD("keyboard", "Keyboard", KeyboardBlockEntity::new, BlockRegistry.KEYBOARD_BLOCK), //WITH FACING (< 3)
|
||||||
// CC_INTERFACE("ccinterface", "ComputerCraft_Interface", TileEntityCCInterface.class),
|
// CC_INTERFACE("ccinterface", "ComputerCraft_Interface", TileEntityCCInterface.class),
|
||||||
// OC_INTERFACE("cointerface", "OpenComputers_Interface", TileEntityOCInterface.class),
|
// OC_INTERFACE("cointerface", "OpenComputers_Interface", TileEntityOCInterface.class),
|
||||||
REMOTE_CONTROLLER("remotectrl", "Remote_Controller", TileEntityRCtrl::new , BlockRegistry.REMOTE_CONTROLLER_BLOCK), //WITHOUT FACING (>= 3)
|
REMOTE_CONTROLLER("remotectrl", "Remote_Controller", RemoteControlBlockEntity::new , BlockRegistry.REMOTE_CONTROLLER_BLOCK), //WITHOUT FACING (>= 3)
|
||||||
REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", TileEntityRedCtrl::new , BlockRegistry.REDSTONE_CONTROL_BLOCK),
|
REDSTONE_CONTROLLER("redstonectrl", "Redstone_Controller", RedstoneControlBlockEntity::new , BlockRegistry.REDSTONE_CONTROL_BLOCK),
|
||||||
SERVER("server", "Server", TileEntityServer::new, BlockRegistry.SERVER_BLOCK);
|
SERVER("server", "Server", ServerBlockEntity::new, BlockRegistry.SERVER_BLOCK);
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String wikiName;
|
private final String wikiName;
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@ package net.montoyo.wd.core;
|
||||||
|
|
||||||
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.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public interface IUpgrade {
|
public interface IUpgrade {
|
||||||
void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is);
|
void onInstall(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is);
|
||||||
boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is); //Return true to prevent dropping
|
boolean onRemove(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is); //Return true to prevent dropping
|
||||||
boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack); //myStack.getItem() is an instance of this class
|
boolean isSameUpgrade(@Nonnull ItemStack myStack, @Nonnull ItemStack otherStack); //myStack.getItem() is an instance of this class
|
||||||
String getJSName(@Nonnull ItemStack is); //modname:upgradename
|
String getJSName(@Nonnull ItemStack is); //modname:upgradename
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
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.montoyo.wd.client.gui.GuiKeyboard;
|
import net.montoyo.wd.client.gui.GuiKeyboard;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
@ -27,7 +27,7 @@ public class KeyboardData extends GuiData {
|
||||||
public KeyboardData() {
|
public KeyboardData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardData(TileEntityScreen tes, BlockSide side, BlockPos kbPos) {
|
public KeyboardData(ScreenBlockEntity tes, BlockSide side, BlockPos kbPos) {
|
||||||
pos = new Vector3i(tes.getBlockPos());
|
pos = new Vector3i(tes.getBlockPos());
|
||||||
this.side = side;
|
this.side = side;
|
||||||
kbX = kbPos.getX();
|
kbX = kbPos.getX();
|
||||||
|
|
@ -39,12 +39,12 @@ public class KeyboardData extends GuiData {
|
||||||
@Override
|
@Override
|
||||||
public Screen createGui(Screen old, Level world) {
|
public Screen createGui(Screen old, Level world) {
|
||||||
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
||||||
if (te == null || !(te instanceof TileEntityScreen)) {
|
if (te == null || !(te instanceof ScreenBlockEntity)) {
|
||||||
Log.error("TileEntity at %s is not a screen; can't open keyboard!", pos.toString());
|
Log.error("TileEntity at %s is not a screen; can't open keyboard!", pos.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GuiKeyboard((TileEntityScreen) te, side, new BlockPos(kbX, kbY, kbZ));
|
return new GuiKeyboard((ScreenBlockEntity) te, side, new BlockPos(kbX, kbY, kbZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
import net.minecraftforge.network.PacketDistributor;
|
import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.montoyo.wd.client.gui.GuiScreenConfig;
|
import net.montoyo.wd.client.gui.GuiScreenConfig;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.BufferUtils;
|
import net.montoyo.wd.net.BufferUtils;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.client_bound.S2CMessageOpenGui;
|
import net.montoyo.wd.net.client_bound.S2CMessageOpenGui;
|
||||||
|
|
@ -33,7 +33,7 @@ public class ScreenConfigData extends GuiData {
|
||||||
public ScreenConfigData() {
|
public ScreenConfigData() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScreenConfigData(Vector3i pos, BlockSide side, TileEntityScreen.Screen scr) {
|
public ScreenConfigData(Vector3i pos, BlockSide side, ScreenBlockEntity.Screen scr) {
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.side = side;
|
this.side = side;
|
||||||
friends = scr.friends.toArray(new NameUUIDPair[0]);
|
friends = scr.friends.toArray(new NameUUIDPair[0]);
|
||||||
|
|
@ -62,12 +62,12 @@ public class ScreenConfigData extends GuiData {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
||||||
if (te == null || !(te instanceof TileEntityScreen)) {
|
if (te == null || !(te instanceof ScreenBlockEntity)) {
|
||||||
Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString());
|
Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GuiScreenConfig(Component.nullToEmpty(""), (TileEntityScreen) te, side, friends, friendRights, otherRights);
|
return new GuiScreenConfig(Component.nullToEmpty(""), (ScreenBlockEntity) te, side, friends, friendRights, otherRights);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
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.montoyo.wd.client.gui.GuiSetURL2;
|
import net.montoyo.wd.client.gui.GuiSetURL2;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.BufferUtils;
|
import net.montoyo.wd.net.BufferUtils;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Log;
|
import net.montoyo.wd.utilities.Log;
|
||||||
|
|
@ -49,12 +49,12 @@ public class SetURLData extends GuiData {
|
||||||
@Override
|
@Override
|
||||||
public Screen createGui(Screen old, Level world) {
|
public Screen createGui(Screen old, Level world) {
|
||||||
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
BlockEntity te = world.getBlockEntity(pos.toBlock());
|
||||||
if (te == null || !(te instanceof TileEntityScreen)) {
|
if (te == null || !(te instanceof ScreenBlockEntity)) {
|
||||||
Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString());
|
Log.error("TileEntity at %s is not a screen; can't open gui!", pos.toString());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new GuiSetURL2((TileEntityScreen) te, side, url, isRemote ? remoteLocation : null);
|
return new GuiSetURL2((ScreenBlockEntity) te, side, url, isRemote ? remoteLocation : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ import java.lang.annotation.Target;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
public abstract class AbstractInterfaceBlockEntity extends AbstractPeripheralBlockEntity {
|
||||||
public TileEntityInterfaceBase(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
|
public AbstractInterfaceBlockEntity(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
|
||||||
super(arg, arg2, arg3);
|
super(arg, arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
throw new IllegalArgumentException("invalid right name");
|
throw new IllegalArgumentException("invalid right name");
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen tes = getConnectedScreenEx();
|
ScreenBlockEntity tes = getConnectedScreenEx();
|
||||||
if(owner == null || tes == null)
|
if(owner == null || tes == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
|
|
@ -118,7 +118,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
public Object[] hasUpgrade(IComputerArgs args) {
|
public Object[] hasUpgrade(IComputerArgs args) {
|
||||||
String name = args.checkString(0);
|
String name = args.checkString(0);
|
||||||
|
|
||||||
TileEntityScreen tes = getConnectedScreenEx();
|
ScreenBlockEntity tes = getConnectedScreenEx();
|
||||||
if(owner == null || tes == null)
|
if(owner == null || tes == null)
|
||||||
return null;
|
return null;
|
||||||
else
|
else
|
||||||
|
|
@ -127,7 +127,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
|
|
||||||
@ComputerFunc
|
@ComputerFunc
|
||||||
public Object[] getSize(IComputerArgs args) {
|
public Object[] getSize(IComputerArgs args) {
|
||||||
TileEntityScreen tes = getConnectedScreenEx();
|
ScreenBlockEntity tes = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || tes == null)
|
if(owner == null || tes == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -139,7 +139,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
|
|
||||||
@ComputerFunc
|
@ComputerFunc
|
||||||
public Object[] getResolution(IComputerArgs args) {
|
public Object[] getResolution(IComputerArgs args) {
|
||||||
TileEntityScreen tes = getConnectedScreenEx();
|
ScreenBlockEntity tes = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || tes == null)
|
if(owner == null || tes == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -151,7 +151,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
|
|
||||||
@ComputerFunc
|
@ComputerFunc
|
||||||
public Object[] getRotation(IComputerArgs args) {
|
public Object[] getRotation(IComputerArgs args) {
|
||||||
TileEntityScreen tes = getConnectedScreenEx();
|
ScreenBlockEntity tes = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || tes == null)
|
if(owner == null || tes == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -161,7 +161,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
|
|
||||||
@ComputerFunc
|
@ComputerFunc
|
||||||
public Object[] getURL(IComputerArgs args) {
|
public Object[] getURL(IComputerArgs args) {
|
||||||
TileEntityScreen tes = getConnectedScreenEx();
|
ScreenBlockEntity tes = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || tes == null)
|
if(owner == null || tes == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -205,12 +205,12 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
// throw new IllegalArgumentException("bad action name");
|
// throw new IllegalArgumentException("bad action name");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
TileEntityScreen scr = getConnectedScreenEx();
|
ScreenBlockEntity scr = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || scr == null)
|
if(owner == null || scr == null)
|
||||||
return err("notlinked");
|
return err("notlinked");
|
||||||
else {
|
else {
|
||||||
TileEntityScreen.Screen scrscr = scr.getScreen(screenSide);
|
ScreenBlockEntity.Screen scrscr = scr.getScreen(screenSide);
|
||||||
|
|
||||||
if((scrscr.rightsFor(owner.uuid) & ScreenRights.INTERACT) == 0)
|
if((scrscr.rightsFor(owner.uuid) & ScreenRights.INTERACT) == 0)
|
||||||
return err("restrictions");
|
return err("restrictions");
|
||||||
|
|
@ -244,7 +244,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] realType(String what) {
|
private Object[] realType(String what) {
|
||||||
TileEntityScreen scr = getConnectedScreenEx();
|
ScreenBlockEntity scr = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || scr == null)
|
if(owner == null || scr == null)
|
||||||
return err("notlinked");
|
return err("notlinked");
|
||||||
|
|
@ -325,7 +325,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
@ComputerFunc
|
@ComputerFunc
|
||||||
public Object[] setURL(IComputerArgs args) {
|
public Object[] setURL(IComputerArgs args) {
|
||||||
String url = args.checkString(0);
|
String url = args.checkString(0);
|
||||||
TileEntityScreen scr = getConnectedScreenEx();
|
ScreenBlockEntity scr = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || scr == null)
|
if(owner == null || scr == null)
|
||||||
return err("notlinked");
|
return err("notlinked");
|
||||||
|
|
@ -345,7 +345,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
public Object[] setResolution(IComputerArgs args) {
|
public Object[] setResolution(IComputerArgs args) {
|
||||||
int rx = args.checkInteger(0);
|
int rx = args.checkInteger(0);
|
||||||
int ry = args.checkInteger(1);
|
int ry = args.checkInteger(1);
|
||||||
TileEntityScreen scr = getConnectedScreenEx();
|
ScreenBlockEntity scr = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || scr == null)
|
if(owner == null || scr == null)
|
||||||
return err("notlinked");
|
return err("notlinked");
|
||||||
|
|
@ -368,7 +368,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
rot /= 90;
|
rot /= 90;
|
||||||
rot &= 3;
|
rot &= 3;
|
||||||
|
|
||||||
TileEntityScreen scr = getConnectedScreenEx();
|
ScreenBlockEntity scr = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || scr == null)
|
if(owner == null || scr == null)
|
||||||
return err("notlinked");
|
return err("notlinked");
|
||||||
|
|
@ -383,7 +383,7 @@ public abstract class TileEntityInterfaceBase extends TileEntityPeripheralBase {
|
||||||
@ComputerFunc
|
@ComputerFunc
|
||||||
public Object[] runJS(IComputerArgs args) {
|
public Object[] runJS(IComputerArgs args) {
|
||||||
String code = args.checkString(0);
|
String code = args.checkString(0);
|
||||||
TileEntityScreen scr = getConnectedScreenEx();
|
ScreenBlockEntity scr = getConnectedScreenEx();
|
||||||
|
|
||||||
if(owner == null || scr == null)
|
if(owner == null || scr == null)
|
||||||
return err("notlinked");
|
return err("notlinked");
|
||||||
|
|
@ -24,11 +24,11 @@ import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public abstract class TileEntityPeripheralBase extends BlockEntity implements IPeripheral {
|
public abstract class AbstractPeripheralBlockEntity extends BlockEntity implements IPeripheral {
|
||||||
protected Vector3i screenPos;
|
protected Vector3i screenPos;
|
||||||
protected BlockSide screenSide;
|
protected BlockSide screenSide;
|
||||||
|
|
||||||
public TileEntityPeripheralBase(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
|
public AbstractPeripheralBlockEntity(BlockEntityType<?> arg, BlockPos arg2, BlockState arg3) {
|
||||||
super(arg, arg2, arg3);
|
super(arg, arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,12 +78,12 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP
|
||||||
@Override
|
@Override
|
||||||
public boolean connect(Level world_, BlockPos blockPos, BlockState blockState, Vector3i pos, BlockSide side) {
|
public boolean connect(Level world_, BlockPos blockPos, BlockState blockState, Vector3i pos, BlockSide side) {
|
||||||
BlockEntity te = world_.getBlockEntity(pos.toBlock());
|
BlockEntity te = world_.getBlockEntity(pos.toBlock());
|
||||||
if (!(te instanceof TileEntityScreen)) {
|
if (!(te instanceof ScreenBlockEntity)) {
|
||||||
Log.error("TileEntityPeripheralBase.connect(): Tile entity at %s is not a screen!", pos.toString());
|
Log.error("TileEntityPeripheralBase.connect(): Tile entity at %s is not a screen!", pos.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((TileEntityScreen) te).getScreen(side) == null) {
|
if (((ScreenBlockEntity) te).getScreen(side) == null) {
|
||||||
Log.error("TileEntityPeripheralBase.connect(): There is no screen at %s on side %s!", pos.toString(), side.toString());
|
Log.error("TileEntityPeripheralBase.connect(): There is no screen at %s on side %s!", pos.toString(), side.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -107,31 +107,31 @@ public abstract class TileEntityPeripheralBase extends BlockEntity implements IP
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TileEntityScreen getConnectedScreen() {
|
public ScreenBlockEntity getConnectedScreen() {
|
||||||
if (screenPos == null || screenSide == null)
|
if (screenPos == null || screenSide == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
|
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
|
||||||
if (!(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null) {
|
if (!(te instanceof ScreenBlockEntity) || ((ScreenBlockEntity) te).getScreen(screenSide) == null) {
|
||||||
screenPos = null;
|
screenPos = null;
|
||||||
screenSide = null;
|
screenSide = null;
|
||||||
setChanged();
|
setChanged();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TileEntityScreen) te;
|
return (ScreenBlockEntity) te;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public TileEntityScreen getConnectedScreenEx() {
|
public ScreenBlockEntity getConnectedScreenEx() {
|
||||||
if (screenPos == null || screenSide == null)
|
if (screenPos == null || screenSide == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
|
BlockEntity te = level.getBlockEntity(screenPos.toBlock());
|
||||||
if (!(te instanceof TileEntityScreen) || ((TileEntityScreen) te).getScreen(screenSide) == null)
|
if (!(te instanceof ScreenBlockEntity) || ((ScreenBlockEntity) te).getScreen(screenSide) == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return (TileEntityScreen) te;
|
return (ScreenBlockEntity) te;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package net.montoyo.wd.entity;
|
package net.montoyo.wd.entity;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
import dan200.computercraft.api.lua.ILuaContext;
|
import dan200.computercraft.api.lua.ILuaContext;
|
||||||
import dan200.computercraft.api.lua.LuaException;
|
import dan200.computercraft.api.lua.LuaException;
|
||||||
|
|
@ -19,17 +20,17 @@ import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "computercraft")
|
@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "computercraft")
|
||||||
public class TileEntityCCInterface extends TileEntityInterfaceBase implements IPeripheral {
|
public class CCInterfaceBlockEntity extends AbstractInterfaceBlockEntity implements IPeripheral {
|
||||||
private static final String[] METHOD_NAMES;
|
private static final String[] METHOD_NAMES;
|
||||||
private static final Method[] METHODS;
|
private static final Method[] METHODS;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ArrayList<String> names = new ArrayList<>();
|
ArrayList<String> names = new ArrayList<>();
|
||||||
ArrayList<Method> methods = new ArrayList<>();
|
ArrayList<Method> methods = new ArrayList<>();
|
||||||
Method[] src = TileEntityInterfaceBase.class.getMethods();
|
Method[] src = AbstractInterfaceBlockEntity.class.getMethods();
|
||||||
|
|
||||||
for(Method m: src) {
|
for(Method m: src) {
|
||||||
if(m.getAnnotation(TileEntityInterfaceBase.ComputerFunc.class) != null) {
|
if(m.getAnnotation(AbstractInterfaceBlockEntity.ComputerFunc.class) != null) {
|
||||||
if(m.getParameterCount() != 1 || m.getParameterTypes()[0] != IComputerArgs.class)
|
if(m.getParameterCount() != 1 || m.getParameterTypes()[0] != IComputerArgs.class)
|
||||||
throw new RuntimeException("Found @ComputerFunc method with invalid arguments");
|
throw new RuntimeException("Found @ComputerFunc method with invalid arguments");
|
||||||
|
|
||||||
|
|
@ -18,10 +18,10 @@ import net.montoyo.wd.data.KeyboardData;
|
||||||
import net.montoyo.wd.registry.TileRegistry;
|
import net.montoyo.wd.registry.TileRegistry;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
public class TileEntityKeyboard extends TileEntityPeripheralBase {
|
public class KeyboardBlockEntity extends AbstractPeripheralBlockEntity {
|
||||||
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 KeyboardBlockEntity(BlockPos arg2, BlockState arg3) {
|
||||||
super(TileRegistry.KEYBOARD.get(), arg2, arg3);
|
super(TileRegistry.KEYBOARD.get(), arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,13 +35,13 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen tes = getConnectedScreen();
|
ScreenBlockEntity tes = getConnectedScreen();
|
||||||
if(tes == null) {
|
if(tes == null) {
|
||||||
Util.toast(player, "notLinked");
|
Util.toast(player, "notLinked");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
|
ScreenBlockEntity.Screen scr = tes.getScreen(screenSide);
|
||||||
if((scr.rightsFor(player) & ScreenRights.INTERACT) == 0) {
|
if((scr.rightsFor(player) & ScreenRights.INTERACT) == 0) {
|
||||||
Util.toast(player, "restrictions");
|
Util.toast(player, "restrictions");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
@ -55,10 +55,10 @@ public class TileEntityKeyboard extends TileEntityPeripheralBase {
|
||||||
if(!isScreenChunkLoaded())
|
if(!isScreenChunkLoaded())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileEntityScreen tes = getConnectedScreen();
|
ScreenBlockEntity tes = getConnectedScreen();
|
||||||
|
|
||||||
if(tes != null) {
|
if(tes != null) {
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
|
ScreenBlockEntity.Screen scr = tes.getScreen(screenSide);
|
||||||
boolean ok;
|
boolean ok;
|
||||||
|
|
||||||
if(ent instanceof Player)
|
if(ent instanceof Player)
|
||||||
|
|
@ -13,8 +13,7 @@ import net.minecraftforge.fml.common.Optional;
|
||||||
import net.montoyo.wd.core.OCArguments;
|
import net.montoyo.wd.core.OCArguments;
|
||||||
|
|
||||||
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")
|
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")
|
||||||
public class TileEntityOCInterface extends TileEntityInterfaceBase implements SimpleComponent {
|
public class OCInterfaceBlockEntity extends AbstractInterfaceBlockEntity implements SimpleComponent {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getComponentName() {
|
public String getComponentName() {
|
||||||
return "webdisplays";
|
return "webdisplays";
|
||||||
|
|
@ -133,5 +132,4 @@ public class TileEntityOCInterface extends TileEntityInterfaceBase implements Si
|
||||||
public Object[] unlink(Context ctx, Arguments args) {
|
public Object[] unlink(Context ctx, Arguments args) {
|
||||||
return unlink(new OCArguments(args));
|
return unlink(new OCArguments(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
@ -19,12 +19,12 @@ import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
public class RedstoneControlBlockEntity extends AbstractPeripheralBlockEntity {
|
||||||
private String risingEdgeURL = "";
|
private String risingEdgeURL = "";
|
||||||
private String fallingEdgeURL = "";
|
private String fallingEdgeURL = "";
|
||||||
private boolean state = false;
|
private boolean state = false;
|
||||||
|
|
||||||
public TileEntityRedCtrl(BlockPos arg2, BlockState arg3) {
|
public RedstoneControlBlockEntity(BlockPos arg2, BlockState arg3) {
|
||||||
super(TileRegistry.REDSTONE_CONTROLLER.get(), arg2, arg3);
|
super(TileRegistry.REDSTONE_CONTROLLER.get(), arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,13 +55,13 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen tes = getConnectedScreen();
|
ScreenBlockEntity tes = getConnectedScreen();
|
||||||
if (tes == null) {
|
if (tes == null) {
|
||||||
Util.toast(player, "notLinked");
|
Util.toast(player, "notLinked");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
|
ScreenBlockEntity.Screen scr = tes.getScreen(screenSide);
|
||||||
if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
|
if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
|
||||||
Util.toast(player, "restrictions");
|
Util.toast(player, "restrictions");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
@ -96,7 +96,7 @@ public class TileEntityRedCtrl extends TileEntityPeripheralBase {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isScreenChunkLoaded()) {
|
if (isScreenChunkLoaded()) {
|
||||||
TileEntityScreen tes = getConnectedScreen();
|
ScreenBlockEntity tes = getConnectedScreen();
|
||||||
|
|
||||||
if (tes != null)
|
if (tes != null)
|
||||||
try {
|
try {
|
||||||
|
|
@ -15,8 +15,8 @@ import net.montoyo.wd.data.SetURLData;
|
||||||
import net.montoyo.wd.registry.TileRegistry;
|
import net.montoyo.wd.registry.TileRegistry;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
public class TileEntityRCtrl extends TileEntityPeripheralBase {
|
public class RemoteControlBlockEntity extends AbstractPeripheralBlockEntity {
|
||||||
public TileEntityRCtrl(BlockPos arg2, BlockState arg3) {
|
public RemoteControlBlockEntity(BlockPos arg2, BlockState arg3) {
|
||||||
super(TileRegistry.REMOTE_CONTROLLER.get(), arg2, arg3);
|
super(TileRegistry.REMOTE_CONTROLLER.get(), arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,13 +30,13 @@ public class TileEntityRCtrl extends TileEntityPeripheralBase {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen tes = getConnectedScreen();
|
ScreenBlockEntity tes = getConnectedScreen();
|
||||||
if (tes == null) {
|
if (tes == null) {
|
||||||
Util.toast(player, "notLinked");
|
Util.toast(player, "notLinked");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(screenSide);
|
ScreenBlockEntity.Screen scr = tes.getScreen(screenSide);
|
||||||
if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
|
if ((scr.rightsFor(player) & ScreenRights.CHANGE_URL) == 0) {
|
||||||
Util.toast(player, "restrictions");
|
Util.toast(player, "restrictions");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
@ -53,8 +53,8 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
import static net.montoyo.wd.block.BlockPeripheral.point;
|
import static net.montoyo.wd.block.BlockPeripheral.point;
|
||||||
|
|
||||||
public class TileEntityScreen extends BlockEntity {
|
public class ScreenBlockEntity extends BlockEntity {
|
||||||
public TileEntityScreen(BlockPos arg2, BlockState arg3) {
|
public ScreenBlockEntity(BlockPos arg2, BlockState arg3) {
|
||||||
super(TileRegistry.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
|
super(TileRegistry.SCREEN_BLOCK_ENTITY.get(), arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -792,7 +792,7 @@ public class TileEntityScreen extends BlockEntity {
|
||||||
// TODO: what? lol
|
// TODO: what? lol
|
||||||
String webUrl;
|
String webUrl;
|
||||||
try {
|
try {
|
||||||
webUrl = TileEntityScreen.url(url);
|
webUrl = ScreenBlockEntity.url(url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
@ -16,10 +16,10 @@ import net.montoyo.wd.registry.TileRegistry;
|
||||||
import net.montoyo.wd.utilities.NameUUIDPair;
|
import net.montoyo.wd.utilities.NameUUIDPair;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
||||||
public class TileEntityServer extends BlockEntity {
|
public class ServerBlockEntity extends BlockEntity {
|
||||||
private NameUUIDPair owner;
|
private NameUUIDPair owner;
|
||||||
|
|
||||||
public TileEntityServer(BlockPos arg2, BlockState arg3) {
|
public ServerBlockEntity(BlockPos arg2, BlockState arg3) {
|
||||||
super(TileRegistry.SERVER.get(), arg2, arg3);
|
super(TileRegistry.SERVER.get(), arg2, arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -16,7 +16,7 @@ import net.montoyo.wd.client.ClientProxy;
|
||||||
import net.montoyo.wd.config.ClientConfig;
|
import net.montoyo.wd.config.ClientConfig;
|
||||||
import net.montoyo.wd.controls.builtin.ClickControl;
|
import net.montoyo.wd.controls.builtin.ClickControl;
|
||||||
import net.montoyo.wd.core.DefaultUpgrade;
|
import net.montoyo.wd.core.DefaultUpgrade;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.registry.BlockRegistry;
|
import net.montoyo.wd.registry.BlockRegistry;
|
||||||
import net.montoyo.wd.net.WDNetworkRegistry;
|
import net.montoyo.wd.net.WDNetworkRegistry;
|
||||||
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
import net.montoyo.wd.net.server_bound.C2SMessageScreenCtrl;
|
||||||
|
|
@ -38,7 +38,7 @@ public class ItemLaserPointer extends Item implements WDItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Laser pointer
|
//Laser pointer
|
||||||
private static TileEntityScreen pointedScreen;
|
private static ScreenBlockEntity pointedScreen;
|
||||||
private static BlockSide pointedScreenSide;
|
private static BlockSide pointedScreenSide;
|
||||||
private static long lastPointPacket;
|
private static long lastPointPacket;
|
||||||
|
|
||||||
|
|
@ -57,11 +57,11 @@ public class ItemLaserPointer extends Item implements WDItem {
|
||||||
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
BlockSide side = BlockSide.values()[result.getDirection().ordinal()];
|
||||||
|
|
||||||
Multiblock.findOrigin(mc.level, pos, side, null);
|
Multiblock.findOrigin(mc.level, pos, side, null);
|
||||||
TileEntityScreen te = (TileEntityScreen) mc.level.getBlockEntity(pos.toBlock());
|
ScreenBlockEntity te = (ScreenBlockEntity) mc.level.getBlockEntity(pos.toBlock());
|
||||||
|
|
||||||
if (te != null && te.hasUpgrade(side, DefaultUpgrade.LASERMOUSE)) { //hasUpgrade returns false is there's no screen on side 'side'
|
if (te != null && te.hasUpgrade(side, DefaultUpgrade.LASERMOUSE)) { //hasUpgrade returns false is there's no screen on side 'side'
|
||||||
//Since rights aren't synchronized, let the server check them for us...
|
//Since rights aren't synchronized, let the server check them for us...
|
||||||
TileEntityScreen.Screen scr = te.getScreen(side);
|
ScreenBlockEntity.Screen scr = te.getScreen(side);
|
||||||
|
|
||||||
if (scr.browser != null) {
|
if (scr.browser != null) {
|
||||||
float hitX = ((float) result.getLocation().x) - (float) pos.x;
|
float hitX = ((float) result.getLocation().x) - (float) pos.x;
|
||||||
|
|
@ -81,7 +81,7 @@ public class ItemLaserPointer extends Item implements WDItem {
|
||||||
deselectScreen();
|
deselectScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void laserClick(TileEntityScreen tes, BlockSide side, TileEntityScreen.Screen scr, Vector2i hit) {
|
private static void laserClick(ScreenBlockEntity tes, BlockSide side, ScreenBlockEntity.Screen scr, Vector2i hit) {
|
||||||
tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, hit, -1);
|
tes.handleMouseEvent(side, ClickControl.ControlType.MOVE, hit, -1);
|
||||||
if (pointedScreen == tes && pointedScreenSide == side) {
|
if (pointedScreen == tes && pointedScreenSide == side) {
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
|
|
@ -125,14 +125,14 @@ public class ItemLaserPointer extends Item implements WDItem {
|
||||||
Vector2i tmp = new Vector2i();
|
Vector2i tmp = new Vector2i();
|
||||||
|
|
||||||
BlockEntity be = mc.level.getBlockEntity(pos.toBlock());
|
BlockEntity be = mc.level.getBlockEntity(pos.toBlock());
|
||||||
if (!(be instanceof TileEntityScreen)) return;
|
if (!(be instanceof ScreenBlockEntity)) return;
|
||||||
|
|
||||||
//noinspection PatternVariableCanBeUsed
|
//noinspection PatternVariableCanBeUsed
|
||||||
TileEntityScreen te = (TileEntityScreen) be;
|
ScreenBlockEntity te = (ScreenBlockEntity) be;
|
||||||
|
|
||||||
if (te.hasUpgrade(side, DefaultUpgrade.LASERMOUSE)) { //hasUpgrade returns false is there's no screen on side 'side'
|
if (te.hasUpgrade(side, DefaultUpgrade.LASERMOUSE)) { //hasUpgrade returns false is there's no screen on side 'side'
|
||||||
//Since rights aren't synchronized, let the server check them for us...
|
//Since rights aren't synchronized, let the server check them for us...
|
||||||
TileEntityScreen.Screen scr = te.getScreen(side);
|
ScreenBlockEntity.Screen scr = te.getScreen(side);
|
||||||
|
|
||||||
if (scr.browser != null) {
|
if (scr.browser != null) {
|
||||||
if (BlockScreen.hit2pixels(side, result.getBlockPos(), new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
|
if (BlockScreen.hit2pixels(side, result.getBlockPos(), new Vector3i(result.getBlockPos()), scr, hitX, hitY, hitZ, tmp)) {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.block.BlockScreen;
|
import net.montoyo.wd.block.BlockScreen;
|
||||||
import net.montoyo.wd.core.IPeripheral;
|
import net.montoyo.wd.core.IPeripheral;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Multiblock;
|
import net.montoyo.wd.utilities.Multiblock;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
@ -90,12 +90,12 @@ public class ItemLinker extends Item implements WDItem {
|
||||||
Multiblock.findOrigin(context.getLevel(), pos, side, null);
|
Multiblock.findOrigin(context.getLevel(), pos, side, null);
|
||||||
|
|
||||||
BlockEntity te = context.getLevel().getBlockEntity(pos.toBlock());
|
BlockEntity te = context.getLevel().getBlockEntity(pos.toBlock());
|
||||||
if (te == null || !(te instanceof TileEntityScreen)) {
|
if (te == null || !(te instanceof ScreenBlockEntity)) {
|
||||||
Util.toast(context.getPlayer(), "turnOn");
|
Util.toast(context.getPlayer(), "turnOn");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen.Screen scr = ((TileEntityScreen) te).getScreen(side);
|
ScreenBlockEntity.Screen scr = ((ScreenBlockEntity) te).getScreen(side);
|
||||||
if (scr == null)
|
if (scr == null)
|
||||||
Util.toast(context.getPlayer(), "turnOn");
|
Util.toast(context.getPlayer(), "turnOn");
|
||||||
else if ((scr.rightsFor(context.getPlayer()) & ScreenRights.MANAGE_UPGRADES) == 0)
|
else if ((scr.rightsFor(context.getPlayer()) & ScreenRights.MANAGE_UPGRADES) == 0)
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.montoyo.wd.WebDisplays;
|
|
||||||
import net.montoyo.wd.block.BlockScreen;
|
import net.montoyo.wd.block.BlockScreen;
|
||||||
import net.montoyo.wd.config.CommonConfig;
|
import net.montoyo.wd.config.CommonConfig;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
@ -55,11 +54,11 @@ public class ItemOwnershipThief extends Item implements WDItem {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
BlockEntity te = context.getLevel().getBlockEntity(bp);
|
BlockEntity te = context.getLevel().getBlockEntity(bp);
|
||||||
if (te == null || !(te instanceof TileEntityScreen))
|
if (te == null || !(te instanceof ScreenBlockEntity))
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
TileEntityScreen tes = (TileEntityScreen) te;
|
ScreenBlockEntity tes = (ScreenBlockEntity) te;
|
||||||
TileEntityScreen.Screen scr = tes.getScreen(side);
|
ScreenBlockEntity.Screen scr = tes.getScreen(side);
|
||||||
if (scr == null)
|
if (scr == null)
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
||||||
|
|
@ -79,12 +78,12 @@ public class ItemOwnershipThief extends Item implements WDItem {
|
||||||
Multiblock.findOrigin(context.getLevel(), pos, side, null);
|
Multiblock.findOrigin(context.getLevel(), pos, side, null);
|
||||||
|
|
||||||
BlockEntity te = context.getLevel().getBlockEntity(pos.toBlock());
|
BlockEntity te = context.getLevel().getBlockEntity(pos.toBlock());
|
||||||
if (te == null || !(te instanceof TileEntityScreen)) {
|
if (te == null || !(te instanceof ScreenBlockEntity)) {
|
||||||
Util.toast(context.getPlayer(), "turnOn");
|
Util.toast(context.getPlayer(), "turnOn");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((TileEntityScreen) te).getScreen(side) == null)
|
if (((ScreenBlockEntity) te).getScreen(side) == null)
|
||||||
Util.toast(context.getPlayer(), "turnOn");
|
Util.toast(context.getPlayer(), "turnOn");
|
||||||
else {
|
else {
|
||||||
CompoundTag tag = new CompoundTag();
|
CompoundTag tag = new CompoundTag();
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,9 @@ import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.context.UseOnContext;
|
import net.minecraft.world.item.context.UseOnContext;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.montoyo.wd.WebDisplays;
|
|
||||||
import net.montoyo.wd.block.BlockScreen;
|
import net.montoyo.wd.block.BlockScreen;
|
||||||
import net.montoyo.wd.data.ScreenConfigData;
|
import net.montoyo.wd.data.ScreenConfigData;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import net.montoyo.wd.utilities.Multiblock;
|
import net.montoyo.wd.utilities.Multiblock;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
|
|
@ -42,12 +41,12 @@ public class ItemScreenConfigurator extends Item implements WDItem {
|
||||||
Multiblock.findOrigin(context.getLevel(), origin, side, null);
|
Multiblock.findOrigin(context.getLevel(), origin, side, null);
|
||||||
BlockEntity te = context.getLevel().getBlockEntity(origin.toBlock());
|
BlockEntity te = context.getLevel().getBlockEntity(origin.toBlock());
|
||||||
|
|
||||||
if (te == null || !(te instanceof TileEntityScreen)) {
|
if (te == null || !(te instanceof ScreenBlockEntity)) {
|
||||||
Util.toast(context.getPlayer(), "turnOn");
|
Util.toast(context.getPlayer(), "turnOn");
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen.Screen scr = ((TileEntityScreen) te).getScreen(side);
|
ScreenBlockEntity.Screen scr = ((ScreenBlockEntity) te).getScreen(side);
|
||||||
if (scr == null)
|
if (scr == null)
|
||||||
Util.toast(context.getPlayer(), "turnOn");
|
Util.toast(context.getPlayer(), "turnOn");
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,9 @@ package net.montoyo.wd.item;
|
||||||
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.Item;
|
||||||
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.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.utilities.BlockSide;
|
import net.montoyo.wd.utilities.BlockSide;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
|
@ -26,11 +25,11 @@ public class ItemUpgrade extends ItemMulti implements IUpgrade, WDItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInstall(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
public void onInstall(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onRemove(@Nonnull TileEntityScreen tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
public boolean onRemove(@Nonnull ScreenBlockEntity tes, @Nonnull BlockSide screenSide, @Nullable Player player, @Nonnull ItemStack is) {
|
||||||
if (DefaultUpgrade.LASERMOUSE.matchesLaserMouse(is))
|
if (DefaultUpgrade.LASERMOUSE.matchesLaserMouse(is))
|
||||||
tes.clearLaserUser(screenSide);
|
tes.clearLaserUser(screenSide);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.WebDisplays;
|
import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.Packet;
|
import net.montoyo.wd.net.Packet;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
|
|
||||||
|
|
@ -22,24 +22,24 @@ import static net.montoyo.wd.block.BlockScreen.hasTE;
|
||||||
public class S2CMessageAddScreen extends Packet {
|
public class S2CMessageAddScreen extends Packet {
|
||||||
private boolean clear;
|
private boolean clear;
|
||||||
private Vector3i pos;
|
private Vector3i pos;
|
||||||
private TileEntityScreen.Screen[] screens;
|
private ScreenBlockEntity.Screen[] screens;
|
||||||
|
|
||||||
public S2CMessageAddScreen(TileEntityScreen tes) {
|
public S2CMessageAddScreen(ScreenBlockEntity tes) {
|
||||||
clear = true;
|
clear = true;
|
||||||
pos = new Vector3i(tes.getBlockPos());
|
pos = new Vector3i(tes.getBlockPos());
|
||||||
screens = new TileEntityScreen.Screen[tes.screenCount()];
|
screens = new ScreenBlockEntity.Screen[tes.screenCount()];
|
||||||
|
|
||||||
for (int i = 0; i < tes.screenCount(); i++)
|
for (int i = 0; i < tes.screenCount(); i++)
|
||||||
screens[i] = tes.getScreen(i);
|
screens[i] = tes.getScreen(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public S2CMessageAddScreen(TileEntityScreen tes, TileEntityScreen.Screen... toSend) {
|
public S2CMessageAddScreen(ScreenBlockEntity tes, ScreenBlockEntity.Screen... toSend) {
|
||||||
clear = false;
|
clear = false;
|
||||||
pos = new Vector3i(tes.getBlockPos());
|
pos = new Vector3i(tes.getBlockPos());
|
||||||
screens = toSend;
|
screens = toSend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public S2CMessageAddScreen(boolean clear, Vector3i pos, TileEntityScreen.Screen[] screens) {
|
public S2CMessageAddScreen(boolean clear, Vector3i pos, ScreenBlockEntity.Screen[] screens) {
|
||||||
this.clear = clear;
|
this.clear = clear;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.screens = screens;
|
this.screens = screens;
|
||||||
|
|
@ -53,9 +53,9 @@ public class S2CMessageAddScreen extends Packet {
|
||||||
|
|
||||||
int cnt = buf.readByte() & 7;
|
int cnt = buf.readByte() & 7;
|
||||||
|
|
||||||
screens = new TileEntityScreen.Screen[cnt];
|
screens = new ScreenBlockEntity.Screen[cnt];
|
||||||
for (int i = 0; i < cnt; i++) {
|
for (int i = 0; i < cnt; i++) {
|
||||||
screens[i] = new TileEntityScreen.Screen();
|
screens[i] = new ScreenBlockEntity.Screen();
|
||||||
screens[i].side = BlockSide.values()[buf.readByte()];
|
screens[i].side = BlockSide.values()[buf.readByte()];
|
||||||
screens[i].size = new Vector2i(buf);
|
screens[i].size = new Vector2i(buf);
|
||||||
screens[i].url = buf.readUtf();
|
screens[i].url = buf.readUtf();
|
||||||
|
|
@ -76,7 +76,7 @@ public class S2CMessageAddScreen extends Packet {
|
||||||
pos.writeTo(buf);
|
pos.writeTo(buf);
|
||||||
buf.writeByte(screens.length);
|
buf.writeByte(screens.length);
|
||||||
|
|
||||||
for (TileEntityScreen.Screen scr : screens) {
|
for (ScreenBlockEntity.Screen scr : screens) {
|
||||||
buf.writeByte(scr.side.ordinal());
|
buf.writeByte(scr.side.ordinal());
|
||||||
scr.size.writeTo(buf);
|
scr.size.writeTo(buf);
|
||||||
buf.writeUtf(scr.url);
|
buf.writeUtf(scr.url);
|
||||||
|
|
@ -95,11 +95,11 @@ public class S2CMessageAddScreen extends Packet {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
Level lvl = (Level) WebDisplays.PROXY.getWorld(ctx);
|
Level lvl = (Level) WebDisplays.PROXY.getWorld(ctx);
|
||||||
BlockEntity te = lvl.getBlockEntity(pos.toBlock());
|
BlockEntity te = lvl.getBlockEntity(pos.toBlock());
|
||||||
if (!(te instanceof TileEntityScreen)) {
|
if (!(te instanceof ScreenBlockEntity)) {
|
||||||
lvl.setBlockAndUpdate(pos.toBlock(), lvl.getBlockState(pos.toBlock()).setValue(hasTE, true));
|
lvl.setBlockAndUpdate(pos.toBlock(), lvl.getBlockState(pos.toBlock()).setValue(hasTE, true));
|
||||||
te = lvl.getBlockEntity(pos.toBlock());
|
te = lvl.getBlockEntity(pos.toBlock());
|
||||||
|
|
||||||
if (!(te instanceof TileEntityScreen)) {
|
if (!(te instanceof ScreenBlockEntity)) {
|
||||||
if (clear)
|
if (clear)
|
||||||
Log.error("CMessageAddScreen: Can't add screen to invalid tile entity at %s", pos.toString());
|
Log.error("CMessageAddScreen: Can't add screen to invalid tile entity at %s", pos.toString());
|
||||||
|
|
||||||
|
|
@ -107,17 +107,17 @@ public class S2CMessageAddScreen extends Packet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen tes = (TileEntityScreen) te;
|
ScreenBlockEntity tes = (ScreenBlockEntity) te;
|
||||||
if (clear)
|
if (clear)
|
||||||
tes.clear();
|
tes.clear();
|
||||||
|
|
||||||
for (TileEntityScreen.Screen entry : screens) {
|
for (ScreenBlockEntity.Screen entry : screens) {
|
||||||
TileEntityScreen.Screen scr = tes.addScreen(entry.side, entry.size, entry.resolution, null, false);
|
ScreenBlockEntity.Screen scr = tes.addScreen(entry.side, entry.size, entry.resolution, null, false);
|
||||||
scr.rotation = entry.rotation;
|
scr.rotation = entry.rotation;
|
||||||
String webUrl;
|
String webUrl;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
webUrl = TileEntityScreen.url(entry.url);
|
webUrl = ScreenBlockEntity.url(entry.url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import net.montoyo.wd.WebDisplays;
|
||||||
import net.montoyo.wd.controls.ScreenControl;
|
import net.montoyo.wd.controls.ScreenControl;
|
||||||
import net.montoyo.wd.controls.ScreenControlRegistry;
|
import net.montoyo.wd.controls.ScreenControlRegistry;
|
||||||
import net.montoyo.wd.controls.builtin.*;
|
import net.montoyo.wd.controls.builtin.*;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.BufferUtils;
|
import net.montoyo.wd.net.BufferUtils;
|
||||||
import net.montoyo.wd.net.Packet;
|
import net.montoyo.wd.net.Packet;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
|
|
@ -39,49 +39,49 @@ public class S2CMessageScreenUpdate extends Packet {
|
||||||
this.control = ScreenControlRegistry.parse(buf);
|
this.control = ScreenControlRegistry.parse(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate setURL(TileEntityScreen screen, BlockSide side, String weburl) {
|
public static S2CMessageScreenUpdate setURL(ScreenBlockEntity screen, BlockSide side, String weburl) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new SetURLControl(weburl, new Vector3i(screenUpdate.pos));
|
screenUpdate.control = new SetURLControl(weburl, new Vector3i(screenUpdate.pos));
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate setResolution(TileEntityScreen screen, BlockSide side, Vector2i res) {
|
public static S2CMessageScreenUpdate setResolution(ScreenBlockEntity screen, BlockSide side, Vector2i res) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new ScreenModifyControl(res);
|
screenUpdate.control = new ScreenModifyControl(res);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate rotation(TileEntityScreen screen, BlockSide side, Rotation rot) {
|
public static S2CMessageScreenUpdate rotation(ScreenBlockEntity screen, BlockSide side, Rotation rot) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new ScreenModifyControl(rot);
|
screenUpdate.control = new ScreenModifyControl(rot);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate upgrade(TileEntityScreen screen, BlockSide side, boolean adding, ItemStack stack) {
|
public static S2CMessageScreenUpdate upgrade(ScreenBlockEntity screen, BlockSide side, boolean adding, ItemStack stack) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new ManageRightsAndUpdgradesControl(adding, stack);
|
screenUpdate.control = new ManageRightsAndUpdgradesControl(adding, stack);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate click(TileEntityScreen screen, BlockSide side, ClickControl.ControlType mouseMove, Vector2i pos) {
|
public static S2CMessageScreenUpdate click(ScreenBlockEntity screen, BlockSide side, ClickControl.ControlType mouseMove, Vector2i pos) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new ClickControl(mouseMove, pos);
|
screenUpdate.control = new ClickControl(mouseMove, pos);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate type(TileEntityScreen screen, BlockSide side, String text) {
|
public static S2CMessageScreenUpdate type(ScreenBlockEntity screen, BlockSide side, String text) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new KeyTypedControl(text, screenUpdate.pos);
|
screenUpdate.control = new KeyTypedControl(text, screenUpdate.pos);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate autoVolume(TileEntityScreen screen, BlockSide side, boolean av) {
|
public static S2CMessageScreenUpdate autoVolume(ScreenBlockEntity screen, BlockSide side, boolean av) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new AutoVolumeControl(av);
|
screenUpdate.control = new AutoVolumeControl(av);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static S2CMessageScreenUpdate owner(TileEntityScreen screen, BlockSide side, NameUUIDPair owner) {
|
public static S2CMessageScreenUpdate owner(ScreenBlockEntity screen, BlockSide side, NameUUIDPair owner) {
|
||||||
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
S2CMessageScreenUpdate screenUpdate = new S2CMessageScreenUpdate(screen.getBlockPos(), side);
|
||||||
screenUpdate.control = new OwnerControl(owner);
|
screenUpdate.control = new OwnerControl(owner);
|
||||||
return screenUpdate;
|
return screenUpdate;
|
||||||
|
|
@ -107,7 +107,7 @@ public class S2CMessageScreenUpdate extends Packet {
|
||||||
ctx.enqueueWork(() -> {
|
ctx.enqueueWork(() -> {
|
||||||
Level level = (Level) WebDisplays.PROXY.getWorld(ctx);
|
Level level = (Level) WebDisplays.PROXY.getWorld(ctx);
|
||||||
BlockEntity be = level.getBlockEntity(pos);
|
BlockEntity be = level.getBlockEntity(pos);
|
||||||
if (be instanceof TileEntityScreen tes) {
|
if (be instanceof ScreenBlockEntity tes) {
|
||||||
control.handleClient(pos, side, tes, ctx);
|
control.handleClient(pos, side, tes, ctx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
import net.minecraftforge.common.ForgeMod;
|
import net.minecraftforge.common.ForgeMod;
|
||||||
import net.minecraftforge.network.NetworkEvent;
|
import net.minecraftforge.network.NetworkEvent;
|
||||||
import net.montoyo.wd.core.ScreenRights;
|
import net.montoyo.wd.core.ScreenRights;
|
||||||
import net.montoyo.wd.entity.TileEntityRedCtrl;
|
import net.montoyo.wd.entity.RedstoneControlBlockEntity;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.Packet;
|
import net.montoyo.wd.net.Packet;
|
||||||
import net.montoyo.wd.utilities.Util;
|
import net.montoyo.wd.utilities.Util;
|
||||||
import net.montoyo.wd.utilities.Vector3i;
|
import net.montoyo.wd.utilities.Vector3i;
|
||||||
|
|
@ -50,16 +50,16 @@ public class C2SMessageRedstoneCtrl extends Packet implements Runnable {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockEntity te = world.getBlockEntity(blockPos);
|
BlockEntity te = world.getBlockEntity(blockPos);
|
||||||
if (te == null || !(te instanceof TileEntityRedCtrl))
|
if (te == null || !(te instanceof RedstoneControlBlockEntity))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TileEntityRedCtrl redCtrl = (TileEntityRedCtrl) te;
|
RedstoneControlBlockEntity redCtrl = (RedstoneControlBlockEntity) te;
|
||||||
if (!redCtrl.isScreenChunkLoaded()) {
|
if (!redCtrl.isScreenChunkLoaded()) {
|
||||||
Util.toast(player, "chunkUnloaded");
|
Util.toast(player, "chunkUnloaded");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntityScreen tes = redCtrl.getConnectedScreen();
|
ScreenBlockEntity tes = redCtrl.getConnectedScreen();
|
||||||
if (tes == null)
|
if (tes == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import net.montoyo.wd.controls.ScreenControlRegistry;
|
||||||
import net.montoyo.wd.controls.builtin.*;
|
import net.montoyo.wd.controls.builtin.*;
|
||||||
import net.montoyo.wd.core.JSServerRequest;
|
import net.montoyo.wd.core.JSServerRequest;
|
||||||
import net.montoyo.wd.core.MissingPermissionException;
|
import net.montoyo.wd.core.MissingPermissionException;
|
||||||
import net.montoyo.wd.entity.TileEntityScreen;
|
import net.montoyo.wd.entity.ScreenBlockEntity;
|
||||||
import net.montoyo.wd.net.BufferUtils;
|
import net.montoyo.wd.net.BufferUtils;
|
||||||
import net.montoyo.wd.net.Packet;
|
import net.montoyo.wd.net.Packet;
|
||||||
import net.montoyo.wd.utilities.*;
|
import net.montoyo.wd.utilities.*;
|
||||||
|
|
@ -40,13 +40,13 @@ public class C2SMessageScreenCtrl extends Packet {
|
||||||
public C2SMessageScreenCtrl() {
|
public C2SMessageScreenCtrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public C2SMessageScreenCtrl(TileEntityScreen screen, BlockSide side, ScreenControl control) {
|
public C2SMessageScreenCtrl(ScreenBlockEntity screen, BlockSide side, ScreenControl control) {
|
||||||
this.pos = screen.getBlockPos();
|
this.pos = screen.getBlockPos();
|
||||||
this.side = side;
|
this.side = side;
|
||||||
this.control = control;
|
this.control = control;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static C2SMessageScreenCtrl base(TileEntityScreen screen, BlockSide side) {
|
protected static C2SMessageScreenCtrl base(ScreenBlockEntity screen, BlockSide side) {
|
||||||
C2SMessageScreenCtrl packet = new C2SMessageScreenCtrl();
|
C2SMessageScreenCtrl packet = new C2SMessageScreenCtrl();
|
||||||
packet.pos = screen.getBlockPos();
|
packet.pos = screen.getBlockPos();
|
||||||
packet.side = side;
|
packet.side = side;
|
||||||
|
|
@ -54,79 +54,79 @@ public class C2SMessageScreenCtrl extends Packet {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl setURL(TileEntityScreen tes, BlockSide side, String url, Vector3i remoteLocation) {
|
public static C2SMessageScreenCtrl setURL(ScreenBlockEntity tes, BlockSide side, String url, Vector3i remoteLocation) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new SetURLControl(url, remoteLocation);
|
ret.control = new SetURLControl(url, remoteLocation);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, NameUUIDPair friend, boolean del) {
|
public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, NameUUIDPair friend, boolean del) {
|
||||||
this(tes, side, new ModifyFriendListControl(friend, !del));
|
this(tes, side, new ModifyFriendListControl(friend, !del));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, int fr, int or) {
|
public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, int fr, int or) {
|
||||||
this(tes, side, new ManageRightsAndUpdgradesControl(fr, or));
|
this(tes, side, new ManageRightsAndUpdgradesControl(fr, or));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, ItemStack toRem) {
|
public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, ItemStack toRem) {
|
||||||
this(tes, side, new ManageRightsAndUpdgradesControl(false, toRem));
|
this(tes, side, new ManageRightsAndUpdgradesControl(false, toRem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public C2SMessageScreenCtrl(TileEntityScreen tes, BlockSide side, Rotation rot) {
|
public C2SMessageScreenCtrl(ScreenBlockEntity tes, BlockSide side, Rotation rot) {
|
||||||
this(tes, side, new ScreenModifyControl(rot));
|
this(tes, side, new ScreenModifyControl(rot));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl vec2(TileEntityScreen tes, BlockSide side, int ctrl, Vector2i vec) {
|
public static C2SMessageScreenCtrl vec2(ScreenBlockEntity tes, BlockSide side, int ctrl, Vector2i vec) {
|
||||||
throw new RuntimeException("Moved: look into ScreenControlRegistry");
|
throw new RuntimeException("Moved: look into ScreenControlRegistry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl resolution(TileEntityScreen tes, BlockSide side, Vector2i vec) {
|
public static C2SMessageScreenCtrl resolution(ScreenBlockEntity tes, BlockSide side, Vector2i vec) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new ScreenModifyControl(vec);
|
ret.control = new ScreenModifyControl(vec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl type(TileEntityScreen tes, BlockSide side, String text, BlockPos soundPos) {
|
public static C2SMessageScreenCtrl type(ScreenBlockEntity tes, BlockSide side, String text, BlockPos soundPos) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new KeyTypedControl(text, soundPos);
|
ret.control = new KeyTypedControl(text, soundPos);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static C2SMessageScreenCtrl laserMove(TileEntityScreen tes, BlockSide side, Vector2i vec) {
|
public static C2SMessageScreenCtrl laserMove(ScreenBlockEntity tes, BlockSide side, Vector2i vec) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new LaserControl(LaserControl.ControlType.MOVE, vec);
|
ret.control = new LaserControl(LaserControl.ControlType.MOVE, vec);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static C2SMessageScreenCtrl laserDown(TileEntityScreen tes, BlockSide side, Vector2i vec, int button) {
|
public static C2SMessageScreenCtrl laserDown(ScreenBlockEntity tes, BlockSide side, Vector2i vec, int button) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new LaserControl(LaserControl.ControlType.DOWN, vec, button);
|
ret.control = new LaserControl(LaserControl.ControlType.DOWN, vec, button);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl laserUp(TileEntityScreen tes, BlockSide side, int button) {
|
public static C2SMessageScreenCtrl laserUp(ScreenBlockEntity tes, BlockSide side, int button) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new LaserControl(LaserControl.ControlType.UP, null, button);
|
ret.control = new LaserControl(LaserControl.ControlType.UP, null, button);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl jsRequest(TileEntityScreen tes, BlockSide side, int reqId, JSServerRequest reqType, Object... data) {
|
public static C2SMessageScreenCtrl jsRequest(ScreenBlockEntity tes, BlockSide side, int reqId, JSServerRequest reqType, Object... data) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new JSRequestControl(reqId, reqType, data);
|
ret.control = new JSRequestControl(reqId, reqType, data);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
public static C2SMessageScreenCtrl autoVol(TileEntityScreen tes, BlockSide side, boolean av) {
|
public static C2SMessageScreenCtrl autoVol(ScreenBlockEntity tes, BlockSide side, boolean av) {
|
||||||
C2SMessageScreenCtrl ret = base(tes, side);
|
C2SMessageScreenCtrl ret = base(tes, side);
|
||||||
ret.control = new AutoVolumeControl(av);
|
ret.control = new AutoVolumeControl(av);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -150,7 +150,7 @@ public class C2SMessageScreenCtrl extends Packet {
|
||||||
control.write(buf);
|
control.write(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkPermission(ServerPlayer sender, TileEntityScreen scr, int right) throws MissingPermissionException {
|
public void checkPermission(ServerPlayer sender, ScreenBlockEntity scr, int right) throws MissingPermissionException {
|
||||||
int prights = scr.getScreen(side).rightsFor(sender);
|
int prights = scr.getScreen(side).rightsFor(sender);
|
||||||
if ((prights & right) == 0)
|
if ((prights & right) == 0)
|
||||||
throw new MissingPermissionException(right, sender);
|
throw new MissingPermissionException(right, sender);
|
||||||
|
|
@ -162,7 +162,7 @@ public class C2SMessageScreenCtrl extends Packet {
|
||||||
try {
|
try {
|
||||||
Level level = (Level) WebDisplays.PROXY.getWorld(ctx);
|
Level level = (Level) WebDisplays.PROXY.getWorld(ctx);
|
||||||
BlockEntity be = level.getBlockEntity(pos);
|
BlockEntity be = level.getBlockEntity(pos);
|
||||||
if (be instanceof TileEntityScreen tes) {
|
if (be instanceof ScreenBlockEntity tes) {
|
||||||
control.handleServer(pos, side, tes, ctx, (perm) -> {
|
control.handleServer(pos, side, tes, ctx, (perm) -> {
|
||||||
try {
|
try {
|
||||||
checkPermission(ctx.getSender(), tes, perm);
|
checkPermission(ctx.getSender(), tes, perm);
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,21 @@ public class TileRegistry {
|
||||||
.create(ForgeRegistries.BLOCK_ENTITY_TYPES, "webdisplays");
|
.create(ForgeRegistries.BLOCK_ENTITY_TYPES, "webdisplays");
|
||||||
|
|
||||||
//Register tile entities
|
//Register tile entities
|
||||||
public static final RegistryObject<BlockEntityType<TileEntityScreen>> SCREEN_BLOCK_ENTITY = TILE_TYPES
|
public static final RegistryObject<BlockEntityType<ScreenBlockEntity>> SCREEN_BLOCK_ENTITY = TILE_TYPES
|
||||||
.register("screen", () -> BlockEntityType.Builder
|
.register("screen", () -> BlockEntityType.Builder
|
||||||
.of(TileEntityScreen::new, BlockRegistry.SCREEN_BLOCk.get()).build(null));
|
.of(ScreenBlockEntity::new, BlockRegistry.SCREEN_BLOCk.get()).build(null));
|
||||||
|
|
||||||
public static final RegistryObject<BlockEntityType<?>> KEYBOARD = TILE_TYPES.register("kb_left", () -> BlockEntityType.Builder
|
public static final RegistryObject<BlockEntityType<?>> KEYBOARD = TILE_TYPES.register("kb_left", () -> BlockEntityType.Builder
|
||||||
.of(TileEntityKeyboard::new, BlockRegistry.KEYBOARD_BLOCK.get()).build(null));
|
.of(KeyboardBlockEntity::new, BlockRegistry.KEYBOARD_BLOCK.get()).build(null));
|
||||||
|
|
||||||
public static final RegistryObject<BlockEntityType<?>> REMOTE_CONTROLLER = TILE_TYPES.register("rctrl",
|
public static final RegistryObject<BlockEntityType<?>> REMOTE_CONTROLLER = TILE_TYPES.register("rctrl",
|
||||||
() -> BlockEntityType.Builder.of(TileEntityRCtrl::new, BlockRegistry.REMOTE_CONTROLLER_BLOCK.get()).build(null)); //WITHOUT FACING (>= 3)
|
() -> BlockEntityType.Builder.of(RemoteControlBlockEntity::new, BlockRegistry.REMOTE_CONTROLLER_BLOCK.get()).build(null)); //WITHOUT FACING (>= 3)
|
||||||
|
|
||||||
public static final RegistryObject<BlockEntityType<?>> REDSTONE_CONTROLLER = TILE_TYPES.register("redctrl",
|
public static final RegistryObject<BlockEntityType<?>> REDSTONE_CONTROLLER = TILE_TYPES.register("redctrl",
|
||||||
() -> BlockEntityType.Builder.of(TileEntityRedCtrl::new, BlockRegistry.REDSTONE_CONTROL_BLOCK.get()).build(null));
|
() -> BlockEntityType.Builder.of(RedstoneControlBlockEntity::new, BlockRegistry.REDSTONE_CONTROL_BLOCK.get()).build(null));
|
||||||
|
|
||||||
public static final RegistryObject<BlockEntityType<?>> SERVER = TILE_TYPES.register("server",
|
public static final RegistryObject<BlockEntityType<?>> SERVER = TILE_TYPES.register("server",
|
||||||
() -> BlockEntityType.Builder.of(TileEntityServer::new, BlockRegistry.SERVER_BLOCK.get()).build(null));
|
() -> BlockEntityType.Builder.of(ServerBlockEntity::new, BlockRegistry.SERVER_BLOCK.get()).build(null));
|
||||||
|
|
||||||
public static void init(IEventBus bus) {
|
public static void init(IEventBus bus) {
|
||||||
TILE_TYPES.register(bus);
|
TILE_TYPES.register(bus);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user