More Peripherals

More Peripherals

219k Downloads

Peripheral state same for all peripherals connected to the same network

crazyvinvin opened this issue ยท 3 comments

commented

When the we connect two peripherals of the same type to the same network, their state according to the computer is the same (both display librarian villager, when only one is librarian or all display the same honey level when they are all in fact different, for example.)
We tested this with the trading interface and the beehive_interface. I think this might have been caused by the update to the modem fix in issue #23. But i'm not sure. There does not seem to be a specific direction (North, south etc.) for which peripheral's state is taken, in fact we saw it change in one test.

When placing a computer directly against every beehive interface, all the states correct according to that computer. Which is why we think it's only on the same network.

Our setups:

Beehives:
image

Villagers:
image

commented

Hello, this is basically the same problem as issue #22, it is occuring because everytime i "create" a peripheral it actually changes the instance of this, and every peripheral returns the same this, like so in the Grinder Peripheral

@Override
    public LazyOptional<IPeripheral> getPeripheral(Level world, BlockPos pos, Direction side) {
        if(world.getBlockState(pos).getBlock().equals(BlockRegister.grinder.get())){
            this.tileEntity = (GrinderEntity) world.getBlockEntity(pos);
            this.fakePlayer = new FakePlayer((ServerLevel) world,new GameProfile(UUID.randomUUID(),"Grinder"));
            return LazyOptional.of(() -> this);
        }
        return LazyOptional.empty();
    }

if i create a new instance like this :

@Override
    public LazyOptional<IPeripheral> getPeripheral(Level world, BlockPos pos, Direction side) {
        if(world.getBlockState(pos).getBlock().equals(BlockRegister.grinder.get())){
            var peripheral = new GrinderPeripheral();
            peripheral.tileEntity = (GrinderEntity) world.getBlockEntity(pos);
            peripheral.fakePlayer = new FakePlayer((ServerLevel) world,new GameProfile(UUID.randomUUID(),"Grinder"));
            return LazyOptional.of(() -> peripheral);
        }
        return LazyOptional.empty();
    }

the problem is gone

commented

its an oversight in my off my part, i'm gonna redo these right now

commented

Fixed in dev

i'm gonna put another release up with this fix