|
本帖最后由 aftersans53228 于 2024-5-3 20:17 编辑
8 q- `/ o" b) L# ~, ^# w' Q
" d4 Y1 w* Q, T# I我嘞个 MinecraftServer server =player.getServer();BlockPos boxPos =buf.readBlockPos(); int[] timeData= buf.readIntArray();Boolean enabled = buf.readBoolean();if (server != null) {server.execute(()-> {if (player.getEntityWorld().getBlockEntity(boxPos) != null && player.getEntityWorld().getBlockEntity(boxPos).getType() == AFRoadsBlockRegistry.TRAFFIC_LIGHTS_CONTROL_ENTITY) {TrafficLightsControlEntity blockEntity = (TrafficLightsControlEntity) player.getEntityWorld().getBlockEntity(boxPos);World world =player.getEntityWorld();world.setBlockState(boxPos,world.getBlockState(boxPos).with(BooleanProperty.of("is_enable"),enabled));blockEntity.setCachedState(blockEntity.getCachedState().with(BooleanProperty.of("is_enable"),enabled));ArrayList<Integer> timeForward = new ArrayList<>();ArrayList<Integer> timeTurn = new ArrayList<>(); timeForward.add(timeData[0]);timeForward.add(timeData[1]);timeTurn.add(timeData[2]); timeTurn.add(timeData[3]);blockEntity.setTimeData(timeForward,timeTurn); AFRoads.LOGGER.info("Set Traffic lights Control Box {"+ Arrays.toString(timeData) + "} ,"+enabled );} else if (player.getEntityWorld().getBlockEntity(boxPos) == null) {AFRoads.LOGGER.info("Invalid Block Entity.");}});} |
|