spawn_potential
This commit is contained in:
1 parent
c283fddd38
commit
460a78f866
4 files changed
+42
-3
No files matched your search
+1
-1
@@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
# or better: https://modmuss50.me/fabric.html
|
# or better: https://modmuss50.me/fabric.html
|
||||||
minecraft_version=20w18a
|
minecraft_version=20w18a
|
||||||
yarn_mappings=20w18a+build.3
|
yarn_mappings=20w18a+build.9
|
||||||
loader_version=0.8.2+build.194
|
loader_version=0.8.2+build.194
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package carpet.fakes;
|
||||||
|
|
||||||
|
import net.minecraft.class_5263;
|
||||||
|
|
||||||
|
public interface SpawnHelperInnerInterface
|
||||||
|
{
|
||||||
|
class_5263 getPotentialCalculator();
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package carpet.mixins;
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.fakes.SpawnHelperInnerInterface;
|
||||||
import carpet.utils.SpawnReporter;
|
import carpet.utils.SpawnReporter;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
|
import net.minecraft.class_5263;
|
||||||
import net.minecraft.entity.EntityCategory;
|
import net.minecraft.entity.EntityCategory;
|
||||||
import net.minecraft.world.SpawnHelper;
|
import net.minecraft.world.SpawnHelper;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
@@ -14,12 +16,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|||||||
// temporary mixin until naming for spawnhelper gets fixed.
|
// temporary mixin until naming for spawnhelper gets fixed.
|
||||||
|
|
||||||
@Mixin(SpawnHelper.class_5262.class)
|
@Mixin(SpawnHelper.class_5262.class)
|
||||||
public class SpawnHelperInnerMixin
|
public class SpawnHelperInnerMixin implements SpawnHelperInnerInterface
|
||||||
{
|
{
|
||||||
@Shadow @Final private int field_24394;
|
@Shadow @Final private int field_24394;
|
||||||
|
|
||||||
@Shadow @Final private Object2IntMap<EntityCategory> field_24395;
|
@Shadow @Final private Object2IntMap<EntityCategory> field_24395;
|
||||||
|
|
||||||
|
@Shadow @Final private class_5263 field_24396;
|
||||||
|
|
||||||
@Inject(method = "method_27826", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "method_27826", at = @At("HEAD"), cancellable = true)
|
||||||
private void changeMobCaps(EntityCategory entityCategory, CallbackInfoReturnable<Boolean> cir)
|
private void changeMobCaps(EntityCategory entityCategory, CallbackInfoReturnable<Boolean> cir)
|
||||||
{
|
{
|
||||||
@@ -28,4 +32,12 @@ public class SpawnHelperInnerMixin
|
|||||||
cir.setReturnValue(field_24395.getInt(entityCategory) < i);
|
cir.setReturnValue(field_24395.getInt(entityCategory) < i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public class_5263 getPotentialCalculator()
|
||||||
|
{
|
||||||
|
return field_24396;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package carpet.script;
|
package carpet.script;
|
||||||
|
|
||||||
import carpet.CarpetServer;
|
import carpet.CarpetServer;
|
||||||
|
import carpet.fakes.BiomeArrayInterface;
|
||||||
import carpet.fakes.ChunkTicketManagerInterface;
|
import carpet.fakes.ChunkTicketManagerInterface;
|
||||||
import carpet.fakes.MinecraftServerInterface;
|
import carpet.fakes.MinecraftServerInterface;
|
||||||
import carpet.fakes.BiomeArrayInterface;
|
|
||||||
import carpet.fakes.ServerChunkManagerInterface;
|
import carpet.fakes.ServerChunkManagerInterface;
|
||||||
|
import carpet.fakes.SpawnHelperInnerInterface;
|
||||||
import carpet.fakes.StatTypeInterface;
|
import carpet.fakes.StatTypeInterface;
|
||||||
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
|
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
|
||||||
import carpet.helpers.FeatureGenerator;
|
import carpet.helpers.FeatureGenerator;
|
||||||
@@ -110,6 +111,7 @@ import net.minecraft.util.math.BlockBox;
|
|||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
import net.minecraft.world.SpawnHelper;
|
||||||
import net.minecraft.world.poi.PointOfInterest;
|
import net.minecraft.world.poi.PointOfInterest;
|
||||||
import net.minecraft.world.poi.PointOfInterestStorage;
|
import net.minecraft.world.poi.PointOfInterestStorage;
|
||||||
import net.minecraft.world.poi.PointOfInterestType;
|
import net.minecraft.world.poi.PointOfInterestType;
|
||||||
@@ -1294,6 +1296,23 @@ public class CarpetExpression
|
|||||||
return (_c, _t) -> ret;
|
return (_c, _t) -> ret;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.expr.addLazyFunction("spawn_potential", -1, (c, t, lv) ->
|
||||||
|
{
|
||||||
|
CarpetContext cc = (CarpetContext)c;
|
||||||
|
BlockArgument locator = BlockArgument.findIn(cc, lv, 0);
|
||||||
|
BlockPos pos = locator.block.getPos();
|
||||||
|
double required_charge = 1;
|
||||||
|
if (lv.size() > locator.offset)
|
||||||
|
required_charge = NumericValue.asNumber(lv.get(locator.offset).evalValue(c)).getDouble();
|
||||||
|
SpawnHelper.class_5262 charger = cc.s.getWorld().getChunkManager().method_27908();
|
||||||
|
if (charger == null) return LazyValue.NULL;
|
||||||
|
Value ret = new NumericValue(
|
||||||
|
((SpawnHelperInnerInterface)charger).getPotentialCalculator().
|
||||||
|
method_27832(pos, required_charge )
|
||||||
|
);
|
||||||
|
return (_c, _t) -> ret;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getScoreboardKeyFromValue(Value keyValue)
|
private static String getScoreboardKeyFromValue(Value keyValue)
|
||||||
|
|||||||
Reference in new issue
Block a user