Java Code Examples for net.minecraft.block.BlockState#method_30101()

The following examples show how to use net.minecraft.block.BlockState#method_30101() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WireBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
@Deprecated
public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean moved) {
    super.onBlockAdded(state, world, pos, oldState, moved);
    if (!world.isClient) {
        WireNetwork network = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos);
        if (network == null) network = new WireNetwork(pos, ((ServerWorld) world));
        for (Direction d : Direction.values()) {
            if (world.getBlockState(pos.offset(d)).getBlock() instanceof WireConnectable) {
                WireConnectionType type = ((WireConnectable) world.getBlockState(pos.offset(d)).getBlock()).canWireConnect(world, d.getOpposite(), pos, pos.offset(d));
                if (type == WireConnectionType.WIRE) {
                    WireNetwork network1 = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos.offset(d));
                    if (network1 != network) {
                        if (network1 != null) {
                            network = network1.merge(network); // prefer other network rather than this one
                        } else {
                            network.addWire(pos.offset(d));
                        }
                        state.method_30101(world, pos, 3);
                    }
                } else if (type != WireConnectionType.NONE) {
                    if (type == WireConnectionType.ENERGY_INPUT) {
                        network.addConsumer(pos.offset(d));
                    } else {
                        network.addProducer(pos.offset(d));
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: WireBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction dir, BlockState otherState, WorldAccess world, BlockPos pos, BlockPos updated) {
    WireConnectionType type = WireConnectionType.NONE;
    if (otherState.getBlock() instanceof WireConnectable) {
        type = ((WireConnectable) otherState.getBlock()).canWireConnect(world, dir.getOpposite(), pos, updated);
    }

    if (!world.isClient() && type != WireConnectionType.NONE) {
        if (world.getBlockState(updated).getBlock() instanceof WireConnectable) {
            WireNetwork network = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(pos);
            if (network == null) network = new WireNetwork(pos, ((ServerWorld) world));
            if (type == WireConnectionType.WIRE) {
                WireNetwork network1 = ((ServerWorldAccessor) world).getNetworkManager().getNetwork(updated);
                if (network1 != network) {
                    if (network1 != null) {
                        network1.merge(network); // prefer other network rather than this one
                    } else {
                        network.addWire(updated);
                    }
                    state.method_30101(world, pos, 3);
                }
            } else if (type == WireConnectionType.ENERGY_INPUT) {
                network.addConsumer(updated);
            } else {
                network.addProducer(updated);
            }

        }
    }
    return state;
}