This commit is contained in:
gnembon committed 2025-01-09 13:41:19 +01:00
1 parent d9c7334400
commit b16eec89e7
34 files changed
+299 -347

No files matched your search

@@ -3,10 +3,10 @@ package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.Registries;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import net.minecraft.world.item.enchantment.Enchantments;
import net.minecraft.world.level.Level;
@@ -14,12 +14,8 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BuddingAmethystBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.PushReaction;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(BuddingAmethystBlock.class)
public class BuddingAmethystBlock_movableAmethystMixin extends Block {
@@ -33,7 +29,7 @@ public class BuddingAmethystBlock_movableAmethystMixin extends Block {
// doing it here rather than though loottables since loottables are loaded on reload
// drawback - not controlled via loottables, but hey
if (CarpetSettings.movableAmethyst &&
stack.getItem() instanceof PickaxeItem &&
stack.is(ItemTags.PICKAXES) &&
EnchantmentHelper.getItemEnchantmentLevel(world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT).getOrThrow(Enchantments.SILK_TOUCH), stack) > 0
)
popResource(world, pos, Items.BUDDING_AMETHYST.getDefaultInstance());
@@ -3,6 +3,7 @@ package carpet.mixins;
import carpet.utils.SpawnOverrides;
import it.unimi.dsi.fastutil.longs.LongSet;
import net.minecraft.core.Holder;
import net.minecraft.util.random.WeightedList;
import net.minecraft.world.level.StructureManager;
import net.minecraft.world.level.levelgen.structure.Structure;
import org.spongepowered.asm.mixin.Mixin;
@@ -11,7 +12,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.core.BlockPos;
import net.minecraft.util.random.WeightedRandomList;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.MobSpawnSettings;
@@ -31,10 +31,10 @@ public abstract class ChunkGenerator_customMobSpawnsMixin
target = "Ljava/util/Map$Entry;getKey()Ljava/lang/Object;"
), cancellable = true)
private void checkCMSpawns(Holder<Biome> holder, StructureManager structureFeatureManager, MobCategory mobCategory, BlockPos blockPos,
CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir,
CallbackInfoReturnable<WeightedList<MobSpawnSettings.SpawnerData>> cir,
Map<Structure, LongSet> map, Iterator<?> var6, Map.Entry<Structure, LongSet> entry)
{
WeightedRandomList<MobSpawnSettings.SpawnerData> res = SpawnOverrides.test(structureFeatureManager, entry.getValue(), mobCategory, entry.getKey(), blockPos);
WeightedList<MobSpawnSettings.SpawnerData> res = SpawnOverrides.test(structureFeatureManager, entry.getValue(), mobCategory, entry.getKey(), blockPos);
if (res != null)
{
cir.setReturnValue(res);
@@ -46,7 +46,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import carpet.fakes.ChunkHolderInterface;
import carpet.fakes.ChunkTicketManagerInterface;
import carpet.fakes.ServerLightingProviderInterface;
import carpet.fakes.ThreadedAnvilChunkStorageInterface;
import carpet.script.utils.WorldTools;
@@ -165,7 +164,6 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
this.world.getServer().execute(() -> CHUNK_LOADED.onChunkEvent(this.world, chpos, generated));
}
}
*/
@Unique
private void addTicket(ChunkPos pos, ChunkStatus status)
@@ -180,7 +178,6 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
}
/*
@Unique
private void addRelightTicket(ChunkPos pos)
{
@@ -195,7 +192,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
() -> "release relight ticket " + pos
));
}
*/
@Unique
private void tickTicketManager()
{
@@ -220,7 +217,7 @@ public abstract class ChunkMap_scarpetChunkCreationMixin implements ThreadedAnvi
}
/*
@Unique
private Set<ChunkPos> loadExistingChunksFromDisk(Set<ChunkPos> requestedChunks)
{
@@ -14,10 +14,10 @@ public abstract class CloneCommands_fillUpdatesMixin
{
@Redirect(method = "clone", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
target = "Lnet/minecraft/server/level/ServerLevel;updateNeighborsAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
))
private static void conditionalUpdating(ServerLevel serverWorld, BlockPos blockPos_1, Block block_1)
{
if (CarpetSettings.fillUpdates) serverWorld.blockUpdated(blockPos_1, block_1);
if (CarpetSettings.fillUpdates) serverWorld.updateNeighborsAt(blockPos_1, block_1);
}
}
@@ -1,25 +0,0 @@
package carpet.mixins;
import java.util.Set;
import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.DistanceManager;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import carpet.fakes.ChunkTicketManagerInterface;
@Mixin(DistanceManager.class)
public abstract class DistanceManager_scarpetChunkCreationMixin implements ChunkTicketManagerInterface
{
@Shadow
@Final
private Set<ChunkHolder> chunksToUpdateFutures;
@Override
public void replaceHolder(final ChunkHolder oldHolder, final ChunkHolder newHolder)
{
this.chunksToUpdateFutures.remove(oldHolder);
this.chunksToUpdateFutures.add(newHolder);
}
}
@@ -1,23 +1,25 @@
package carpet.mixins;
import carpet.fakes.ChunkTicketManagerInterface;
import carpet.fakes.TicketsFetcherInterface;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.server.level.DistanceManager;
import net.minecraft.server.level.Ticket;
import net.minecraft.util.SortedArraySet;
import net.minecraft.world.level.TicketStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.List;
@Mixin(DistanceManager.class)
public abstract class DistanceManager_scarpetMixin implements ChunkTicketManagerInterface
public abstract class DistanceManager_scarpetMixin implements TicketsFetcherInterface
{
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> tickets;
@Shadow @Final private TicketStorage ticketStorage;
@Override
public Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> getTicketsByPosition()
public Long2ObjectOpenHashMap<List<Ticket>> getTicketsByPosition()
{
return tickets;
return ((TicketsFetcherInterface)ticketStorage).getTicketsByPosition();
}
}
@@ -1,55 +0,0 @@
package carpet.mixins;
import carpet.fakes.ChunkTicketManagerInterface;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.server.level.DistanceManager;
import net.minecraft.server.level.Ticket;
import net.minecraft.server.level.TicketType;
import net.minecraft.util.SortedArraySet;
import net.minecraft.util.Unit;
import net.minecraft.world.level.ChunkPos;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Iterator;
@Mixin(DistanceManager.class)
public abstract class DistanceManager_spawnChunksMixin implements ChunkTicketManagerInterface
{
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> tickets;
@Shadow protected abstract void removeTicket(long pos, Ticket<?> ticket);
@Shadow public abstract <T> void addRegionTicket(TicketType<T> type, ChunkPos pos, int radius, T argument);
@Override
public void changeSpawnChunks(ChunkPos chunkPos, int distance)
{
long pos = chunkPos.toLong();
SortedArraySet<Ticket<?>> set = tickets.get(pos);
Ticket<?> existingTicket = null;
if (set != null)
{
Iterator<Ticket<?>> iter = set.iterator();
while(iter.hasNext())
{
Ticket<?> ticket = iter.next();
if (ticket.getType() == TicketType.START)
{
existingTicket = ticket;
iter.remove();
}
}
set.add(existingTicket);
}
// the reason we are removing the ticket this way is that there are sideeffects of removal
if (existingTicket != null)
{
removeTicket(pos, existingTicket);
}
// set optionally new spawn ticket
if (distance > 0)
addRegionTicket(TicketType.START, chunkPos, distance, Unit.INSTANCE);
}
}
+1 -1
View File
@@ -32,7 +32,7 @@ public abstract class EntityMixin implements EntityInterface
return partialTicks == 1.0F ? this.yRot : Mth.lerp(partialTicks, this.yRotO, this.yRot);
}
@Inject(method = "isControlledByLocalInstance", at = @At("HEAD"), cancellable = true)
@Inject(method = "isLocalInstanceAuthoritative", at = @At("HEAD"), cancellable = true)
private void isFakePlayer(CallbackInfoReturnable<Boolean> cir)
{
if (getControllingPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!level.isClientSide);
@@ -14,10 +14,10 @@ public abstract class FillCommandMixin
{
@Redirect(method = "fillBlocks", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
target = "Lnet/minecraft/server/level/ServerLevel;updateNeighborsAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
))
private static void conditionalUpdating(ServerLevel serverWorld, BlockPos blockPos_1, Block block_1)
{
if (CarpetSettings.fillUpdates) serverWorld.blockUpdated(blockPos_1, block_1);
if (CarpetSettings.fillUpdates) serverWorld.updateNeighborsAt(blockPos_1, block_1);
}
}
@@ -0,0 +1,30 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.core.component.DataComponents;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.Tool;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Item.class)
public class Item_missingToolsMixin
{
@Inject(method = "getDestroySpeed", at = @At("HEAD"), cancellable = true)
public void getDestroySpeed(ItemStack itemStack, BlockState blockState, CallbackInfoReturnable<Float> cir) {
if (CarpetSettings.missingTools && blockState.getSoundType() == SoundType.GLASS && itemStack.is(ItemTags.PICKAXES))
{
Tool tool = itemStack.get(DataComponents.TOOL);
if (tool != null) {
cir.setReturnValue(tool.getMiningSpeed(Blocks.STONE.defaultBlockState()));
}
}
}
}
@@ -2,7 +2,9 @@ package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import org.spongepowered.asm.mixin.Mixin;
@@ -25,20 +27,25 @@ public class LevelChunk_fillUpdatesMixin
@Redirect(method = "setBlockState", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;onRemove(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Z)V"
target = "Lnet/minecraft/world/level/block/entity/BlockEntity;preRemoveSideEffects(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Z)V"
))
private void onRemovedBlock(BlockState blockState, Level world, BlockPos pos, BlockState state, boolean moved)
private void onPreRemoveSideEffects(BlockEntity blockEntity, BlockPos blockPos_1, BlockState blockState_1, boolean boolean_1)
{
if (CarpetSettings.impendingFillSkipUpdates.get()) // doing due dilligence from AbstractBlock onStateReplaced
if (!CarpetSettings.impendingFillSkipUpdates.get())
{
if (blockState.hasBlockEntity() && !blockState.is(state.getBlock()))
{
world.removeBlockEntity(pos);
}
blockEntity.preRemoveSideEffects(blockPos_1, blockState_1, boolean_1);
}
else
}
@Redirect(method = "setBlockState", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/block/state/BlockState;affectNeighborsAfterRemoval(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Z)V"
))
private void onAffectNeighborsAfterRemoval(final BlockState instance, final ServerLevel serverLevel, final BlockPos blockPos, final boolean b)
{
if (!CarpetSettings.impendingFillSkipUpdates.get())
{
blockState.onRemove(world, pos, state, moved);
instance.affectNeighborsAfterRemoval(serverLevel, blockPos, b);
}
}
}
@@ -4,6 +4,10 @@ import carpet.CarpetSettings;
import carpet.fakes.WorldChunkInterface;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.core.SectionPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.Profiler;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelHeightAccessor;
@@ -19,6 +23,7 @@ import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.UpgradeData;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.blending.BlendingData;
import net.minecraft.world.level.lighting.LightEngine;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -74,90 +79,119 @@ public abstract class LevelChunk_movableBEMixin extends ChunkAccess implements W
// todo update me to the new version
@Override
public BlockState setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState newBlockState, BlockEntity newBlockEntity,
boolean boolean_1)
int flags)
{
int x = blockPos_1.getX() & 15;
boolean boolean_1 = (flags & 64) != 0;
int y = blockPos_1.getY();
int z = blockPos_1.getZ() & 15;
LevelChunkSection chunkSection = this.getSection(this.getSectionIndex(y));
if (chunkSection.hasOnlyAir())
boolean hadOnlyAir = chunkSection.hasOnlyAir();
if (hadOnlyAir && newBlockState.isAir())
{
if (newBlockState.isAir())
{
return null;
}
return null;
}
boolean boolean_2 = chunkSection.hasOnlyAir();
BlockState oldBlockState = chunkSection.setBlockState(x, y & 15, z, newBlockState);
int x = blockPos_1.getX() & 15;
int chunkY = blockPos_1.getY() & 15;
int z = blockPos_1.getZ() & 15;
BlockState oldBlockState = chunkSection.setBlockState(x, chunkY, z, newBlockState);
if (oldBlockState == newBlockState)
{
return null;
}
else
Block newBlock = newBlockState.getBlock();
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(x, y, z, newBlockState);
this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(x, y, z, newBlockState);
this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(x, y, z, newBlockState);
this.heightmaps.get(Heightmap.Types.WORLD_SURFACE).update(x, y, z, newBlockState);
boolean hasOnlyAir = chunkSection.hasOnlyAir();
if (hadOnlyAir != hasOnlyAir)
{
Block newBlock = newBlockState.getBlock();
Block oldBlock = oldBlockState.getBlock();
((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING)).update(x, y, z, newBlockState);
((Heightmap) this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES)).update(x, y, z, newBlockState);
((Heightmap) this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR)).update(x, y, z, newBlockState);
((Heightmap) this.heightmaps.get(Heightmap.Types.WORLD_SURFACE)).update(x, y, z, newBlockState);
boolean boolean_3 = chunkSection.hasOnlyAir();
if (boolean_2 != boolean_3)
{
this.level.getChunkSource().getLightEngine().updateSectionStatus(blockPos_1, boolean_3);
this.level.getChunkSource().getLightEngine().updateSectionStatus(blockPos_1, hasOnlyAir);
this.level.getChunkSource().onSectionEmptinessChanged(chunkPos.x, SectionPos.blockToSectionCoord(y), chunkPos.z, hasOnlyAir);
}
if (LightEngine.hasDifferentLightProperties(oldBlockState, newBlockState)) {
ProfilerFiller profiler = Profiler.get();
profiler.push("updateSkyLightSources");
skyLightSources.update(this, x, chunkY, z);
profiler.popPush("queueCheckLight");
level.getChunkSource().getLightEngine().checkBlock(blockPos_1);
profiler.pop();
}
boolean hadBlockEntity = oldBlockState.hasBlockEntity();
boolean blockChanged = !oldBlockState.is(newBlock);
boolean sideEffects = (flags & Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS) == 0;
if (blockChanged) {
if (level instanceof ServerLevel serverLevel && !(oldBlockState.getBlock() instanceof MovingPistonBlock)) {
if (hadBlockEntity && sideEffects) {
final BlockEntity blockEntity = level.getBlockEntity(blockPos_1);
if (blockEntity != null) {
blockEntity.preRemoveSideEffects(blockPos_1, oldBlockState, boolean_1);
}
}
if (hadBlockEntity) {
removeBlockEntity(blockPos_1);
}
if ((flags & Block.UPDATE_NEIGHBORS) != 0) { // scary change // so many other places that used to call this regardless if the UPDATE_NEIGHBORS flag was set
oldBlockState.affectNeighborsAfterRemoval(serverLevel, blockPos_1, boolean_1);
}
} else if (hadBlockEntity) {
removeBlockEntity(blockPos_1);
}
if (!this.level.isClientSide)
}
if (chunkSection.getBlockState(x, chunkY, z).getBlock() != newBlock)
{
return null;
}
if (!level.isClientSide && sideEffects) {
// this updates stuff, schedule ticks - do we want that since its only be called from MovingPistonBlock really?
newBlockState.onPlace(level, blockPos_1, oldBlockState, boolean_1);
}
BlockEntity oldBlockEntity = null;
if (oldBlockState.hasBlockEntity())
{
oldBlockEntity = this.getBlockEntity(blockPos_1, LevelChunk.EntityCreationType.CHECK);
if (oldBlockEntity != null && !oldBlockEntity.isValidBlockState(oldBlockState))
{
if (!(oldBlock instanceof MovingPistonBlock))//this is a movableTE special case, if condition wasn't there it would remove the blockentity that was carried for some reason
oldBlockState.onRemove(this.level, blockPos_1, newBlockState, boolean_1);//this kills it
}
else if (oldBlock != newBlock && oldBlock instanceof EntityBlock)
{
this.level.removeBlockEntity(blockPos_1);
}
if (chunkSection.getBlockState(x, y & 15, z).getBlock() != newBlock)
{
return null;
oldBlockEntity.setBlockState(oldBlockState);
updateBlockEntityTicker(oldBlockEntity);
}
else
{
BlockEntity oldBlockEntity = null;
if (oldBlockState.hasBlockEntity())
if (newBlockEntity == null)
{
oldBlockEntity = this.getBlockEntity(blockPos_1, LevelChunk.EntityCreationType.CHECK);
if (oldBlockEntity != null)
newBlockEntity = ((EntityBlock) newBlock).newBlockEntity(blockPos_1, newBlockState);
if (newBlockEntity != null)
{
oldBlockEntity.setBlockState(oldBlockState);
updateBlockEntityTicker(oldBlockEntity);
addAndRegisterBlockEntity(newBlockEntity);
}
}
if (oldBlockState.hasBlockEntity())
if (newBlockEntity != oldBlockEntity && newBlockEntity != null)
{
if (newBlockEntity == null)
{
newBlockEntity = ((EntityBlock) newBlock).newBlockEntity(blockPos_1, newBlockState);
}
if (newBlockEntity != oldBlockEntity && newBlockEntity != null)
{
newBlockEntity.clearRemoved();
this.level.setBlockEntity(newBlockEntity);
newBlockEntity.setBlockState(newBlockState);
updateBlockEntityTicker(newBlockEntity);
}
newBlockEntity.clearRemoved();
this.level.setBlockEntity(newBlockEntity);
newBlockEntity.setBlockState(newBlockState);
updateBlockEntityTicker(newBlockEntity);
}
if (!this.level.isClientSide)
{
newBlockState.onPlace(this.level, blockPos_1, oldBlockState, boolean_1); //This can call setblockstate! (e.g. hopper does)
}
markUnsaved();
return oldBlockState;
}
}
markUnsaved();
return oldBlockState;
}
}
@@ -23,11 +23,11 @@ public abstract class Level_fillUpdatesMixin
@Redirect(method = "setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;II)Z", at = @At( //setBlockState main
value = "INVOKE",
target = "Lnet/minecraft/world/level/Level;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
target = "Lnet/minecraft/world/level/Level;updateNeighborsAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
))
private void updateNeighborsMaybe(Level world, BlockPos blockPos, Block block)
{
if (!CarpetSettings.impendingFillSkipUpdates.get()) world.blockUpdated(blockPos, block);
if (!CarpetSettings.impendingFillSkipUpdates.get()) world.updateNeighborsAt(blockPos, block);
}
}
@@ -33,17 +33,13 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces
@Shadow
public abstract void sendBlockUpdated(BlockPos var1, BlockState var2, BlockState var3, int var4);
@Shadow
public abstract void updateNeighborsAt(BlockPos blockPos_1, Block block_1);
@Shadow
public abstract void onBlockStateChange(BlockPos blockPos_1, BlockState blockState_1, BlockState blockState_2);
@Shadow public abstract void updateNeighbourForOutputSignal(BlockPos pos, Block block);
@Shadow public abstract boolean isDebug();
@Shadow public abstract void updatePOIOnBlockStateChange(final BlockPos blockPos, final BlockState blockState, final BlockState blockState2);
/**
* @author 2No2Name
*/
@@ -57,7 +53,7 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces
BlockState blockState_2;
if (newBlockEntity != null && block_1 instanceof EntityBlock)
{
blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, (int_1 & 64) != 0);
blockState_2 = ((WorldChunkInterface) worldChunk_1).setBlockStateWithBlockEntity(blockPos_1, blockState_1, newBlockEntity, int_1);
if (newBlockEntity instanceof LidBlockEntity)
{
scheduleTick(blockPos_1, block_1, 5);
@@ -65,56 +61,46 @@ public abstract class Level_movableBEMixin implements LevelInterface, LevelAcces
}
else
{
blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, (int_1 & 64) != 0);
blockState_2 = worldChunk_1.setBlockState(blockPos_1, blockState_1, int_1);
}
if (blockState_2 == null)
{
return false;
}
else
BlockState blockState_3 = this.getBlockState(blockPos_1);
if (blockState_3 == blockState_1)
{
BlockState blockState_3 = this.getBlockState(blockPos_1);
if (blockState_3 != blockState_2 && (blockState_3.getLightBlock() != blockState_2.getLightBlock() || blockState_3.getLightEmission() != blockState_2.getLightEmission() || blockState_3.useShapeForLightOcclusion() || blockState_2.useShapeForLightOcclusion()))
if (blockState_2 != blockState_3)
{
ProfilerFiller profiler = Profiler.get();
profiler.push("queueCheckLight");
this.getChunkSource().getLightEngine().checkBlock(blockPos_1);
profiler.pop();
this.setBlocksDirty(blockPos_1, blockState_2, blockState_3);
}
if (blockState_3 == blockState_1)
if ((int_1 & 2) != 0 && (!this.isClientSide || (int_1 & 4) == 0) && (this.isClientSide || worldChunk_1.getFullStatus() != null && worldChunk_1.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))
{
if (blockState_2 != blockState_3)
{
this.setBlocksDirty(blockPos_1, blockState_2, blockState_3);
}
if ((int_1 & 2) != 0 && (!this.isClientSide || (int_1 & 4) == 0) && (this.isClientSide || worldChunk_1.getFullStatus() != null && worldChunk_1.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))
{
this.sendBlockUpdated(blockPos_1, blockState_2, blockState_1, int_1);
}
if (!this.isClientSide && (int_1 & 1) != 0)
{
this.updateNeighborsAt(blockPos_1, blockState_2.getBlock());
if (blockState_1.hasAnalogOutputSignal())
{
updateNeighbourForOutputSignal(blockPos_1, block_1);
}
}
if ((int_1 & 16) == 0)
{
int int_2 = int_1 & -34;
blockState_2.updateIndirectNeighbourShapes(this, blockPos_1, int_2); // prepare
blockState_1.updateNeighbourShapes(this, blockPos_1, int_2); // updateNeighbours
blockState_1.updateIndirectNeighbourShapes(this, blockPos_1, int_2); // prepare
}
this.onBlockStateChange(blockPos_1, blockState_2, blockState_3);
this.sendBlockUpdated(blockPos_1, blockState_2, blockState_1, int_1);
}
return true;
if (!this.isClientSide && (int_1 & 1) != 0)
{
this.updateNeighborsAt(blockPos_1, blockState_2.getBlock());
if (blockState_1.hasAnalogOutputSignal())
{
updateNeighbourForOutputSignal(blockPos_1, block_1);
}
}
if ((int_1 & 16) == 0)
{
int int_2 = int_1 & -34;
blockState_2.updateIndirectNeighbourShapes(this, blockPos_1, int_2); // prepare
blockState_1.updateNeighbourShapes(this, blockPos_1, int_2); // updateNeighbours
blockState_1.updateIndirectNeighbourShapes(this, blockPos_1, int_2); // prepare
}
updatePOIOnBlockStateChange(blockPos_1, blockState_2, blockState_3);
}
return true;
}
}
@@ -1,36 +0,0 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.core.component.DataComponents;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.PickaxeItem;
import net.minecraft.world.item.ToolMaterial;
import net.minecraft.world.item.component.Tool;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(PickaxeItem.class)
public class PickaxeItem_missingToolsMixin extends DiggerItem
{
protected PickaxeItem_missingToolsMixin(final ToolMaterial toolMaterial, final TagKey<Block> tagKey, final float f, final float g, final Properties properties)
{
super(toolMaterial, tagKey, f, g, properties);
}
@Override
public float getDestroySpeed(ItemStack stack, BlockState state) {
if (CarpetSettings.missingTools && state.getSoundType() == SoundType.GLASS)
{
final Tool tool = stack.get(DataComponents.TOOL);
return tool != null ? tool.getMiningSpeed(Blocks.STONE.defaultBlockState()) : super.getDestroySpeed(stack, state);
}
return super.getDestroySpeed(stack, state);
}
}
@@ -119,7 +119,7 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
fastUpdate(world_1, blockPos_1, blockState_1, o, sup);
}
@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;Z)V"))
@Redirect(method = "affectNeighborsAfterRemoval", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;Z)V"))
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o, boolean sup) {
fastUpdate(world_1, blockPos_1, blockState_1, o, sup);
}
@@ -14,10 +14,10 @@ public class SetBlockCommand_fillUpdatesMixin
{
@Redirect(method = "setBlock", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
target = "Lnet/minecraft/server/level/ServerLevel;updateNeighborsAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
))
private static void conditionalUpdating(ServerLevel serverWorld, BlockPos blockPos_1, Block block_1)
{
if (CarpetSettings.fillUpdates) serverWorld.blockUpdated(blockPos_1, block_1);
if (CarpetSettings.fillUpdates) serverWorld.updateNeighborsAt(blockPos_1, block_1);
}
}
@@ -15,12 +15,12 @@ public class StructureTemplate_fillUpdatesMixin
{
@Redirect( method = "placeInWorld", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/ServerLevelAccessor;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
target = "Lnet/minecraft/world/level/ServerLevelAccessor;updateNeighborsAt(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
))
private void skipUpdateNeighbours(ServerLevelAccessor serverWorldAccess, BlockPos pos, Block block)
{
if (!CarpetSettings.impendingFillSkipUpdates.get())
serverWorldAccess.blockUpdated(pos, block);
serverWorldAccess.updateNeighborsAt(pos, block);
}
@Redirect(method = "placeInWorld", at = @At(
@@ -0,0 +1,23 @@
package carpet.mixins;
import carpet.fakes.TicketsFetcherInterface;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import net.minecraft.server.level.Ticket;
import net.minecraft.world.level.TicketStorage;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.List;
@Mixin(TicketStorage.class)
public class TicketStorage_scarpetMixin implements TicketsFetcherInterface
{
@Shadow @Final private Long2ObjectOpenHashMap<List<Ticket>> tickets;
@Override
public Long2ObjectOpenHashMap<List<Ticket>> getTicketsByPosition()
{
return tickets;
}
}