21w37a
This commit is contained in:
1 parent
70754dbfe8
commit
bc175509a2
24 files changed
+155
-113
No files matched your search
@@ -1,23 +1,23 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.world.biome.source.BiomeArray;
|
||||
//import net.minecraft.world.biome.source.BiomeArray;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(BiomeArray.class)
|
||||
//@Mixin(BiomeArray.class)
|
||||
public class BiomeArray_cleanLogsMixin
|
||||
{
|
||||
// this changed in 21w18a - maybe its not needed anymore, please check
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "<init>(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/HeightLimitView;[I)V", at = @At(
|
||||
//@SuppressWarnings("UnresolvedMixinReference")
|
||||
/*@Redirect(method = "<init>(Lnet/minecraft/util/collection/IndexedIterable;Lnet/minecraft/world/HeightLimitView;[I)V", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V")
|
||||
)
|
||||
private void skipLog(Logger logger, String message, Object p0, Object p1)
|
||||
{
|
||||
if (!CarpetSettings.cleanLogs) logger.warn(message, p0, p1);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -5,16 +5,16 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeArray;
|
||||
//import net.minecraft.world.biome.source.BiomeArray;
|
||||
import net.minecraft.world.biome.source.BiomeCoords;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(BiomeArray.class)
|
||||
public class BiomeArray_getBiomeArrayMixin implements BiomeArrayInterface
|
||||
//@Mixin(BiomeArray.class)
|
||||
public class BiomeArray_getBiomeArrayMixin //implements BiomeArrayInterface
|
||||
{
|
||||
|
||||
/*
|
||||
@Shadow @Final private static int HORIZONTAL_SECTION_COUNT;
|
||||
|
||||
@Shadow @Final public static int HORIZONTAL_BIT_MASK;
|
||||
@@ -35,4 +35,6 @@ public class BiomeArray_getBiomeArrayMixin implements BiomeArrayInterface
|
||||
int int_6 = BiomeCoords.fromBlock(pos.getZ()) & HORIZONTAL_BIT_MASK;
|
||||
data[(int_5 << (HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT)) | (int_6 << HORIZONTAL_SECTION_COUNT) | int_4] = what;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.mojang.datafixers.util.Either;
|
||||
import net.minecraft.server.world.ChunkHolder;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.thread.ThreadExecutor;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
@@ -29,7 +30,7 @@ public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHold
|
||||
{
|
||||
int i = ChunkStatus.EMPTY.getIndex();
|
||||
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> completableFuture2 = CompletableFuture.supplyAsync(
|
||||
() -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA, world)),
|
||||
() -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA, world, world.getRegistryManager().get(Registry.BIOME_KEY))),
|
||||
executor
|
||||
);
|
||||
combineSavingFuture(completableFuture2, "unfull"); // possible debug data
|
||||
|
||||
@@ -142,12 +142,12 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
}
|
||||
|
||||
@Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void onToTag(NbtCompound NbtCompound_1, CallbackInfoReturnable<NbtCompound> cir)
|
||||
private void onToTag(NbtCompound NbtCompound_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null)
|
||||
{
|
||||
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
|
||||
NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.writeNbt(new NbtCompound()));
|
||||
NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.method_38244()); // toNBT
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +231,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
))
|
||||
private void onEntityInteract(PlayerInteractEntityC2SPacket playerInteractEntityC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), playerInteractEntityC2SPacket_1.getHand());
|
||||
PLAYER_INTERACTS_WITH_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.method_37908()), playerInteractEntityC2SPacket_1.getHand());
|
||||
}*/
|
||||
|
||||
/*@Inject(method = "onPlayerInteractEntity", at = @At(
|
||||
@@ -241,7 +241,7 @@ public class ServerPlayNetworkHandler_scarpetEventsMixin
|
||||
private void onEntityAttack(PlayerInteractEntityC2SPacket playerInteractEntityC2SPacket_1, CallbackInfo ci)
|
||||
{
|
||||
//todo add hit and hand in the future
|
||||
PLAYER_ATTACKS_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.getServerWorld()), null);
|
||||
PLAYER_ATTACKS_ENTITY.onEntityHandAction(player, playerInteractEntityC2SPacket_1.getEntity(player.method_37908()), null);
|
||||
}*/
|
||||
|
||||
@Inject(method = "onButtonClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;updateLastActionTime()V"))
|
||||
|
||||
@@ -2,25 +2,32 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.StructureFeatureInterface;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.structure.StructureStart;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeCoords;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.gen.ChunkRandom;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.FeatureConfig;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@Mixin(StructureFeature.class)
|
||||
public abstract class StructureFeatureMixin<C extends FeatureConfig> implements StructureFeatureInterface<C>
|
||||
@@ -29,7 +36,9 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
|
||||
@Shadow public abstract StructureFeature.StructureStartFactory getStructureStartFactory();
|
||||
|
||||
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView);
|
||||
//@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos chunkPos, Biome biome, ChunkPos chunkPos2, C featureConfig, HeightLimitView heightLimitView);
|
||||
|
||||
@Shadow protected abstract boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, ChunkPos pos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView);
|
||||
|
||||
@Override
|
||||
public boolean plopAnywhere(ServerWorld world, BlockPos pos, ChunkGenerator generator, boolean wireOnly, Biome biome, FeatureConfig config)
|
||||
@@ -48,12 +57,26 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
{
|
||||
return false;
|
||||
}
|
||||
world.getChunk(j, k).addStructureReference((StructureFeature) (Object)this, chId);
|
||||
StructureFeature<?> thiss = (StructureFeature) (Object)this;
|
||||
world.getChunk(j, k).addStructureReference(thiss, chId);
|
||||
|
||||
BlockBox box = structurestart.setBoundingBoxFromChildren(); // getBB
|
||||
|
||||
if (!wireOnly)
|
||||
{
|
||||
structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand,box, new ChunkPos(j, k));
|
||||
Registry<StructureFeature<?>> registry3 = world.getRegistryManager().get(Registry.STRUCTURE_FEATURE_KEY);
|
||||
Registry<Biome> registry = world.getRegistryManager().get(Registry.BIOME_KEY);
|
||||
world.method_36972(() -> {
|
||||
Objects.requireNonNull(thiss);
|
||||
return registry3.getKey(thiss).map(Object::toString).orElseGet(thiss::toString);
|
||||
});
|
||||
ImmutableMultimap<ConfiguredStructureFeature<?, ?>, RegistryKey<Biome>> immutableMultimap = generator.getStructuresConfig().method_38424((StructureFeature) (Object)this);
|
||||
|
||||
Predicate<Biome> predicate = (b) -> {
|
||||
Objects.requireNonNull(immutableMultimap);
|
||||
return registry.getKey(b).filter(immutableMultimap::containsValue).isPresent();
|
||||
};
|
||||
structurestart.generateStructure(world, world.getStructureAccessor(), generator, rand, predicate, box, new ChunkPos(j, k));
|
||||
}
|
||||
//structurestart.notifyPostProcessAt(new ChunkPos(j, k));
|
||||
int i = Math.max(box.getBlockCountX(),box.getBlockCountZ())/16+1;
|
||||
@@ -67,7 +90,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
long nbchkid = ChunkPos.toLong(k1, l1);
|
||||
if (box.intersectsXZ(k1<<4, l1<<4, (k1<<4) + 15, (l1<<4) + 15))
|
||||
{
|
||||
world.getChunk(k1, l1).addStructureReference((StructureFeature) (Object)this, chId);
|
||||
world.getChunk(k1, l1).addStructureReference(thiss, chId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,6 +111,7 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
private StructureStart forceStructureStart(ServerWorld worldIn, ChunkGenerator generator, Random rand, long packedChunkPos, Biome biome, FeatureConfig config)
|
||||
{
|
||||
ChunkPos chunkpos = new ChunkPos(packedChunkPos);
|
||||
BlockPos centerpos = chunkpos.getBlockPos(9, 0, 9);
|
||||
StructureStart structurestart;
|
||||
|
||||
Chunk ichunk = worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_STARTS, false);
|
||||
@@ -103,12 +127,13 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
Biome biome_1 = biome;
|
||||
if (biome == null)
|
||||
biome_1 = generator.getBiomeSource().getBiomeForNoiseGen((chunkpos.getStartX() + 9) >> 2, 0, (chunkpos.getStartZ() + 9) >> 2 );
|
||||
biome_1 = generator.getBiomeForNoiseGen(BiomeCoords.fromBlock(centerpos.getX()),
|
||||
BiomeCoords.fromBlock(centerpos.getY()), BiomeCoords.fromBlock(centerpos.getZ()));
|
||||
|
||||
StructureStart structurestart1 = getStructureStartFactory().create((StructureFeature)(Object)this, chunkpos,0,worldIn.getSeed());
|
||||
if (config == null)
|
||||
config = new DefaultFeatureConfig();
|
||||
structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, biome_1, config, ichunk);
|
||||
structurestart1.init(worldIn.getRegistryManager(), generator, worldIn.getStructureManager() , chunkpos, config, ichunk, b -> true);
|
||||
structurestart = structurestart1.hasChildren() ? structurestart1 : StructureStart.DEFAULT;
|
||||
|
||||
if (structurestart.hasChildren())
|
||||
@@ -121,8 +146,8 @@ public abstract class StructureFeatureMixin<C extends FeatureConfig> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, Biome biome, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
|
||||
public boolean shouldStartPublicAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long l, ChunkRandom chunkRandom, ChunkPos chpos, ChunkPos chunkPos, C featureConfig, HeightLimitView heightLimitView)
|
||||
{
|
||||
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, chpos, biome, chunkPos, featureConfig, heightLimitView);
|
||||
return shouldStartAt(chunkGenerator, biomeSource, l, chunkRandom, chpos, chunkPos, featureConfig, heightLimitView);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public abstract class TradeOutputSlot_scarpetEventMixin {
|
||||
target = "Lnet/minecraft/village/Merchant;trade(Lnet/minecraft/village/TradeOffer;)V")
|
||||
)
|
||||
private void onTrade(PlayerEntity player, ItemStack stack, CallbackInfo ci) {
|
||||
if(PLAYER_TRADES.isNeeded() && !this.merchant.getMerchantWorld().isClient())
|
||||
if(PLAYER_TRADES.isNeeded() && !player.world.isClient())
|
||||
{
|
||||
PLAYER_TRADES.onTrade((ServerPlayerEntity) player, merchant, merchantInventory.getTradeOffer());
|
||||
}
|
||||
|
||||
@@ -7,43 +7,46 @@ import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.PistonExtensionBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.HeightLimitView;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.TickScheduler;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
import net.minecraft.world.chunk.UpgradeData;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.Redirect;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static net.minecraft.world.chunk.WorldChunk.EMPTY_SECTION;
|
||||
|
||||
@Mixin(WorldChunk.class)
|
||||
public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
|
||||
public abstract class WorldChunk_movableTEMixin extends Chunk implements WorldChunkInterface
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private ChunkSection[] sections;
|
||||
@Shadow
|
||||
@Final
|
||||
private Map<Heightmap.Type, Heightmap> heightmaps;
|
||||
@Shadow
|
||||
private boolean shouldSave;
|
||||
@Shadow
|
||||
@Final
|
||||
private World world;
|
||||
|
||||
World world;
|
||||
|
||||
public WorldChunk_movableTEMixin(ChunkPos chunkPos, UpgradeData upgradeData, HeightLimitView heightLimitView, Registry<Biome> registry, long l, @Nullable ChunkSection[] chunkSections, TickScheduler<Block> tickScheduler, TickScheduler<Fluid> tickScheduler2)
|
||||
{
|
||||
super(chunkPos, upgradeData, heightLimitView, registry, l, chunkSections, tickScheduler, tickScheduler2);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
/* @Nullable */
|
||||
public abstract BlockEntity getBlockEntity(BlockPos blockPos_1, WorldChunk.CreationType worldChunk$CreationType_1);
|
||||
|
||||
@Shadow protected abstract <T extends BlockEntity> void updateTicker(T blockEntity);
|
||||
|
||||
@Shadow public abstract void addBlockEntity(BlockEntity blockEntity);
|
||||
|
||||
// Fix Failure: If a moving BlockEntity is placed while BlockEntities are ticking, this will not find it and then replace it with a new TileEntity!
|
||||
// blockEntity_2 = this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK);
|
||||
// question is - with the changes in the BE handling this might not be a case anymore
|
||||
@@ -70,23 +73,20 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
|
||||
* @author 2No2Name
|
||||
*/
|
||||
/* @Nullable */
|
||||
// todo update me to the new version
|
||||
public BlockState setBlockStateWithBlockEntity(BlockPos blockPos_1, BlockState newBlockState, BlockEntity newBlockEntity,
|
||||
boolean boolean_1)
|
||||
{
|
||||
int x = blockPos_1.getX() & 15;
|
||||
int y = blockPos_1.getY();
|
||||
int z = blockPos_1.getZ() & 15;
|
||||
int section = world.getSectionIndex(y);
|
||||
ChunkSection chunkSection = this.sections[section];
|
||||
if (chunkSection == EMPTY_SECTION)
|
||||
ChunkSection chunkSection = this.getSection(this.getSectionIndex(y));
|
||||
if (chunkSection.isEmpty())
|
||||
{
|
||||
if (newBlockState.isAir())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
chunkSection = new ChunkSection(ChunkSectionPos.getSectionCoord(y));
|
||||
this.sections[section] = chunkSection;
|
||||
}
|
||||
|
||||
boolean boolean_2 = chunkSection.isEmpty();
|
||||
@@ -99,10 +99,10 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
|
||||
{
|
||||
Block newBlock = newBlockState.getBlock();
|
||||
Block oldBlock = oldBlockState.getBlock();
|
||||
((Heightmap) this.heightmaps.get(Heightmap.Type.MOTION_BLOCKING)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.heightmaps.get(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.heightmaps.get(Heightmap.Type.OCEAN_FLOOR)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.heightmaps.get(Heightmap.Type.WORLD_SURFACE)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.field_34541.get(Heightmap.Type.MOTION_BLOCKING)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.field_34541.get(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.field_34541.get(Heightmap.Type.OCEAN_FLOOR)).trackUpdate(x, y, z, newBlockState);
|
||||
((Heightmap) this.field_34541.get(Heightmap.Type.WORLD_SURFACE)).trackUpdate(x, y, z, newBlockState);
|
||||
boolean boolean_3 = chunkSection.isEmpty();
|
||||
if (boolean_2 != boolean_3)
|
||||
{
|
||||
@@ -156,7 +156,7 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
|
||||
newBlockState.onBlockAdded(this.world, blockPos_1, oldBlockState, boolean_1); //This can call setblockstate! (e.g. hopper does)
|
||||
}
|
||||
|
||||
this.shouldSave = true;
|
||||
this.field_34537 = true; // shouldSave
|
||||
return oldBlockState;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user