This commit is contained in:
gnembon committed 2020-03-11 14:52:13 -03:00
commit 877863819c
22 files changed
+88 -63

No files matched your search

+3 -3
View File
@@ -5,11 +5,11 @@ org.gradle.jvmargs=-Xmx1G
# check these on https://fabricmc.net/use
# or better: https://modmuss50.me/fabric.html
minecraft_version=20w10a
yarn_mappings=20w10a+build.10
loader_version=0.7.8+build.186
yarn_mappings=20w10a+build.20
loader_version=0.7.8+build.187
# Mod Properties
mod_version = 1.3.13+v200304
mod_version = 1.3.14+v200311
maven_group = carpet
archives_base_name = fabric-carpet
+24 -5
View File
@@ -28,11 +28,12 @@ import static carpet.settings.RuleCategory.OPTIMIZATION;
import static carpet.settings.RuleCategory.SURVIVAL;
import static carpet.settings.RuleCategory.TNT;
import static carpet.settings.RuleCategory.DISPENSER;
import static carpet.settings.RuleCategory.SCARPET;
@SuppressWarnings("CanBeFinal")
public class CarpetSettings
{
public static final String carpetVersion = "1.3.13+v200304";
public static final String carpetVersion = "1.3.14+v200311";
public static final Logger LOG = LogManager.getLogger();
public static boolean skipGenerationChecks = false;
public static boolean impendingFillSkipUpdates = false;
@@ -303,13 +304,27 @@ public class CarpetSettings
@Rule(desc = "Enables /draw commands", extra = "... allows for drawing simple shapes", category = COMMAND)
public static String commandDraw = "true";
@Rule(desc = "Enables /script command", extra = "An in-game scripting API for Scarpet programming language", category = COMMAND)
public static boolean commandScript = true;
@Rule(
desc = "Enables /script command",
extra = "An in-game scripting API for Scarpet programming language",
category = {COMMAND, SCARPET}
)
public static String commandScript = "true";
@Rule(
desc = "Enables restrictions for arbitrary code execution with scarpet",
extra = {
"Users that don't have this permission level",
"won't be able to load apps or /script run"
},
category = {COMMAND, SCARPET}
)
public static String commandScriptACE = "ops";
@Rule(
desc = "Scarpet script from world files will autoload on server/world start ",
extra = "if /script is enabled",
category = CREATIVE
category = SCARPET
)
public static boolean scriptsAutoload = false;
@@ -322,7 +337,11 @@ public class CarpetSettings
@Rule(desc = "Placing carpets may issue carpet commands for non-op players", category = SURVIVAL)
public static boolean carpets = false;
@Rule(desc = "Pistons, Glass and Sponge can be broken faster with their appropriate tools", category = SURVIVAL)
@Rule(
desc = "Glass and Sponge can be broken faster with their appropriate tools",
extra = "Glass is pickaxes, sponge is shears",
category = SURVIVAL
)
public static boolean missingTools = false;
//@Rule(desc = "Alternative, persistent caching strategy for nether portals", category = {SURVIVAL, CREATIVE})
@@ -80,7 +80,7 @@ public class DrawCommand
final int ceilRadiusY = (int) Math.ceil(radiusY);
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
BlockPos.Mutable mbpos = pos.method_25503();
BlockPos.Mutable mbpos = pos.mutableCopy();
List<BlockPos> list = Lists.newArrayList();
double nextXn = 0;
@@ -11,6 +11,7 @@ import carpet.script.LazyValue;
import carpet.script.Tokenizer;
import carpet.script.exception.CarpetExpressionException;
import carpet.script.value.FunctionValue;
import carpet.settings.SettingsManager;
import carpet.utils.Messenger;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
@@ -79,7 +80,7 @@ public class ScriptCommand
LiteralArgumentBuilder<ServerCommandSource> u = literal("resume").
executes( (cc) -> { CarpetServer.scriptServer.stopAll = false; return 1;});
LiteralArgumentBuilder<ServerCommandSource> l = literal("run").
requires((player) -> player.hasPermissionLevel(2)).
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE)).
then(argument("expr", StringArgumentType.greedyString()).suggests(ScriptCommand::suggestCode).
executes((cc) -> compute(
cc,
@@ -205,7 +206,7 @@ public class ScriptCommand
BlockPredicateArgumentType.getBlockPredicate(cc, "filter"),
"outline"
)))))))));
LiteralArgumentBuilder<ServerCommandSource> a = literal("load").requires( (player) -> player.hasPermissionLevel(2) ).
LiteralArgumentBuilder<ServerCommandSource> a = literal("load").requires( (player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE) ).
then(argument("app", StringArgumentType.word()).
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.listAvailableModules(true),bb)).
executes((cc) ->
@@ -222,7 +223,7 @@ public class ScriptCommand
)
)
);
LiteralArgumentBuilder<ServerCommandSource> f = literal("unload").requires( (player) -> player.hasPermissionLevel(2) ).
LiteralArgumentBuilder<ServerCommandSource> f = literal("unload").requires( (player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE) ).
then(argument("app", StringArgumentType.word()).
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(),bb)).
executes((cc) ->
@@ -231,7 +232,7 @@ public class ScriptCommand
return success?1:0;
}));
LiteralArgumentBuilder<ServerCommandSource> q = literal("event").requires( (player) -> player.hasPermissionLevel(2) ).
LiteralArgumentBuilder<ServerCommandSource> q = literal("event").requires( (player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScriptACE) ).
executes( (cc) -> listEvents(cc.getSource())).
then(literal("add_to").
then(argument("event", StringArgumentType.word()).
@@ -268,10 +269,10 @@ public class ScriptCommand
dispatcher.register(literal("script").
requires((player) -> CarpetSettings.commandScript).
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScript)).
then(b).then(u).then(o).then(l).then(s).then(c).then(h).then(i).then(e).then(t).then(a).then(f).then(q));
dispatcher.register(literal("script").
requires((player) -> CarpetSettings.commandScript).
requires((player) -> SettingsManager.canUseCommand(player, CarpetSettings.commandScript)).
then(literal("in").
then(argument("app", StringArgumentType.word()).
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(), bb)).
@@ -489,7 +490,7 @@ public class ScriptCommand
boolean[][][] volume = new boolean[area.getBlockCountX()][area.getBlockCountY()][area.getBlockCountZ()];
BlockPos.Mutable mbpos = origin.method_25503();
BlockPos.Mutable mbpos = origin.mutableCopy();
ServerWorld world = source.getWorld();
for (int x = area.minX; x <= area.maxX; x++)
@@ -269,8 +269,8 @@ public class FeatureGenerator
:simplePlop(Feature.CORAL_CLAW).plop(w, p));
put("sea_pickle", simplePlop(Feature.SEA_PICKLE.configure( new SeaPickleFeatureConfig(20))));
put("boulder", simplePlop(Feature.FOREST_ROCK.configure( new BoulderFeatureConfig(Blocks.MOSSY_COBBLESTONE.getDefaultState(), 0))));
put("crimson_fungus", simplePlop(Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.field_22432)));
put("warped_fungus", simplePlop(Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.field_22434)));
put("crimson_fungus", simplePlop(Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.CRIMSON_FUNGUS_NOT_PLANTED_CONFIG)));
put("warped_fungus", simplePlop(Feature.HUGE_FUNGUS.configure(HugeFungusFeatureConfig.WARPED_FUNGUS_NOT_PLANTED_CONFIG)));
put("nether_sprouts", simplePlop(Feature.NETHER_FOREST_VEGETATION.configure(DefaultBiomeFeatures.NETHER_SPROUTS_CONFIG)));
put("crimson_roots", simplePlop(Feature.NETHER_FOREST_VEGETATION.configure(DefaultBiomeFeatures.CRIMSON_ROOTS_CONFIG)));
put("warped_roots", simplePlop(Feature.NETHER_FOREST_VEGETATION.configure(DefaultBiomeFeatures.WARPED_ROOTS_CONFIG)));
@@ -192,13 +192,16 @@ public class OptimizedExplosion
world.playSound(null, posX, posY, posZ, SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F,
(1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F);
if (eAccess.getPower() >= 2.0F && damagesTerrain)
if (spawnParticles)
{
world.addParticle(ParticleTypes.EXPLOSION_EMITTER, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
}
else
{
world.addParticle(ParticleTypes.EXPLOSION, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
if (eAccess.getPower() >= 2.0F && damagesTerrain)
{
world.addParticle(ParticleTypes.EXPLOSION_EMITTER, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
}
else
{
world.addParticle(ParticleTypes.EXPLOSION, posX, posY, posZ, 1.0D, 0.0D, 0.0D);
}
}
}
@@ -212,7 +215,7 @@ public class OptimizedExplosion
BlockState state = world.getBlockState(blockpos);
Block block = state.getBlock();
if (spawnParticles)
/*if (spawnParticles)
{
double d0 = (double)((float)blockpos.getX() + world.random.nextFloat());
double d1 = (double)((float)blockpos.getY() + world.random.nextFloat());
@@ -232,7 +235,7 @@ public class OptimizedExplosion
world.addParticle(ParticleTypes.POOF,
(d0 + posX) / 2.0D, (d1 + posY) / 2.0D, (d2 + posZ) / 2.0D, d3, d4, d5);
world.addParticle(ParticleTypes.SMOKE, d0, d1, d2, d3, d4, d5);
}
}*/
if (state.getMaterial() != Material.AIR)
{
@@ -30,7 +30,7 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity
@Inject(method = "readCustomDataFromTag", at = @At("HEAD"))
private void checkScarpetMarkerUnloaded(CallbackInfo ci)
{
if ((CarpetSettings.scriptsAutoload || CarpetSettings.commandScript) && !world.isClient)
if ((CarpetSettings.scriptsAutoload || !CarpetSettings.commandScript.equals("false")) && !world.isClient)
{
if (getScoreboardTags().contains(ExpressionInspector.MARKER_STRING))
{
@@ -42,6 +42,7 @@ public abstract class CommandManagerMixin
CarpetSettings.impendingFillSkipUpdates = false;
}
// warning expected
@Redirect(method = "execute", at = @At(
value = "INVOKE",
target = "Lorg/apache/logging/log4j/Logger;isDebugEnabled()Z"
@@ -1,12 +1,12 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.container.Container;
import net.minecraft.container.Slot;
import net.minecraft.container.SlotActionType;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandler;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
@Mixin(Container.class)
@Mixin(ScreenHandler.class)
public abstract class ContainerMixin
{
@Shadow @Final public List<Slot> slots;
@@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(PickaxeItem.class)
public class PickaxeItem_missingToolsMixin
{
@Redirect(method = "getMiningSpeed", at = @At(
@Redirect(method = "getMiningSpeedMultiplier", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/BlockState;getMaterial()Lnet/minecraft/block/Material;"
))
@@ -18,16 +18,16 @@ public abstract class PlayerEntity_antiCheatDisabled
{
@Shadow public abstract ItemStack getEquippedStack(EquipmentSlot equipmentSlot_1);
@Shadow public abstract void method_23669();
@Shadow public abstract void startFallFlying();
@Inject(method = "method_23668", at = @At("HEAD"), cancellable = true)
@Inject(method = "checkFallFlying", at = @At("HEAD"), cancellable = true)
private void allowDeploys(CallbackInfoReturnable<Boolean> cir)
{
if (CarpetSettings.antiCheatDisabled && CarpetServer.minecraft_server.isDedicated())
{
ItemStack itemStack_1 = getEquippedStack(EquipmentSlot.CHEST);
if (itemStack_1.getItem() == Items.ELYTRA && ElytraItem.isUsable(itemStack_1)) {
method_23669();
startFallFlying();
cir.setReturnValue(true);
}
}
@@ -24,8 +24,6 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
@Shadow protected abstract void dropShoulderEntities();
@Shadow protected abstract void method_7296(CompoundTag compoundTag_1);
@Shadow public abstract CompoundTag getShoulderEntityLeft();
@Shadow protected abstract void setShoulderEntityLeft(CompoundTag compoundTag_1);
@@ -33,7 +31,9 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
@Shadow protected abstract void setShoulderEntityRight(CompoundTag compoundTag_1);
@Shadow public abstract CompoundTag getShoulderEntityRight();
@Shadow protected abstract void dropShoulderEntity(CompoundTag entityNbt);
protected PlayerEntity_parrotMixin(EntityType<? extends LivingEntity> entityType_1, World world_1)
{
super(entityType_1, world_1);
@@ -66,13 +66,13 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
protected void dismount_left()
{
this.method_7296(this.getShoulderEntityLeft());
dropShoulderEntity(this.getShoulderEntityLeft());
this.setShoulderEntityLeft(new CompoundTag());
}
protected void dismount_right()
{
this.method_7296(this.getShoulderEntityRight());
dropShoulderEntity(this.getShoulderEntityRight());
this.setShoulderEntityRight(new CompoundTag());
}
@@ -51,7 +51,7 @@ public class PortalForcer_portalSuffocationMixin
CarpetSettings.fixedPosition = null;
}
@SuppressWarnings("UnresolvedMixinReference")
@Redirect(method = "method_22391",at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/pattern/BlockPattern$Result;getTeleportTarget(Lnet/minecraft/util/math/Direction;Lnet/minecraft/util/math/BlockPos;DLnet/minecraft/util/math/Vec3d;D)Lnet/minecraft/block/pattern/BlockPattern$TeleportTarget;"
@@ -18,6 +18,7 @@ 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;
import java.util.Iterator;
import java.util.Set;
@@ -41,13 +42,6 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa
@Shadow
private BlockState update(World world_1, BlockPos blockPos_1, BlockState blockState_1) { return null; }
// =
@Override
public BlockState updateLogicPublic(World world_1, BlockPos blockPos_1, BlockState blockState_1) {
return updateLogic(world_1, blockPos_1, blockState_1);
}
@Override
@Accessor("wiresGivePower")
public abstract void setWiresGivePower(boolean wiresGivePower);
@@ -79,8 +73,15 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa
/**
* @author theosib, soykaf, gnembon
*/
@Overwrite
private BlockState updateLogic(World world_1, BlockPos blockPos_1, BlockState blockState_1) {
@Inject(method = "updateLogic", at = @At("HEAD"), cancellable = true)
private void updateLogicAlternative(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<BlockState> cir)
{
if (CarpetSettings.fastRedstoneDust)
cir.setReturnValue(updateLogicPublic(world, pos, state));
}
@Override
public BlockState updateLogicPublic(World world_1, BlockPos blockPos_1, BlockState blockState_1) {
BlockState blockState_2 = blockState_1;
int int_1 = (Integer)blockState_1.get(POWER); // i
this.wiresGivePower = false;
@@ -193,7 +193,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
@Inject(method = "onClientCommand", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/network/ServerPlayerEntity;method_23668()Z",
target = "Lnet/minecraft/server/network/ServerPlayerEntity;checkFallFlying()Z",
shift = At.Shift.BEFORE
))
private void onElytraEngage(ClientCommandC2SPacket clientCommandC2SPacket_1, CallbackInfo ci)
@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ShearsItem.class)
public class ShearsItem_missingToolsMixin
{
@Inject(method = "getMiningSpeed", at = @At("HEAD"), cancellable = true)
@Inject(method = "getMiningSpeedMultiplier", at = @At("HEAD"), cancellable = true)
private void getCustomMaterial(ItemStack itemStack_1, BlockState blockState_1, CallbackInfoReturnable<Float> cir)
{
if (CarpetSettings.missingTools && (blockState_1.getMaterial() == Material.SPONGE))
@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(Structure.class)
public class Structure_fillUpdatesMixin
{
@Redirect( method = "method_15172", at = @At(
@Redirect( method = "place(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;I)Z", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/IWorld;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
))
@@ -23,7 +23,7 @@ public class Structure_fillUpdatesMixin
iWorld.updateNeighbors(var1, var2);
}
@Redirect(method = "method_15172", at = @At(
@Redirect(method = "place(Lnet/minecraft/world/IWorld;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/structure/StructurePlacementData;I)Z", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/structure/StructurePlacementData;shouldUpdateNeighbors()Z"
))
@@ -52,8 +52,6 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
@Shadow private boolean chunkHolderListDirty;
@Shadow protected abstract void method_20458(long l, ChunkHolder chunkHolder);
@Shadow @Final private Queue<Runnable> field_19343;
@Shadow @Final private ServerLightingProvider serverLightingProvider;
@@ -73,6 +71,8 @@ public abstract class ThreadedAnvilChunkStorage_scarpetChunkCreationMixin implem
//in method_20617
//method_19534(Lnet/minecraft/server/world/ChunkHolder;Lnet/minecraft/world/chunk/Chunk;)Ljava/util/concurrent/CompletableFuture;
// incmopatibility with optifine makes this mixin fail.
// lambda for convertToFullChunk
@SuppressWarnings("UnresolvedMixinReference")
@Inject(method = "method_19534", require = 0, at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;convertToFullChunk(Lnet/minecraft/server/world/ChunkHolder;)Ljava/util/concurrent/CompletableFuture;",
@@ -48,14 +48,13 @@ public abstract class World_movableTEMixin implements WorldInterface
@Shadow
public abstract void updateNeighborsAlways(BlockPos blockPos_1, Block block_1);
@Shadow
public abstract void updateHorizontalAdjacent(BlockPos blockPos_1, Block block_1);
@Shadow
public abstract void onBlockChanged(BlockPos blockPos_1, BlockState blockState_1, BlockState blockState_2);
@Shadow public abstract Profiler getProfiler();
@Shadow public abstract void updateComparators(BlockPos pos, Block block);
/**
* @author 2No2Name
*/
@@ -116,7 +115,7 @@ public abstract class World_movableTEMixin implements WorldInterface
this.updateNeighborsAlways(blockPos_1, blockState_2.getBlock());
if (blockState_1.hasComparatorOutput())
{
this.updateHorizontalAdjacent(blockPos_1, block_1);
updateComparators(blockPos_1, block_1);
}
}
@@ -54,7 +54,7 @@ import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ShearsItem;
import net.minecraft.item.SwordItem;
import net.minecraft.item.TridentItem;
import net.minecraft.network.packet.s2c.play.ContainerSlotUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket;
import net.minecraft.network.packet.s2c.play.PlaySoundIdS2CPacket;
import net.minecraft.command.arguments.ItemStackArgument;
import net.minecraft.command.arguments.ParticleArgumentType;
@@ -2101,7 +2101,7 @@ public class CarpetExpression
if (inventory.owner instanceof ServerPlayerEntity && !inventory.isEnder)
{
ServerPlayerEntity player = (ServerPlayerEntity) inventory.owner;
player.networkHandler.sendPacket(new ContainerSlotUpdateS2CPacket(
player.networkHandler.sendPacket(new ScreenHandlerSlotUpdateS2CPacket(
-2,
int_1,
inventory.inventory.getInvStack(int_1)
@@ -11,5 +11,6 @@ public class RuleCategory
public static final String COMMAND = "command";
public static final String TNT = "tnt";
public static final String DISPENSER = "dispenser";
public static final String SCARPET = "scarpet";
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "carpet",
"version": "1.3.13",
"version": "1.3.14",
"name": "Carpet Mod in Fabric",
"description": "Carpet made out of fabric",