Merge branch 'master' into 1.15
This commit is contained in:
commit
bf22134640
19 files changed
+138
-57
No files matched your search
@@ -276,8 +276,8 @@ Pistons, Glass and Sponge can be broken faster with their appropriate tools
|
|||||||
* Required options: `true`, `false`
|
* Required options: `true`, `false`
|
||||||
* Categories: `SURVIVAL`
|
* Categories: `SURVIVAL`
|
||||||
|
|
||||||
## movableTileEntities
|
## movableBlockEntities
|
||||||
Pistons can push tile entities, like hoppers, chests etc.
|
Pistons can push block entities, like hoppers, chests etc.
|
||||||
* Type: `boolean`
|
* Type: `boolean`
|
||||||
* Default value: `false`
|
* Default value: `false`
|
||||||
* Required options: `true`, `false`
|
* Required options: `true`, `false`
|
||||||
|
|||||||
@@ -59,7 +59,9 @@ public class TickSpeed
|
|||||||
}
|
}
|
||||||
if (time_bias > 0)
|
if (time_bias > 0)
|
||||||
{
|
{
|
||||||
return Messenger.c("l Another player is already advancing time at the moment. Try later or talk to them");
|
String who = "Another player";
|
||||||
|
if (time_advancerer != null) who = time_advancerer.getEntityName();
|
||||||
|
return Messenger.c("l "+who+" is already advancing time at the moment. Try later or ask them");
|
||||||
}
|
}
|
||||||
time_advancerer = player;
|
time_advancerer = player;
|
||||||
time_warp_start_time = System.nanoTime();
|
time_warp_start_time = System.nanoTime();
|
||||||
@@ -89,15 +91,7 @@ public class TickSpeed
|
|||||||
CommandManager icommandmanager = tick_warp_sender.getMinecraftServer().getCommandManager();
|
CommandManager icommandmanager = tick_warp_sender.getMinecraftServer().getCommandManager();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int j = icommandmanager.execute(tick_warp_sender, tick_warp_callback);
|
icommandmanager.execute(tick_warp_sender, tick_warp_callback);
|
||||||
|
|
||||||
if (j < 1)
|
|
||||||
{
|
|
||||||
if (time_advancerer != null)
|
|
||||||
{
|
|
||||||
Messenger.m(time_advancerer, "r Command Callback failed: ", "rb /"+tick_warp_callback,"/"+tick_warp_callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Throwable var23)
|
catch (Throwable var23)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package carpet.mixins;
|
||||||
|
|
||||||
|
import carpet.helpers.TickSpeed;
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
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.Redirect;
|
||||||
|
|
||||||
|
@Mixin(MinecraftClient.class)
|
||||||
|
public class MinecraftClient_pausedShakeMixin
|
||||||
|
{
|
||||||
|
@Shadow private boolean paused;
|
||||||
|
|
||||||
|
@Redirect(method = "render", at = @At(
|
||||||
|
value = "FIELD",
|
||||||
|
target = "Lnet/minecraft/client/MinecraftClient;paused:Z",
|
||||||
|
ordinal = 0
|
||||||
|
))
|
||||||
|
private boolean isPausedForRendering(MinecraftClient client)
|
||||||
|
{
|
||||||
|
return paused || !TickSpeed.process_entities;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin extends BlockEnti
|
|||||||
double double_3, float float_1, int int_1, CallbackInfo ci)
|
double double_3, float float_1, int int_1, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if (!((PistonBlockEntityInterface) pistonBlockEntity_1).isRenderModeSet())
|
if (!((PistonBlockEntityInterface) pistonBlockEntity_1).isRenderModeSet())
|
||||||
((PistonBlockEntityInterface) pistonBlockEntity_1).setRenderCarriedBlockEntity(CarpetSettings.movableTileEntities && ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity() != null);
|
((PistonBlockEntityInterface) pistonBlockEntity_1).setRenderCarriedBlockEntity(CarpetSettings.movableBlockEntities && ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity() != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "method_3576", at = @At("RETURN"))
|
@Inject(method = "method_3576", at = @At("RETURN"))
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
|||||||
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
|
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
|
||||||
private boolean movableTEsetBlockState0(World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1)
|
private boolean movableTEsetBlockState0(World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1)
|
||||||
{
|
{
|
||||||
if (!CarpetSettings.movableTileEntities)
|
if (!CarpetSettings.movableBlockEntities)
|
||||||
return world.setBlockState(blockPos_1, blockAState_2, int_1);
|
return world.setBlockState(blockPos_1, blockAState_2, int_1);
|
||||||
else
|
else
|
||||||
return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, this.carriedBlockEntity, int_1);
|
return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, this.carriedBlockEntity, int_1);
|
||||||
@@ -87,7 +87,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
|||||||
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
|
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
|
||||||
private boolean movableTEsetBlockState1(World world, BlockPos blockPos_1, BlockState blockState_2, int int_1)
|
private boolean movableTEsetBlockState1(World world, BlockPos blockPos_1, BlockState blockState_2, int int_1)
|
||||||
{
|
{
|
||||||
if (!CarpetSettings.movableTileEntities)
|
if (!CarpetSettings.movableBlockEntities)
|
||||||
return world.setBlockState(blockPos_1, blockState_2, int_1);
|
return world.setBlockState(blockPos_1, blockState_2, int_1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
|||||||
//Handle TNT Explosions or other ways the moving Block is broken
|
//Handle TNT Explosions or other ways the moving Block is broken
|
||||||
//Also /setblock will cause this to be called, and drop e.g. a moving chest's contents.
|
//Also /setblock will cause this to be called, and drop e.g. a moving chest's contents.
|
||||||
// This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
|
// This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
|
||||||
if (CarpetSettings.movableTileEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
|
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
|
||||||
{
|
{
|
||||||
BlockState blockState_2;
|
BlockState blockState_2;
|
||||||
if (this.source)
|
if (this.source)
|
||||||
@@ -118,7 +118,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
|||||||
@Inject(method = "fromTag", at = @At(value = "TAIL"))
|
@Inject(method = "fromTag", at = @At(value = "TAIL"))
|
||||||
private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci)
|
private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if (CarpetSettings.movableTileEntities && compoundTag_1.containsKey("carriedTileEntityCM", 10))
|
if (CarpetSettings.movableBlockEntities && compoundTag_1.containsKey("carriedTileEntityCM", 10))
|
||||||
{
|
{
|
||||||
if (this.pushedBlock.getBlock() instanceof BlockEntityProvider)
|
if (this.pushedBlock.getBlock() instanceof BlockEntityProvider)
|
||||||
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(this.world);
|
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(this.world);
|
||||||
@@ -130,7 +130,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
|||||||
@Inject(method = "toTag", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
@Inject(method = "toTag", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||||
private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable<CompoundTag> cir)
|
private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable<CompoundTag> cir)
|
||||||
{
|
{
|
||||||
if (CarpetSettings.movableTileEntities && this.carriedBlockEntity != null)
|
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null)
|
||||||
{
|
{
|
||||||
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
|
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
|
||||||
compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.toTag(new CompoundTag()));
|
compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.toTag(new CompoundTag()));
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
|||||||
{
|
{
|
||||||
Block block_1 = blockState_1.getBlock();
|
Block block_1 = blockState_1.getBlock();
|
||||||
//Make CommandBlocks movable, either use instanceof CommandBlock or the 3 cmd block objects,
|
//Make CommandBlocks movable, either use instanceof CommandBlock or the 3 cmd block objects,
|
||||||
if (CarpetSettings.movableTileEntities && block_1 instanceof CommandBlock)
|
if (CarpetSettings.movableBlockEntities && block_1 instanceof CommandBlock)
|
||||||
{
|
{
|
||||||
cir.setReturnValue(true);
|
cir.setReturnValue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPushableTileEntityBlock(Block block)
|
private static boolean isPushableBlockEntity(Block block)
|
||||||
{
|
{
|
||||||
//Making PISTON_EXTENSION (BlockPistonMoving) pushable would not work as its createNewTileEntity()-method returns null
|
//Making PISTON_EXTENSION (BlockPistonMoving) pushable would not work as its createNewTileEntity()-method returns null
|
||||||
return block != Blocks.ENDER_CHEST && block != Blocks.ENCHANTING_TABLE &&
|
return block != Blocks.ENDER_CHEST && block != Blocks.ENCHANTING_TABLE &&
|
||||||
@@ -58,7 +58,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return !(CarpetSettings.movableTileEntities && isPushableTileEntityBlock(block));
|
return !(CarpetSettings.movableBlockEntities && isPushableBlockEntity(block));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||||
@@ -69,7 +69,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
|||||||
Direction direction_2, Set set_1)
|
Direction direction_2, Set set_1)
|
||||||
{
|
{
|
||||||
//Get the blockEntities and remove them from the world before any magic starts to happen
|
//Get the blockEntities and remove them from the world before any magic starts to happen
|
||||||
if (CarpetSettings.movableTileEntities)
|
if (CarpetSettings.movableBlockEntities)
|
||||||
{
|
{
|
||||||
list1_BlockEntities.set(Lists.<BlockEntity>newArrayList());
|
list1_BlockEntities.set(Lists.<BlockEntity>newArrayList());
|
||||||
for (int i = 0; i < list_1.size(); ++i)
|
for (int i = 0; i < list_1.size(); ++i)
|
||||||
@@ -99,7 +99,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
|||||||
{
|
{
|
||||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
|
||||||
direction_1, boolean_1, false);
|
direction_1, boolean_1, false);
|
||||||
if (CarpetSettings.movableTileEntities)
|
if (CarpetSettings.movableBlockEntities)
|
||||||
((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3));
|
((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3));
|
||||||
world_1.setBlockEntity(blockPos_4, blockEntityPiston);
|
world_1.setBlockEntity(blockPos_4, blockEntityPiston);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public abstract class PistonHandler_movableTEMixin
|
|||||||
* @author 2No2Name
|
* @author 2No2Name
|
||||||
*/
|
*/
|
||||||
private boolean stickToStickySide(BlockPos blockPos_1){
|
private boolean stickToStickySide(BlockPos blockPos_1){
|
||||||
if(!CarpetSettings.movableTileEntities)
|
if(!CarpetSettings.movableBlockEntities)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
BlockState blockState_1 = this.world.getBlockState(blockPos_1);
|
BlockState blockState_1 = this.world.getBlockState(blockPos_1);
|
||||||
@@ -107,7 +107,7 @@ public abstract class PistonHandler_movableTEMixin
|
|||||||
* @author 2No2Nameb
|
* @author 2No2Nameb
|
||||||
*/
|
*/
|
||||||
private Block redirectSlimeBlock() {
|
private Block redirectSlimeBlock() {
|
||||||
if (CarpetSettings.movableTileEntities && isStickyOnSide(blockState_1, this.direction.getOpposite()))
|
if (CarpetSettings.movableBlockEntities && isStickyOnSide(blockState_1, this.direction.getOpposite()))
|
||||||
return blockState_1.getBlock(); //this makes the comparison in the while condition "while(blockState_1.getBlock() == redirectSlimeBlock())" evaluate to true, so the block is treated as sticky
|
return blockState_1.getBlock(); //this makes the comparison in the while condition "while(blockState_1.getBlock() == redirectSlimeBlock())" evaluate to true, so the block is treated as sticky
|
||||||
else
|
else
|
||||||
return Blocks.SLIME_BLOCK; //vanilla behavior
|
return Blocks.SLIME_BLOCK; //vanilla behavior
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ public class ServerPlayNetworkHandler_tickMixin
|
|||||||
))
|
))
|
||||||
private void checkMove(PlayerMoveC2SPacket p, CallbackInfo ci)
|
private void checkMove(PlayerMoveC2SPacket p, CallbackInfo ci)
|
||||||
{
|
{
|
||||||
if (p.getX(player.x) - lastTickX > 0.0001D || p.getY(player.y) - lastTickY > 0.0001D || p.getY(player.y) - lastTickY > 0.0001D)
|
if (Math.abs(p.getX(player.x) - lastTickX) > 0.0001D
|
||||||
|
|| Math.abs(p.getY(player.y) - lastTickY) > 0.0001D
|
||||||
|
|| Math.abs(p.getY(player.y) - lastTickY) > 0.0001D)
|
||||||
{
|
{
|
||||||
TickSpeed.reset_player_active_timeout();
|
TickSpeed.reset_player_active_timeout();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
|
|||||||
private BlockEntity ifGetBlockEntity(WorldChunk worldChunk, BlockPos blockPos_1,
|
private BlockEntity ifGetBlockEntity(WorldChunk worldChunk, BlockPos blockPos_1,
|
||||||
WorldChunk.CreationType worldChunk$CreationType_1)
|
WorldChunk.CreationType worldChunk$CreationType_1)
|
||||||
{
|
{
|
||||||
if (!CarpetSettings.movableTileEntities)
|
if (!CarpetSettings.movableBlockEntities)
|
||||||
{
|
{
|
||||||
return this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK);
|
return this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public abstract class World_tickMixin implements WorldInterface
|
|||||||
|
|
||||||
@Inject(method = "tickBlockEntities", at = @At("HEAD"))
|
@Inject(method = "tickBlockEntities", at = @At("HEAD"))
|
||||||
private void startBlockEntities(CallbackInfo ci) {
|
private void startBlockEntities(CallbackInfo ci) {
|
||||||
currentSection = CarpetProfiler.start_section((World) (Object) this, "Tile Entities", CarpetProfiler.TYPE.GENERAL);
|
currentSection = CarpetProfiler.start_section((World) (Object) this, "Block Entities", CarpetProfiler.TYPE.GENERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "tickBlockEntities", at = @At("TAIL"))
|
@Inject(method = "tickBlockEntities", at = @At("TAIL"))
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ public class CarpetEventServer
|
|||||||
{
|
{
|
||||||
eventHandlers.get("player_clicks_block").call( () -> Arrays.asList(
|
eventHandlers.get("player_clicks_block").call( () -> Arrays.asList(
|
||||||
((c, t) -> new EntityValue(player)),
|
((c, t) -> new EntityValue(player)),
|
||||||
((c, t) -> new BlockValue(null, player.world, blockpos)),
|
((c, t) -> new BlockValue(null, player.getServerWorld(), blockpos)),
|
||||||
((c, t) -> new StringValue(facing.getName()))
|
((c, t) -> new StringValue(facing.getName()))
|
||||||
), player::getCommandSource);
|
), player::getCommandSource);
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ public class CarpetEventServer
|
|||||||
((c, t) -> new EntityValue(player)),
|
((c, t) -> new EntityValue(player)),
|
||||||
((c, t) -> ListValue.fromItemStack(itemstack)),
|
((c, t) -> ListValue.fromItemStack(itemstack)),
|
||||||
((c, t) -> new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand")),
|
((c, t) -> new StringValue(enumhand == Hand.MAIN_HAND ? "mainhand" : "offhand")),
|
||||||
((c, t) -> new BlockValue(null, player.world, blockpos)),
|
((c, t) -> new BlockValue(null, player.getServerWorld(), blockpos)),
|
||||||
((c, t) -> new StringValue(enumfacing.getName())),
|
((c, t) -> new StringValue(enumfacing.getName())),
|
||||||
((c, t) -> ListValue.of(
|
((c, t) -> ListValue.of(
|
||||||
new NumericValue(vec3d.x),
|
new NumericValue(vec3d.x),
|
||||||
@@ -330,11 +330,11 @@ public class CarpetEventServer
|
|||||||
}, player::getCommandSource);
|
}, player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockBroken(PlayerEntity player, BlockPos pos, BlockState previousBS)
|
public void onBlockBroken(ServerPlayerEntity player, BlockPos pos, BlockState previousBS)
|
||||||
{
|
{
|
||||||
eventHandlers.get("player_breaks_block").call( () -> Arrays.asList(
|
eventHandlers.get("player_breaks_block").call( () -> Arrays.asList(
|
||||||
((c, t) -> new EntityValue(player)),
|
((c, t) -> new EntityValue(player)),
|
||||||
((c, t) -> new BlockValue(previousBS, player.getEntityWorld(), pos))
|
((c, t) -> new BlockValue(previousBS, player.getServerWorld(), pos))
|
||||||
), player::getCommandSource);
|
), player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,22 +355,22 @@ public class CarpetEventServer
|
|||||||
), player::getCommandSource);
|
), player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStartSneaking(PlayerEntity player)
|
public void onStartSneaking(ServerPlayerEntity player)
|
||||||
{
|
{
|
||||||
eventHandlers.get("player_starts_sneaking").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
eventHandlers.get("player_starts_sneaking").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopSneaking(PlayerEntity player)
|
public void onStopSneaking(ServerPlayerEntity player)
|
||||||
{
|
{
|
||||||
eventHandlers.get("player_stops_sneaking").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
eventHandlers.get("player_stops_sneaking").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStartSprinting(PlayerEntity player)
|
public void onStartSprinting(ServerPlayerEntity player)
|
||||||
{
|
{
|
||||||
eventHandlers.get("player_starts_sprinting").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
eventHandlers.get("player_starts_sprinting").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopSprinting(PlayerEntity player)
|
public void onStopSprinting(ServerPlayerEntity player)
|
||||||
{
|
{
|
||||||
eventHandlers.get("player_stops_sprinting").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
eventHandlers.get("player_stops_sprinting").call( () -> Arrays.asList(((c, t) -> new EntityValue(player))), player::getCommandSource);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ import net.minecraft.sound.SoundCategory;
|
|||||||
import net.minecraft.state.StateFactory;
|
import net.minecraft.state.StateFactory;
|
||||||
import net.minecraft.state.property.Property;
|
import net.minecraft.state.property.Property;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.TranslatableText;
|
|
||||||
import net.minecraft.util.Clearable;
|
import net.minecraft.util.Clearable;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -75,6 +74,7 @@ import net.minecraft.world.LightType;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.biome.Biome;
|
import net.minecraft.world.biome.Biome;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraft.world.loot.context.LootContext;
|
import net.minecraft.world.loot.context.LootContext;
|
||||||
import net.minecraft.world.loot.context.LootContextParameters;
|
import net.minecraft.world.loot.context.LootContextParameters;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
@@ -798,7 +798,7 @@ public class CarpetExpression
|
|||||||
this.expr.addLazyFunction("set", -1, (c, t, lv) ->
|
this.expr.addLazyFunction("set", -1, (c, t, lv) ->
|
||||||
{
|
{
|
||||||
CarpetContext cc = (CarpetContext)c;
|
CarpetContext cc = (CarpetContext)c;
|
||||||
World world = cc.s.getWorld();
|
ServerWorld world = cc.s.getWorld();
|
||||||
if (lv.size() < 2 || lv.size() % 2 == 1)
|
if (lv.size() < 2 || lv.size() % 2 == 1)
|
||||||
throw new InternalExpressionException("set block should have at least 2 params and odd attributes");
|
throw new InternalExpressionException("set block should have at least 2 params and odd attributes");
|
||||||
BlockValue.LocatorResult targetLocator = BlockValue.fromParams(cc, lv, 0);
|
BlockValue.LocatorResult targetLocator = BlockValue.fromParams(cc, lv, 0);
|
||||||
@@ -1983,7 +1983,7 @@ public class CarpetExpression
|
|||||||
{
|
{
|
||||||
|
|
||||||
BlockPos center = BlockValue.fromParams((CarpetContext) c, lv,0).block.getPos();
|
BlockPos center = BlockValue.fromParams((CarpetContext) c, lv,0).block.getPos();
|
||||||
World world = ((CarpetContext) c).s.getWorld();
|
ServerWorld world = ((CarpetContext) c).s.getWorld();
|
||||||
|
|
||||||
List<Value> neighbours = new ArrayList<>();
|
List<Value> neighbours = new ArrayList<>();
|
||||||
neighbours.add(new BlockValue(null, world, center.up()));
|
neighbours.add(new BlockValue(null, world, center.up()));
|
||||||
@@ -2308,6 +2308,10 @@ public class CarpetExpression
|
|||||||
* </pre>
|
* </pre>
|
||||||
* <h3><code>current_dimension()</code></h3>
|
* <h3><code>current_dimension()</code></h3>
|
||||||
* <p>Returns current dimension that scripts run in.</p>
|
* <p>Returns current dimension that scripts run in.</p>
|
||||||
|
* <h3><code>in_dimension(smth, expr)</code></h3>
|
||||||
|
* <p>Evaluates the expression <code>expr</code> with different dimension execution context. <code>smth</code> can
|
||||||
|
* be an entity, world-localized block, so not <code>block('stone')</code>, or a string representing a dimension like:
|
||||||
|
* <code>'nether'</code>, <code>'end'</code> or <code>'overworld'</code>.</p>
|
||||||
* <h3><code>schedule(delay, function, args...)</code></h3>
|
* <h3><code>schedule(delay, function, args...)</code></h3>
|
||||||
* <p>Schedules a user defined function to run with a specified <code>delay</code> ticks of delay.
|
* <p>Schedules a user defined function to run with a specified <code>delay</code> ticks of delay.
|
||||||
* Scheduled functions run at the end of the tick, and they will run in order they were scheduled.</p>
|
* Scheduled functions run at the end of the tick, and they will run in order they were scheduled.</p>
|
||||||
@@ -2681,6 +2685,53 @@ public class CarpetExpression
|
|||||||
return (cc, tt) -> retval;
|
return (cc, tt) -> retval;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.expr.addLazyFunction("in_dimension", 2, (c, t, lv) -> {
|
||||||
|
ServerCommandSource outerSource = ((CarpetContext)c).s;
|
||||||
|
Value dimensionValue = lv.get(0).evalValue(c);
|
||||||
|
ServerCommandSource innerSource = outerSource;
|
||||||
|
if (dimensionValue instanceof EntityValue)
|
||||||
|
{
|
||||||
|
innerSource = outerSource.withWorld((ServerWorld) ((EntityValue)dimensionValue).getEntity().getEntityWorld());
|
||||||
|
}
|
||||||
|
else if (dimensionValue instanceof BlockValue)
|
||||||
|
{
|
||||||
|
BlockValue bv = (BlockValue)dimensionValue;
|
||||||
|
if (bv.getWorld() != null)
|
||||||
|
{
|
||||||
|
innerSource = outerSource.withWorld(bv.getWorld());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new InternalExpressionException("in_dimension accepts only world-localized block arguments");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String dimString = dimensionValue.getString().toLowerCase(Locale.ROOT);
|
||||||
|
switch (dimString)
|
||||||
|
{
|
||||||
|
case "nether":
|
||||||
|
case "the_nether":
|
||||||
|
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_NETHER));
|
||||||
|
break;
|
||||||
|
case "end":
|
||||||
|
case "the_end":
|
||||||
|
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.THE_END));
|
||||||
|
break;
|
||||||
|
case "overworld":
|
||||||
|
case "over_world":
|
||||||
|
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(DimensionType.OVERWORLD));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
((CarpetContext) c).s = innerSource;
|
||||||
|
Value retval = lv.get(1).evalValue(c);
|
||||||
|
((CarpetContext) c).s = outerSource;
|
||||||
|
return (cc, tt) -> retval;
|
||||||
|
});
|
||||||
|
|
||||||
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
this.expr.addLazyFunction("plop", 4, (c, t, lv) ->{
|
||||||
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
BlockValue.LocatorResult locator = BlockValue.fromParams((CarpetContext)c, lv, 0);
|
||||||
if (lv.size() <= locator.offset)
|
if (lv.size() <= locator.offset)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.minecraft.block.Blocks;
|
|||||||
import net.minecraft.item.ItemPlacementContext;
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@@ -32,7 +33,7 @@ public class BlockValue extends Value
|
|||||||
public static final BlockValue NULL = new BlockValue(null, null, null);
|
public static final BlockValue NULL = new BlockValue(null, null, null);
|
||||||
private BlockState blockState;
|
private BlockState blockState;
|
||||||
private BlockPos pos;
|
private BlockPos pos;
|
||||||
private World world;
|
private ServerWorld world;
|
||||||
private CompoundTag data;
|
private CompoundTag data;
|
||||||
|
|
||||||
public static BlockValue fromCoords(CarpetContext c, int x, int y, int z)
|
public static BlockValue fromCoords(CarpetContext c, int x, int y, int z)
|
||||||
@@ -212,7 +213,7 @@ public class BlockValue extends Value
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public BlockValue(BlockState state, World world, BlockPos position)
|
public BlockValue(BlockState state, ServerWorld world, BlockPos position)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
blockState = state;
|
blockState = state;
|
||||||
@@ -220,7 +221,7 @@ public class BlockValue extends Value
|
|||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockValue(BlockState state, World world, BlockPos position, CompoundTag nbt)
|
public BlockValue(BlockState state, ServerWorld world, BlockPos position, CompoundTag nbt)
|
||||||
{
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
blockState = state;
|
blockState = state;
|
||||||
@@ -258,6 +259,8 @@ public class BlockValue extends Value
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServerWorld getWorld() { return world;}
|
||||||
|
|
||||||
|
|
||||||
public static class LocatorResult
|
public static class LocatorResult
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,12 +7,10 @@ import carpet.helpers.Tracer;
|
|||||||
import carpet.script.CarpetContext;
|
import carpet.script.CarpetContext;
|
||||||
import carpet.script.Fluff;
|
import carpet.script.Fluff;
|
||||||
import carpet.script.exception.InternalExpressionException;
|
import carpet.script.exception.InternalExpressionException;
|
||||||
import carpet.settings.CarpetSettings;
|
|
||||||
import com.mojang.brigadier.StringReader;
|
import com.mojang.brigadier.StringReader;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
||||||
import net.minecraft.client.network.packet.EntityPositionS2CPacket;
|
import net.minecraft.client.network.packet.EntityPositionS2CPacket;
|
||||||
import net.minecraft.client.network.packet.EntityVelocityUpdateS2CPacket;
|
|
||||||
import net.minecraft.command.EntitySelector;
|
import net.minecraft.command.EntitySelector;
|
||||||
import net.minecraft.command.EntitySelectorReader;
|
import net.minecraft.command.EntitySelectorReader;
|
||||||
import net.minecraft.command.arguments.NbtPathArgumentType;
|
import net.minecraft.command.arguments.NbtPathArgumentType;
|
||||||
@@ -234,7 +232,7 @@ public class EntityValue extends Value
|
|||||||
put("home", (e, a) -> {
|
put("home", (e, a) -> {
|
||||||
if (e instanceof MobEntity)
|
if (e instanceof MobEntity)
|
||||||
{
|
{
|
||||||
return (((MobEntity) e).getWalkTargetRange () > 0)?new BlockValue(null, e.getEntityWorld(), ((MobEntityWithAi) e).getWalkTarget()):Value.FALSE;
|
return (((MobEntity) e).getWalkTargetRange () > 0)?new BlockValue(null, (ServerWorld) e.getEntityWorld(), ((MobEntityWithAi) e).getWalkTarget()):Value.FALSE;
|
||||||
}
|
}
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
});
|
});
|
||||||
@@ -379,7 +377,7 @@ public class EntityValue extends Value
|
|||||||
switch (hitres.getType())
|
switch (hitres.getType())
|
||||||
{
|
{
|
||||||
case MISS: return Value.NULL;
|
case MISS: return Value.NULL;
|
||||||
case BLOCK: return new BlockValue(null, e.getEntityWorld(), ((BlockHitResult)hitres).getBlockPos() );
|
case BLOCK: return new BlockValue(null, (ServerWorld) e.getEntityWorld(), ((BlockHitResult)hitres).getBlockPos() );
|
||||||
case ENTITY: return new EntityValue(((EntityHitResult)hitres).getEntity());
|
case ENTITY: return new EntityValue(((EntityHitResult)hitres).getEntity());
|
||||||
}
|
}
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
|
|||||||
@@ -147,8 +147,8 @@ public class CarpetSettings
|
|||||||
@Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE )
|
@Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE )
|
||||||
public static boolean renewableSponges = false;
|
public static boolean renewableSponges = false;
|
||||||
|
|
||||||
@Rule( desc = "Pistons can push tile entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
|
@Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
|
||||||
public static boolean movableTileEntities = false;
|
public static boolean movableBlockEntities = false;
|
||||||
|
|
||||||
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
|
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
|
||||||
public static boolean desertShrubs = false;
|
public static boolean desertShrubs = false;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|||||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.ServerTask;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.BaseText;
|
import net.minecraft.text.BaseText;
|
||||||
@@ -168,10 +169,13 @@ public class SettingsManager
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
server.method_18858(new ServerTask(this.server.getTicks(), () ->
|
||||||
|
{
|
||||||
for (ServerPlayerEntity entityplayermp : server.getPlayerManager().getPlayerList())
|
for (ServerPlayerEntity entityplayermp : server.getPlayerManager().getPlayerList())
|
||||||
{
|
{
|
||||||
server.getCommandManager().sendCommandTree(entityplayermp);
|
server.getCommandManager().sendCommandTree(entityplayermp);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfigurationFromConf()
|
private void loadConfigurationFromConf()
|
||||||
@@ -434,6 +438,11 @@ public class SettingsManager
|
|||||||
args.add(makeSetRuleButton(rule, option, true));
|
args.add(makeSetRuleButton(rule, option, true));
|
||||||
args.add("w ");
|
args.add("w ");
|
||||||
}
|
}
|
||||||
|
if (!rule.options.contains(rule.getAsString()))
|
||||||
|
{
|
||||||
|
args.add(makeSetRuleButton(rule, rule.getAsString(), true));
|
||||||
|
args.add("w ");
|
||||||
|
}
|
||||||
args.remove(args.size()-1);
|
args.remove(args.size()-1);
|
||||||
return Messenger.c(args.toArray(new Object[0]));
|
return Messenger.c(args.toArray(new Object[0]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ public class CarpetProfiler
|
|||||||
private static String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
private static String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
||||||
private static String[] SECTIONS = {
|
private static String[] SECTIONS = {
|
||||||
"Spawning and Random Ticks", "Ticket Manager","Unloading",
|
"Spawning and Random Ticks", "Ticket Manager","Unloading",
|
||||||
"Blocks", "Entities", "Tile Entities",
|
"Blocks", "Entities", "Block Entities",
|
||||||
"Entities (Client)", "Tile Entities (Client)",
|
"Entities (Client)", "Block Entities (Client)",
|
||||||
"Village", "Environment"};
|
"Village", "Environment"};
|
||||||
|
|
||||||
public enum TYPE
|
public enum TYPE
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import net.minecraft.server.world.ServerWorld;
|
|||||||
import net.minecraft.util.DyeColor;
|
import net.minecraft.util.DyeColor;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.world.Heightmap;
|
import net.minecraft.world.Heightmap;
|
||||||
import net.minecraft.world.SpawnHelper;
|
import net.minecraft.world.SpawnHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@@ -109,7 +108,7 @@ public class SpawnReporter
|
|||||||
int rounds = spawn_tries.get(enumcreaturetype);
|
int rounds = spawn_tries.get(enumcreaturetype);
|
||||||
lst.add(Messenger.c(String.format("w %s: ", enumcreaturetype.getName()),
|
lst.add(Messenger.c(String.format("w %s: ", enumcreaturetype.getName()),
|
||||||
(cur < 0) ? "g -" : (color + " " + cur), "g / ", mobColor + " " + max,
|
(cur < 0) ? "g -" : (color + " " + cur), "g / ", mobColor + " " + max,
|
||||||
(rounds == 1) ? "w " : String.format("fi (%d rounds/tick)", spawn_tries.get(enumcreaturetype))
|
(rounds == 1) ? "w " : String.format("gi (%d rounds/tick)", spawn_tries.get(enumcreaturetype))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -152,7 +151,7 @@ public class SpawnReporter
|
|||||||
lst.add( Messenger.c(
|
lst.add( Messenger.c(
|
||||||
"w - ",
|
"w - ",
|
||||||
Messenger.tp("wb",pair.getRight()),
|
Messenger.tp("wb",pair.getRight()),
|
||||||
String.format("w : %s", EntityType.getId(pair.getLeft()).toString().replaceFirst("minecraft.",""))
|
String.format("w : %s", pair.getLeft().getName().getString())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +265,7 @@ public class SpawnReporter
|
|||||||
lst.add( Messenger.c(
|
lst.add( Messenger.c(
|
||||||
"w - ",
|
"w - ",
|
||||||
Messenger.tp("wb",pos),
|
Messenger.tp("wb",pos),
|
||||||
String.format("w : %s", EntityType.getId(type).toString().replaceFirst("minecraft.",""))
|
String.format("w : %s", type.getName().getString())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,7 +358,7 @@ public class SpawnReporter
|
|||||||
for (EntityType type: spawn_stats.get(code).keySet())
|
for (EntityType type: spawn_stats.get(code).keySet())
|
||||||
{
|
{
|
||||||
report.add(Messenger.s(String.format(" - %s: %d spawns, %d per hour",
|
report.add(Messenger.s(String.format(" - %s: %d spawns, %d per hour",
|
||||||
Registry.ENTITY_TYPE.getId(type).toString().replaceFirst("minecraft:",""),
|
type.getName().getString(),
|
||||||
spawn_stats.get(code).getLong(type),
|
spawn_stats.get(code).getLong(type),
|
||||||
(72000 * spawn_stats.get(code).getLong(type)/duration ))));
|
(72000 * spawn_stats.get(code).getLong(type)/duration ))));
|
||||||
}
|
}
|
||||||
@@ -476,7 +475,7 @@ public class SpawnReporter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String creature_name = Registry.ENTITY_TYPE.getId(mob.getType()).toString().replaceFirst("minecraft:","");
|
String creature_name = mob.getType().getName().getString();
|
||||||
String pack_size = String.format("%d", mob.getLimitPerChunk());//String.format("%d-%d", animal.minGroupCount, animal.maxGroupCount);
|
String pack_size = String.format("%d", mob.getLimitPerChunk());//String.format("%d-%d", animal.minGroupCount, animal.maxGroupCount);
|
||||||
int weight = ((WeightedPickerEntryMixin) spawnEntry).getWeight();
|
int weight = ((WeightedPickerEntryMixin) spawnEntry).getWeight();
|
||||||
if (canspawn)
|
if (canspawn)
|
||||||
|
|||||||
@@ -140,7 +140,8 @@
|
|||||||
"ClientPlayerInteractionManager_ghostBlocksMixin",
|
"ClientPlayerInteractionManager_ghostBlocksMixin",
|
||||||
|
|
||||||
"BlockEntityRenderDispatcher_movableTEMixin",
|
"BlockEntityRenderDispatcher_movableTEMixin",
|
||||||
"PistonBlockEntityRenderer_movableTEMixin"
|
"PistonBlockEntityRenderer_movableTEMixin",
|
||||||
|
"MinecraftClient_pausedShakeMixin"
|
||||||
],
|
],
|
||||||
"server": [
|
"server": [
|
||||||
"MinecraftDedicatedServerMixin"
|
"MinecraftDedicatedServerMixin"
|
||||||
|
|||||||
Reference in new issue
Block a user