12 files changed
+132
-45
No files matched your search
+3
-3
@@ -4,9 +4,9 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/use
|
||||
# or better: https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.14.3-pre2
|
||||
yarn_mappings=1.14.3-pre2+build.1
|
||||
loader_version=0.4.8+build.154
|
||||
minecraft_version=1.14.3-pre4
|
||||
yarn_mappings=1.14.3-pre4+build.1
|
||||
loader_version=0.4.8+build.155
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.1a
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.settings.CarpetSettings;
|
||||
import net.minecraft.block.dispenser.BlockPlacementDispenserBehavior;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(BlockPlacementDispenserBehavior.class)
|
||||
public class BlockPlacementDispenserBehaviourMixin
|
||||
{
|
||||
@Redirect(method = "dispenseSilently", at = @At(value="INVOKE", target="Lnet/minecraft/item/ItemStack;decrement(I)V"))
|
||||
private void cancleDoubleDecrement(ItemStack stack, int amount)
|
||||
{
|
||||
if (!CarpetSettings.stackableShulkerBoxes)
|
||||
{
|
||||
stack.decrement(amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,13 @@ import carpet.settings.CarpetSettings;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@@ -39,4 +41,15 @@ public abstract class CommandManagerMixin
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates = false;
|
||||
}
|
||||
|
||||
@Redirect(method = "execute", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lorg/apache/logging/log4j/Logger;isDebugEnabled()Z"
|
||||
))
|
||||
private boolean doesOutputCommandStackTrace(Logger logger)
|
||||
{
|
||||
if (CarpetSettings.superSecretSetting)
|
||||
return true;
|
||||
return logger.isDebugEnabled();
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
||||
{
|
||||
List<Entity> list_1 = this.world.getEntities((Entity)this, this.getBoundingBox(), EntityPredicates.canBePushedBy(this));
|
||||
if (!list_1.isEmpty()) {
|
||||
int int_1 = this.world.getGameRules().getInteger(GameRules.MAX_ENTITY_CRAMMING);
|
||||
int int_1 = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
|
||||
int int_2;
|
||||
if (int_1 > 0 && list_1.size() > int_1 - 1 && this.random.nextInt(4) == 0) {
|
||||
int_2 = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.function.BooleanSupplier;
|
||||
@Mixin(ServerChunkManager.class)
|
||||
public abstract class ServerChunkManager_tickMixin
|
||||
{
|
||||
/*
|
||||
|
||||
@Shadow @Final private ServerWorld world;
|
||||
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
@@ -66,7 +66,7 @@ public abstract class ServerChunkManager_tickMixin
|
||||
{
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
//// Tick freeze
|
||||
@Redirect(method = "tickChunks", at = @At(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.script;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.script.value.NullValue;
|
||||
import carpet.settings.CarpetSettings;
|
||||
import carpet.helpers.FeatureGenerator;
|
||||
import carpet.fakes.MinecraftServerInterface;
|
||||
@@ -24,6 +25,8 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.command.arguments.ParticleArgumentType;
|
||||
@@ -38,10 +41,12 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.state.StateFactory;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.EulerRotation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.LightType;
|
||||
@@ -1874,6 +1879,62 @@ public class CarpetExpression
|
||||
return (c_, t_) -> new NumericValue(particleCount);
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("create_marker", -1, (c, t, lv) ->{
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
BlockState targetBlock = null;
|
||||
BlockValue.VectorLocator pointLocator;
|
||||
String name;
|
||||
try
|
||||
{
|
||||
Value nameValue = lv.get(0).evalValue(c);
|
||||
name = nameValue instanceof NullValue ? "" : nameValue.getString();
|
||||
pointLocator = BlockValue.locateVec(cc, lv, 1, true);
|
||||
if (lv.size()>pointLocator.offset)
|
||||
targetBlock = BlockValue.fromParams(cc, lv, pointLocator.offset, true).block.getBlockState();
|
||||
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
throw new InternalExpressionException("create_marker requires a name and three coordinates, with optional direction, and optional block on its head");
|
||||
}
|
||||
|
||||
ArmorStandEntity armorstand = new ArmorStandEntity(EntityType.ARMOR_STAND, cc.s.getWorld());
|
||||
armorstand.setPositionAndAngles(
|
||||
pointLocator.vec.x,
|
||||
pointLocator.vec.y - ((targetBlock==null)?(armorstand.getHeight()+0.41):(armorstand.getHeight()-0.3)),
|
||||
pointLocator.vec.z,
|
||||
(float)pointLocator.yaw,
|
||||
(float) pointLocator.pitch
|
||||
);
|
||||
armorstand.addScoreboardTag("__scarpet_marker");
|
||||
if (targetBlock != null)
|
||||
armorstand.setEquippedStack(EquipmentSlot.HEAD, new ItemStack(targetBlock.getBlock().asItem()));
|
||||
if (!name.isEmpty())
|
||||
{
|
||||
armorstand.setCustomName(new LiteralText(name));
|
||||
armorstand.setCustomNameVisible(true);
|
||||
}
|
||||
armorstand.setHeadRotation(new EulerRotation((int)pointLocator.pitch,0,0));
|
||||
armorstand.setNoGravity(true);
|
||||
armorstand.setInvisible(true);
|
||||
armorstand.setInvulnerable(true);
|
||||
cc.s.getWorld().spawnEntity(armorstand);
|
||||
EntityValue result = new EntityValue(armorstand);
|
||||
return (_c, _t) -> result;
|
||||
});
|
||||
|
||||
this.expr.addLazyFunction("remove_all_markers", 0, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
int total = 0;
|
||||
for (Entity e : cc.s.getWorld().getEntities(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains("__scarpet_marker")))
|
||||
{
|
||||
total ++;
|
||||
e.remove();
|
||||
}
|
||||
int finalTotal = total;
|
||||
return (_cc, _tt) -> new NumericValue(finalTotal);
|
||||
});
|
||||
|
||||
//"overridden" native call that prints to stderr
|
||||
this.expr.addLazyFunction("print", 1, (c, t, lv) ->
|
||||
{
|
||||
|
||||
@@ -2375,9 +2375,15 @@ public class Expression implements Cloneable
|
||||
String format = lv.get(0).getString();
|
||||
if (lv.size() == 1)
|
||||
return new StringValue(format);
|
||||
int argIndex = 1;
|
||||
if (lv.get(1) instanceof ListValue)
|
||||
{
|
||||
lv = ((ListValue) lv.get(1)).getItems();
|
||||
argIndex = 0;
|
||||
}
|
||||
List<Object> args = new ArrayList<>();
|
||||
Matcher m = formatPattern.matcher(format);
|
||||
int argIndex = 1;
|
||||
|
||||
for (int i = 0, len = format.length(); i < len; ) {
|
||||
if (m.find(i)) {
|
||||
// Anything between the start of the string and the beginning
|
||||
|
||||
@@ -5,11 +5,9 @@ import carpet.script.LazyValue;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.arguments.BlockArgumentParser;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
@@ -57,6 +55,10 @@ public class BlockValue extends Value
|
||||
}
|
||||
|
||||
public static VectorLocator locateVec(CarpetContext c, List<LazyValue> params, int offset)
|
||||
{
|
||||
return locateVec(c,params, offset, false);
|
||||
}
|
||||
public static VectorLocator locateVec(CarpetContext c, List<LazyValue> params, int offset, boolean optionalDirection)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -68,19 +70,34 @@ public class BlockValue extends Value
|
||||
if (v1 instanceof ListValue)
|
||||
{
|
||||
List<Value> args = ((ListValue) v1).getItems();
|
||||
return new VectorLocator( new Vec3d(
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(args.get(0)).getDouble(),
|
||||
NumericValue.asNumber(args.get(1)).getDouble(),
|
||||
NumericValue.asNumber(args.get(2)).getDouble()),
|
||||
offset+1
|
||||
);
|
||||
NumericValue.asNumber(args.get(2)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
if (args.size()>3 && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(args.get(3)).getDouble();
|
||||
pitch = NumericValue.asNumber(args.get(4)).getDouble();
|
||||
}
|
||||
return new VectorLocator(pos,offset+1, yaw, pitch);
|
||||
}
|
||||
return new VectorLocator( new Vec3d(
|
||||
Vec3d pos = new Vec3d(
|
||||
NumericValue.asNumber(v1).getDouble(),
|
||||
NumericValue.asNumber(params.get(1 + offset).evalValue(c)).getDouble(),
|
||||
NumericValue.asNumber(params.get(2 + offset).evalValue(c)).getDouble()),
|
||||
offset+3
|
||||
);
|
||||
NumericValue.asNumber(params.get(2 + offset).evalValue(c)).getDouble());
|
||||
double yaw = 0.0D;
|
||||
double pitch = 0.0D;
|
||||
int eatenLength = 3;
|
||||
if (params.size()>3+offset && optionalDirection)
|
||||
{
|
||||
yaw = NumericValue.asNumber(params.get(3 + offset).evalValue(c)).getDouble();
|
||||
pitch = NumericValue.asNumber(params.get(4 + offset).evalValue(c)).getDouble();
|
||||
eatenLength = 5;
|
||||
}
|
||||
|
||||
return new VectorLocator(pos,offset+eatenLength, yaw, pitch);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
@@ -205,10 +222,21 @@ public class BlockValue extends Value
|
||||
{
|
||||
public Vec3d vec;
|
||||
public int offset;
|
||||
public double yaw;
|
||||
public double pitch;
|
||||
VectorLocator(Vec3d v, int o)
|
||||
{
|
||||
vec = v;
|
||||
offset = o;
|
||||
yaw = 0.0D;
|
||||
pitch = 0.0D;
|
||||
}
|
||||
VectorLocator(Vec3d v, int o, double y, double p)
|
||||
{
|
||||
vec = v;
|
||||
offset = o;
|
||||
yaw = y;
|
||||
pitch = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,8 +174,8 @@ public class EntityValue extends Value
|
||||
|
||||
put("invulnerable", (e, a) -> new NumericValue(e.isInvulnerable()));
|
||||
put("dimension", (e, a) -> new StringValue(e.dimension.toString().replaceFirst("minecraft:","")));
|
||||
put("height", (e, a) -> new NumericValue(e.getSize(EntityPose.STANDING).height));
|
||||
put("width", (e, a) -> new NumericValue(e.getSize(EntityPose.STANDING).width));
|
||||
put("height", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).height));
|
||||
put("width", (e, a) -> new NumericValue(e.getDimensions(EntityPose.STANDING).width));
|
||||
put("eye_height", (e, a) -> new NumericValue(e.getEyeHeight(EntityPose.STANDING)));
|
||||
put("age", (e, a) -> new NumericValue(e.age));
|
||||
put("item", (e, a) -> (e instanceof ItemEntity)?new StringValue(((ItemEntity) e).getStack().getName().getString()):Value.NULL);
|
||||
|
||||
@@ -177,7 +177,9 @@ public class PerimeterDiagnostics
|
||||
if (SpawnHelper.canSpawn(spt, worldServer, pos, sle.type))
|
||||
{
|
||||
el.setPositionAndAngles((float)pos.getX() + 0.5F, (float)pos.getY(), (float)pos.getZ()+0.5F, 0.0F, 0.0F);
|
||||
return el.canSpawn(worldServer) && el.canSpawn(worldServer, SpawnType.NATURAL) && worldServer.doesNotCollide(el); // check collision rules once they stop fiddling with them after 1.14.1
|
||||
return el.canSpawn(worldServer) &&
|
||||
SpawnRestriction.method_20638(el.getType(),el.getEntityWorld(), SpawnType.NATURAL, el.getBlockPos(), el.getEntityWorld().random) &&
|
||||
worldServer.doesNotCollide(el); // check collision rules once they stop fiddling with them after 1.14.1
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ public class SpawnReporter
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
if (mob.canSpawn(worldIn, SpawnType.NATURAL))
|
||||
if (SpawnRestriction.method_20638(mob.getType(),mob.getEntityWorld(), SpawnType.NATURAL, mob.getBlockPos(), mob.getEntityWorld().random))
|
||||
{
|
||||
will_spawn += 1;
|
||||
}
|
||||
|
||||
@@ -91,9 +91,7 @@
|
||||
"PistonBlock_movableTEMixin",
|
||||
"PistonBlockEntity_movableTEMixin",
|
||||
"World_movableTEMixin",
|
||||
"WorldChunk_movableTEMixin",
|
||||
|
||||
"BlockPlacementDispenserBehaviourMixin"
|
||||
"WorldChunk_movableTEMixin"
|
||||
],
|
||||
"client": [
|
||||
"MinecraftClientMixin",
|
||||
|
||||
Reference in new issue
Block a user