missing stuff from quickcarpet
This commit is contained in:
1 parent
c4276b2bd4
commit
24e70ba9ed
8 files changed
+280
-1
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.datafixers.Dynamic;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.EndCityFeature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(EndCityFeature.class)
|
||||
public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatureConfig>
|
||||
{
|
||||
private static final List<Biome.SpawnEntry> spawnList = Lists.newArrayList(new Biome.SpawnEntry(EntityType.SHULKER, 10, 4, 4));
|
||||
|
||||
public EndCityFeatureMixin(Function<Dynamic<?>, ? extends DefaultFeatureConfig> function_1)
|
||||
{
|
||||
super(function_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Biome.SpawnEntry> getMonsterSpawns()
|
||||
{
|
||||
if (CarpetSettings.b_shulkerSpawningInEndCities)
|
||||
return spawnList;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.EntityCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.chunk.FloatingIslandsChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.FloatingIslandsChunkGeneratorConfig;
|
||||
import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(FloatingIslandsChunkGenerator.class)
|
||||
public abstract class FloatingIslandsChunkGeneratorMixin extends SurfaceChunkGenerator<FloatingIslandsChunkGeneratorConfig>
|
||||
{
|
||||
public FloatingIslandsChunkGeneratorMixin(IWorld iWorld_1, BiomeSource biomeSource_1, int int_1, int int_2, int int_3, FloatingIslandsChunkGeneratorConfig chunkGeneratorConfig_1, boolean boolean_1)
|
||||
{
|
||||
super(iWorld_1, biomeSource_1, int_1, int_2, int_3, chunkGeneratorConfig_1, boolean_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Biome.SpawnEntry> getEntitySpawnList(EntityCategory entityCategory_1, BlockPos blockPos_1)
|
||||
{
|
||||
if (CarpetSettings.b_shulkerSpawningInEndCities && EntityCategory.MONSTER == entityCategory_1)
|
||||
{
|
||||
if (Feature.END_CITY.isInsideStructure(this.world, blockPos_1))
|
||||
{
|
||||
return Feature.END_CITY.getMonsterSpawns();
|
||||
}
|
||||
}
|
||||
return this.world.getBiome(blockPos_1).getEntitySpawnList(entityCategory_1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.InfestedBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(InfestedBlock.class)
|
||||
public abstract class InfestedBlockMixin extends Block
|
||||
{
|
||||
public InfestedBlockMixin(Settings block$Settings_1)
|
||||
{
|
||||
super(block$Settings_1);
|
||||
}
|
||||
|
||||
@Inject(method = "onStacksDropped", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
|
||||
target = "Lnet/minecraft/entity/mob/SilverfishEntity;playSpawnEffects()V"))
|
||||
private void onOnStacksDropped(BlockState blockState_1, World world_1, BlockPos blockPos_1,
|
||||
ItemStack itemStack_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.getBool("silverFishDropGravel"))
|
||||
{
|
||||
dropStack(world_1, blockPos_1, new ItemStack(Blocks.GRAVEL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.PortalHelper;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(PlayerEntity.class)
|
||||
public abstract class PlayerEntityMixin
|
||||
{
|
||||
@ModifyConstant(method = "getMaxPortalTime",
|
||||
constant = @Constant(intValue = 1))
|
||||
private int addFillUpdatesInt(int original) {
|
||||
if (CarpetSettings.getBool("portalCreativeDelay"))
|
||||
if (PortalHelper.player_holds_obsidian((PlayerEntity) (Object)this))
|
||||
return 72000;
|
||||
else
|
||||
return 80;
|
||||
return original;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import carpet.patches.NetHandlerPlayServerFake;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(PlayerManager.class)
|
||||
public abstract class PlayerManagerMixin
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftServer server;
|
||||
|
||||
@Inject(method = "loadPlayerData", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void fixStartingPos(ServerPlayerEntity serverPlayerEntity_1, CallbackInfoReturnable<CompoundTag> cir)
|
||||
{
|
||||
if (serverPlayerEntity_1 instanceof EntityPlayerMPFake)
|
||||
{
|
||||
((EntityPlayerMPFake) serverPlayerEntity_1).fixStartingPosition.run();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "onPlayerConnect", at = @At(value = "NEW", target = "net/minecraft/server/network/ServerPlayNetworkHandler"))
|
||||
private ServerPlayNetworkHandler replaceNetworkHandler(MinecraftServer server, ClientConnection clientConnection, ServerPlayerEntity playerIn)
|
||||
{
|
||||
boolean isServerPlayerEntity = playerIn instanceof EntityPlayerMPFake;
|
||||
if (isServerPlayerEntity)
|
||||
{
|
||||
return new NetHandlerPlayServerFake(this.server, clientConnection, playerIn);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ServerPlayNetworkHandler(this.server, clientConnection, playerIn);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "createPlayer", at = @At(value = "INVOKE", target = "Ljava/util/Iterator;hasNext()Z"))
|
||||
private boolean cancelWhileLoop(Iterator iterator)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Inject(method = "createPlayer", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
target = "Ljava/util/Iterator;hasNext()Z"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void newWhileLoop(GameProfile gameProfile_1, CallbackInfoReturnable<ServerPlayerEntity> cir, UUID uUID_1,
|
||||
List list_1, Iterator var5)
|
||||
{
|
||||
while (var5.hasNext())
|
||||
{
|
||||
ServerPlayerEntity serverPlayerEntity_3 = (ServerPlayerEntity) var5.next();
|
||||
if(serverPlayerEntity_3 instanceof EntityPlayerMPFake)
|
||||
{
|
||||
serverPlayerEntity_3.kill();
|
||||
continue;
|
||||
}
|
||||
serverPlayerEntity_3.networkHandler.disconnect(new TranslatableComponent("multiplayer.disconnect.duplicate_login", new Object[0]));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.PrimedTntEntity;
|
||||
import net.minecraft.world.World;
|
||||
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.CallbackInfo;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.logging.logHelpers.TNTLogHelper;
|
||||
|
||||
@Mixin(PrimedTntEntity.class)
|
||||
public abstract class PrimedTntEntityMixin extends Entity
|
||||
{
|
||||
private TNTLogHelper logHelper = null;
|
||||
|
||||
public PrimedTntEntityMixin(EntityType<?> entityType_1, World world_1)
|
||||
{
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/entity/LivingEntity;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void initTNTLogger(World world_1, double double_1, double double_2, double double_3,
|
||||
LivingEntity livingEntity_1, CallbackInfo ci)
|
||||
{
|
||||
double double_4 = world_1.random.nextDouble() * 6.2831854820251465D;
|
||||
if (LoggerRegistry.__tnt)
|
||||
{
|
||||
logHelper = new TNTLogHelper();
|
||||
logHelper.onPrimed(double_1, double_2, double_3, (float)double_4);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "explode", at = @At(value = "HEAD"))
|
||||
private void onExplode(CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__tnt && logHelper != null)
|
||||
logHelper.onExploded(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.SpawnRestriction;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(SpawnRestriction.class)
|
||||
public abstract class SpawnRestrictionMixin
|
||||
{
|
||||
@Shadow
|
||||
private static void register(EntityType<?> a, SpawnRestriction.Location b, Heightmap.Type c) { }
|
||||
|
||||
static {
|
||||
register(EntityType.SHULKER, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user