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 2019-03-11 14:41:31 -07:00
parent 7292b63052
commit 7113f4400c
7 changed files with 41 additions and 41 deletions

View file

@ -610,10 +610,10 @@
- int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + 2.0D) / 16.0D);
- int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - 2.0D) / 16.0D);
- int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + 2.0D) / 16.0D);
+ int i = MathHelper.func_76128_c((p_175674_2_.field_72340_a - MAX_ENTITY_RADIUS) / 16.0D);
+ int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + MAX_ENTITY_RADIUS) / 16.0D);
+ int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - MAX_ENTITY_RADIUS) / 16.0D);
+ int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + MAX_ENTITY_RADIUS) / 16.0D);
+ int i = MathHelper.func_76128_c((p_175674_2_.field_72340_a - getMaxEntityRadius()) / 16.0D);
+ int j = MathHelper.func_76128_c((p_175674_2_.field_72336_d + getMaxEntityRadius()) / 16.0D);
+ int k = MathHelper.func_76128_c((p_175674_2_.field_72339_c - getMaxEntityRadius()) / 16.0D);
+ int l = MathHelper.func_76128_c((p_175674_2_.field_72334_f + getMaxEntityRadius()) / 16.0D);
for(int i1 = i; i1 <= j; ++i1) {
for(int j1 = k; j1 <= l; ++j1) {
@ -625,10 +625,10 @@
- int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + 2.0D) / 16.0D);
- int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - 2.0D) / 16.0D);
- int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + 2.0D) / 16.0D);
+ int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - MAX_ENTITY_RADIUS) / 16.0D);
+ int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + MAX_ENTITY_RADIUS) / 16.0D);
+ int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - MAX_ENTITY_RADIUS) / 16.0D);
+ int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + MAX_ENTITY_RADIUS) / 16.0D);
+ int i = MathHelper.func_76128_c((p_175647_2_.field_72340_a - getMaxEntityRadius()) / 16.0D);
+ int j = MathHelper.func_76143_f((p_175647_2_.field_72336_d + getMaxEntityRadius()) / 16.0D);
+ int k = MathHelper.func_76128_c((p_175647_2_.field_72339_c - getMaxEntityRadius()) / 16.0D);
+ int l = MathHelper.func_76143_f((p_175647_2_.field_72334_f + getMaxEntityRadius()) / 16.0D);
List<T> list = Lists.newArrayList();
for(int i1 = i; i1 < j; ++i1) {
@ -766,7 +766,7 @@
iblockstate.func_189546_a(this, blockpos, p_175666_2_, p_175666_1_);
}
}
@@ -2464,4 +2590,28 @@
@@ -2464,4 +2590,40 @@
public abstract RecipeManager func_199532_z();
public abstract NetworkTagManager func_205772_D();
@ -793,5 +793,17 @@
+ }
+ }
+ return ret;
+ }
+
+ private double maxEntityRadius = 2.0D;
+ @Override
+ public double getMaxEntityRadius() {
+ return maxEntityRadius;
+ }
+ @Override
+ public double increaseMaxEntityRadius(double value) {
+ if (value > maxEntityRadius)
+ maxEntityRadius = value;
+ return maxEntityRadius;
+ }
}

View file

@ -165,8 +165,8 @@
public void func_177414_a(@Nullable Entity p_177414_1_, AxisAlignedBB p_177414_2_, List<Entity> p_177414_3_, Predicate<? super Entity> p_177414_4_) {
- int i = MathHelper.func_76128_c((p_177414_2_.field_72338_b - 2.0D) / 16.0D);
- int j = MathHelper.func_76128_c((p_177414_2_.field_72337_e + 2.0D) / 16.0D);
+ int i = MathHelper.func_76128_c((p_177414_2_.field_72338_b - net.minecraftforge.common.extensions.IForgeWorld.MAX_ENTITY_RADIUS) / 16.0D);
+ int j = MathHelper.func_76128_c((p_177414_2_.field_72337_e + net.minecraftforge.common.extensions.IForgeWorld.MAX_ENTITY_RADIUS) / 16.0D);
+ int i = MathHelper.func_76128_c((p_177414_2_.field_72338_b - this.field_76637_e.getMaxEntityRadius()) / 16.0D);
+ int j = MathHelper.func_76128_c((p_177414_2_.field_72337_e + this.field_76637_e.getMaxEntityRadius()) / 16.0D);
i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1);
j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1);
@ -176,8 +176,8 @@
public <T extends Entity> void func_177430_a(Class<? extends T> p_177430_1_, AxisAlignedBB p_177430_2_, List<T> p_177430_3_, @Nullable Predicate<? super T> p_177430_4_) {
- int i = MathHelper.func_76128_c((p_177430_2_.field_72338_b - 2.0D) / 16.0D);
- int j = MathHelper.func_76128_c((p_177430_2_.field_72337_e + 2.0D) / 16.0D);
+ int i = MathHelper.func_76128_c((p_177430_2_.field_72338_b - net.minecraftforge.common.extensions.IForgeWorld.MAX_ENTITY_RADIUS) / 16.0D);
+ int j = MathHelper.func_76128_c((p_177430_2_.field_72337_e + net.minecraftforge.common.extensions.IForgeWorld.MAX_ENTITY_RADIUS) / 16.0D);
+ int i = MathHelper.func_76128_c((p_177430_2_.field_72338_b - this.field_76637_e.getMaxEntityRadius()) / 16.0D);
+ int j = MathHelper.func_76128_c((p_177430_2_.field_72337_e + this.field_76637_e.getMaxEntityRadius()) / 16.0D);
i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1);
j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1);

View file

@ -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);
}

View file

@ -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() {}

View file

@ -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);
}

View file

@ -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

View file

@ -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)