Fix max entity radius not being settable by making it a instance method on world. Closes #5601

Fix VoidFluidHandler.INSTANCE not being a instance of VoidFluidHandler. Closes #5602
Remove backwards compat code and make IItemHandler.isItemValid non-default. Closes #5598
This commit is contained in:
LexManos committed 2019-03-11 15:04:04 -07:00
1 parent 7292b63052
commit 7113f4400c
7 files changed
+41 -41

No files matched your search

@@ -24,9 +24,16 @@ import net.minecraftforge.common.capabilities.ICapabilityProvider;
public interface IForgeWorld extends ICapabilityProvider
{
/**
* Used in the getEntitiesWithinAABB functions to expand the search area for entities.
* Modders should change this variable to a higher value if it is less then the radius
* of one of there entities.
* The maximum radius to scan for entities when trying to check bounding boxes. Vanilla's default is
* 2.0D But mods that add larger entities may increase this.
*/
public static double MAX_ENTITY_RADIUS = 2.0D;
public double getMaxEntityRadius();
/**
* Increases the max entity radius, this is safe to call with any value.
* The setter will verify the input value is larger then the current setting.
*
* @param value New max radius to set.
* @return The new max radius
*/
public double increaseMaxEntityRadius(double value);
}
@@ -36,7 +36,7 @@ import static net.minecraftforge.fluids.capability.templates.EmptyFluidHandler.E
*/
public class VoidFluidHandler implements IFluidHandler, IFluidTank
{
public static final EmptyFluidHandler INSTANCE = new EmptyFluidHandler();
public static final VoidFluidHandler INSTANCE = new VoidFluidHandler();
public VoidFluidHandler() {}
@@ -117,6 +117,5 @@ public interface IItemHandler
* @return true if the slot can insert the ItemStack, not considering the current state of the inventory.
* false if the slot can never insert the ItemStack in any situation.
*/
//todo Make non-default and/or replace in 1.13
default boolean isItemValid(int slot, @Nonnull ItemStack stack) { return true; }
boolean isItemValid(int slot, @Nonnull ItemStack stack);
}
@@ -44,27 +44,9 @@ public class SlotItemHandler extends Slot
@Override
public boolean isItemValid(@Nonnull ItemStack stack)
{
if (stack.isEmpty() || !itemHandler.isItemValid(index, stack))
if (stack.isEmpty())
return false;
IItemHandler handler = this.getItemHandler();
ItemStack remainder;
if (handler instanceof IItemHandlerModifiable)
{
IItemHandlerModifiable handlerModifiable = (IItemHandlerModifiable) handler;
ItemStack currentStack = handlerModifiable.getStackInSlot(index);
handlerModifiable.setStackInSlot(index, ItemStack.EMPTY);
remainder = handlerModifiable.insertItem(index, stack, true);
handlerModifiable.setStackInSlot(index, currentStack);
}
else
{
remainder = handler.insertItem(index, stack, true);
}
return remainder.getCount() < stack.getCount();
return itemHandler.isItemValid(index, stack);
}
@Override
@@ -183,7 +183,7 @@ public abstract class EntityEquipmentInvWrapper implements IItemHandlerModifiabl
@Override
public boolean isItemValid(int slot, @Nonnull ItemStack stack)
{
return IItemHandlerModifiable.super.isItemValid(slot, stack);
return true;
}
protected EntityEquipmentSlot validateSlotIndex(final int slot)