Bonsai Trees 3

Bonsai Trees 3

51M Downloads

The bonsai pot's getCapability method always returns the handler, even if the given capability is of a different type.

AlexIIL opened this issue ยท 1 comments

commented

Specifically that the bonsai pot tile entitty's getCapability method just casts the handler to T, and returns it. However the forge javadoc states that it should Returns null when {@link #hasCapability(Capability, EnumFacing)} would return false. You could probably fix this by changing the method to:

@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
    if (hasCapability(capability, facing) {
        // For some reason forge does an unchecked cast in here, and pretends that it doesn't matter.
        return capability.cast(handler);
    }
    return null;
}

(Reported in BuildCraft/BuildCraft#4061)

commented

Hey thanks for the report!