1.4.87 for 22w44a

This commit is contained in:
gnembon committed 2022-11-02 22:30:46 +01:00
1 parent c51f59c799
commit 4be362e58b
20 files changed
+236 -185

No files matched your search

@@ -200,7 +200,7 @@ public class Auxiliary {
}
}
}
ParticleOptions particle = ShapeDispatcher.getParticleData(particleName);
ParticleOptions particle = ShapeDispatcher.getParticleData(particleName, world.registryAccess());
Vec3 vec = locator.vec;
if (player == null)
{
@@ -225,7 +225,7 @@ public class Auxiliary {
CarpetContext cc = (CarpetContext)c;
ServerLevel world = cc.s.getLevel();
String particleName = lv.get(0).getString();
ParticleOptions particle = ShapeDispatcher.getParticleData(particleName);
ParticleOptions particle = ShapeDispatcher.getParticleData(particleName, world.registryAccess());
Vector3Argument pos1 = Vector3Argument.findIn(lv, 1);
Vector3Argument pos2 = Vector3Argument.findIn(lv, pos1.offset);
double density = 1.0;
@@ -259,14 +259,14 @@ public class Auxiliary {
));
});
expression.addUnaryFunction("item_display_name", v -> new FormattedTextValue(ValueConversions.getItemStackFromValue(v, false).getHoverName()));
expression.addContextFunction("item_display_name", 1, (c, t, lv) -> new FormattedTextValue(ValueConversions.getItemStackFromValue(lv.get(0), false, ((CarpetContext)c).s.registryAccess() ).getHoverName()));
expression.addContextFunction("particle_box", -1, (c, t, lv) ->
{
CarpetContext cc = (CarpetContext)c;
ServerLevel world = cc.s.getLevel();
String particleName = lv.get(0).getString();
ParticleOptions particle = ShapeDispatcher.getParticleData(particleName);
ParticleOptions particle = ShapeDispatcher.getParticleData(particleName, world.registryAccess() );
Vector3Argument pos1 = Vector3Argument.findIn(lv, 1);
Vector3Argument pos2 = Vector3Argument.findIn(lv, pos1.offset);
@@ -4,7 +4,6 @@ import carpet.fakes.IngredientInterface;
import carpet.fakes.RecipeManagerInterface;
import carpet.script.CarpetContext;
import carpet.script.Expression;
import carpet.script.argument.BlockArgument;
import carpet.script.argument.FunctionArgument;
import carpet.script.exception.InternalExpressionException;
import carpet.script.exception.ThrowStatement;
@@ -40,7 +39,6 @@ import net.minecraft.tags.TagKey;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
@@ -50,14 +48,13 @@ import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.ShapedRecipe;
import net.minecraft.world.item.crafting.ShapelessRecipe;
import net.minecraft.world.item.crafting.SingleItemRecipe;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.Vec3;
public class Inventories {
public static void apply(Expression expression)
{
expression.addUnaryFunction("stack_limit", v ->
new NumericValue(NBTSerializableValue.parseItem(v.getString()).getItem().getMaxStackSize()));
expression.addContextFunction("stack_limit", 1, (c, t, lv) ->
new NumericValue(NBTSerializableValue.parseItem(lv.get(0).getString(), ((CarpetContext) c).s.registryAccess() ).getItem().getMaxStackSize()));
expression.addContextFunction("item_category", -1, (c, t, lv) -> {
CarpetContext cc = (CarpetContext)c;
@@ -91,7 +88,7 @@ public class Inventories {
Registry<Item> blocks = cc.s.getServer().registryAccess().registryOrThrow(Registry.ITEM_REGISTRY);
if (lv.size() == 0)
return ListValue.wrap(blocks.getTagNames().map(ValueConversions::of).collect(Collectors.toList()));
Item item = NBTSerializableValue.parseItem(lv.get(0).getString()).getItem();
Item item = NBTSerializableValue.parseItem(lv.get(0).getString(), cc.s.registryAccess()).getItem();
if (lv.size() == 1)
{
return ListValue.wrap( blocks.getTags().filter(e -> e.getSecond().stream().anyMatch(h -> (h.value() == item))).map(e -> ValueConversions.of(e.getFirst())).collect(Collectors.toList()));
@@ -280,7 +277,7 @@ public class Inventories {
else
nbt = new NBTSerializableValue(nbtValue.getString()).getCompoundTag();
}
ItemInput newitem = NBTSerializableValue.parseItem(lv.get(inventoryLocator.offset()+2).getString(), nbt);
ItemInput newitem = NBTSerializableValue.parseItem(lv.get(inventoryLocator.offset()+2).getString(), nbt, cc.s.registryAccess());
ItemStack previousStack = inventoryLocator.inventory().getItem(slot);
try
{
@@ -305,7 +302,7 @@ public class Inventories {
{
Value secondArg = lv.get(inventoryLocator.offset()+0);
if (!secondArg.isNull())
itemArg = NBTSerializableValue.parseItem(secondArg.getString());
itemArg = NBTSerializableValue.parseItem(secondArg.getString(), cc.s.registryAccess());
}
int startIndex = 0;
if (lv.size() > inventoryLocator.offset()+1)
@@ -330,7 +327,7 @@ public class Inventories {
if (inventoryLocator == null) return Value.NULL;
if (lv.size() <= inventoryLocator.offset())
throw new InternalExpressionException("'inventory_remove' requires at least an item to be removed");
ItemInput searchItem = NBTSerializableValue.parseItem(lv.get(inventoryLocator.offset()).getString());
ItemInput searchItem = NBTSerializableValue.parseItem(lv.get(inventoryLocator.offset()).getString(), cc.s.registryAccess());
int amount = 1;
if (lv.size() > inventoryLocator.offset()+1)
amount = (int)NumericValue.asNumber(lv.get(inventoryLocator.offset()+1)).getLong();
@@ -34,7 +34,6 @@ import carpet.script.value.StringValue;
import carpet.script.value.Value;
import carpet.script.value.ValueConversions;
import carpet.utils.BlockInfo;
import carpet.utils.CommandHelper;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
@@ -926,7 +925,7 @@ public class WorldAccess {
throw new InternalExpressionException("'create_explosion' requires at least a position to explode");
CarpetContext cc = (CarpetContext)c;
float powah = 4.0f;
Explosion.BlockInteraction mode = Explosion.BlockInteraction.BREAK;
Explosion.BlockInteraction mode = Explosion.BlockInteraction.DESTROY; // should probably read the gamerule for default behaviour
boolean createFire = false;
Entity source = null;
LivingEntity attacker = null;
@@ -994,7 +993,7 @@ public class WorldAccess {
};
explosion.explode();
explosion.finalizeExplosion(false);
if (mode == Explosion.BlockInteraction.NONE) explosion.clearToBlow();
if (mode == Explosion.BlockInteraction.KEEP) explosion.clearToBlow();
cc.s.getLevel().players().forEach(spe -> {
if (spe.distanceToSqr(pos) < 4096.0D)
spe.connection.send(new ClientboundExplodePacket(pos.x, pos.y, pos.z, thePowah, explosion.getToBlow(), explosion.getHitPlayers().get(spe)));
@@ -1010,7 +1009,7 @@ public class WorldAccess {
CarpetContext cc = (CarpetContext) c;
String itemString = lv.get(0).getString();
Vector3Argument locator = Vector3Argument.findIn(lv, 1);
ItemInput stackArg = NBTSerializableValue.parseItem(itemString);
ItemInput stackArg = NBTSerializableValue.parseItem(itemString, cc.s.registryAccess());
BlockPos where = new BlockPos(locator.vec);
String facing;
if (lv.size() > locator.offset) {