Migrate the Carpet codebase to Mojang Mappings
This commit is contained in:
346 files changed
+8353
-8492
No files matched your search
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.AbstractCauldronBlock;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.block.cauldron.CauldronBehavior;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.cauldron.CauldronInteraction;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.AbstractCauldronBlock;
|
||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
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.Redirect;
|
||||
@@ -19,16 +19,16 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(AbstractCauldronBlock.class)
|
||||
public class AbstractCauldronBlock_stackableSBoxesMixin
|
||||
{
|
||||
@Redirect(method = "onUse", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/cauldron/CauldronBehavior;interact(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/util/ActionResult;"))
|
||||
private ActionResult wrapInteractor(CauldronBehavior cauldronBehavior, BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, ItemStack itemStack)
|
||||
@Redirect(method = "use", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/cauldron/CauldronInteraction;interact(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/InteractionResult;"))
|
||||
private InteractionResult wrapInteractor(CauldronInteraction cauldronBehavior, BlockState blockState, Level world, BlockPos blockPos, Player playerEntity, InteractionHand hand, ItemStack itemStack)
|
||||
{
|
||||
int count = -1;
|
||||
if (CarpetSettings.shulkerBoxStackSize > 1 && itemStack.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
count = itemStack.getCount();
|
||||
ActionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
|
||||
if (count > 0 && result.isAccepted())
|
||||
InteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack);
|
||||
if (count > 0 && result.consumesAction())
|
||||
{
|
||||
ItemStack current = playerEntity.getStackInHand(hand);
|
||||
ItemStack current = playerEntity.getItemInHand(hand);
|
||||
if (current.getItem() instanceof BlockItem && ((BlockItem)itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
current.setCount(count);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ScreenHandlerInterface;
|
||||
import net.minecraft.recipe.Recipe;
|
||||
import net.minecraft.screen.AbstractRecipeScreenHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.inventory.RecipeBookMenu;
|
||||
import net.minecraft.world.item.crafting.Recipe;
|
||||
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(AbstractRecipeScreenHandler.class)
|
||||
@Mixin(RecipeBookMenu.class)
|
||||
public class AbstractRecipeScreenHandler_scarpetMixin {
|
||||
@Inject(method = "fillInputSlots",at = @At("HEAD"), cancellable = true)
|
||||
private void selectRecipeCallback(boolean craftAll, Recipe<?> recipe, ServerPlayerEntity player, CallbackInfo ci) {
|
||||
@Inject(method = "handlePlacement",at = @At("HEAD"), cancellable = true)
|
||||
private void selectRecipeCallback(boolean craftAll, Recipe<?> recipe, ServerPlayer player, CallbackInfo ci) {
|
||||
if(((ScreenHandlerInterface) this).callSelectRecipeListener(player,recipe,craftAll))
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@@ -2,10 +2,6 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.script.api.Auxiliary;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -13,11 +9,15 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Optional;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(ArmorStandEntity.class)
|
||||
@Mixin(ArmorStand.class)
|
||||
public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity
|
||||
{
|
||||
protected ArmorStandEntity_scarpetMarkerMixin(EntityType<? extends LivingEntity> entityType_1, World world_1)
|
||||
protected ArmorStandEntity_scarpetMarkerMixin(EntityType<? extends LivingEntity> entityType_1, Level world_1)
|
||||
{
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
@@ -26,15 +26,15 @@ public abstract class ArmorStandEntity_scarpetMarkerMixin extends LivingEntity
|
||||
* Remove all markers that do not belong to any script host and not part of the global one when loaded
|
||||
* @param ci
|
||||
*/
|
||||
@Inject(method = "readCustomDataFromNbt", at = @At("HEAD"))
|
||||
@Inject(method = "readAdditionalSaveData", at = @At("HEAD"))
|
||||
private void checkScarpetMarkerUnloaded(CallbackInfo ci)
|
||||
{
|
||||
if (!world.isClient)
|
||||
if (!level.isClientSide)
|
||||
{
|
||||
if (getScoreboardTags().contains(Auxiliary.MARKER_STRING))
|
||||
if (getTags().contains(Auxiliary.MARKER_STRING))
|
||||
{
|
||||
String prefix = Auxiliary.MARKER_STRING+"_";
|
||||
Optional<String> owner = getScoreboardTags().stream().filter(s -> s.startsWith(prefix)).findFirst();
|
||||
Optional<String> owner = getTags().stream().filter(s -> s.startsWith(prefix)).findFirst();
|
||||
if (owner.isPresent())
|
||||
{
|
||||
String hostName = StringUtils.removeStart(owner.get(),prefix);
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BarrierBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.PoweredRailBlock;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BarrierBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.PoweredRailBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@Mixin(BarrierBlock.class)
|
||||
public class BarrierBlock_updateSuppressionBlockMixin extends Block {
|
||||
private boolean shouldPower = false;
|
||||
|
||||
public BarrierBlock_updateSuppressionBlockMixin(Settings settings) { super(settings); }
|
||||
public BarrierBlock_updateSuppressionBlockMixin(Properties settings) { super(settings); }
|
||||
|
||||
@Override
|
||||
public int getWeakRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction direction) {
|
||||
public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) {
|
||||
return (shouldPower && direction == Direction.DOWN) ? 15 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
|
||||
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
|
||||
if (CarpetSettings.updateSuppressionBlockSetting != -1) {
|
||||
if (fromPos.equals(pos.up())) {
|
||||
if (fromPos.equals(pos.above())) {
|
||||
BlockState stateAbove = world.getBlockState(fromPos);
|
||||
if (stateAbove.isOf(Blocks.ACTIVATOR_RAIL) && !stateAbove.get(PoweredRailBlock.POWERED)) {
|
||||
if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) {
|
||||
if (CarpetSettings.updateSuppressionBlockSetting > 0) {
|
||||
world.createAndScheduleBlockTick(pos, this, CarpetSettings.updateSuppressionBlockSetting);
|
||||
world.scheduleTick(pos, this, CarpetSettings.updateSuppressionBlockSetting);
|
||||
}
|
||||
throw new StackOverflowError("updateSuppressionBlock");
|
||||
}
|
||||
}
|
||||
}
|
||||
super.neighborUpdate(state, world, pos, block, fromPos, notify);
|
||||
super.neighborChanged(state, world, pos, block, fromPos, notify);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
|
||||
BlockPos posAbove = pos.up();
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
||||
BlockPos posAbove = pos.above();
|
||||
BlockState stateAbove = world.getBlockState(posAbove);
|
||||
if (stateAbove.isOf(Blocks.ACTIVATOR_RAIL) && !stateAbove.get(PoweredRailBlock.POWERED)) {
|
||||
if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) {
|
||||
shouldPower = true;
|
||||
world.setBlockState(posAbove, stateAbove.with(PoweredRailBlock.POWERED, true), 3);
|
||||
world.setBlock(posAbove, stateAbove.setValue(PoweredRailBlock.POWERED, true), 3);
|
||||
shouldPower = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,13 @@ import carpet.CarpetSettings;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.world.MobSpawnerLogic;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.gen.feature.BastionRemnantFeature;
|
||||
|
||||
import net.minecraft.world.gen.feature.JigsawFeature;
|
||||
import net.minecraft.world.gen.feature.StructurePoolFeatureConfig;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.level.levelgen.feature.BastionFeature;
|
||||
|
||||
@Mixin(BastionRemnantFeature.class)
|
||||
@Mixin(BastionFeature.class)
|
||||
public abstract class BastionRemnantFeatureMixin //extends JigsawFeature
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BiomeArrayInterface;
|
||||
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.BiomeCoords;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(targets = "net.minecraft.entity.mob.BlazeEntity$ShootFireballGoal")
|
||||
@Mixin(targets = "net.minecraft.world.entity.monster.Blaze$BlazeAttackGoal")
|
||||
public class BlazeEntityShootFireballGoal_extremeMixin
|
||||
{
|
||||
@Redirect(method = "tick()V", expect = 2, at = @At(
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.RandomTools;
|
||||
import net.minecraft.entity.mob.BlazeEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.entity.monster.Blaze;
|
||||
|
||||
@Mixin(BlazeEntity.class)
|
||||
@Mixin(Blaze.class)
|
||||
public class BlazeEntity_extremeMixin
|
||||
{
|
||||
// unused actually
|
||||
@Redirect(method = "mobTick", expect = 1, at = @At(
|
||||
@Redirect(method = "customServerAiStep", expect = 1, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Random;nextGaussian()D"
|
||||
))
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BlockEntityInterface;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
@@ -12,10 +12,10 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
public abstract class BlockEntity_movableBEMixin implements BlockEntityInterface
|
||||
{
|
||||
@Mutable
|
||||
@Shadow @Final protected BlockPos pos;
|
||||
@Shadow @Final protected BlockPos worldPosition;
|
||||
|
||||
public void setCMPos(BlockPos newPos)
|
||||
{
|
||||
pos = newPos;
|
||||
worldPosition = newPos;
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.ShapeContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.shapes.CollisionContext;
|
||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -18,19 +18,19 @@ public class BlockItem_creativeNoClipMixin
|
||||
{
|
||||
@Redirect(method = "canPlace", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;canPlace(Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/ShapeContext;)Z"
|
||||
target = "Lnet/minecraft/world/level/Level;isUnobstructed(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/phys/shapes/CollisionContext;)Z"
|
||||
))
|
||||
private boolean canSpectatingPlace(World world, BlockState state, BlockPos pos, ShapeContext context,
|
||||
ItemPlacementContext contextOuter, BlockState stateOuter)
|
||||
private boolean canSpectatingPlace(Level world, BlockState state, BlockPos pos, CollisionContext context,
|
||||
BlockPlaceContext contextOuter, BlockState stateOuter)
|
||||
{
|
||||
PlayerEntity player = contextOuter.getPlayer();
|
||||
Player player = contextOuter.getPlayer();
|
||||
if (CarpetSettings.creativeNoClip && player != null && player.isCreative() && player.getAbilities().flying)
|
||||
{
|
||||
// copy from canPlace
|
||||
VoxelShape voxelShape = state.getCollisionShape(world, pos, context);
|
||||
return voxelShape.isEmpty() || world.doesNotIntersectEntities(player, voxelShape.offset(pos.getX(), pos.getY(), pos.getZ()));
|
||||
return voxelShape.isEmpty() || world.isUnobstructed(player, voxelShape.move(pos.getX(), pos.getY(), pos.getZ()));
|
||||
|
||||
}
|
||||
return world.canPlace(state, pos, context);
|
||||
return world.isUnobstructed(state, pos, context);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -11,17 +7,22 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_PLACES_BLOCK;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
|
||||
@Mixin(BlockItem.class)
|
||||
public class BlockItem_scarpetEventMixin
|
||||
{
|
||||
@Inject(method = "place(Lnet/minecraft/item/ItemPlacementContext;)Lnet/minecraft/util/ActionResult;", at = @At(
|
||||
@Inject(method = "place(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/InteractionResult;", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/Block;onPlaced(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;)V",
|
||||
target = "Lnet/minecraft/world/level/block/Block;setPlacedBy(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;)V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void afterPlacement(ItemPlacementContext context, CallbackInfoReturnable<ActionResult> cir)
|
||||
private void afterPlacement(BlockPlaceContext context, CallbackInfoReturnable<InteractionResult> cir)
|
||||
{
|
||||
if (context.getPlayer() instanceof ServerPlayerEntity && PLAYER_PLACES_BLOCK.isNeeded())
|
||||
PLAYER_PLACES_BLOCK.onBlockPlaced((ServerPlayerEntity) context.getPlayer(), context.getBlockPos(), context.getHand(), context.getStack());
|
||||
if (context.getPlayer() instanceof ServerPlayer && PLAYER_PLACES_BLOCK.isNeeded())
|
||||
PLAYER_PLACES_BLOCK.onBlockPlaced((ServerPlayer) context.getPlayer(), context.getClickedPos(), context.getHand(), context.getItemInHand());
|
||||
}
|
||||
}
|
||||
@@ -4,55 +4,55 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import carpet.fakes.ChunkLightProviderInterface;
|
||||
import carpet.fakes.LightStorageInterface;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
import net.minecraft.world.chunk.ChunkProvider;
|
||||
import net.minecraft.world.chunk.light.BlockLightStorage;
|
||||
import net.minecraft.world.chunk.light.BlockLightStorage.Data;
|
||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||
import net.minecraft.world.chunk.light.LightStorage;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.LightLayer;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
import net.minecraft.world.level.chunk.LightChunkGetter;
|
||||
import net.minecraft.world.level.lighting.BlockLightSectionStorage;
|
||||
import net.minecraft.world.level.lighting.BlockLightSectionStorage.BlockDataLayerStorageMap;
|
||||
import net.minecraft.world.level.lighting.LayerLightEngine;
|
||||
import net.minecraft.world.level.lighting.LayerLightSectionStorage;
|
||||
|
||||
@Mixin(BlockLightStorage.class)
|
||||
public abstract class BlockLightStorage_scarpetChunkCreationMixin extends LightStorage<Data> implements LightStorageInterface
|
||||
@Mixin(BlockLightSectionStorage.class)
|
||||
public abstract class BlockLightStorage_scarpetChunkCreationMixin extends LayerLightSectionStorage<BlockDataLayerStorageMap> implements LightStorageInterface
|
||||
{
|
||||
private BlockLightStorage_scarpetChunkCreationMixin(final LightType lightType, final ChunkProvider chunkProvider, final Data lightData)
|
||||
private BlockLightStorage_scarpetChunkCreationMixin(final LightLayer lightType, final LightChunkGetter chunkProvider, final BlockDataLayerStorageMap lightData)
|
||||
{
|
||||
super(lightType, chunkProvider, lightData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRelight(final ChunkLightProvider<?, ?> lightProvider, final long cPos)
|
||||
public void processRelight(final LayerLightEngine<?, ?> lightProvider, final long cPos)
|
||||
{
|
||||
final LevelPropagator_resetChunkInterface levelPropagator = (LevelPropagator_resetChunkInterface) lightProvider;
|
||||
|
||||
for (int y = -1; y < 17; ++y)
|
||||
{
|
||||
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.unpackX(cPos), y, ChunkSectionPos.unpackZ(cPos));
|
||||
final long pos = BlockPos.asLong(ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackX(sectionPos)), ChunkSectionPos.getBlockCoord(y), ChunkSectionPos.getBlockCoord(ChunkSectionPos.unpackZ(sectionPos)));
|
||||
final long sectionPos = SectionPos.asLong(SectionPos.x(cPos), y, SectionPos.z(cPos));
|
||||
final long pos = BlockPos.asLong(SectionPos.sectionToBlockCoord(SectionPos.x(sectionPos)), SectionPos.sectionToBlockCoord(y), SectionPos.sectionToBlockCoord(SectionPos.z(sectionPos)));
|
||||
|
||||
if (!this.hasSection(sectionPos))
|
||||
if (!this.storingLightForSection(sectionPos))
|
||||
continue;
|
||||
|
||||
for (final Direction dir : Direction.Type.HORIZONTAL)
|
||||
for (final Direction dir : Direction.Plane.HORIZONTAL)
|
||||
{
|
||||
final ChunkNibbleArray neighborLightArray = this.getLightSection(ChunkSectionPos.offset(sectionPos, dir));
|
||||
final DataLayer neighborLightArray = this.getDataLayerData(SectionPos.offset(sectionPos, dir));
|
||||
|
||||
if (neighborLightArray == null)
|
||||
continue;
|
||||
|
||||
final int ox = 15 * Math.max(dir.getOffsetX(), 0);
|
||||
final int oz = 15 * Math.max(dir.getOffsetZ(), 0);
|
||||
final int ox = 15 * Math.max(dir.getStepX(), 0);
|
||||
final int oz = 15 * Math.max(dir.getStepZ(), 0);
|
||||
|
||||
final int dx = Math.abs(dir.getOffsetZ());
|
||||
final int dz = Math.abs(dir.getOffsetX());
|
||||
final int dx = Math.abs(dir.getStepZ());
|
||||
final int dz = Math.abs(dir.getStepX());
|
||||
|
||||
for (int t = 0; t < 16; ++t)
|
||||
for (int dy = 0; dy < 16; ++dy)
|
||||
{
|
||||
final long dst = BlockPos.add(pos, ox + t * dx, dy, oz + t * dz);
|
||||
final long dst = BlockPos.offset(pos, ox + t * dx, dy, oz + t * dz);
|
||||
final long src = BlockPos.offset(dst, dir);
|
||||
|
||||
final int srcLevel = ((ChunkLightProviderInterface) lightProvider).callGetCurrentLevelFromSection(neighborLightArray, src);
|
||||
|
||||
@@ -5,26 +5,26 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.argument.BlockStateArgument;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.commands.arguments.blocks.BlockInput;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@Mixin(BlockStateArgument.class)
|
||||
@Mixin(BlockInput.class)
|
||||
public class BlockStateArgument_fillUpdatesMixin
|
||||
{
|
||||
@Redirect(method = "setBlockState", at = @At(
|
||||
@Redirect(method = "place", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/Block;postProcessState(Lnet/minecraft/block/BlockState;Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"
|
||||
target = "Lnet/minecraft/world/level/block/Block;updateFromNeighbourShapes(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"
|
||||
))
|
||||
private BlockState postProcessStateProxy(BlockState state, WorldAccess serverWorld, BlockPos blockPos)
|
||||
private BlockState postProcessStateProxy(BlockState state, LevelAccessor serverWorld, BlockPos blockPos)
|
||||
{
|
||||
if (CarpetSettings.impendingFillSkipUpdates.get())
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
return Block.postProcessState(state, serverWorld, blockPos);
|
||||
return Block.updateFromNeighbourShapes(state, serverWorld, blockPos);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.BlockStateArgumentInterface;
|
||||
import net.minecraft.command.argument.BlockStateArgument;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.commands.arguments.blocks.BlockInput;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(BlockStateArgument.class)
|
||||
@Mixin(BlockInput.class)
|
||||
public class BlockStateArgument_scarpetMixin implements BlockStateArgumentInterface
|
||||
{
|
||||
@Shadow @Final private @Nullable NbtCompound data;
|
||||
@Shadow @Final private @Nullable CompoundTag tag;
|
||||
|
||||
@Override
|
||||
public NbtCompound getCMTag()
|
||||
public CompoundTag getCMTag()
|
||||
{
|
||||
return data;
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.BuddingAmethystBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
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;
|
||||
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;
|
||||
@@ -22,24 +22,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(BuddingAmethystBlock.class)
|
||||
public class BuddingAmethystBlock_movableAmethystMixin extends Block {
|
||||
public BuddingAmethystBlock_movableAmethystMixin(Settings settings) {
|
||||
public BuddingAmethystBlock_movableAmethystMixin(Properties settings) {
|
||||
super(settings);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "getPistonBehavior(Lnet/minecraft/block/BlockState;)Lnet/minecraft/block/piston/PistonBehavior;", cancellable = true)
|
||||
void getPistonBehavior(BlockState state, CallbackInfoReturnable<PistonBehavior> cir) {
|
||||
if (CarpetSettings.movableAmethyst) cir.setReturnValue(PistonBehavior.NORMAL);
|
||||
@Inject(at = @At("HEAD"), method = "getPistonPushReaction(Lnet/minecraft/world/level/block/state/BlockState;)Lnet/minecraft/world/level/material/PushReaction;", cancellable = true)
|
||||
void getPistonBehavior(BlockState state, CallbackInfoReturnable<PushReaction> cir) {
|
||||
if (CarpetSettings.movableAmethyst) cir.setReturnValue(PushReaction.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
|
||||
super.afterBreak(world, player, pos, state, blockEntity, stack);
|
||||
public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) {
|
||||
super.playerDestroy(world, player, pos, state, blockEntity, stack);
|
||||
// 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 &&
|
||||
EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) > 0
|
||||
EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) > 0
|
||||
)
|
||||
dropStack(world, pos, Items.BUDDING_AMETHYST.getDefaultStack());
|
||||
popResource(world, pos, Items.BUDDING_AMETHYST.getDefaultInstance());
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.WoolTool;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.DyedCarpetBlock;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.WoolCarpetBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(DyedCarpetBlock.class) // WoolCarpetBlock
|
||||
@Mixin(WoolCarpetBlock.class) // WoolCarpetBlock
|
||||
public abstract class CarpetBlockMixin extends Block
|
||||
{
|
||||
|
||||
public CarpetBlockMixin(Settings block$Settings_1)
|
||||
public CarpetBlockMixin(Properties block$Settings_1)
|
||||
{
|
||||
super(block$Settings_1);
|
||||
}
|
||||
|
||||
public BlockState getPlacementState(ItemPlacementContext context)
|
||||
public BlockState getStateForPlacement(BlockPlaceContext context)
|
||||
{
|
||||
BlockState state = super.getPlacementState(context);
|
||||
if (context.getPlayer() != null && !context.getWorld().isClient)
|
||||
BlockState state = super.getStateForPlacement(context);
|
||||
if (context.getPlayer() != null && !context.getLevel().isClientSide)
|
||||
{ // getColor()
|
||||
WoolTool.carpetPlacedAction(((DyedCarpetBlock)(Object)this).getDyeColor(), context.getPlayer(), context.getBlockPos(), (ServerWorld) context.getWorld());
|
||||
WoolTool.carpetPlacedAction(((WoolCarpetBlock)(Object)this).getColor(), context.getPlayer(), context.getClickedPos(), (ServerLevel) context.getLevel());
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.CauldronBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.block.CauldronBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.world.gen.NoiseColumnSampler;
|
||||
import net.minecraft.world.level.levelgen.NoiseSampler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
|
||||
@Mixin(NoiseColumnSampler.CaveScaler.class)
|
||||
@Mixin(NoiseSampler.QuantizedSpaghettiRarity.class)
|
||||
public interface CaveScalerMixin_scarpetMixin {
|
||||
@Invoker
|
||||
static double invokeScaleTunnels(double d) {
|
||||
static double invokeGetSpaghettiRarity3D(double d) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ChunkGeneratorInterface;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ChunkGenerator.class)
|
||||
public abstract class ChunkGenerator_scarpetMixin implements ChunkGeneratorInterface
|
||||
{
|
||||
@Shadow protected abstract void generateStrongholdPositions();
|
||||
@Shadow private static boolean canPlaceStrongholdInBiome(Biome biome) { return true;}
|
||||
@Shadow protected abstract void generateStrongholds();
|
||||
@Shadow private static boolean validStrongholdBiome(Biome biome) { return true;}
|
||||
|
||||
@Override
|
||||
public void initStrongholds()
|
||||
{
|
||||
generateStrongholdPositions();
|
||||
generateStrongholds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceStrongholdInBiomeCM(Biome biome) {
|
||||
return canPlaceStrongholdInBiome(biome);
|
||||
return validStrongholdBiome(biome);
|
||||
}
|
||||
}
|
||||
@@ -2,39 +2,39 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ChunkHolderInterface;
|
||||
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;
|
||||
import net.minecraft.world.chunk.ProtoChunk;
|
||||
import net.minecraft.world.chunk.UpgradeData;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.thread.BlockableEventLoop;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ProtoChunk;
|
||||
import net.minecraft.world.level.chunk.UpgradeData;
|
||||
|
||||
@Mixin(ChunkHolder.class)
|
||||
public abstract class ChunkHolder_scarpetChunkCreationMixin implements ChunkHolderInterface
|
||||
{
|
||||
@Shadow protected abstract void combineSavingFuture(CompletableFuture<? extends Either<? extends Chunk, ChunkHolder.Unloaded>> newChunkFuture, String type);
|
||||
@Shadow protected abstract void updateChunkToSave(CompletableFuture<? extends Either<? extends ChunkAccess, ChunkHolder.ChunkLoadingFailure>> newChunkFuture, String type);
|
||||
|
||||
@Shadow @Final private AtomicReferenceArray<CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>>> futuresByStatus;
|
||||
@Shadow @Final private AtomicReferenceArray<CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>>> futures;
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> setDefaultProtoChunk(ChunkPos chpos, ThreadExecutor<Runnable> executor, ServerWorld world)
|
||||
public CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> setDefaultProtoChunk(ChunkPos chpos, BlockableEventLoop<Runnable> executor, ServerLevel world)
|
||||
{
|
||||
int i = ChunkStatus.EMPTY.getIndex();
|
||||
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> completableFuture2 = CompletableFuture.supplyAsync(
|
||||
() -> Either.left(new ProtoChunk(chpos, UpgradeData.NO_UPGRADE_DATA, world, world.getRegistryManager().get(Registry.BIOME_KEY), null)), // todo figure out what that does - maybe add an option to reset with blending enabled..?
|
||||
CompletableFuture<Either<ChunkAccess, ChunkHolder.ChunkLoadingFailure>> completableFuture2 = CompletableFuture.supplyAsync(
|
||||
() -> Either.left(new ProtoChunk(chpos, UpgradeData.EMPTY, world, world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null)), // todo figure out what that does - maybe add an option to reset with blending enabled..?
|
||||
executor
|
||||
);
|
||||
combineSavingFuture(completableFuture2, "unfull"); // possible debug data
|
||||
futuresByStatus.set(i, completableFuture2);
|
||||
updateChunkToSave(completableFuture2, "unfull"); // possible debug data
|
||||
futures.set(i, completableFuture2);
|
||||
return completableFuture2;
|
||||
}
|
||||
}
|
||||
@@ -7,30 +7,30 @@ import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import carpet.fakes.ChunkLightProviderInterface;
|
||||
import carpet.fakes.Lighting_scarpetChunkCreationInterface;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||
import net.minecraft.world.chunk.light.LightStorage;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
import net.minecraft.world.level.lighting.LayerLightEngine;
|
||||
import net.minecraft.world.level.lighting.LayerLightSectionStorage;
|
||||
|
||||
@Mixin(ChunkLightProvider.class)
|
||||
@Mixin(LayerLightEngine.class)
|
||||
public abstract class ChunkLightProvider_scarpetChunkCreationMixin implements Lighting_scarpetChunkCreationInterface, ChunkLightProviderInterface
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
protected LightStorage<?> lightStorage;
|
||||
protected LayerLightSectionStorage<?> storage;
|
||||
|
||||
@Override
|
||||
public void removeLightData(final long pos)
|
||||
{
|
||||
((Lighting_scarpetChunkCreationInterface) this.lightStorage).removeLightData(pos);
|
||||
((Lighting_scarpetChunkCreationInterface) this.storage).removeLightData(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relight(final long pos)
|
||||
{
|
||||
((Lighting_scarpetChunkCreationInterface) this.lightStorage).relight(pos);
|
||||
((Lighting_scarpetChunkCreationInterface) this.storage).relight(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Invoker("getCurrentLevelFromSection")
|
||||
public abstract int callGetCurrentLevelFromSection(ChunkNibbleArray array, long blockPos);
|
||||
@Invoker("getLevel")
|
||||
public abstract int callGetCurrentLevelFromSection(DataLayer array, long blockPos);
|
||||
}
|
||||
@@ -1,18 +1,18 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
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(Chunk.class)
|
||||
@Mixin(ChunkAccess.class)
|
||||
public abstract class ChunkMixin
|
||||
{
|
||||
// failed to mixin into interface. need to mixin in two places that uses it
|
||||
@Inject(method = "markBlockForPostProcessing(Lnet/minecraft/util/math/BlockPos;)V",
|
||||
@Inject(method = "markPosForPostprocessing(Lnet/minecraft/core/BlockPos;)V",
|
||||
at =@At("HEAD"), cancellable = true)
|
||||
private void squashWarnings(BlockPos blockPos_1, CallbackInfo ci)
|
||||
{
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.WorldGenRegion;
|
||||
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(ChunkRegion.class)
|
||||
@Mixin(WorldGenRegion.class)
|
||||
public class ChunkRegion_scarpetPlopMixin
|
||||
{
|
||||
@Inject(method = "markBlockForPostProcessing", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "markPosForPostprocessing", at = @At("HEAD"), cancellable = true)
|
||||
private void markOrNot(BlockPos blockPos, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.skipGenerationChecks.get()) ci.cancel();
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
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;
|
||||
import net.minecraft.server.world.ChunkHolder;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
|
||||
@Mixin(ChunkTicketManager.class)
|
||||
@Mixin(DistanceManager.class)
|
||||
public abstract class ChunkTicketManager_scarpetChunkCreationMixin implements ChunkTicketManagerInterface
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private Set<ChunkHolder> chunkHolders;
|
||||
private Set<ChunkHolder> chunksToUpdateFutures;
|
||||
|
||||
@Override
|
||||
public void replaceHolder(final ChunkHolder oldHolder, final ChunkHolder newHolder)
|
||||
{
|
||||
this.chunkHolders.remove(oldHolder);
|
||||
this.chunkHolders.add(newHolder);
|
||||
this.chunksToUpdateFutures.remove(oldHolder);
|
||||
this.chunksToUpdateFutures.add(newHolder);
|
||||
}
|
||||
}
|
||||
@@ -2,22 +2,22 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ChunkTicketManagerInterface;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.server.world.ChunkTicket;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.util.collection.SortedArraySet;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
import net.minecraft.server.level.Ticket;
|
||||
import net.minecraft.util.SortedArraySet;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(ChunkTicketManager.class)
|
||||
@Mixin(DistanceManager.class)
|
||||
public abstract class ChunkTicketManager_scarpetMixin implements ChunkTicketManagerInterface
|
||||
{
|
||||
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> ticketsByPosition;
|
||||
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> tickets;
|
||||
|
||||
@Override
|
||||
public Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> getTicketsByPosition()
|
||||
public Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> getTicketsByPosition()
|
||||
{
|
||||
return ticketsByPosition;
|
||||
return tickets;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,40 +2,40 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ChunkTicketManagerInterface;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.minecraft.server.world.ChunkTicket;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.server.world.ChunkTicketType;
|
||||
import net.minecraft.util.collection.SortedArraySet;
|
||||
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.util.math.ChunkPos;
|
||||
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(ChunkTicketManager.class)
|
||||
@Mixin(DistanceManager.class)
|
||||
public abstract class ChunkTicketManager_spawnChunksMixin implements ChunkTicketManagerInterface
|
||||
{
|
||||
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<ChunkTicket<?>>> ticketsByPosition;
|
||||
@Shadow @Final private Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> tickets;
|
||||
|
||||
@Shadow protected abstract void removeTicket(long pos, ChunkTicket<?> ticket);
|
||||
@Shadow protected abstract void removeTicket(long pos, Ticket<?> ticket);
|
||||
|
||||
@Shadow public abstract <T> void addTicket(ChunkTicketType<T> type, ChunkPos pos, int radius, T argument);
|
||||
@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<ChunkTicket<?>> set = ticketsByPosition.get(pos);
|
||||
ChunkTicket existingTicket = null;
|
||||
SortedArraySet<Ticket<?>> set = tickets.get(pos);
|
||||
Ticket existingTicket = null;
|
||||
if (set != null)
|
||||
{
|
||||
Iterator<ChunkTicket<?>> iter = set.iterator();
|
||||
Iterator<Ticket<?>> iter = set.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
ChunkTicket ticket = iter.next();
|
||||
if (ticket.getType() == ChunkTicketType.START)
|
||||
Ticket ticket = iter.next();
|
||||
if (ticket.getType() == TicketType.START)
|
||||
{
|
||||
existingTicket = ticket;
|
||||
iter.remove();
|
||||
@@ -50,6 +50,6 @@ public abstract class ChunkTicketManager_spawnChunksMixin implements ChunkTicket
|
||||
}
|
||||
// set optionally new spawn ticket
|
||||
if (distance > 0)
|
||||
addTicket(ChunkTicketType.START, chunkPos, distance, Unit.INSTANCE);
|
||||
addRegionTicket(TicketType.START, chunkPos, distance, Unit.INSTANCE);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,23 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import net.minecraft.server.world.ChunkTicketManager;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ChunkTicketManager.class)
|
||||
@Mixin(DistanceManager.class)
|
||||
public class ChunkTicketManager_tickMixin
|
||||
{
|
||||
@Shadow private long age;
|
||||
@Shadow private long ticketTickCounter;
|
||||
|
||||
@Inject(method = "purge", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "purgeStaleTickets", at = @At("HEAD"), cancellable = true)
|
||||
private void pauseTicketSystem(CallbackInfo ci)
|
||||
{
|
||||
// pausing expiry of tickets
|
||||
// that will prevent also chunks from unloading, so require a deep frozen state
|
||||
if (!TickSpeed.process_entities && TickSpeed.deeplyFrozen()) age--;
|
||||
if (!TickSpeed.process_entities && TickSpeed.deeplyFrozen()) ticketTickCounter--;
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,15 @@ import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import io.netty.util.concurrent.GenericFutureListener;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientConnection.class)
|
||||
@Mixin(Connection.class)
|
||||
public abstract class ClientConnectionMixin implements ClientConnectionInterface
|
||||
{
|
||||
// Add to the packet counter whenever a packet is received.
|
||||
@@ -25,7 +25,7 @@ public abstract class ClientConnectionMixin implements ClientConnectionInterface
|
||||
}
|
||||
|
||||
// Add to the packet counter whenever a packet is sent.
|
||||
@Inject(method = "sendImmediately", at = @At("HEAD"))
|
||||
@Inject(method = "sendPacket", at = @At("HEAD"))
|
||||
private void packetOutCount(Packet<?> packet_1,
|
||||
GenericFutureListener<? extends Future<? super Void>> genericFutureListener_1, CallbackInfo ci)
|
||||
{
|
||||
|
||||
@@ -2,40 +2,40 @@ package carpet.mixins;
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.network.ClientNetworkHandler;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundLoginPacket;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClientPlayNetworkHandler.class)
|
||||
@Mixin(ClientPacketListener.class)
|
||||
public abstract class ClientPlayNetworkHandlerMixin
|
||||
{
|
||||
@Shadow private MinecraftClient client;
|
||||
@Shadow private Minecraft minecraft;
|
||||
|
||||
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
private void onOnCustomPayload(CustomPayloadS2CPacket packet, CallbackInfo ci)
|
||||
@Inject(method = "handleCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
private void onOnCustomPayload(ClientboundCustomPayloadPacket packet, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(packet.getChannel()))
|
||||
if (CarpetClient.CARPET_CHANNEL.equals(packet.getIdentifier()))
|
||||
{
|
||||
ClientNetworkHandler.handleData(packet.getData(), client.player);
|
||||
ClientNetworkHandler.handleData(packet.getData(), minecraft.player);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "onGameJoin", at = @At("RETURN"))
|
||||
private void onGameJoined(GameJoinS2CPacket packet, CallbackInfo info)
|
||||
@Inject(method = "handleLogin", at = @At("RETURN"))
|
||||
private void onGameJoined(ClientboundLoginPacket packet, CallbackInfo info)
|
||||
{
|
||||
CarpetClient.gameJoined(client.player);
|
||||
CarpetClient.gameJoined(minecraft.player);
|
||||
}
|
||||
|
||||
@Inject(method = "onDisconnected", at = @At("HEAD"))
|
||||
private void onCMDisconnected(Text reason, CallbackInfo ci)
|
||||
@Inject(method = "onDisconnect", at = @At("HEAD"))
|
||||
private void onCMDisconnected(Component reason, CallbackInfo ci)
|
||||
{
|
||||
CarpetClient.disconnect();
|
||||
}
|
||||
|
||||
@@ -3,16 +3,16 @@ package carpet.mixins;
|
||||
import carpet.CarpetServer;
|
||||
import carpet.network.CarpetClient;
|
||||
import carpet.settings.SettingsManager;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
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(ClientPlayerEntity.class)
|
||||
@Mixin(LocalPlayer.class)
|
||||
public class ClientPlayerEntity_clientCommandMixin
|
||||
{
|
||||
@Inject(method = "sendChatMessage", at = @At("HEAD"))
|
||||
@Inject(method = "chat", at = @At("HEAD"))
|
||||
private void inspectMessage(String string, CallbackInfo ci)
|
||||
{
|
||||
if (string.startsWith("/call "))
|
||||
@@ -22,11 +22,11 @@ public class ClientPlayerEntity_clientCommandMixin
|
||||
}
|
||||
if (CarpetServer.minecraft_server == null && !CarpetClient.isCarpet())
|
||||
{
|
||||
ClientPlayerEntity playerSource = (ClientPlayerEntity)(Object) this;
|
||||
CarpetServer.settingsManager.inspectClientsideCommand(playerSource.getCommandSource(), string);
|
||||
LocalPlayer playerSource = (LocalPlayer)(Object) this;
|
||||
CarpetServer.settingsManager.inspectClientsideCommand(playerSource.createCommandSourceStack(), string);
|
||||
CarpetServer.extensions.forEach(e -> {
|
||||
SettingsManager sm = e.customSettingsManager();
|
||||
if (sm != null) sm.inspectClientsideCommand(playerSource.getCommandSource(), string);
|
||||
if (sm != null) sm.inspectClientsideCommand(playerSource.createCommandSourceStack(), string);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.server.command.CloneCommand;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.commands.CloneCommands;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -12,20 +12,20 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
|
||||
@Mixin(CloneCommand.class)
|
||||
@Mixin(CloneCommands.class)
|
||||
public abstract class CloneCommandMixin
|
||||
{
|
||||
@ModifyConstant(method = "execute", constant = @Constant(intValue = 32768))
|
||||
@ModifyConstant(method = "clone", constant = @Constant(intValue = 32768))
|
||||
private static int fillLimit(int original) {
|
||||
return CarpetSettings.fillLimit;
|
||||
}
|
||||
|
||||
@Redirect(method = "execute", at = @At(
|
||||
@Redirect(method = "clone", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerWorld;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
|
||||
target = "Lnet/minecraft/server/level/ServerLevel;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
|
||||
))
|
||||
private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1)
|
||||
private static void conditionalUpdating(ServerLevel serverWorld, BlockPos blockPos_1, Block block_1)
|
||||
{
|
||||
if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
|
||||
if (CarpetSettings.fillUpdates) serverWorld.blockUpdated(blockPos_1, block_1);
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package carpet.mixins;
|
||||
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.function.CommandFunctionManager;
|
||||
import net.minecraft.server.ServerFunctionManager;
|
||||
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(CommandFunctionManager.class)
|
||||
@Mixin(ServerFunctionManager.class)
|
||||
public class CommandFunctionManager_tickMixin
|
||||
{
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
@@ -3,8 +3,8 @@ package carpet.mixins;
|
||||
import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -16,35 +16,35 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
|
||||
@Mixin(CommandManager.class)
|
||||
@Mixin(Commands.class)
|
||||
public abstract class CommandManagerMixin
|
||||
{
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private CommandDispatcher<ServerCommandSource> dispatcher;
|
||||
private CommandDispatcher<CommandSourceStack> dispatcher;
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void onRegister(CommandManager.RegistrationEnvironment arg, CallbackInfo ci) {
|
||||
private void onRegister(Commands.CommandSelection arg, CallbackInfo ci) {
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher);
|
||||
CarpetServer.registerCarpetCommands(this.dispatcher, arg);
|
||||
}
|
||||
|
||||
@Inject(method = "execute", at = @At("HEAD"))
|
||||
private void onExecuteBegin(ServerCommandSource serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
|
||||
@Inject(method = "performCommand", at = @At("HEAD"))
|
||||
private void onExecuteBegin(CommandSourceStack serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
|
||||
{
|
||||
if (!CarpetSettings.fillUpdates)
|
||||
CarpetSettings.impendingFillSkipUpdates.set(true);
|
||||
}
|
||||
|
||||
@Inject(method = "execute", at = @At("RETURN"))
|
||||
private void onExecuteEnd(ServerCommandSource serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
|
||||
@Inject(method = "performCommand", at = @At("RETURN"))
|
||||
private void onExecuteEnd(CommandSourceStack serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
|
||||
{
|
||||
CarpetSettings.impendingFillSkipUpdates.set(false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "execute", at = @At(
|
||||
@Redirect(method = "performCommand", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lorg/slf4j/Logger;isDebugEnabled()Z"
|
||||
),
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.screen.slot.Slot;
|
||||
import net.minecraft.screen.slot.SlotActionType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -17,39 +10,46 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.inventory.ClickType;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@Mixin(ScreenHandler.class)
|
||||
@Mixin(AbstractContainerMenu.class)
|
||||
public abstract class ContainerMixin
|
||||
{
|
||||
|
||||
@Shadow public abstract void onSlotClick(int int_1, int int_2, SlotActionType slotActionType_1, PlayerEntity playerEntity_1);
|
||||
@Shadow public abstract void clicked(int int_1, int int_2, ClickType slotActionType_1, Player playerEntity_1);
|
||||
|
||||
@Shadow public abstract void sendContentUpdates();
|
||||
@Shadow public abstract void broadcastChanges();
|
||||
|
||||
@Shadow @Final public DefaultedList<Slot> slots;
|
||||
@Shadow @Final public NonNullList<Slot> slots;
|
||||
|
||||
@Shadow protected abstract void endQuickCraft();
|
||||
@Shadow protected abstract void resetQuickCraft();
|
||||
|
||||
@Shadow public abstract ItemStack getCursorStack();
|
||||
@Shadow public abstract ItemStack getCarried();
|
||||
|
||||
@Inject( method = "internalOnSlotClick", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void onThrowClick(int slotId, int clickData, SlotActionType actionType, PlayerEntity playerEntity, CallbackInfo ci)
|
||||
@Inject( method = "doClick", at = @At(value = "HEAD"), cancellable = true)
|
||||
private void onThrowClick(int slotId, int clickData, ClickType actionType, Player playerEntity, CallbackInfo ci)
|
||||
{
|
||||
if (actionType == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && this.getCursorStack().isEmpty() && slotId >= 0)
|
||||
if (actionType == ClickType.THROW && CarpetSettings.ctrlQCraftingFix && this.getCarried().isEmpty() && slotId >= 0)
|
||||
{
|
||||
ItemStack itemStack_1 = ItemStack.EMPTY;
|
||||
Slot slot_4 = slots.get(slotId);
|
||||
if (/*slot_4 != null && */slot_4.hasStack() && slot_4.canTakeItems(playerEntity))
|
||||
if (/*slot_4 != null && */slot_4.hasItem() && slot_4.mayPickup(playerEntity))
|
||||
{
|
||||
if(slotId == 0 && clickData == 1)
|
||||
{
|
||||
Item craftedItem = slot_4.getStack().getItem();
|
||||
while(slot_4.hasStack() && slot_4.getStack().getItem() == craftedItem)
|
||||
Item craftedItem = slot_4.getItem().getItem();
|
||||
while(slot_4.hasItem() && slot_4.getItem().getItem() == craftedItem)
|
||||
{
|
||||
this.onSlotClick(slotId, 0, SlotActionType.THROW, playerEntity);
|
||||
this.clicked(slotId, 0, ClickType.THROW, playerEntity);
|
||||
}
|
||||
this.sendContentUpdates();
|
||||
this.endQuickCraft();
|
||||
this.broadcastChanges();
|
||||
this.resetQuickCraft();
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,80 +2,80 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.CoralFeatureInterface;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CoralBlock;
|
||||
import net.minecraft.block.CoralParentBlock;
|
||||
import net.minecraft.block.Fertilizable;
|
||||
import net.minecraft.block.MapColor;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.FluidTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.CoralClawFeature;
|
||||
import net.minecraft.world.gen.feature.CoralFeature;
|
||||
import net.minecraft.world.gen.feature.CoralMushroomFeature;
|
||||
import net.minecraft.world.gen.feature.CoralTreeFeature;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseCoralPlantTypeBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.BonemealableBlock;
|
||||
import net.minecraft.world.level.block.CoralPlantBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralClawFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralMushroomFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralTreeFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
|
||||
@Mixin(CoralBlock.class)
|
||||
public abstract class CoralBlockMixin implements Fertilizable
|
||||
@Mixin(CoralPlantBlock.class)
|
||||
public abstract class CoralBlockMixin implements BonemealableBlock
|
||||
{
|
||||
public boolean isFertilizable(BlockView var1, BlockPos var2, BlockState var3, boolean var4)
|
||||
public boolean isValidBonemealTarget(BlockGetter var1, BlockPos var2, BlockState var3, boolean var4)
|
||||
{
|
||||
return CarpetSettings.renewableCoral == CarpetSettings.RenewableCoralMode.EXPANDED
|
||||
|| CarpetSettings.renewableCoral == CarpetSettings.RenewableCoralMode.TRUE
|
||||
&& var3.get(CoralParentBlock.WATERLOGGED)
|
||||
&& var1.getFluidState(var2.up()).isIn(FluidTags.WATER);
|
||||
&& var3.getValue(BaseCoralPlantTypeBlock.WATERLOGGED)
|
||||
&& var1.getFluidState(var2.above()).is(FluidTags.WATER);
|
||||
}
|
||||
|
||||
public boolean canGrow(World var1, Random var2, BlockPos var3, BlockState var4)
|
||||
public boolean isBonemealSuccess(Level var1, Random var2, BlockPos var3, BlockState var4)
|
||||
{
|
||||
return (double)var1.random.nextFloat() < 0.15D;
|
||||
}
|
||||
|
||||
public void grow(ServerWorld worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
public void performBonemeal(ServerLevel worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
{
|
||||
|
||||
CoralFeature coral;
|
||||
int variant = random.nextInt(3);
|
||||
if (variant == 0)
|
||||
coral = new CoralClawFeature(DefaultFeatureConfig.CODEC);
|
||||
coral = new CoralClawFeature(NoneFeatureConfiguration.CODEC);
|
||||
else if (variant == 1)
|
||||
coral = new CoralTreeFeature(DefaultFeatureConfig.CODEC);
|
||||
coral = new CoralTreeFeature(NoneFeatureConfiguration.CODEC);
|
||||
else
|
||||
coral = new CoralMushroomFeature(DefaultFeatureConfig.CODEC);
|
||||
coral = new CoralMushroomFeature(NoneFeatureConfiguration.CODEC);
|
||||
|
||||
MapColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
MaterialColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
BlockState proper_block = blockUnder;
|
||||
for (Block block: BlockTags.CORAL_BLOCKS.values())
|
||||
for (Block block: BlockTags.CORAL_BLOCKS.getValues())
|
||||
{
|
||||
proper_block = block.getDefaultState();
|
||||
proper_block = block.defaultBlockState();
|
||||
if (proper_block.getMapColor(worldIn,pos) == color)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
worldIn.setBlockState(pos, Blocks.WATER.getDefaultState(), 4);
|
||||
worldIn.setBlock(pos, Blocks.WATER.defaultBlockState(), 4);
|
||||
|
||||
if (!((CoralFeatureInterface)coral).growSpecific(worldIn, random, pos, proper_block))
|
||||
{
|
||||
worldIn.setBlockState(pos, blockUnder, 3);
|
||||
worldIn.setBlock(pos, blockUnder, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (worldIn.random.nextInt(10)==0)
|
||||
{
|
||||
BlockPos randomPos = pos.add(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
|
||||
BlockPos randomPos = pos.offset(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
|
||||
if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
|
||||
{
|
||||
worldIn.setBlockState(randomPos, Blocks.WET_SPONGE.getDefaultState(), 3);
|
||||
worldIn.setBlock(randomPos, Blocks.WET_SPONGE.defaultBlockState(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,69 +2,79 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.CoralFeatureInterface;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.tag.BlockTags;
|
||||
import net.minecraft.tag.FluidTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.*;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.BaseCoralPlantTypeBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.BonemealableBlock;
|
||||
import net.minecraft.world.level.block.CoralFanBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralClawFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralMushroomFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralTreeFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;
|
||||
import net.minecraft.world.level.material.MaterialColor;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Mixin(CoralFanBlock.class)
|
||||
public abstract class CoralFanBlockMixin implements Fertilizable
|
||||
public abstract class CoralFanBlockMixin implements BonemealableBlock
|
||||
{
|
||||
public boolean isFertilizable(BlockView var1, BlockPos var2, BlockState var3, boolean var4)
|
||||
public boolean isValidBonemealTarget(BlockGetter var1, BlockPos var2, BlockState var3, boolean var4)
|
||||
{
|
||||
return CarpetSettings.renewableCoral == CarpetSettings.RenewableCoralMode.EXPANDED
|
||||
&& var3.get(CoralParentBlock.WATERLOGGED)
|
||||
&& var1.getFluidState(var2.up()).isIn(FluidTags.WATER);
|
||||
&& var3.getValue(BaseCoralPlantTypeBlock.WATERLOGGED)
|
||||
&& var1.getFluidState(var2.above()).is(FluidTags.WATER);
|
||||
}
|
||||
|
||||
public boolean canGrow(World var1, Random var2, BlockPos var3, BlockState var4)
|
||||
public boolean isBonemealSuccess(Level var1, Random var2, BlockPos var3, BlockState var4)
|
||||
{
|
||||
return (double)var1.random.nextFloat() < 0.15D;
|
||||
}
|
||||
|
||||
public void grow(ServerWorld worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
public void performBonemeal(ServerLevel worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
{
|
||||
|
||||
CoralFeature coral;
|
||||
int variant = random.nextInt(3);
|
||||
if (variant == 0)
|
||||
coral = new CoralClawFeature(DefaultFeatureConfig.CODEC);
|
||||
coral = new CoralClawFeature(NoneFeatureConfiguration.CODEC);
|
||||
else if (variant == 1)
|
||||
coral = new CoralTreeFeature(DefaultFeatureConfig.CODEC);
|
||||
coral = new CoralTreeFeature(NoneFeatureConfiguration.CODEC);
|
||||
else
|
||||
coral = new CoralMushroomFeature(DefaultFeatureConfig.CODEC);
|
||||
coral = new CoralMushroomFeature(NoneFeatureConfiguration.CODEC);
|
||||
|
||||
MapColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
MaterialColor color = blockUnder.getMapColor(worldIn, pos);
|
||||
BlockState proper_block = blockUnder;
|
||||
for (Block block: BlockTags.CORAL_BLOCKS.values())
|
||||
for (Block block: BlockTags.CORAL_BLOCKS.getValues())
|
||||
{
|
||||
proper_block = block.getDefaultState();
|
||||
proper_block = block.defaultBlockState();
|
||||
if (proper_block.getMapColor(worldIn,pos) == color)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
worldIn.setBlockState(pos, Blocks.WATER.getDefaultState(), 4);
|
||||
worldIn.setBlock(pos, Blocks.WATER.defaultBlockState(), 4);
|
||||
|
||||
if (!((CoralFeatureInterface)coral).growSpecific(worldIn, random, pos, proper_block))
|
||||
{
|
||||
worldIn.setBlockState(pos, blockUnder, 3);
|
||||
worldIn.setBlock(pos, blockUnder, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (worldIn.random.nextInt(10)==0)
|
||||
{
|
||||
BlockPos randomPos = pos.add(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
|
||||
BlockPos randomPos = pos.offset(worldIn.random.nextInt(16)-8,worldIn.random.nextInt(8),worldIn.random.nextInt(16)-8 );
|
||||
if (BlockTags.CORAL_BLOCKS.contains(worldIn.getBlockState(randomPos).getBlock()))
|
||||
{
|
||||
worldIn.setBlockState(randomPos, Blocks.WET_SPONGE.getDefaultState(), 3);
|
||||
worldIn.setBlock(randomPos, Blocks.WET_SPONGE.defaultBlockState(), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.CoralFeatureInterface;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.gen.feature.CoralFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.feature.CoralFeature;
|
||||
|
||||
@Mixin(CoralFeature.class)
|
||||
public abstract class CoralFeatureMixin implements CoralFeatureInterface
|
||||
{
|
||||
|
||||
@Shadow protected abstract boolean generateCoral(WorldAccess var1, Random var2, BlockPos var3, BlockState var4);
|
||||
@Shadow protected abstract boolean placeFeature(LevelAccessor var1, Random var2, BlockPos var3, BlockState var4);
|
||||
|
||||
@Override
|
||||
public boolean growSpecific(World worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
public boolean growSpecific(Level worldIn, Random random, BlockPos pos, BlockState blockUnder)
|
||||
{
|
||||
return generateCoral(worldIn, random, pos, blockUnder);
|
||||
return placeFeature(worldIn, random, pos, blockUnder);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,7 @@ package carpet.mixins;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.util.SystemDetails;
|
||||
import net.minecraft.SystemReport;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -12,15 +11,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
|
||||
@Mixin(SystemDetails.class)
|
||||
@Mixin(SystemReport.class)
|
||||
public abstract class CrashReport_addScarpetAppsMixin
|
||||
{
|
||||
@Shadow public abstract void addSection(String name, Supplier<String> valueSupplier);
|
||||
@Shadow public abstract void setDetail(String name, Supplier<String> valueSupplier);
|
||||
|
||||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void fillSystemDetails(CallbackInfo info) {
|
||||
if (CarpetServer.scriptServer == null || CarpetServer.scriptServer.modules.isEmpty()) return;
|
||||
addSection("Loaded Scarpet Apps", () -> {
|
||||
setDetail("Loaded Scarpet Apps", () -> {
|
||||
return CarpetServer.scriptServer.modules.keySet().stream().collect(Collectors.joining("\n\t\t", "\n\t\t", ""));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.network.CarpetClient;
|
||||
import net.minecraft.client.render.debug.DebugRenderer;
|
||||
import net.minecraft.client.renderer.debug.DebugRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(DebugRenderer.class)
|
||||
public class DebugRenderer_scarpetRenderMixin
|
||||
{
|
||||
@Inject(method = "reset", at = @At("HEAD"))
|
||||
@Inject(method = "clear", at = @At("HEAD"))
|
||||
private void resetScarpetRenderes(CallbackInfo ci)
|
||||
{
|
||||
if (CarpetClient.shapes != null)
|
||||
|
||||
@@ -3,16 +3,11 @@ package carpet.mixins;
|
||||
import carpet.CarpetSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.gen.feature.DefaultFeatureConfig;
|
||||
import net.minecraft.world.gen.feature.DesertPyramidFeature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.world.level.levelgen.feature.DesertPyramidFeature;
|
||||
|
||||
@Mixin(DesertPyramidFeature.class)
|
||||
public abstract class DesertPyramidFeatureMixin
|
||||
|
||||
@@ -3,8 +3,8 @@ package carpet.mixins;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.helpers.BlockRotator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -12,13 +12,13 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(Direction.class)
|
||||
public abstract class DirectionMixin
|
||||
{
|
||||
@Redirect(method = "getEntityFacingOrder", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getYaw(F)F"))
|
||||
@Redirect(method = "orderedByNearest", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getViewYRot(F)F"))
|
||||
private static float getYaw(Entity entity, float float_1)
|
||||
{
|
||||
float yaw;
|
||||
if (!CarpetSettings.placementRotationFix)
|
||||
{
|
||||
yaw = entity.getYaw(float_1);
|
||||
yaw = entity.getViewYRot(float_1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -30,10 +30,10 @@ public abstract class DirectionMixin
|
||||
}
|
||||
return yaw;
|
||||
}
|
||||
@Redirect(method = "getEntityFacingOrder", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;getPitch(F)F"))
|
||||
@Redirect(method = "orderedByNearest", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getViewXRot(F)F"))
|
||||
private static float getPitch(Entity entity, float float_1)
|
||||
{
|
||||
float pitch = entity.getPitch(float_1);
|
||||
float pitch = entity.getViewXRot(float_1);
|
||||
if (BlockRotator.flippinEligibility(entity))
|
||||
{
|
||||
pitch = -pitch;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.BlockRotator;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.block.dispenser.DispenserBehavior;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.core.dispenser.DispenseItemBehavior;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -14,8 +14,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(DispenserBlock.class)
|
||||
public abstract class DispenserBlock_cactusMixin
|
||||
{
|
||||
@Inject(method = "getBehaviorForItem", at = @At("HEAD"), cancellable = true)
|
||||
private void registerCarpetBehaviors(ItemStack stack, CallbackInfoReturnable<DispenserBehavior> cir)
|
||||
@Inject(method = "getDispenseMethod", at = @At("HEAD"), cancellable = true)
|
||||
private void registerCarpetBehaviors(ItemStack stack, CallbackInfoReturnable<DispenseItemBehavior> cir)
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
if (item == Items.CACTUS)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -11,15 +11,15 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(DispenserBlock.class)
|
||||
public class DispenserBlock_qcMixin
|
||||
{
|
||||
@Redirect(method = "neighborUpdate", at = @At(
|
||||
@Redirect(method = "neighborChanged", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;isReceivingRedstonePower(Lnet/minecraft/util/math/BlockPos;)Z",
|
||||
target = "Lnet/minecraft/world/level/Level;hasNeighborSignal(Lnet/minecraft/core/BlockPos;)Z",
|
||||
ordinal = 1
|
||||
))
|
||||
private boolean checkUpPower(World world, BlockPos blockPos_1)
|
||||
private boolean checkUpPower(Level world, BlockPos blockPos_1)
|
||||
{
|
||||
if (!CarpetSettings.quasiConnectivity)
|
||||
return false;
|
||||
return world.isReceivingRedstonePower(blockPos_1);
|
||||
return world.hasNeighborSignal(blockPos_1);
|
||||
}
|
||||
}
|
||||
@@ -3,16 +3,11 @@ package carpet.mixins;
|
||||
import carpet.CarpetSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
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 net.minecraft.world.level.levelgen.feature.EndCityFeature;
|
||||
|
||||
@Mixin(EndCityFeature.class)
|
||||
public abstract class EndCityFeatureMixin //extends StructureFeature<DefaultFeatureConfig>
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.entity.EndGatewayBlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity;
|
||||
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(EndGatewayBlockEntity.class)
|
||||
@Mixin(TheEndGatewayBlockEntity.class)
|
||||
public class EndGatewayBlockEntity_creativeNoClipMixin
|
||||
{
|
||||
@Inject(method = "canTeleport", cancellable = true, at = @At("HEAD"))
|
||||
@Inject(method = "canEntityTeleport", cancellable = true, at = @At("HEAD"))
|
||||
private static void checkFlyingCreative(Entity entity, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.isCreativeFlying(entity)) cir.setReturnValue(false);
|
||||
|
||||
@@ -2,9 +2,9 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -16,23 +16,23 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public abstract class EntityMixin implements EntityInterface
|
||||
{
|
||||
@Shadow
|
||||
public float yaw;
|
||||
public float yRot;
|
||||
|
||||
@Shadow
|
||||
public float prevYaw;
|
||||
public float yRotO;
|
||||
|
||||
@Shadow public @Nullable abstract Entity getPrimaryPassenger();
|
||||
@Shadow public @Nullable abstract Entity getControllingPassenger();
|
||||
|
||||
@Shadow public World world;
|
||||
@Shadow public Level level;
|
||||
|
||||
public float getMainYaw(float partialTicks)
|
||||
{
|
||||
return partialTicks == 1.0F ? this.yaw : MathHelper.lerp(partialTicks, this.prevYaw, this.yaw);
|
||||
return partialTicks == 1.0F ? this.yRot : Mth.lerp(partialTicks, this.yRotO, this.yRot);
|
||||
}
|
||||
|
||||
@Inject(method = "isLogicalSideForUpdatingMovement", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "isControlledByLocalInstance", at = @At("HEAD"), cancellable = true)
|
||||
private void isFakePlayer(CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (getPrimaryPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!world.isClient);
|
||||
if (getControllingPassenger() instanceof EntityPlayerMPFake) cir.setReturnValue(!level.isClientSide);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,6 @@ package carpet.mixins;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.logging.logHelpers.PathfindingVisualizer;
|
||||
import net.minecraft.entity.ai.pathing.EntityNavigation;
|
||||
import net.minecraft.entity.ai.pathing.Path;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -15,45 +10,50 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.navigation.PathNavigation;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@Mixin(EntityNavigation.class)
|
||||
@Mixin(PathNavigation.class)
|
||||
public abstract class EntityNavigation_pathfindingMixin
|
||||
{
|
||||
|
||||
@Shadow @Final protected MobEntity entity;
|
||||
@Shadow @Final protected Mob mob;
|
||||
|
||||
|
||||
@Shadow protected @Nullable abstract Path findPathTo(Set<BlockPos> set, int i, boolean bl, int j);
|
||||
@Shadow protected @Nullable abstract Path createPath(Set<BlockPos> set, int i, boolean bl, int j);
|
||||
|
||||
@Redirect(method = "findPathTo(Lnet/minecraft/util/math/BlockPos;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At(
|
||||
@Redirect(method = "createPath(Lnet/minecraft/core/BlockPos;I)Lnet/minecraft/world/level/pathfinder/Path;", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathTo(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;"
|
||||
target = "Lnet/minecraft/world/entity/ai/navigation/PathNavigation;createPath(Ljava/util/Set;IZI)Lnet/minecraft/world/level/pathfinder/Path;"
|
||||
))
|
||||
private Path pathToBlock(EntityNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2)
|
||||
private Path pathToBlock(PathNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2)
|
||||
{
|
||||
if (!LoggerRegistry.__pathfinding)
|
||||
return findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
return createPath(set_1, int_1, boolean_1, int_2);
|
||||
long start = System.nanoTime();
|
||||
Path path = findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
Path path = createPath(set_1, int_1, boolean_1, int_2);
|
||||
long finish = System.nanoTime();
|
||||
float duration = (1.0F*((finish - start)/1000))/1000;
|
||||
set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null)); // ground centered position
|
||||
set_1.forEach(b -> PathfindingVisualizer.slowPath(mob, Vec3.atBottomCenterOf(b), duration, path != null)); // ground centered position
|
||||
return path;
|
||||
}
|
||||
|
||||
@Redirect(method = "findPathTo(Lnet/minecraft/entity/Entity;I)Lnet/minecraft/entity/ai/pathing/Path;", at = @At(
|
||||
@Redirect(method = "createPath(Lnet/minecraft/world/entity/Entity;I)Lnet/minecraft/world/level/pathfinder/Path;", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/ai/pathing/EntityNavigation;findPathTo(Ljava/util/Set;IZI)Lnet/minecraft/entity/ai/pathing/Path;"
|
||||
target = "Lnet/minecraft/world/entity/ai/navigation/PathNavigation;createPath(Ljava/util/Set;IZI)Lnet/minecraft/world/level/pathfinder/Path;"
|
||||
))
|
||||
private Path pathToEntity(EntityNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2)
|
||||
private Path pathToEntity(PathNavigation entityNavigation, Set<BlockPos> set_1, int int_1, boolean boolean_1, int int_2)
|
||||
{
|
||||
if (!LoggerRegistry.__pathfinding)
|
||||
return findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
return createPath(set_1, int_1, boolean_1, int_2);
|
||||
long start = System.nanoTime();
|
||||
Path path = findPathTo(set_1, int_1, boolean_1, int_2);
|
||||
Path path = createPath(set_1, int_1, boolean_1, int_2);
|
||||
long finish = System.nanoTime();
|
||||
float duration = (1.0F*((finish - start)/1000))/1000;
|
||||
set_1.forEach(b -> PathfindingVisualizer.slowPath(entity, Vec3d.ofBottomCenter(b), duration, path != null));
|
||||
set_1.forEach(b -> PathfindingVisualizer.slowPath(mob, Vec3.atBottomCenterOf(b), duration, path != null));
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.network.packet.s2c.play.EntityAttachS2CPacket;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.server.network.EntityTrackerEntry;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -14,20 +9,25 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket;
|
||||
import net.minecraft.server.level.ServerEntity;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
||||
@Mixin(EntityTrackerEntry.class)
|
||||
@Mixin(ServerEntity.class)
|
||||
public class EntityTrackerEntry_leashFixMixin
|
||||
{
|
||||
@Shadow @Final private Entity entity;
|
||||
|
||||
@Inject(method = "sendPackets", at = @At("RETURN"))
|
||||
@Inject(method = "sendPairingData", at = @At("RETURN"))
|
||||
private void sendLeashPackets(Consumer<Packet<?>> consumer_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.leadFix)
|
||||
{
|
||||
if (entity instanceof MobEntity)
|
||||
if (entity instanceof Mob)
|
||||
{
|
||||
consumer_1.accept( new EntityAttachS2CPacket(entity, ((MobEntity) entity).getHoldingEntity()));
|
||||
consumer_1.accept( new ClientboundSetEntityLinkPacket(entity, ((Mob) entity).getLeashHolder()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -15,18 +15,18 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
{
|
||||
//@Shadow public boolean removed;
|
||||
|
||||
@Shadow protected int netherPortalTime;
|
||||
@Shadow private int netherPortalCooldown;
|
||||
@Shadow protected int portalTime;
|
||||
@Shadow private int portalCooldown;
|
||||
|
||||
@Shadow public abstract boolean isRemoved();
|
||||
|
||||
@Shadow private Vec3d pos, velocity;
|
||||
@Shadow private Vec3 position, deltaMovement;
|
||||
|
||||
private boolean permanentVehicle;
|
||||
|
||||
private final EntityEventsGroup events = new EntityEventsGroup((Entity) (Object)this);
|
||||
|
||||
private Vec3d pos1, motion;
|
||||
private Vec3 pos1, motion;
|
||||
|
||||
@Override
|
||||
public EntityEventsGroup getEventContainer()
|
||||
@@ -49,25 +49,25 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
@Override
|
||||
public int getPublicNetherPortalCooldown()
|
||||
{
|
||||
return netherPortalCooldown;
|
||||
return portalCooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPublicNetherPortalCooldown(int what)
|
||||
{
|
||||
netherPortalCooldown = what;
|
||||
portalCooldown = what;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPortalTimer()
|
||||
{
|
||||
return netherPortalTime;
|
||||
return portalTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPortalTimer(int amount)
|
||||
{
|
||||
netherPortalTime = amount;
|
||||
portalTime = amount;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
@@ -84,17 +84,17 @@ public abstract class Entity_scarpetEventsMixin implements EntityInterface
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "setPos", at = @At("HEAD"))
|
||||
@Inject(method = "setPosRaw", at = @At("HEAD"))
|
||||
private void firstPos(CallbackInfo ci)
|
||||
{
|
||||
pos1 = this.pos;
|
||||
motion = this.velocity;
|
||||
pos1 = this.position;
|
||||
motion = this.deltaMovement;
|
||||
}
|
||||
|
||||
@Inject(method = "setPos", at = @At("TAIL"))
|
||||
@Inject(method = "setPosRaw", at = @At("TAIL"))
|
||||
private void secondPos(CallbackInfo ci)
|
||||
{
|
||||
if(pos1!=this.pos)
|
||||
events.onEvent(EntityEventsGroup.Event.ON_MOVE, motion, pos1, this.pos);
|
||||
if(pos1!=this.position)
|
||||
events.onEvent(EntityEventsGroup.Event.ON_MOVE, motion, pos1, this.position);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +1,45 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ExperienceOrb;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ExperienceOrbEntity.class)
|
||||
@Mixin(ExperienceOrb.class)
|
||||
public abstract class ExperienceOrbEntityMixin extends Entity
|
||||
{
|
||||
@Shadow
|
||||
private int pickingCount;
|
||||
private int count;
|
||||
|
||||
@Shadow
|
||||
private int amount;
|
||||
private int value;
|
||||
|
||||
public ExperienceOrbEntityMixin(EntityType<?> type, World world)
|
||||
public ExperienceOrbEntityMixin(EntityType<?> type, Level world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Shadow
|
||||
protected abstract int repairPlayerGears(PlayerEntity player, int amount);
|
||||
protected abstract int repairPlayerItems(Player player, int amount);
|
||||
|
||||
@Inject(method = "onPlayerCollision", at = @At("HEAD"))
|
||||
private void addXP(PlayerEntity player, CallbackInfo ci) {
|
||||
if (CarpetSettings.xpNoCooldown && !world.isClient) {
|
||||
player.experiencePickUpDelay = 0;
|
||||
@Inject(method = "playerTouch", at = @At("HEAD"))
|
||||
private void addXP(Player player, CallbackInfo ci) {
|
||||
if (CarpetSettings.xpNoCooldown && !level.isClientSide) {
|
||||
player.takeXpDelay = 0;
|
||||
// reducing the count to 1 and leaving vanilla to deal with it
|
||||
while (this.pickingCount > 1) {
|
||||
int remainder = this.repairPlayerGears(player, this.amount);
|
||||
while (this.count > 1) {
|
||||
int remainder = this.repairPlayerItems(player, this.value);
|
||||
if (remainder > 0) {
|
||||
player.addExperience(remainder);
|
||||
player.giveExperiencePoints(remainder);
|
||||
}
|
||||
this.pickingCount--;
|
||||
this.count--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(Explosion.class)
|
||||
public interface ExplosionAccessor {
|
||||
|
||||
@Accessor
|
||||
boolean isCreateFire();
|
||||
boolean isFire();
|
||||
|
||||
@Accessor
|
||||
Explosion.DestructionType getDestructionType();
|
||||
Explosion.BlockInteraction getBlockInteraction();
|
||||
|
||||
@Accessor
|
||||
World getWorld();
|
||||
Level getLevel();
|
||||
|
||||
@Accessor
|
||||
Random getRandom();
|
||||
@@ -33,9 +33,9 @@ public interface ExplosionAccessor {
|
||||
double getZ();
|
||||
|
||||
@Accessor
|
||||
float getPower();
|
||||
float getRadius();
|
||||
|
||||
@Accessor
|
||||
Entity getEntity();
|
||||
Entity getSource();
|
||||
|
||||
}
|
||||
@@ -4,15 +4,6 @@ import carpet.helpers.OptimizedExplosion;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.logging.logHelpers.ExplosionLogHelper;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import net.minecraft.world.explosion.ExplosionBehavior;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -22,19 +13,28 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
@Mixin(value = Explosion.class)
|
||||
public abstract class ExplosionMixin
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private List<BlockPos> affectedBlocks;
|
||||
private List<BlockPos> toBlow;
|
||||
|
||||
@Shadow @Final private World world;
|
||||
@Shadow @Final private Level level;
|
||||
|
||||
private ExplosionLogHelper eLogger;
|
||||
|
||||
@Inject(method = "collectBlocksAndDamageEntities", at = @At("HEAD"),
|
||||
@Inject(method = "explode", at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void onExplosionA(CallbackInfo ci)
|
||||
{
|
||||
@@ -45,18 +45,18 @@ public abstract class ExplosionMixin
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "affectWorld", at = @At("HEAD"),
|
||||
@Inject(method = "finalizeExplosion", at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void onExplosionB(boolean spawnParticles, CallbackInfo ci)
|
||||
{
|
||||
if (eLogger != null)
|
||||
{
|
||||
eLogger.setAffectBlocks( ! affectedBlocks.isEmpty());
|
||||
eLogger.onExplosionDone(this.world.getTime());
|
||||
eLogger.setAffectBlocks( ! toBlow.isEmpty());
|
||||
eLogger.onExplosionDone(this.level.getGameTime());
|
||||
}
|
||||
if (CarpetSettings.explosionNoBlockDamage)
|
||||
{
|
||||
affectedBlocks.clear();
|
||||
toBlow.clear();
|
||||
}
|
||||
if (CarpetSettings.optimizedTNT)
|
||||
{
|
||||
@@ -66,31 +66,31 @@ public abstract class ExplosionMixin
|
||||
}
|
||||
//optional due to Overwrite in Lithium
|
||||
//should kill most checks if no block damage is requested
|
||||
@Redirect(method = "collectBlocksAndDamageEntities", require = 0, at = @At(value = "INVOKE",
|
||||
target ="Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/BlockState;"))
|
||||
private BlockState noBlockCalcsWithNoBLockDamage(World world, BlockPos pos)
|
||||
@Redirect(method = "explode", require = 0, at = @At(value = "INVOKE",
|
||||
target ="Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
|
||||
private BlockState noBlockCalcsWithNoBLockDamage(Level world, BlockPos pos)
|
||||
{
|
||||
if (CarpetSettings.explosionNoBlockDamage) return Blocks.BEDROCK.getDefaultState();
|
||||
if (CarpetSettings.explosionNoBlockDamage) return Blocks.BEDROCK.defaultBlockState();
|
||||
return world.getBlockState(pos);
|
||||
}
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/damage/DamageSource;Lnet/minecraft/world/explosion/ExplosionBehavior;DDDFZLnet/minecraft/world/explosion/Explosion$DestructionType;)V",
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void onExplosionCreated(World world, Entity entity, DamageSource damageSource, ExplosionBehavior explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType, CallbackInfo ci)
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__explosions && ! world.isClient)
|
||||
if (LoggerRegistry.__explosions && ! world.isClientSide)
|
||||
{
|
||||
eLogger = new ExplosionLogHelper(entity, x, y, z, power, createFire, destructionType);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "collectBlocksAndDamageEntities",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(Lnet/minecraft/util/math/Vec3d;)V"))
|
||||
private void setVelocityAndUpdateLogging(Entity entity, Vec3d velocity)
|
||||
@Redirect(method = "explode",
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"))
|
||||
private void setVelocityAndUpdateLogging(Entity entity, Vec3 velocity)
|
||||
{
|
||||
if (eLogger != null) {
|
||||
eLogger.onEntityImpacted(entity, velocity.subtract(entity.getVelocity()));
|
||||
eLogger.onEntityImpacted(entity, velocity.subtract(entity.getDeltaMovement()));
|
||||
}
|
||||
entity.setVelocity(velocity);
|
||||
entity.setDeltaMovement(velocity);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.explosion.Explosion;
|
||||
import net.minecraft.world.explosion.ExplosionBehavior;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -22,57 +13,66 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Explosion;
|
||||
import net.minecraft.world.level.ExplosionDamageCalculator;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.EXPLOSION_OUTCOME;
|
||||
|
||||
@Mixin(value = Explosion.class, priority = 990)
|
||||
public abstract class Explosion_scarpetEventMixin
|
||||
{
|
||||
@Shadow @Final private World world;
|
||||
@Shadow @Final private Level level;
|
||||
@Shadow @Final private double x;
|
||||
@Shadow @Final private double y;
|
||||
@Shadow @Final private double z;
|
||||
@Shadow @Final private float power;
|
||||
@Shadow @Final private boolean createFire;
|
||||
@Shadow @Final private List<BlockPos> affectedBlocks;
|
||||
@Shadow @Final private Explosion.DestructionType destructionType;
|
||||
@Shadow @Final private @Nullable Entity entity;
|
||||
@Shadow @Final private float radius;
|
||||
@Shadow @Final private boolean fire;
|
||||
@Shadow @Final private List<BlockPos> toBlow;
|
||||
@Shadow @Final private Explosion.BlockInteraction blockInteraction;
|
||||
@Shadow @Final private @Nullable Entity source;
|
||||
|
||||
@Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getCausingEntity();
|
||||
@Shadow /*@Nullable*/ public abstract /*@Nullable*/ LivingEntity getSourceMob();
|
||||
|
||||
@Shadow public static float getExposure(Vec3d source, Entity entity) {return 0.0f;}
|
||||
@Shadow public static float getSeenPercent(Vec3 source, Entity entity) {return 0.0f;}
|
||||
|
||||
private List<Entity> affectedEntities;
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/damage/DamageSource;Lnet/minecraft/world/explosion/ExplosionBehavior;DDDFZLnet/minecraft/world/explosion/Explosion$DestructionType;)V",
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;Lnet/minecraft/world/level/ExplosionDamageCalculator;DDDFZLnet/minecraft/world/level/Explosion$BlockInteraction;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void onExplosionCreated(World world, Entity entity, DamageSource damageSource, ExplosionBehavior explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.DestructionType destructionType, CallbackInfo ci)
|
||||
private void onExplosionCreated(Level world, Entity entity, DamageSource damageSource, ExplosionDamageCalculator explosionBehavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType, CallbackInfo ci)
|
||||
{
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClient())
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClientSide())
|
||||
{
|
||||
affectedEntities = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "collectBlocksAndDamageEntities", at=@At(
|
||||
@Redirect(method = "explode", at=@At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/explosion/Explosion;getExposure(Lnet/minecraft/util/math/Vec3d;Lnet/minecraft/entity/Entity;)F")
|
||||
target = "Lnet/minecraft/world/level/Explosion;getSeenPercent(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)F")
|
||||
)
|
||||
private float onExplosion(Vec3d source, Entity entity)
|
||||
private float onExplosion(Vec3 source, Entity entity)
|
||||
{
|
||||
if (affectedEntities != null)
|
||||
{
|
||||
affectedEntities.add(entity);
|
||||
}
|
||||
return getExposure(source, entity);
|
||||
return getSeenPercent(source, entity);
|
||||
}
|
||||
|
||||
@Inject(method = "affectWorld", at = @At("HEAD"))
|
||||
@Inject(method = "finalizeExplosion", at = @At("HEAD"))
|
||||
private void onExplosion(boolean spawnParticles, CallbackInfo ci)
|
||||
{
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !world.isClient())
|
||||
if (EXPLOSION_OUTCOME.isNeeded() && !level.isClientSide())
|
||||
{
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerWorld) world, entity, this::getCausingEntity, x, y, z, power, createFire, affectedBlocks, affectedEntities, destructionType);
|
||||
EXPLOSION_OUTCOME.onExplosion((ServerLevel) level, source, this::getSourceMob, x, y, z, radius, fire, toBlow, affectedEntities, blockInteraction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,11 @@ package carpet.mixins;
|
||||
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.logging.logHelpers.TrajectoryLogHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.FallingBlockEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
import net.minecraft.world.entity.projectile.Projectile;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -16,12 +16,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
public abstract class FallingBlockEntityMixin extends Entity
|
||||
{
|
||||
private TrajectoryLogHelper logHelper;
|
||||
public FallingBlockEntityMixin(EntityType<?> entityType_1, World world_1) { super(entityType_1, world_1); }
|
||||
public FallingBlockEntityMixin(EntityType<?> entityType_1, Level world_1) { super(entityType_1, world_1); }
|
||||
|
||||
@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", at = @At("RETURN"))
|
||||
private void addLogger(EntityType<? extends ProjectileEntity> entityType_1, World world_1, CallbackInfo ci)
|
||||
@Inject(method = "<init>(Lnet/minecraft/world/entity/EntityType;Lnet/minecraft/world/level/Level;)V", at = @At("RETURN"))
|
||||
private void addLogger(EntityType<? extends Projectile> entityType_1, Level world_1, CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__fallingBlocks && !world_1.isClient)
|
||||
if (LoggerRegistry.__fallingBlocks && !world_1.isClientSide)
|
||||
logHelper = new TrajectoryLogHelper("fallingBlocks");
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public abstract class FallingBlockEntityMixin extends Entity
|
||||
private void tickCheck(CallbackInfo ci)
|
||||
{
|
||||
if (LoggerRegistry.__fallingBlocks && logHelper != null)
|
||||
logHelper.onTick(getX(), getY(), getZ(), getVelocity());
|
||||
logHelper.onTick(getX(), getY(), getZ(), getDeltaMovement());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,10 +2,10 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.FallingBlockEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.item.FallingBlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(FallingBlockEntity.class)
|
||||
public abstract class FallingBlockEntity_scarpetEventsMixin extends Entity
|
||||
{
|
||||
public FallingBlockEntity_scarpetEventsMixin(EntityType<?> type, World world)
|
||||
public FallingBlockEntity_scarpetEventsMixin(EntityType<?> type, Level world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.server.command.FillCommand;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.commands.FillCommand;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
@@ -14,18 +14,18 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(FillCommand.class)
|
||||
public abstract class FillCommandMixin
|
||||
{
|
||||
@ModifyConstant(method = "execute", constant = @Constant(intValue = 32768))
|
||||
@ModifyConstant(method = "fillBlocks", constant = @Constant(intValue = 32768))
|
||||
private static int fillLimit(int original)
|
||||
{
|
||||
return CarpetSettings.fillLimit;
|
||||
}
|
||||
|
||||
@Redirect(method = "execute", at = @At(
|
||||
@Redirect(method = "fillBlocks", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerWorld;updateNeighbors(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/Block;)V"
|
||||
target = "Lnet/minecraft/server/level/ServerLevel;blockUpdated(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/Block;)V"
|
||||
))
|
||||
private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1)
|
||||
private static void conditionalUpdating(ServerLevel serverWorld, BlockPos blockPos_1, Block block_1)
|
||||
{
|
||||
if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
|
||||
if (CarpetSettings.fillUpdates) serverWorld.blockUpdated(blockPos_1, block_1);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.RandomTools;
|
||||
import net.minecraft.entity.projectile.FireworkRocketEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
||||
|
||||
@Mixin(FireworkRocketEntity.class)
|
||||
public class FireworkEntity_extremeMixin
|
||||
{
|
||||
@Redirect(method = "<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", expect = 2, at = @At(
|
||||
@Redirect(method = "<init>(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", expect = 2, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Random;nextGaussian()D"
|
||||
))
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.RandomTools;
|
||||
import net.minecraft.entity.projectile.FishingBobberEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.entity.projectile.FishingHook;
|
||||
|
||||
@Mixin(FishingBobberEntity.class)
|
||||
@Mixin(FishingHook.class)
|
||||
public class FishingBobberEntity_extremeMixin
|
||||
{
|
||||
@Redirect(method = "<init>(Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/world/World;II)V", expect =3, at = @At(
|
||||
@Redirect(method = "<init>(Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/Level;II)V", expect =3, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Random;nextGaussian()D"
|
||||
))
|
||||
|
||||
@@ -2,91 +2,91 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.CustomSpawnLists;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.FlatChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
import net.minecraft.world.gen.feature.NetherFortressFeature;
|
||||
import net.minecraft.world.gen.feature.OceanMonumentFeature;
|
||||
import net.minecraft.world.gen.feature.PillagerOutpostFeature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import net.minecraft.world.gen.feature.SwampHutFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.FlatLevelSource;
|
||||
import net.minecraft.world.level.levelgen.StructureSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.NetherFortressFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.OceanMonumentFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.PillagerOutpostFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.SwamplandHutFeature;
|
||||
|
||||
@Mixin(FlatChunkGenerator.class)
|
||||
@Mixin(FlatLevelSource.class)
|
||||
public abstract class FlatChunkGeneratorMixin extends ChunkGenerator
|
||||
{
|
||||
|
||||
public FlatChunkGeneratorMixin(BiomeSource biomeSource, StructuresConfig structuresConfig)
|
||||
public FlatChunkGeneratorMixin(BiomeSource biomeSource, StructureSettings structuresConfig)
|
||||
{
|
||||
super(biomeSource, structuresConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pool<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)
|
||||
public WeightedRandomList<MobSpawnSettings.SpawnerData> getMobsAt(Biome biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos)
|
||||
{
|
||||
if (!CarpetSettings.flatWorldStructureSpawning) return super.getEntitySpawnList(biome, accessor, group, pos);
|
||||
if (!CarpetSettings.flatWorldStructureSpawning) return super.getMobsAt(biome, accessor, group, pos);
|
||||
|
||||
// vanila noise one
|
||||
if (accessor.getStructureAt(pos, StructureFeature.SWAMP_HUT).hasChildren()) {
|
||||
if (group == SpawnGroup.MONSTER) {
|
||||
return SwampHutFeature.MONSTER_SPAWNS;
|
||||
if (accessor.getStructureAt(pos, StructureFeature.SWAMP_HUT).isValid()) {
|
||||
if (group == MobCategory.MONSTER) {
|
||||
return SwamplandHutFeature.SWAMPHUT_ENEMIES;
|
||||
}
|
||||
|
||||
if (group == SpawnGroup.CREATURE) {
|
||||
return SwampHutFeature.CREATURE_SPAWNS;
|
||||
if (group == MobCategory.CREATURE) {
|
||||
return SwamplandHutFeature.SWAMPHUT_ANIMALS;
|
||||
}
|
||||
}
|
||||
|
||||
if (group == SpawnGroup.MONSTER) {
|
||||
if (accessor.getStructureAt(pos, StructureFeature.PILLAGER_OUTPOST).hasChildren()) {
|
||||
return PillagerOutpostFeature.MONSTER_SPAWNS;
|
||||
if (group == MobCategory.MONSTER) {
|
||||
if (accessor.getStructureAt(pos, StructureFeature.PILLAGER_OUTPOST).isValid()) {
|
||||
return PillagerOutpostFeature.OUTPOST_ENEMIES;
|
||||
}
|
||||
|
||||
if (accessor.getStructureAt(pos, StructureFeature.MONUMENT).hasChildren()) {
|
||||
return OceanMonumentFeature.MONSTER_SPAWNS;
|
||||
if (accessor.getStructureAt(pos, StructureFeature.OCEAN_MONUMENT).isValid()) {
|
||||
return OceanMonumentFeature.MONUMENT_ENEMIES;
|
||||
}
|
||||
|
||||
if (accessor.getStructureAt(pos, StructureFeature.FORTRESS).hasChildren()) {
|
||||
return NetherFortressFeature.MONSTER_SPAWNS;
|
||||
if (accessor.getStructureAt(pos, StructureFeature.NETHER_BRIDGE).isValid()) {
|
||||
return NetherFortressFeature.FORTRESS_ENEMIES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// carpet spawns
|
||||
if (group == SpawnGroup.MONSTER)
|
||||
if (group == MobCategory.MONSTER)
|
||||
{
|
||||
if (CarpetSettings.huskSpawningInTemples)
|
||||
{
|
||||
if (accessor.getStructureAt(pos, StructureFeature.DESERT_PYRAMID).hasChildren())
|
||||
if (accessor.getStructureAt(pos, StructureFeature.DESERT_PYRAMID).isValid())
|
||||
{
|
||||
return CustomSpawnLists.PYRAMID_SPAWNS;
|
||||
}
|
||||
}
|
||||
if (CarpetSettings.shulkerSpawningInEndCities)
|
||||
{
|
||||
if (accessor.getStructureAt(pos, StructureFeature.END_CITY).hasChildren())
|
||||
if (accessor.getStructureAt(pos, StructureFeature.END_CITY).isValid())
|
||||
{
|
||||
return CustomSpawnLists.SHULKER_SPAWNS;
|
||||
}
|
||||
}
|
||||
if (CarpetSettings.piglinsSpawningInBastions)
|
||||
{
|
||||
if (accessor.getStructureAt(pos, StructureFeature.BASTION_REMNANT).hasChildren())
|
||||
if (accessor.getStructureAt(pos, StructureFeature.BASTION_REMNANT).isValid())
|
||||
{
|
||||
return CustomSpawnLists.BASTION_SPAWNS;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (group == SpawnGroup.UNDERGROUND_WATER_CREATURE || group == SpawnGroup.AXOLOTLS) && accessor.getStructureAt(pos, StructureFeature.MONUMENT).hasChildren() ? SpawnSettings.EMPTY_ENTRY_POOL : super.getEntitySpawnList(biome, accessor, group, pos);
|
||||
return (group == MobCategory.UNDERGROUND_WATER_CREATURE || group == MobCategory.AXOLOTLS) && accessor.getStructureAt(pos, StructureFeature.OCEAN_MONUMENT).isValid() ? MobSpawnSettings.EMPTY_MOB_LIST : super.getMobsAt(biome, accessor, group, pos);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.fluid.FlowableFluid;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
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(FlowableFluid.class)
|
||||
@Mixin(FlowingFluid.class)
|
||||
public class FlowableFluid_liquidDamageDisabledMixin
|
||||
{
|
||||
@Inject(
|
||||
method = "canFill",
|
||||
method = "canHoldFluid",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/Material;blocksMovement()Z"
|
||||
target = "Lnet/minecraft/world/level/material/Material;blocksMotion()Z"
|
||||
),
|
||||
cancellable = true
|
||||
)
|
||||
private void stopBreakingBlock(BlockView world, BlockPos pos, BlockState state, Fluid fluid, CallbackInfoReturnable<Boolean> cir)
|
||||
private void stopBreakingBlock(BlockGetter world, BlockPos pos, BlockState state, Fluid fluid, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.liquidDamageDisabled)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.fluid.FlowableFluid;
|
||||
import net.minecraft.tag.FluidTags;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -17,26 +17,26 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FluidBlock.class)
|
||||
@Mixin(LiquidBlock.class)
|
||||
public abstract class FluidBlock_renewableBlackstoneMixin
|
||||
{
|
||||
@Shadow @Final protected FlowableFluid fluid;
|
||||
@Shadow @Final protected FlowingFluid fluid;
|
||||
|
||||
@Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos);
|
||||
@Shadow protected abstract void fizz(LevelAccessor world, BlockPos pos);
|
||||
|
||||
@Inject(method = "receiveNeighborFluids", at = @At("TAIL"), cancellable = true)
|
||||
private void receiveFluidToBlackstone(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir)
|
||||
@Inject(method = "shouldSpreadLiquid", at = @At("TAIL"), cancellable = true)
|
||||
private void receiveFluidToBlackstone(Level world, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.renewableBlackstone)
|
||||
{
|
||||
if (fluid.isIn(FluidTags.LAVA)) {
|
||||
if (fluid.is(FluidTags.LAVA)) {
|
||||
for(Direction direction : Direction.values())
|
||||
{
|
||||
if (direction != Direction.DOWN) {
|
||||
BlockPos blockPos = pos.offset(direction); // offset
|
||||
if (world.getBlockState(blockPos).isOf(Blocks.BLUE_ICE)) {
|
||||
world.setBlockState(pos, Blocks.BLACKSTONE.getDefaultState());
|
||||
playExtinguishSound(world, pos);
|
||||
BlockPos blockPos = pos.relative(direction); // offset
|
||||
if (world.getBlockState(blockPos).is(Blocks.BLUE_ICE)) {
|
||||
world.setBlockAndUpdate(pos, Blocks.BLACKSTONE.defaultBlockState());
|
||||
fizz(world, pos);
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
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.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(FluidBlock.class)
|
||||
@Mixin(LiquidBlock.class)
|
||||
public abstract class FluidBlock_renewableDeepslateMixin {
|
||||
|
||||
@Shadow protected abstract void playExtinguishSound(WorldAccess world, BlockPos pos);
|
||||
@Shadow protected abstract void fizz(LevelAccessor world, BlockPos pos);
|
||||
|
||||
@Inject(method = "receiveNeighborFluids", at = @At(value = "INVOKE",target = "Lnet/minecraft/fluid/FluidState;isStill()Z"), cancellable = true)
|
||||
private void receiveFluidToDeepslate(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir)
|
||||
@Inject(method = "shouldSpreadLiquid", at = @At(value = "INVOKE",target = "Lnet/minecraft/world/level/material/FluidState;isSource()Z"), cancellable = true)
|
||||
private void receiveFluidToDeepslate(Level world, BlockPos pos, BlockState state, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if(CarpetSettings.renewableDeepslate && !world.getFluidState(pos).isStill() && world.getRegistryKey() == World.OVERWORLD && pos.getY() < 16)
|
||||
if(CarpetSettings.renewableDeepslate && !world.getFluidState(pos).isSource() && world.dimension() == Level.OVERWORLD && pos.getY() < 16)
|
||||
{
|
||||
world.setBlockState(pos, Blocks.COBBLED_DEEPSLATE.getDefaultState());
|
||||
this.playExtinguishSound(world, pos);
|
||||
world.setBlockAndUpdate(pos, Blocks.COBBLED_DEEPSLATE.defaultBlockState());
|
||||
this.fizz(world, pos);
|
||||
cir.setReturnValue(false);
|
||||
cir.cancel();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.command.ForceLoadCommand;
|
||||
import net.minecraft.server.commands.ForceLoadCommand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@@ -9,13 +9,13 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
@Mixin(ForceLoadCommand.class)
|
||||
public class ForceLoadCommand_forceLoadLimitMixin
|
||||
{
|
||||
@ModifyConstant(method = "executeChange", constant = @Constant(longValue = 256L))
|
||||
@ModifyConstant(method = "changeForceLoad", constant = @Constant(longValue = 256L))
|
||||
private static long forceloadLimit(long original)
|
||||
{
|
||||
return CarpetSettings.forceloadLimit;
|
||||
}
|
||||
|
||||
@ModifyConstant(method = "executeChange", constant = @Constant(intValue = 256))
|
||||
@ModifyConstant(method = "changeForceLoad", constant = @Constant(intValue = 256))
|
||||
private static int forceloadLimitError(int original)
|
||||
{
|
||||
return CarpetSettings.forceloadLimit;
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.EntityData;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.entity.mob.ElderGuardianEntity;
|
||||
import net.minecraft.entity.mob.GuardianEntity;
|
||||
import net.minecraft.entity.mob.HostileEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.monster.ElderGuardian;
|
||||
import net.minecraft.world.entity.monster.Guardian;
|
||||
import net.minecraft.world.entity.monster.Monster;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(GuardianEntity.class)
|
||||
public abstract class GuardianEntityMixin extends HostileEntity
|
||||
@Mixin(Guardian.class)
|
||||
public abstract class GuardianEntityMixin extends Monster
|
||||
{
|
||||
protected GuardianEntityMixin(EntityType<? extends HostileEntity> entityType_1, World world_1)
|
||||
protected GuardianEntityMixin(EntityType<? extends Monster> entityType_1, Level world_1)
|
||||
{
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(ServerWorld serverWorld, LightningEntity lightningEntity)
|
||||
public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity)
|
||||
{ // isRemoved()
|
||||
if (!this.world.isClient && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardianEntity))
|
||||
if (!this.level.isClientSide && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian))
|
||||
{
|
||||
ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
|
||||
elderGuardian.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch());
|
||||
elderGuardian.initialize(serverWorld ,this.world.getLocalDifficulty(elderGuardian.getBlockPos()), SpawnReason.CONVERSION, (EntityData)null, (NbtCompound)null);
|
||||
elderGuardian.setAiDisabled(this.isAiDisabled());
|
||||
ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level);
|
||||
elderGuardian.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
|
||||
elderGuardian.finalizeSpawn(serverWorld ,this.level.getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData)null, (CompoundTag)null);
|
||||
elderGuardian.setNoAi(this.isNoAi());
|
||||
|
||||
if (this.hasCustomName())
|
||||
{
|
||||
@@ -37,12 +37,12 @@ public abstract class GuardianEntityMixin extends HostileEntity
|
||||
elderGuardian.setCustomNameVisible(this.isCustomNameVisible());
|
||||
}
|
||||
|
||||
this.world.spawnEntity(elderGuardian);
|
||||
this.level.addFreshEntity(elderGuardian);
|
||||
this.discard(); // discard remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.onStruckByLightning(serverWorld, lightningEntity);
|
||||
super.thunderHit(serverWorld, lightningEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.HopperBlock;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -18,40 +8,50 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import carpet.helpers.HopperCounter;
|
||||
import carpet.utils.WoolTool;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.HopperBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.HopperBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
/**
|
||||
* The {@link Mixin} which removes items in a hopper if it points into a wool counter, and calls {@link HopperCounter#add}
|
||||
*/
|
||||
@Mixin(HopperBlockEntity.class)
|
||||
public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntity
|
||||
public abstract class HopperBlockEntityMixin extends RandomizableContainerBlockEntity
|
||||
{
|
||||
protected HopperBlockEntityMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
}
|
||||
|
||||
@Shadow public abstract int size();
|
||||
@Shadow public abstract int getContainerSize();
|
||||
|
||||
@Shadow public abstract void setStack(int slot, ItemStack stack);
|
||||
@Shadow public abstract void setItem(int slot, ItemStack stack);
|
||||
|
||||
/**
|
||||
* A method to remove items from hoppers pointing into wool and count them via {@link HopperCounter#add} method
|
||||
*/
|
||||
@Inject(method = "insert", at = @At("HEAD"), cancellable = true)
|
||||
private static void onInsert(World world, BlockPos blockPos, BlockState blockState, Inventory inventory, CallbackInfoReturnable<Boolean> cir)
|
||||
@Inject(method = "ejectItems", at = @At("HEAD"), cancellable = true)
|
||||
private static void onInsert(Level world, BlockPos blockPos, BlockState blockState, Container inventory, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (CarpetSettings.hopperCounters) {
|
||||
DyeColor wool_color = WoolTool.getWoolColorAtPosition(
|
||||
world,
|
||||
blockPos.offset(blockState.get(HopperBlock.FACING))); // offset
|
||||
blockPos.relative(blockState.getValue(HopperBlock.FACING))); // offset
|
||||
if (wool_color != null)
|
||||
{
|
||||
for (int i = 0; i < inventory.size(); ++i)
|
||||
for (int i = 0; i < inventory.getContainerSize(); ++i)
|
||||
{
|
||||
if (!inventory.getStack(i).isEmpty())
|
||||
if (!inventory.getItem(i).isEmpty())
|
||||
{
|
||||
ItemStack itemstack = inventory.getStack(i);//.copy();
|
||||
ItemStack itemstack = inventory.getItem(i);//.copy();
|
||||
HopperCounter.COUNTERS.get(wool_color).add(world.getServer(), itemstack);
|
||||
inventory.setStack(i, ItemStack.EMPTY);
|
||||
inventory.setItem(i, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
cir.setReturnValue(true);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.BlockRotator;
|
||||
import net.minecraft.block.HopperBlock;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.level.block.HopperBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -11,16 +11,16 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@Mixin(HopperBlock.class)
|
||||
public class HopperBlock_cactusMixin
|
||||
{
|
||||
@Redirect(method = "getPlacementState", at = @At(
|
||||
@Redirect(method = "getStateForPlacement", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/item/ItemPlacementContext;getSide()Lnet/minecraft/util/math/Direction;"
|
||||
target = "Lnet/minecraft/world/item/context/BlockPlaceContext;getClickedFace()Lnet/minecraft/core/Direction;"
|
||||
))
|
||||
private Direction getOppositeOpposite(ItemPlacementContext context)
|
||||
private Direction getOppositeOpposite(BlockPlaceContext context)
|
||||
{
|
||||
if (BlockRotator.flippinEligibility(context.getPlayer()))
|
||||
{
|
||||
return context.getSide().getOpposite();
|
||||
return context.getClickedFace().getOpposite();
|
||||
}
|
||||
return context.getSide();
|
||||
return context.getClickedFace();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.InventoryBearerInterface;
|
||||
import net.minecraft.entity.passive.HorseBaseEntity;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.inventory.SimpleInventory;
|
||||
import net.minecraft.world.Container;
|
||||
import net.minecraft.world.SimpleContainer;
|
||||
import net.minecraft.world.entity.animal.horse.AbstractHorse;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(HorseBaseEntity.class)
|
||||
@Mixin(AbstractHorse.class)
|
||||
public class HorseBaseEntity_scarpetMixin implements InventoryBearerInterface
|
||||
{
|
||||
|
||||
@Shadow protected SimpleInventory items;
|
||||
@Shadow protected SimpleContainer inventory;
|
||||
|
||||
@Override
|
||||
public Inventory getCMInventory()
|
||||
public Container getCMInventory()
|
||||
{
|
||||
return items;
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.mob.HuskEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ServerWorldAccess;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.monster.Husk;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(HuskEntity.class)
|
||||
@Mixin(Husk.class)
|
||||
public class HuskEntityMixin
|
||||
{
|
||||
@Redirect(method = "canSpawn", at = @At(value = "INVOKE", target="Lnet/minecraft/world/ServerWorldAccess;isSkyVisible(Lnet/minecraft/util/math/BlockPos;)Z"))
|
||||
private static boolean isSkylightOrTempleVisible(ServerWorldAccess serverWorldAccess, BlockPos pos)
|
||||
@Redirect(method = "checkHuskSpawnRules", at = @At(value = "INVOKE", target="Lnet/minecraft/world/level/ServerLevelAccessor;canSeeSky(Lnet/minecraft/core/BlockPos;)Z"))
|
||||
private static boolean isSkylightOrTempleVisible(ServerLevelAccessor serverWorldAccess, BlockPos pos)
|
||||
{
|
||||
return serverWorldAccess.isSkyVisible(pos) ||
|
||||
(CarpetSettings.huskSpawningInTemples && (((ServerWorld)serverWorldAccess).getStructureAccessor().getStructureAt(pos, StructureFeature.DESERT_PYRAMID).hasChildren()));
|
||||
return serverWorldAccess.canSeeSky(pos) ||
|
||||
(CarpetSettings.huskSpawningInTemples && (((ServerLevel)serverWorldAccess).structureFeatureManager().getStructureAt(pos, StructureFeature.DESERT_PYRAMID).isValid()));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,28 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.PlayerListHudInterface;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import net.minecraft.client.gui.hud.PlayerListHud;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.components.PlayerTabOverlay;
|
||||
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;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
@Mixin(Gui.class)
|
||||
public abstract class InGameHudMixin
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private MinecraftClient client;
|
||||
private Minecraft minecraft;
|
||||
|
||||
@Shadow @Final private PlayerListHud playerListHud;
|
||||
@Shadow @Final private PlayerTabOverlay tabList;
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;isInSingleplayer()Z"))
|
||||
private boolean onDraw(MinecraftClient minecraftClient)
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isLocalServer()Z"))
|
||||
private boolean onDraw(Minecraft minecraftClient)
|
||||
{
|
||||
return this.client.isInSingleplayer() && !((PlayerListHudInterface) playerListHud).hasFooterOrHeader();
|
||||
return this.minecraft.isLocalServer() && !((PlayerListHudInterface) tabList).hasFooterOrHeader();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.InfestedBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.InfestedBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -15,18 +15,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(InfestedBlock.class)
|
||||
public abstract class InfestedBlockMixin extends Block
|
||||
{
|
||||
public InfestedBlockMixin(Settings block$Settings_1)
|
||||
public InfestedBlockMixin(Properties block$Settings_1)
|
||||
{
|
||||
super(block$Settings_1);
|
||||
}
|
||||
|
||||
@Inject(method = "spawnSilverfish", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
|
||||
target = "Lnet/minecraft/entity/mob/SilverfishEntity;playSpawnEffects()V"))
|
||||
private void onOnStacksDropped(ServerWorld serverWorld, BlockPos pos, CallbackInfo ci)
|
||||
@Inject(method = "spawnInfestation", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
|
||||
target = "Lnet/minecraft/world/entity/monster/Silverfish;spawnAnim()V"))
|
||||
private void onOnStacksDropped(ServerLevel serverWorld, BlockPos pos, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.silverFishDropGravel)
|
||||
{
|
||||
dropStack(serverWorld, pos, new ItemStack(Blocks.GRAVEL));
|
||||
popResource(serverWorld, pos, new ItemStack(Blocks.GRAVEL));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.IngredientInterface;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -11,16 +9,18 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.Ingredient;
|
||||
|
||||
@Mixin(Ingredient.class)
|
||||
public class Ingredient_scarpetMixin implements IngredientInterface
|
||||
{
|
||||
@Shadow @Final private Ingredient.Entry[] entries;
|
||||
@Shadow @Final private Ingredient.Value[] values;
|
||||
|
||||
@Override
|
||||
public List<Collection<ItemStack>> getRecipeStacks()
|
||||
{
|
||||
List<Collection<ItemStack>> res = Arrays.stream(entries).map(Ingredient.Entry::getStacks).collect(Collectors.toList());
|
||||
List<Collection<ItemStack>> res = Arrays.stream(values).map(Ingredient.Value::getItems).collect(Collectors.toList());
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.RandomTools;
|
||||
import net.minecraft.block.dispenser.ItemDispenserBehavior;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
|
||||
|
||||
@Mixin(ItemDispenserBehavior.class)
|
||||
@Mixin(DefaultDispenseItemBehavior.class)
|
||||
public class ItemDispenserBehaviour_extremeBehavioursMixin
|
||||
{
|
||||
@Redirect(method = "spawnItem", expect = 3, at = @At(
|
||||
|
||||
@@ -2,16 +2,16 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.InventoryHelper;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LightningBolt;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
import carpet.fakes.ItemEntityInterface;
|
||||
import net.minecraft.block.ShulkerBoxBlock;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -24,21 +24,21 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
{
|
||||
private static final int SHULKERBOX_MAX_STACK_AMOUNT = 64;
|
||||
|
||||
@Shadow private int itemAge;
|
||||
@Shadow private int age;
|
||||
@Shadow private int pickupDelay;
|
||||
|
||||
public ItemEntityMixin(EntityType<?> entityType_1, World world_1) {
|
||||
public ItemEntityMixin(EntityType<?> entityType_1, Level world_1) {
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStruckByLightning(ServerWorld world, LightningEntity lightning) {
|
||||
public void thunderHit(ServerLevel world, LightningBolt lightning) {
|
||||
if (CarpetSettings.lightningKillsDropsFix) {
|
||||
if (this.itemAge > 8) { //Only kill item if its older then 8 ticks
|
||||
super.onStruckByLightning(world, lightning);
|
||||
if (this.age > 8) { //Only kill item if its older then 8 ticks
|
||||
super.thunderHit(world, lightning);
|
||||
}
|
||||
} else {
|
||||
super.onStruckByLightning(world, lightning);
|
||||
super.thunderHit(world, lightning);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,69 +47,69 @@ public abstract class ItemEntityMixin extends Entity implements ItemEntityInterf
|
||||
return this.pickupDelay;
|
||||
}
|
||||
|
||||
@Inject(method="<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", at = @At("RETURN"))
|
||||
private void removeEmptyShulkerBoxTags(World worldIn, double x, double y, double z, ItemStack stack, CallbackInfo ci)
|
||||
@Inject(method="<init>(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", at = @At("RETURN"))
|
||||
private void removeEmptyShulkerBoxTags(Level worldIn, double x, double y, double z, ItemStack stack, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.shulkerBoxStackSize > 1
|
||||
&& stack.getItem() instanceof BlockItem
|
||||
&& ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
{
|
||||
if (InventoryHelper.cleanUpShulkerBoxTag(stack)) {
|
||||
((ItemEntity) (Object) this).setStack(stack);
|
||||
((ItemEntity) (Object) this).setItem(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "canMerge()Z",
|
||||
method = "isMergable()Z",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/item/ItemStack;getMaxCount()I"
|
||||
target = "Lnet/minecraft/world/item/ItemStack;getMaxStackSize()I"
|
||||
)
|
||||
)
|
||||
private int getItemStackMaxAmount(ItemStack stack) {
|
||||
if (CarpetSettings.shulkerBoxStackSize > 1 && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
|
||||
return CarpetSettings.shulkerBoxStackSize;
|
||||
|
||||
return stack.getMaxCount();
|
||||
return stack.getMaxStackSize();
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "tryMerge(Lnet/minecraft/entity/ItemEntity;)V",
|
||||
method = "tryToMerge(Lnet/minecraft/world/entity/item/ItemEntity;)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true
|
||||
)
|
||||
private void tryStackShulkerBoxes(ItemEntity other, CallbackInfo ci)
|
||||
{
|
||||
ItemEntity self = (ItemEntity)(Object)this;
|
||||
ItemStack selfStack = self.getStack();
|
||||
ItemStack selfStack = self.getItem();
|
||||
if (CarpetSettings.shulkerBoxStackSize == 1 || !(selfStack.getItem() instanceof BlockItem) || !(((BlockItem)selfStack.getItem()).getBlock() instanceof ShulkerBoxBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack otherStack = other.getStack();
|
||||
ItemStack otherStack = other.getItem();
|
||||
if (selfStack.getItem() == otherStack.getItem()
|
||||
&& !InventoryHelper.shulkerBoxHasItems(selfStack)
|
||||
&& !InventoryHelper.shulkerBoxHasItems(otherStack)
|
||||
&& selfStack.hasNbt() == otherStack.hasNbt()
|
||||
&& selfStack.hasTag() == otherStack.hasTag()
|
||||
&& selfStack.getCount() + otherStack.getCount() <= CarpetSettings.shulkerBoxStackSize)
|
||||
{
|
||||
int amount = Math.min(otherStack.getCount(), CarpetSettings.shulkerBoxStackSize - selfStack.getCount());
|
||||
|
||||
selfStack.increment(amount);
|
||||
self.setStack(selfStack);
|
||||
selfStack.grow(amount);
|
||||
self.setItem(selfStack);
|
||||
|
||||
this.pickupDelay = Math.max(((ItemEntityInterface)other).getPickupDelayCM(), this.pickupDelay);
|
||||
this.itemAge = Math.min(other.getItemAge(), this.itemAge);
|
||||
this.age = Math.min(other.getAge(), this.age);
|
||||
|
||||
otherStack.decrement(amount);
|
||||
otherStack.shrink(amount);
|
||||
if (otherStack.isEmpty())
|
||||
{
|
||||
other.discard(); // discard remove();
|
||||
}
|
||||
else
|
||||
{
|
||||
other.setStack(otherStack);
|
||||
other.setItem(otherStack);
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.RandomTools;
|
||||
import net.minecraft.util.ItemScatterer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.Containers;
|
||||
|
||||
@Mixin(ItemScatterer.class)
|
||||
@Mixin(Containers.class)
|
||||
public class ItemScatterer_extremeMixin
|
||||
{
|
||||
@Redirect(method = "spawn(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", expect = 3, at = @At(
|
||||
@Redirect(method = "dropItemStack(Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/item/ItemStack;)V", expect = 3, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Random;nextGaussian()D"
|
||||
))
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.helpers.BlockRotator;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemUsageContext;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.context.UseOnContext;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ItemUsageContext.class)
|
||||
@Mixin(UseOnContext.class)
|
||||
public class ItemUsageContext_cactusMixin
|
||||
{
|
||||
@Redirect(method = "getPlayerFacing", at = @At(
|
||||
@Redirect(method = "getHorizontalDirection", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/player/PlayerEntity;getHorizontalFacing()Lnet/minecraft/util/math/Direction;"
|
||||
target = "Lnet/minecraft/world/entity/player/Player;getDirection()Lnet/minecraft/core/Direction;"
|
||||
))
|
||||
private Direction getPlayerFacing(PlayerEntity playerEntity)
|
||||
private Direction getPlayerFacing(Player playerEntity)
|
||||
{
|
||||
Direction dir = playerEntity.getHorizontalFacing();
|
||||
Direction dir = playerEntity.getDirection();
|
||||
if (BlockRotator.flippinEligibility(playerEntity))
|
||||
{
|
||||
dir = dir.getOpposite();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.LavaFluid;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.level.material.LavaFluid;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -17,15 +17,15 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LavaFluid.class)
|
||||
public abstract class LavaFluid_renewableDeepslateMixin {
|
||||
@Shadow protected abstract void playExtinguishEvent(WorldAccess world, BlockPos pos);
|
||||
@Shadow protected abstract void fizz(LevelAccessor world, BlockPos pos);
|
||||
|
||||
@Inject(method = "flow", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;getDefaultState()Lnet/minecraft/block/BlockState;"), cancellable = true)
|
||||
private void generateDeepslate(WorldAccess world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci)
|
||||
@Inject(method = "spreadTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;defaultBlockState()Lnet/minecraft/world/level/block/state/BlockState;"), cancellable = true)
|
||||
private void generateDeepslate(LevelAccessor world, BlockPos pos, BlockState state, Direction direction, FluidState fluidState, CallbackInfo ci)
|
||||
{
|
||||
if(CarpetSettings.renewableDeepslate && ((World)world).getRegistryKey() == World.OVERWORLD && pos.getY() < 16)
|
||||
if(CarpetSettings.renewableDeepslate && ((Level)world).dimension() == Level.OVERWORLD && pos.getY() < 16)
|
||||
{
|
||||
world.setBlockState(pos, Blocks.DEEPSLATE.getDefaultState(), 3);
|
||||
this.playExtinguishEvent(world, pos);
|
||||
world.setBlock(pos, Blocks.DEEPSLATE.defaultBlockState(), 3);
|
||||
this.fizz(world, pos);
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import net.minecraft.world.level.lighting.DynamicGraphMinFixedPoint;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.chunk.light.LevelPropagator;
|
||||
|
||||
@Mixin(LevelPropagator.class)
|
||||
@Mixin(DynamicGraphMinFixedPoint.class)
|
||||
public interface LevelPropagator_resetChunkInterface
|
||||
{
|
||||
@Invoker("updateLevel")
|
||||
@Invoker("checkEdge")
|
||||
void cmInvokeUpdateLevel(long sourceId, long id, int level, boolean decrease);
|
||||
|
||||
@Invoker("getPropagatedLevel")
|
||||
@Invoker("computeLevelFromNeighbor")
|
||||
int cmCallGetPropagatedLevel(long sourceId, long targetId, int level);
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.core.SectionPos;
|
||||
import net.minecraft.world.level.chunk.DataLayer;
|
||||
import net.minecraft.world.level.lighting.DataLayerStorageMap;
|
||||
import net.minecraft.world.level.lighting.LayerLightEngine;
|
||||
import net.minecraft.world.level.lighting.LayerLightSectionStorage;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -14,36 +18,31 @@ import carpet.fakes.LightStorageInterface;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
import net.minecraft.world.chunk.ChunkToNibbleArrayMap;
|
||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||
import net.minecraft.world.chunk.light.LightStorage;
|
||||
|
||||
@Mixin(LightStorage.class)
|
||||
@Mixin(LayerLightSectionStorage.class)
|
||||
public abstract class LightStorage_scarpetChunkCreationMixin implements LightStorageInterface
|
||||
{
|
||||
@Shadow
|
||||
protected abstract ChunkNibbleArray getLightSection(final long sectionPos, final boolean cached);
|
||||
protected abstract DataLayer getDataLayer(final long sectionPos, final boolean cached);
|
||||
|
||||
@Shadow
|
||||
protected abstract void removeSection(final ChunkLightProvider<?, ?> storage, final long blockChunkPos);
|
||||
protected abstract void clearQueuedSectionBlocks(final LayerLightEngine<?, ?> storage, final long blockChunkPos);
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected LongSet dirtySections;
|
||||
protected LongSet changedSections;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected ChunkToNibbleArrayMap<?> storage;
|
||||
protected DataLayerStorageMap<?> updatingSectionData;
|
||||
|
||||
@Shadow protected abstract boolean hasSection(final long sectionPos);
|
||||
@Shadow protected abstract boolean storingLightForSection(final long sectionPos);
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected Long2ObjectMap<ChunkNibbleArray> queuedSections;
|
||||
protected Long2ObjectMap<DataLayer> queuedSections;
|
||||
|
||||
@Shadow protected abstract void setColumnEnabled(final long l, final boolean bl);
|
||||
@Shadow protected abstract void enableLightSources(final long l, final boolean bl);
|
||||
|
||||
@Unique
|
||||
private final LongSet removedChunks = new LongOpenHashSet();
|
||||
@@ -64,10 +63,10 @@ public abstract class LightStorage_scarpetChunkCreationMixin implements LightSto
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "updateLight(Lnet/minecraft/world/chunk/light/ChunkLightProvider;ZZ)V",
|
||||
method = "markNewInconsistencies(Lnet/minecraft/world/level/lighting/LayerLightEngine;ZZ)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void processData(final ChunkLightProvider<?, ?> lightProvider, final boolean doSkylight, final boolean skipEdgeLightPropagation, final CallbackInfo ci)
|
||||
private void processData(final LayerLightEngine<?, ?> lightProvider, final boolean doSkylight, final boolean skipEdgeLightPropagation, final CallbackInfo ci)
|
||||
{
|
||||
// Process light removal
|
||||
|
||||
@@ -75,18 +74,18 @@ public abstract class LightStorage_scarpetChunkCreationMixin implements LightSto
|
||||
{
|
||||
for (int y = -1; y < 17; ++y)
|
||||
{
|
||||
final long sectionPos = ChunkSectionPos.asLong(ChunkSectionPos.unpackX(cPos), y, ChunkSectionPos.unpackZ(cPos));
|
||||
final long sectionPos = SectionPos.asLong(SectionPos.x(cPos), y, SectionPos.z(cPos));
|
||||
|
||||
this.queuedSections.remove(sectionPos);
|
||||
|
||||
if (this.hasSection(sectionPos))
|
||||
if (this.storingLightForSection(sectionPos))
|
||||
{
|
||||
this.removeSection(lightProvider, sectionPos);
|
||||
this.clearQueuedSectionBlocks(lightProvider, sectionPos);
|
||||
|
||||
if (this.dirtySections.add(sectionPos))
|
||||
this.storage.replaceWithCopy(sectionPos);
|
||||
if (this.changedSections.add(sectionPos))
|
||||
this.updatingSectionData.copyDataLayer(sectionPos);
|
||||
|
||||
Arrays.fill(this.getLightSection(sectionPos, true).asByteArray(), (byte) 0);
|
||||
Arrays.fill(this.getDataLayer(sectionPos, true).getData(), (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +108,7 @@ public abstract class LightStorage_scarpetChunkCreationMixin implements LightSto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRelight(final ChunkLightProvider<?, ?> lightProvider, final long pos)
|
||||
public void processRelight(final LayerLightEngine<?, ?> lightProvider, final long pos)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,37 +5,37 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import carpet.fakes.Lighting_scarpetChunkCreationInterface;
|
||||
import net.minecraft.world.chunk.light.ChunkLightProvider;
|
||||
import net.minecraft.world.chunk.light.LightingProvider;
|
||||
import net.minecraft.world.level.lighting.LayerLightEngine;
|
||||
import net.minecraft.world.level.lighting.LevelLightEngine;
|
||||
|
||||
@Mixin(LightingProvider.class)
|
||||
@Mixin(LevelLightEngine.class)
|
||||
public abstract class LightingProvider_scarpetChunkCreationMixin implements Lighting_scarpetChunkCreationInterface
|
||||
{
|
||||
@Shadow
|
||||
@Final
|
||||
private ChunkLightProvider<?, ?> blockLightProvider;
|
||||
private LayerLightEngine<?, ?> blockEngine;
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ChunkLightProvider<?, ?> skyLightProvider;
|
||||
private LayerLightEngine<?, ?> skyEngine;
|
||||
|
||||
@Override
|
||||
public void removeLightData(final long pos)
|
||||
{
|
||||
if (this.blockLightProvider != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.blockLightProvider).removeLightData(pos);
|
||||
if (this.blockEngine != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.blockEngine).removeLightData(pos);
|
||||
|
||||
if (this.skyLightProvider != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.skyLightProvider).removeLightData(pos);
|
||||
if (this.skyEngine != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.skyEngine).removeLightData(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relight(final long pos)
|
||||
{
|
||||
if (this.blockLightProvider != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.blockLightProvider).relight(pos);
|
||||
if (this.blockEngine != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.blockEngine).relight(pos);
|
||||
|
||||
if (this.skyLightProvider != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.skyLightProvider).relight(pos);
|
||||
if (this.skyEngine != null)
|
||||
((Lighting_scarpetChunkCreationInterface) this.skyEngine).relight(pos);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -14,14 +14,14 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
public abstract class LivingEntityMixin extends Entity
|
||||
{
|
||||
|
||||
public LivingEntityMixin(EntityType<?> type, World world)
|
||||
public LivingEntityMixin(EntityType<?> type, Level world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Redirect(method = "onDeath", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;hasCustomName()Z"))
|
||||
@Redirect(method = "die", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;hasCustomName()Z"))
|
||||
private boolean shouldLogDeaths(LivingEntity livingEntity)
|
||||
{
|
||||
return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES);
|
||||
return livingEntity.hasCustomName() && CarpetSettings.cleanLogs && level.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -17,9 +17,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
{
|
||||
@Shadow public float airStrafingSpeed;
|
||||
@Shadow public float flyingSpeed;
|
||||
|
||||
public LivingEntity_creativeFlyMixin(EntityType<?> type, World world)
|
||||
public LivingEntity_creativeFlyMixin(EntityType<?> type, Level world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
@@ -27,9 +27,9 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
@ModifyConstant(method = "travel", constant = @Constant(floatValue = 0.91F), expect = 2)
|
||||
private float drag(float original)
|
||||
{
|
||||
if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof PlayerEntity)
|
||||
if (CarpetSettings.creativeFlyDrag != 0.09 && (Object)this instanceof Player)
|
||||
{
|
||||
PlayerEntity self = (PlayerEntity)(Object)(this);
|
||||
Player self = (Player)(Object)(this);
|
||||
if (self.getAbilities().flying && ! onGround )
|
||||
return (float)(1.0-CarpetSettings.creativeFlyDrag);
|
||||
}
|
||||
@@ -37,14 +37,14 @@ public abstract class LivingEntity_creativeFlyMixin extends Entity
|
||||
}
|
||||
|
||||
|
||||
@Inject(method = "getMovementSpeed(F)F", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "getFrictionInfluencedSpeed(F)F", at = @At("HEAD"), cancellable = true)
|
||||
private void flyingAltSpeed(float slipperiness, CallbackInfoReturnable<Float> cir)
|
||||
{
|
||||
if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof PlayerEntity)
|
||||
if (CarpetSettings.creativeFlySpeed != 1.0D && (Object)this instanceof Player)
|
||||
{
|
||||
PlayerEntity self = (PlayerEntity)(Object)(this);
|
||||
Player self = (Player)(Object)(this);
|
||||
if (self.getAbilities().flying && !onGround)
|
||||
cir.setReturnValue( airStrafingSpeed* (float)CarpetSettings.creativeFlySpeed);
|
||||
cir.setReturnValue( flyingSpeed* (float)CarpetSettings.creativeFlySpeed);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,6 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.WorldInterface;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -16,63 +9,70 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntitySelector;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class LivingEntity_maxCollisionsMixin extends Entity
|
||||
{
|
||||
|
||||
public LivingEntity_maxCollisionsMixin(EntityType<?> entityType_1, World world_1)
|
||||
public LivingEntity_maxCollisionsMixin(EntityType<?> entityType_1, Level world_1)
|
||||
{
|
||||
super(entityType_1, world_1);
|
||||
}
|
||||
|
||||
@Shadow protected abstract void pushAway(Entity entity_1);
|
||||
@Shadow protected abstract void doPush(Entity entity_1);
|
||||
|
||||
@Inject(method = "tickCramming", cancellable = true, at = @At("HEAD"))
|
||||
@Inject(method = "pushEntities", cancellable = true, at = @At("HEAD"))
|
||||
private void tickPushingReplacement(CallbackInfo ci) {
|
||||
List<Entity> entities;
|
||||
int maxEntityCramming =-1;
|
||||
if (CarpetSettings.maxEntityCollisions > 0)
|
||||
{
|
||||
maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
|
||||
entities = ((WorldInterface) this.world).getOtherEntitiesLimited(
|
||||
maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
|
||||
entities = ((WorldInterface) this.level).getOtherEntitiesLimited(
|
||||
this,
|
||||
this.getBoundingBox(),
|
||||
EntityPredicates.canBePushedBy(this),
|
||||
EntitySelector.pushableBy(this),
|
||||
Math.max(CarpetSettings.maxEntityCollisions, maxEntityCramming));
|
||||
}
|
||||
else
|
||||
{
|
||||
entities = this.world.getOtherEntities(this, this.getBoundingBox(), EntityPredicates.canBePushedBy(this));
|
||||
entities = this.level.getEntities(this, this.getBoundingBox(), EntitySelector.pushableBy(this));
|
||||
}
|
||||
|
||||
if (!entities.isEmpty()) {
|
||||
if (maxEntityCramming < 0) maxEntityCramming = this.world.getGameRules().getInt(GameRules.MAX_ENTITY_CRAMMING);
|
||||
if (maxEntityCramming < 0) maxEntityCramming = this.level.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING);
|
||||
if (maxEntityCramming > 0 && entities.size() > maxEntityCramming - 1 && this.random.nextInt(4) == 0) {
|
||||
int candidates = 0;
|
||||
|
||||
for (Entity entity : entities) {
|
||||
if (!entity.hasVehicle()) {
|
||||
if (!entity.isPassenger()) {
|
||||
++candidates;
|
||||
}
|
||||
}
|
||||
|
||||
if (candidates > maxEntityCramming - 1) {
|
||||
this.damage(DamageSource.CRAMMING, 6.0F);
|
||||
this.hurt(DamageSource.CRAMMING, 6.0F);
|
||||
}
|
||||
}
|
||||
if (CarpetSettings.maxEntityCollisions > 0 && entities.size() > CarpetSettings.maxEntityCollisions)
|
||||
{
|
||||
for (Entity entity : entities.subList(0, CarpetSettings.maxEntityCollisions))
|
||||
{
|
||||
this.pushAway(entity);
|
||||
this.doPush(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Entity entity : entities)
|
||||
{
|
||||
this.pushAway(entity);
|
||||
this.doPush(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package carpet.mixins;
|
||||
import carpet.fakes.EntityInterface;
|
||||
import carpet.fakes.LivingEntityInterface;
|
||||
import carpet.script.EntityEventsGroup;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -22,24 +22,24 @@ import static carpet.script.CarpetEventServer.Event.PLAYER_DEALS_DAMAGE;
|
||||
public abstract class LivingEntity_scarpetEventsMixin extends Entity implements LivingEntityInterface
|
||||
{
|
||||
|
||||
@Shadow protected abstract void jump();
|
||||
@Shadow protected abstract void jumpFromGround();
|
||||
|
||||
@Shadow protected boolean jumping;
|
||||
|
||||
public LivingEntity_scarpetEventsMixin(EntityType<?> type, World world)
|
||||
public LivingEntity_scarpetEventsMixin(EntityType<?> type, Level world)
|
||||
{
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
@Inject(method = "onDeath", at = @At("HEAD"))
|
||||
@Inject(method = "die", at = @At("HEAD"))
|
||||
private void onDeathCall(DamageSource damageSource_1, CallbackInfo ci)
|
||||
{
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, damageSource_1.name);
|
||||
((EntityInterface)this).getEventContainer().onEvent(EntityEventsGroup.Event.ON_DEATH, damageSource_1.msgId);
|
||||
}
|
||||
|
||||
@Inject(method = "applyDamage", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
@Inject(method = "actuallyHurt", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/LivingEntity;applyArmorToDamage(Lnet/minecraft/entity/damage/DamageSource;F)F",
|
||||
target = "Lnet/minecraft/world/entity/LivingEntity;getDamageAfterArmorAbsorb(Lnet/minecraft/world/damagesource/DamageSource;F)F",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void entityTakingDamage(DamageSource source, float amount, CallbackInfo ci)
|
||||
@@ -50,7 +50,7 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
|
||||
//{
|
||||
// PLAYER_TAKES_DAMAGE.onDamage(entity, float_2, damageSource_1);
|
||||
//}
|
||||
if (source.getAttacker() instanceof ServerPlayerEntity && PLAYER_DEALS_DAMAGE.isNeeded())
|
||||
if (source.getEntity() instanceof ServerPlayer && PLAYER_DEALS_DAMAGE.isNeeded())
|
||||
{
|
||||
PLAYER_DEALS_DAMAGE.onDamage(this, amount, source);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public abstract class LivingEntity_scarpetEventsMixin extends Entity implements
|
||||
@Override
|
||||
public void doJumpCM()
|
||||
{
|
||||
jump();
|
||||
jumpFromGround();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,21 +3,21 @@ package carpet.mixins;
|
||||
import carpet.CarpetServer;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.network.CarpetClient;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
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.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftClientMixin
|
||||
{
|
||||
@Shadow public ClientWorld world;
|
||||
@Shadow public ClientLevel level;
|
||||
|
||||
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;)V", at = @At("HEAD"))
|
||||
@Inject(method = "clearLevel(Lnet/minecraft/client/gui/screens/Screen;)V", at = @At("HEAD"))
|
||||
private void onCloseGame(Screen screen, CallbackInfo ci)
|
||||
{
|
||||
CarpetClient.disconnect();
|
||||
@@ -25,7 +25,7 @@ public class MinecraftClientMixin
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "tick")
|
||||
private void onClientTick(CallbackInfo info) {
|
||||
if (this.world != null) {
|
||||
if (this.level != null) {
|
||||
if (CarpetServer.minecraft_server == null)
|
||||
TickSpeed.tick();
|
||||
if (!TickSpeed.process_entities)
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.MinecraftClientInferface;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftClient_pausedShakeMixin implements MinecraftClientInferface
|
||||
{
|
||||
@Shadow private float pausedTickDelta;
|
||||
@Shadow private float pausePartialTick;
|
||||
|
||||
@Override
|
||||
public float getPausedTickDelta()
|
||||
{
|
||||
return pausedTickDelta;
|
||||
return pausePartialTick;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import carpet.CarpetServer;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.WorldGenerationProgressListener;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -18,10 +18,10 @@ public abstract class MinecraftServer_coreMixin
|
||||
//to inject right before
|
||||
// this.tickWorlds(booleanSupplier_1);
|
||||
@Inject(
|
||||
method = "tick",
|
||||
method = "tickServer",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;tickWorlds(Ljava/util/function/BooleanSupplier;)V",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;tickChildren(Ljava/util/function/BooleanSupplier;)V",
|
||||
shift = At.Shift.BEFORE,
|
||||
ordinal = 0
|
||||
)
|
||||
@@ -32,32 +32,32 @@ public abstract class MinecraftServer_coreMixin
|
||||
CarpetProfiler.end_current_section(token);
|
||||
}
|
||||
|
||||
@Inject(method = "loadWorld", at = @At("HEAD"))
|
||||
@Inject(method = "loadLevel", at = @At("HEAD"))
|
||||
private void serverLoaded(CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerLoaded((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "loadWorld", at = @At("RETURN"))
|
||||
@Inject(method = "loadLevel", at = @At("RETURN"))
|
||||
private void serverLoadedWorlds(CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerLoadedWorlds((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "shutdown", at = @At("HEAD"))
|
||||
@Inject(method = "stopServer", at = @At("HEAD"))
|
||||
private void serverClosed(CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerClosed((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "shutdown", at = @At("TAIL"))
|
||||
@Inject(method = "stopServer", at = @At("TAIL"))
|
||||
private void serverDoneClosed(CallbackInfo ci)
|
||||
{
|
||||
CarpetServer.onServerDoneClosing((MinecraftServer) (Object) this);
|
||||
}
|
||||
|
||||
@Inject(method = "prepareStartRegion", at = @At("RETURN"))
|
||||
private void afterSpawnCreated(WorldGenerationProgressListener worldGenerationProgressListener, CallbackInfo ci)
|
||||
@Inject(method = "prepareLevels", at = @At("RETURN"))
|
||||
private void afterSpawnCreated(ChunkProgressListener worldGenerationProgressListener, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.spawnChunksSize != 11)
|
||||
CarpetSettings.ChangeSpawnChunksValidator.changeSpawnSize(CarpetSettings.spawnChunksSize);
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
public abstract class MinecraftServer_pingPlayerSampleLimit
|
||||
{
|
||||
|
||||
@ModifyConstant(method = "tick", constant = @Constant(intValue = 12), require = 0, allow = 1)
|
||||
@ModifyConstant(method = "tickServer", constant = @Constant(intValue = 12), require = 0, allow = 1)
|
||||
private int modifyPlayerSampleLimit(int value)
|
||||
{
|
||||
return CarpetSettings.pingPlayerListLimit;
|
||||
|
||||
@@ -2,15 +2,15 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.MinecraftServerInterface;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import net.minecraft.resource.ServerResourceManager;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.level.storage.LevelStorage;
|
||||
import net.minecraft.server.ServerResources;
|
||||
import net.minecraft.server.TickTask;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.thread.ReentrantBlockableEventLoop;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -26,53 +26,53 @@ import static carpet.script.CarpetEventServer.Event.NETHER_TICK;
|
||||
import static carpet.script.CarpetEventServer.Event.TICK;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public abstract class MinecraftServer_scarpetMixin extends ReentrantThreadExecutor<ServerTask> implements MinecraftServerInterface
|
||||
public abstract class MinecraftServer_scarpetMixin extends ReentrantBlockableEventLoop<TickTask> implements MinecraftServerInterface
|
||||
{
|
||||
public MinecraftServer_scarpetMixin(String string_1)
|
||||
{
|
||||
super(string_1);
|
||||
}
|
||||
|
||||
@Shadow protected abstract void tick(BooleanSupplier booleanSupplier_1);
|
||||
@Shadow protected abstract void tickServer(BooleanSupplier booleanSupplier_1);
|
||||
|
||||
@Shadow private long timeReference;
|
||||
@Shadow private long nextTickTime;
|
||||
|
||||
@Shadow private long lastTimeReference;
|
||||
@Shadow private long lastOverloadWarning;
|
||||
|
||||
@Shadow public abstract boolean runTask();
|
||||
@Shadow public abstract boolean pollTask();
|
||||
|
||||
@Shadow @Final protected LevelStorage.Session session;
|
||||
@Shadow @Final protected LevelStorageSource.LevelStorageAccess storageSource;
|
||||
|
||||
@Shadow @Final private Map<RegistryKey<World>, ServerWorld> worlds;
|
||||
@Shadow @Final private Map<ResourceKey<Level>, ServerLevel> levels;
|
||||
|
||||
@Shadow private ServerResourceManager serverResourceManager;
|
||||
@Shadow private ServerResources resources;
|
||||
|
||||
@Override
|
||||
public void forceTick(BooleanSupplier isAhead)
|
||||
{
|
||||
timeReference = lastTimeReference = Util.getMeasuringTimeMs();
|
||||
tick(isAhead);
|
||||
while(runTask()) {Thread.yield();}
|
||||
nextTickTime = lastOverloadWarning = Util.getMillis();
|
||||
tickServer(isAhead);
|
||||
while(pollTask()) {Thread.yield();}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LevelStorage.Session getCMSession()
|
||||
public LevelStorageSource.LevelStorageAccess getCMSession()
|
||||
{
|
||||
return session;
|
||||
return storageSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerResourceManager getResourceManager() {
|
||||
return serverResourceManager;
|
||||
public ServerResources getResourceManager() {
|
||||
return resources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<RegistryKey<World>, ServerWorld> getCMWorlds()
|
||||
public Map<ResourceKey<Level>, ServerLevel> getCMWorlds()
|
||||
{
|
||||
return worlds;
|
||||
return levels;
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
@Inject(method = "tickServer", at = @At(
|
||||
value = "CONSTANT",
|
||||
args = "stringValue=tallying"
|
||||
))
|
||||
|
||||
@@ -3,14 +3,14 @@ package carpet.mixins;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.patches.CopyProfilerResult;
|
||||
import carpet.utils.CarpetProfiler;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.ServerTask;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.profiler.EmptyProfileResult;
|
||||
import net.minecraft.util.profiler.ProfileResult;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
import net.minecraft.util.thread.ReentrantThreadExecutor;
|
||||
import net.minecraft.server.TickTask;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.util.profiling.EmptyProfileResults;
|
||||
import net.minecraft.util.profiling.ProfileResults;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.util.thread.ReentrantBlockableEventLoop;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
@@ -25,44 +25,44 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExecutor<ServerTask>
|
||||
public abstract class MinecraftServer_tickspeedMixin extends ReentrantBlockableEventLoop<TickTask>
|
||||
{
|
||||
@Shadow private volatile boolean running;
|
||||
|
||||
@Shadow private long timeReference;
|
||||
@Shadow private long nextTickTime;
|
||||
|
||||
@Shadow @Final private static Logger LOGGER;
|
||||
|
||||
@Shadow private Profiler profiler;
|
||||
@Shadow private ProfilerFiller profiler;
|
||||
|
||||
public MinecraftServer_tickspeedMixin(String name)
|
||||
{
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Shadow protected abstract void tick(BooleanSupplier booleanSupplier_1);
|
||||
@Shadow protected abstract void tickServer(BooleanSupplier booleanSupplier_1);
|
||||
|
||||
@Shadow protected abstract boolean shouldKeepTicking();
|
||||
@Shadow protected abstract boolean haveTime();
|
||||
|
||||
@Shadow private long nextTickTimestamp;
|
||||
@Shadow private long delayedTasksMaxNextTickTime;
|
||||
|
||||
@Shadow private volatile boolean loading;
|
||||
@Shadow private volatile boolean isReady;
|
||||
|
||||
@Shadow private long lastTimeReference;
|
||||
@Shadow private long lastOverloadWarning;
|
||||
|
||||
@Shadow private boolean waitingForNextTick;
|
||||
@Shadow private boolean mayHaveDelayedTasks;
|
||||
|
||||
@Shadow public abstract Iterable<ServerWorld> getWorlds();
|
||||
@Shadow public abstract Iterable<ServerLevel> getAllLevels();
|
||||
|
||||
@Shadow private int ticks;
|
||||
@Shadow private int tickCount;
|
||||
|
||||
@Shadow protected abstract void runTasksTillTickEnd();
|
||||
@Shadow protected abstract void waitUntilNextTick();
|
||||
|
||||
@Shadow protected abstract void startTickMetrics();
|
||||
@Shadow protected abstract void startMetricsRecordingTick();
|
||||
|
||||
@Shadow protected abstract void endTickMetrics();
|
||||
@Shadow protected abstract void endMetricsRecordingTick();
|
||||
|
||||
@Shadow private boolean needsDebugSetup;
|
||||
@Shadow private boolean debugCommandProfilerDelayStart;
|
||||
CarpetProfiler.ProfilerToken currentSection;
|
||||
|
||||
private float carpetMsptAccum = 0.0f;
|
||||
@@ -82,7 +82,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
// could possibly just inject that mspt selection at the beginning of the loop, but then adding all mspt's to
|
||||
// replace 50L will be a hassle
|
||||
@Inject(method = "runServer", at = @At(value = "INVOKE", shift = At.Shift.AFTER,
|
||||
target = "Lnet/minecraft/server/MinecraftServer;setFavicon(Lnet/minecraft/server/ServerMetadata;)V"))
|
||||
target = "Lnet/minecraft/server/MinecraftServer;updateStatusIcon(Lnet/minecraft/network/protocol/status/ServerStatus;)V"))
|
||||
private void modifiedRunLoop(CallbackInfo ci)
|
||||
{
|
||||
while (this.running)
|
||||
@@ -98,7 +98,7 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
if (TickSpeed.time_warp_start_time != 0 && TickSpeed.continueWarp())
|
||||
{
|
||||
//making sure server won't flop after the warp or if the warp is interrupted
|
||||
this.timeReference = this.lastTimeReference = Util.getMeasuringTimeMs();
|
||||
this.nextTickTime = this.lastOverloadWarning = Util.getMillis();
|
||||
carpetMsptAccum = TickSpeed.mspt;
|
||||
}
|
||||
else
|
||||
@@ -112,41 +112,41 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
msThisTick = (long)carpetMsptAccum; // regular tick
|
||||
carpetMsptAccum += TickSpeed.mspt - msThisTick;
|
||||
|
||||
long_1 = Util.getMeasuringTimeMs() - this.timeReference;
|
||||
long_1 = Util.getMillis() - this.nextTickTime;
|
||||
}
|
||||
//end tick deciding
|
||||
//smoothed out delay to include mcpt component. With 50L gives defaults.
|
||||
if (long_1 > /*2000L*/1000L+20*TickSpeed.mspt && this.timeReference - this.lastTimeReference >= /*15000L*/10000L+100*TickSpeed.mspt)
|
||||
if (long_1 > /*2000L*/1000L+20*TickSpeed.mspt && this.nextTickTime - this.lastOverloadWarning >= /*15000L*/10000L+100*TickSpeed.mspt)
|
||||
{
|
||||
long long_2 = (long)(long_1 / TickSpeed.mspt);//50L;
|
||||
LOGGER.warn("Can't keep up! Is the server overloaded? Running {}ms or {} ticks behind", long_1, long_2);
|
||||
this.timeReference += (long)(long_2 * TickSpeed.mspt);//50L;
|
||||
this.lastTimeReference = this.timeReference;
|
||||
this.nextTickTime += (long)(long_2 * TickSpeed.mspt);//50L;
|
||||
this.lastOverloadWarning = this.nextTickTime;
|
||||
}
|
||||
|
||||
if (this.needsDebugSetup) {
|
||||
this.needsDebugSetup = false;
|
||||
this.profilerTimings = Pair.of(Util.getMeasuringTimeNano(), ticks);
|
||||
if (this.debugCommandProfilerDelayStart) {
|
||||
this.debugCommandProfilerDelayStart = false;
|
||||
this.profilerTimings = Pair.of(Util.getNanos(), tickCount);
|
||||
//this.field_33978 = new MinecraftServer.class_6414(Util.getMeasuringTimeNano(), this.ticks);
|
||||
}
|
||||
this.timeReference += msThisTick;//50L;
|
||||
this.nextTickTime += msThisTick;//50L;
|
||||
//TickDurationMonitor tickDurationMonitor = TickDurationMonitor.create("Server");
|
||||
//this.startMonitor(tickDurationMonitor);
|
||||
this.startTickMetrics();
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
this.tick(TickSpeed.time_warp_start_time != 0 ? ()->true : this::shouldKeepTicking);
|
||||
this.profiler.swap("nextTickWait");
|
||||
this.tickServer(TickSpeed.time_warp_start_time != 0 ? ()->true : this::haveTime);
|
||||
this.profiler.popPush("nextTickWait");
|
||||
if (TickSpeed.time_warp_start_time != 0) // clearing all hanging tasks no matter what when warping
|
||||
{
|
||||
while(this.runEveryTask()) {Thread.yield();}
|
||||
}
|
||||
this.waitingForNextTick = true;
|
||||
this.nextTickTimestamp = Math.max(Util.getMeasuringTimeMs() + /*50L*/ msThisTick, this.timeReference);
|
||||
this.mayHaveDelayedTasks = true;
|
||||
this.delayedTasksMaxNextTickTime = Math.max(Util.getMillis() + /*50L*/ msThisTick, this.nextTickTime);
|
||||
// run all tasks (this will not do a lot when warping), but that's fine since we already run them
|
||||
this.runTasksTillTickEnd();
|
||||
this.waitUntilNextTick();
|
||||
this.profiler.pop();
|
||||
this.endTickMetrics();
|
||||
this.loading = true;
|
||||
this.endMetricsRecordingTick();
|
||||
this.isReady = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -154,20 +154,20 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
// just because profilerTimings class is public
|
||||
Pair<Long,Integer> profilerTimings = null;
|
||||
/// overworld around profiler timings
|
||||
@Inject(method = "isDebugRunning", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "isTimeProfilerRunning", at = @At("HEAD"), cancellable = true)
|
||||
public void isCMDebugRunning(CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
cir.setReturnValue(needsDebugSetup || profilerTimings != null);
|
||||
cir.setReturnValue(debugCommandProfilerDelayStart || profilerTimings != null);
|
||||
}
|
||||
@Inject(method = "stopDebug", at = @At("HEAD"), cancellable = true)
|
||||
public void stopCMDebug(CallbackInfoReturnable<ProfileResult> cir)
|
||||
@Inject(method = "stopTimeProfiler", at = @At("HEAD"), cancellable = true)
|
||||
public void stopCMDebug(CallbackInfoReturnable<ProfileResults> cir)
|
||||
{
|
||||
if (this.profilerTimings == null) {
|
||||
cir.setReturnValue(EmptyProfileResult.INSTANCE);
|
||||
cir.setReturnValue(EmptyProfileResults.EMPTY);
|
||||
} else {
|
||||
ProfileResult profileResult = new CopyProfilerResult(
|
||||
ProfileResults profileResult = new CopyProfilerResult(
|
||||
profilerTimings.getRight(), profilerTimings.getLeft(),
|
||||
this.ticks, Util.getMeasuringTimeNano()
|
||||
this.tickCount, Util.getNanos()
|
||||
);
|
||||
this.profilerTimings = null;
|
||||
cir.setReturnValue(profileResult);
|
||||
@@ -176,12 +176,12 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
|
||||
|
||||
private boolean runEveryTask() {
|
||||
if (super.runTask()) {
|
||||
if (super.pollTask()) {
|
||||
return true;
|
||||
} else {
|
||||
if (true) { // unconditionally this time
|
||||
for(ServerWorld serverlevel : getWorlds()) {
|
||||
if (serverlevel.getChunkManager().executeQueuedTasks()) {
|
||||
for(ServerLevel serverlevel : getAllLevels()) {
|
||||
if (serverlevel.getChunkSource().pollTask()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -191,9 +191,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
@Inject(method = "tickServer", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;saveAll(ZZZ)Z", // save
|
||||
target = "Lnet/minecraft/server/MinecraftServer;saveEverything(ZZZ)Z", // save
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
@@ -201,9 +201,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
currentSection = CarpetProfiler.start_section(null, "Autosave", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tick", at = @At(
|
||||
@Inject(method = "tickServer", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;saveAll(ZZZ)Z",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;saveEverything(ZZZ)Z",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void finishAutosave(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
@@ -211,9 +211,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "tickWorlds", at = @At(
|
||||
@Inject(method = "tickChildren", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getNetworkIo()Lnet/minecraft/server/ServerNetworkIo;",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;getConnection()Lnet/minecraft/server/network/ServerConnectionListener;",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void startNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
@@ -221,9 +221,9 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
currentSection = CarpetProfiler.start_section(null, "Network", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
|
||||
@Inject(method = "tickWorlds", at = @At(
|
||||
@Inject(method = "tickChildren", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/PlayerManager;updatePlayerLatency()V",
|
||||
target = "Lnet/minecraft/server/players/PlayerList;tick()V",
|
||||
shift = At.Shift.AFTER
|
||||
))
|
||||
private void finishNetwork(BooleanSupplier booleanSupplier_1, CallbackInfo ci)
|
||||
@@ -231,14 +231,14 @@ public abstract class MinecraftServer_tickspeedMixin extends ReentrantThreadExec
|
||||
CarpetProfiler.end_current_section(currentSection);
|
||||
}
|
||||
|
||||
@Inject(method = "runTasksTillTickEnd", at = @At("HEAD"))
|
||||
@Inject(method = "waitUntilNextTick", at = @At("HEAD"))
|
||||
private void startAsync(CallbackInfo ci)
|
||||
{
|
||||
currentSection = CarpetProfiler.start_section(null, "Async Tasks", CarpetProfiler.TYPE.GENERAL);
|
||||
}
|
||||
@Inject(method = "runTasksTillTickEnd", at = @At(
|
||||
@Inject(method = "waitUntilNextTick", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;runTasks(Ljava/util/function/BooleanSupplier;)V",
|
||||
target = "Lnet/minecraft/server/MinecraftServer;managedBlock(Ljava/util/function/BooleanSupplier;)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void stopAsync(CallbackInfo ci)
|
||||
|
||||
@@ -4,11 +4,11 @@ import carpet.CarpetSettings;
|
||||
import carpet.helpers.ThrowableSuppression;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.utils.Messenger;
|
||||
import net.minecraft.ReportedException;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.chat.BaseComponent;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
@@ -19,21 +19,21 @@ import java.util.function.BooleanSupplier;
|
||||
public class MinecraftServer_updateSuppressionCrashFixMixin {
|
||||
|
||||
@Redirect(
|
||||
method = "tickWorlds",
|
||||
method = "tickChildren",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ServerWorld;tick(Ljava/util/function/BooleanSupplier;)V"
|
||||
target = "Lnet/minecraft/server/level/ServerLevel;tick(Ljava/util/function/BooleanSupplier;)V"
|
||||
),
|
||||
require = 0
|
||||
)
|
||||
private void fixUpdateSuppressionCrashTick(ServerWorld serverWorld, BooleanSupplier shouldKeepTicking){
|
||||
private void fixUpdateSuppressionCrashTick(ServerLevel serverWorld, BooleanSupplier shouldKeepTicking){
|
||||
if (!CarpetSettings.updateSuppressionCrashFix) {
|
||||
serverWorld.tick(shouldKeepTicking);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
serverWorld.tick(shouldKeepTicking);
|
||||
} catch (CrashException e) {
|
||||
} catch (ReportedException e) {
|
||||
if (!(e.getCause() instanceof ThrowableSuppression throwableSuppression)) throw e;
|
||||
logUpdateSuppression(throwableSuppression.pos);
|
||||
} catch (ThrowableSuppression e) {
|
||||
@@ -45,7 +45,7 @@ public class MinecraftServer_updateSuppressionCrashFixMixin {
|
||||
private void logUpdateSuppression(BlockPos pos) {
|
||||
if(LoggerRegistry.__updateSuppressedCrashes) {
|
||||
LoggerRegistry.getLogger("updateSuppressedCrashes").log(() -> {
|
||||
return new BaseText[]{Messenger.c(
|
||||
return new BaseComponent[]{Messenger.c(
|
||||
"w Server crash prevented in: ",
|
||||
"m world tick ",
|
||||
"w - at: ",
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.fakes.MobEntityInterface;
|
||||
import net.minecraft.entity.ai.goal.Goal;
|
||||
import net.minecraft.entity.ai.goal.GoalSelector;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
import net.minecraft.world.entity.ai.goal.Goal;
|
||||
import net.minecraft.world.entity.ai.goal.GoalSelector;
|
||||
|
||||
@Mixin(MobEntity.class)
|
||||
@Mixin(Mob.class)
|
||||
public abstract class MobEntityMixin implements MobEntityInterface
|
||||
{
|
||||
@Shadow @Final protected GoalSelector targetSelector;
|
||||
@Shadow @Final protected GoalSelector goalSelector;
|
||||
@Shadow private boolean persistent;
|
||||
@Shadow private boolean persistenceRequired;
|
||||
public final Map<String, Goal> temporaryTasks = new HashMap<>();
|
||||
|
||||
@Override
|
||||
@@ -34,6 +34,6 @@ public abstract class MobEntityMixin implements MobEntityInterface
|
||||
@Override
|
||||
public void setPersistence(boolean what)
|
||||
{
|
||||
persistent = what;
|
||||
persistenceRequired = what;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.RandomTools;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
|
||||
@Mixin(MobEntity.class)
|
||||
@Mixin(Mob.class)
|
||||
public class MobEntity_extremeMixin
|
||||
{
|
||||
@Redirect(method = "initialize", expect = 1, at = @At(
|
||||
@Redirect(method = "finalizeSpawn", expect = 1, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Ljava/util/Random;nextGaussian()D"
|
||||
))
|
||||
|
||||
@@ -2,42 +2,41 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.helpers.CustomSpawnLists;
|
||||
import net.minecraft.entity.SpawnGroup;
|
||||
import net.minecraft.util.collection.Pool;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.SpawnSettings;
|
||||
import net.minecraft.world.biome.source.BiomeSource;
|
||||
import net.minecraft.world.gen.StructureAccessor;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.NoiseChunkGenerator;
|
||||
import net.minecraft.world.gen.chunk.StructuresConfig;
|
||||
//import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.level.StructureFeatureManager;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.biome.BiomeSource;
|
||||
import net.minecraft.world.level.biome.MobSpawnSettings;
|
||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator;
|
||||
import net.minecraft.world.level.levelgen.StructureSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
|
||||
@Mixin(NoiseChunkGenerator.class)
|
||||
@Mixin(NoiseBasedChunkGenerator.class)
|
||||
// todo rename mixin after 1.15 is gone
|
||||
public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator
|
||||
{
|
||||
public NoiseChunkGenerator_husksSpawnMixin(BiomeSource biomeSource, StructuresConfig structuresConfig)
|
||||
public NoiseChunkGenerator_husksSpawnMixin(BiomeSource biomeSource, StructureSettings structuresConfig)
|
||||
{
|
||||
super(biomeSource, structuresConfig);
|
||||
}
|
||||
|
||||
@Inject(method = "getEntitySpawnList", at = @At("HEAD"), cancellable = true)
|
||||
private void isInsidePyramid(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos, CallbackInfoReturnable<Pool<SpawnSettings.SpawnEntry>> cir)
|
||||
@Inject(method = "getMobsAt", at = @At("HEAD"), cancellable = true)
|
||||
private void isInsidePyramid(Biome biome, StructureFeatureManager accessor, MobCategory group, BlockPos pos, CallbackInfoReturnable<WeightedRandomList<MobSpawnSettings.SpawnerData>> cir)
|
||||
{
|
||||
if (group == SpawnGroup.MONSTER)
|
||||
if (group == MobCategory.MONSTER)
|
||||
{
|
||||
if (CarpetSettings.huskSpawningInTemples)
|
||||
{
|
||||
if (accessor.getStructureAt(pos, StructureFeature.DESERT_PYRAMID).hasChildren())
|
||||
if (accessor.getStructureAt(pos, StructureFeature.DESERT_PYRAMID).isValid())
|
||||
{
|
||||
cir.setReturnValue(CustomSpawnLists.PYRAMID_SPAWNS);
|
||||
return;
|
||||
@@ -45,7 +44,7 @@ public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator
|
||||
}
|
||||
if (CarpetSettings.shulkerSpawningInEndCities)
|
||||
{
|
||||
if (accessor.getStructureAt(pos, StructureFeature.END_CITY).hasChildren())
|
||||
if (accessor.getStructureAt(pos, StructureFeature.END_CITY).isValid())
|
||||
{
|
||||
cir.setReturnValue(CustomSpawnLists.SHULKER_SPAWNS);
|
||||
return;
|
||||
@@ -53,7 +52,7 @@ public abstract class NoiseChunkGenerator_husksSpawnMixin extends ChunkGenerator
|
||||
}
|
||||
if (CarpetSettings.piglinsSpawningInBastions)
|
||||
{
|
||||
if (accessor.getStructureAt(pos, StructureFeature.BASTION_REMNANT).hasChildren())
|
||||
if (accessor.getStructureAt(pos, StructureFeature.BASTION_REMNANT).isValid())
|
||||
{
|
||||
cir.setReturnValue(CustomSpawnLists.BASTION_SPAWNS);
|
||||
}
|
||||
|
||||
@@ -2,247 +2,247 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.NoiseColumnSamplerInterface;
|
||||
import carpet.script.exception.InternalExpressionException;
|
||||
import net.minecraft.util.math.noise.DoublePerlinNoiseSampler;
|
||||
import net.minecraft.util.math.noise.InterpolatedNoiseSampler;
|
||||
import net.minecraft.util.math.noise.SimplexNoiseSampler;
|
||||
import net.minecraft.world.biome.source.BiomeCoords;
|
||||
import net.minecraft.world.biome.source.util.MultiNoiseUtil;
|
||||
import net.minecraft.world.biome.source.util.TerrainNoisePoint;
|
||||
import net.minecraft.world.gen.NoiseColumnSampler;
|
||||
import net.minecraft.world.gen.NoiseHelper;
|
||||
import net.minecraft.world.gen.chunk.Blender;
|
||||
import net.minecraft.world.gen.chunk.GenerationShapeConfig;
|
||||
import net.minecraft.core.QuartPos;
|
||||
import net.minecraft.world.level.biome.Climate;
|
||||
import net.minecraft.world.level.levelgen.NoiseSampler;
|
||||
import net.minecraft.world.level.levelgen.NoiseSettings;
|
||||
import net.minecraft.world.level.levelgen.TerrainInfo;
|
||||
import net.minecraft.world.level.levelgen.blending.Blender;
|
||||
import net.minecraft.world.level.levelgen.synth.BlendedNoise;
|
||||
import net.minecraft.world.level.levelgen.synth.NoiseUtils;
|
||||
import net.minecraft.world.level.levelgen.synth.NormalNoise;
|
||||
import net.minecraft.world.level.levelgen.synth.SimplexNoise;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(NoiseColumnSampler.class)
|
||||
@Mixin(NoiseSampler.class)
|
||||
public abstract class NoiseColumnSamplerMixin_scarpetMixin implements NoiseColumnSamplerInterface {
|
||||
|
||||
@Shadow @Final
|
||||
private InterpolatedNoiseSampler terrainNoise;
|
||||
private BlendedNoise blendedNoise;
|
||||
|
||||
@Shadow @Final @Nullable
|
||||
private SimplexNoiseSampler islandNoise;
|
||||
private SimplexNoise islandNoise;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler aquiferBarrierNoise;
|
||||
private NormalNoise barrierNoise;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler aquiferFluidLevelFloodednessNoise;
|
||||
private NormalNoise fluidLevelFloodednessNoise;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler aquiferFluidLevelSpreadNoise;
|
||||
private NormalNoise fluidLevelSpreadNoise;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler aquiferLavaNoise;
|
||||
private NormalNoise lavaNoise;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler pillarRarenessNoise;
|
||||
private NormalNoise pillarRarenessModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler pillarThicknessNoise;
|
||||
private NormalNoise pillarThicknessModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti2dElevationNoise;
|
||||
private NormalNoise spaghetti2DElevationModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti2dModulatorNoise;
|
||||
private NormalNoise spaghetti2DRarityModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti2dThicknessNoise;
|
||||
private NormalNoise spaghetti2DThicknessModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti3dFirstNoise;
|
||||
private NormalNoise spaghetti3DNoiseSource1;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti3dSecondNoise;
|
||||
private NormalNoise spaghetti3DNoiseSource2;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti3dRarityNoise;
|
||||
private NormalNoise spaghetti3DRarityModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghetti3dThicknessNoise;
|
||||
private NormalNoise spaghetti3DThicknessModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler spaghettiRoughnessModulatorNoise;
|
||||
private NormalNoise spaghettiRoughnessModulator;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler caveCheeseNoise;
|
||||
private NormalNoise cheeseNoiseSource;
|
||||
|
||||
@Shadow @Final
|
||||
private DoublePerlinNoiseSampler oreGapNoise;
|
||||
private NormalNoise gapNoise;
|
||||
|
||||
@Shadow @Final
|
||||
private GenerationShapeConfig config;
|
||||
private NoiseSettings noiseSettings;
|
||||
|
||||
@Shadow
|
||||
protected abstract double method_38409(double d, double e, double f);
|
||||
protected abstract double sampleJaggedNoise(double d, double e, double f);
|
||||
|
||||
@Shadow
|
||||
protected abstract double sampleCaveLayerNoise(int x, int y, int z);
|
||||
protected abstract double getLayerizedCaverns(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract double samplePillarNoise(int x, int y, int z);
|
||||
protected abstract double getPillars(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract double sampleSpaghetti2dNoise(int x, int y, int z);
|
||||
protected abstract double getSpaghetti2D(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract double sampleSpaghetti3dNoise(int x, int y, int z);
|
||||
protected abstract double getSpaghetti3D(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract double sampleSpaghettiRoughnessNoise(int x, int y, int z);
|
||||
protected abstract double spaghettiRoughness(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
protected abstract double sampleCaveEntranceNoise(int x, int y, int z);
|
||||
protected abstract double getBigEntrances(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
public abstract double sampleShiftNoise(int x, int y, int z);
|
||||
public abstract double getOffset(int x, int y, int z);
|
||||
|
||||
@Shadow
|
||||
private static double sample(DoublePerlinNoiseSampler sampler, double x, double y, double z, double invertedScale) {
|
||||
private static double sampleWithRarity(NormalNoise sampler, double x, double y, double z, double invertedScale) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract MultiNoiseUtil.NoiseValuePoint sample(int i, int j, int k);
|
||||
public abstract Climate.TargetPoint sample(int i, int j, int k);
|
||||
|
||||
@Shadow
|
||||
public abstract TerrainNoisePoint createTerrainNoisePoint(int x, int z, float continentalness, float weirdness, float erosion, Blender blender);
|
||||
public abstract TerrainInfo terrainInfo(int x, int z, float continentalness, float weirdness, float erosion, Blender blender);
|
||||
|
||||
@Override
|
||||
public double getNoiseSample(String name, int x, int y, int z) {
|
||||
MultiNoiseUtil.NoiseValuePoint noiseValuePoint = this.sample(x, y, z);
|
||||
TerrainNoisePoint terrainNoisePoint = createTerrainNoisePoint(
|
||||
Climate.TargetPoint noiseValuePoint = this.sample(x, y, z);
|
||||
TerrainInfo terrainNoisePoint = terrainInfo(
|
||||
x,
|
||||
z,
|
||||
MultiNoiseUtil.method_38666(noiseValuePoint.continentalnessNoise()),
|
||||
MultiNoiseUtil.method_38666(noiseValuePoint.weirdnessNoise()),
|
||||
MultiNoiseUtil.method_38666(noiseValuePoint.erosionNoise()),
|
||||
Blender.getNoBlending()
|
||||
Climate.unquantizeCoord(noiseValuePoint.continentalness()),
|
||||
Climate.unquantizeCoord(noiseValuePoint.weirdness()),
|
||||
Climate.unquantizeCoord(noiseValuePoint.erosion()),
|
||||
Blender.empty()
|
||||
);
|
||||
switch (name) {
|
||||
case "temperature" -> {
|
||||
return MultiNoiseUtil.method_38666(noiseValuePoint.temperatureNoise());
|
||||
return Climate.unquantizeCoord(noiseValuePoint.temperature());
|
||||
}
|
||||
case "humidity" -> {
|
||||
return MultiNoiseUtil.method_38666(noiseValuePoint.humidityNoise());
|
||||
return Climate.unquantizeCoord(noiseValuePoint.humidity());
|
||||
}
|
||||
case "continentalness" -> {
|
||||
return MultiNoiseUtil.method_38666(noiseValuePoint.continentalnessNoise());
|
||||
return Climate.unquantizeCoord(noiseValuePoint.continentalness());
|
||||
}
|
||||
case "erosion" -> {
|
||||
return MultiNoiseUtil.method_38666(noiseValuePoint.erosionNoise());
|
||||
return Climate.unquantizeCoord(noiseValuePoint.erosion());
|
||||
}
|
||||
case "weirdness" -> {
|
||||
return MultiNoiseUtil.method_38666(noiseValuePoint.weirdnessNoise());
|
||||
return Climate.unquantizeCoord(noiseValuePoint.weirdness());
|
||||
}
|
||||
case "depth" -> {
|
||||
return MultiNoiseUtil.method_38666(noiseValuePoint.depth());
|
||||
return Climate.unquantizeCoord(noiseValuePoint.depth());
|
||||
}
|
||||
case "shiftX" -> {
|
||||
return x + this.sampleShiftNoise(x, 0, z);
|
||||
return x + this.getOffset(x, 0, z);
|
||||
}
|
||||
case "shiftY" -> {
|
||||
return y + this.sampleShiftNoise(y, z, x);
|
||||
return y + this.getOffset(y, z, x);
|
||||
}
|
||||
case "shiftZ" -> {
|
||||
return z + this.sampleShiftNoise(z, x, 0);
|
||||
return z + this.getOffset(z, x, 0);
|
||||
}
|
||||
case "terrain" -> {
|
||||
return this.terrainNoise.calculateNoise(x, y, z);
|
||||
return this.blendedNoise.calculateNoise(x, y, z);
|
||||
}
|
||||
case "island" -> {
|
||||
return this.islandNoise == null ? 0 : this.islandNoise.sample(x, y, z);
|
||||
return this.islandNoise == null ? 0 : this.islandNoise.getValue(x, y, z);
|
||||
}
|
||||
case "jagged" -> {
|
||||
return this.method_38409(terrainNoisePoint.peaks(), x, z);
|
||||
return this.sampleJaggedNoise(terrainNoisePoint.jaggedness(), x, z);
|
||||
}
|
||||
case "aquiferBarrier" -> {
|
||||
return this.aquiferBarrierNoise.sample(x, y, z);
|
||||
return this.barrierNoise.getValue(x, y, z);
|
||||
}
|
||||
case "aquiferFluidLevelFloodedness" -> {
|
||||
return this.aquiferFluidLevelFloodednessNoise.sample(x, y, z);
|
||||
return this.fluidLevelFloodednessNoise.getValue(x, y, z);
|
||||
}
|
||||
case "aquiferFluidLevelSpread" -> {
|
||||
return this.aquiferFluidLevelSpreadNoise.sample(x, y, z);
|
||||
return this.fluidLevelSpreadNoise.getValue(x, y, z);
|
||||
}
|
||||
case "aquiferLava" -> {
|
||||
return this.aquiferLavaNoise.sample(x, y, z);
|
||||
return this.lavaNoise.getValue(x, y, z);
|
||||
}
|
||||
case "pillar" -> {
|
||||
return this.samplePillarNoise(x, y, z);
|
||||
return this.getPillars(x, y, z);
|
||||
}
|
||||
case "pillarRareness" -> {
|
||||
return NoiseHelper.lerpFromProgress(this.pillarRarenessNoise, x, y, z, 0.0D, 2.0D);
|
||||
return NoiseUtils.sampleNoiseAndMapToRange(this.pillarRarenessModulator, x, y, z, 0.0D, 2.0D);
|
||||
}
|
||||
case "pillarThickness" -> {
|
||||
return NoiseHelper.lerpFromProgress(this.pillarThicknessNoise, x, y, z, 0.0D, 1.1D);
|
||||
return NoiseUtils.sampleNoiseAndMapToRange(this.pillarThicknessModulator, x, y, z, 0.0D, 1.1D);
|
||||
}
|
||||
case "spaghetti2d" -> {
|
||||
return this.sampleSpaghetti2dNoise(x, y, z);
|
||||
return this.getSpaghetti2D(x, y, z);
|
||||
}
|
||||
case "spaghetti2dElevation" -> {
|
||||
return NoiseHelper.lerpFromProgress(this.spaghetti2dElevationNoise, x, 0.0, z, this.config.minimumBlockY(), 8.0);
|
||||
return NoiseUtils.sampleNoiseAndMapToRange(this.spaghetti2DElevationModulator, x, 0.0, z, this.noiseSettings.getMinCellY(), 8.0);
|
||||
}
|
||||
case "spaghetti2dModulator" -> {
|
||||
return this.spaghetti2dModulatorNoise.sample(x * 2, y, z * 2);
|
||||
return this.spaghetti2DRarityModulator.getValue(x * 2, y, z * 2);
|
||||
}
|
||||
case "spaghetti2dThickness" -> {
|
||||
return NoiseHelper.lerpFromProgress(this.spaghetti2dThicknessNoise, x * 2, y, z * 2, 0.6, 1.3);
|
||||
return NoiseUtils.sampleNoiseAndMapToRange(this.spaghetti2DThicknessModulator, x * 2, y, z * 2, 0.6, 1.3);
|
||||
}
|
||||
case "spaghetti3d" -> {
|
||||
return this.sampleSpaghetti3dNoise(x, y, z);
|
||||
return this.getSpaghetti3D(x, y, z);
|
||||
}
|
||||
case "spaghetti3dFirst" -> {
|
||||
double d = this.spaghetti3dRarityNoise.sample(x * 2, y, z * 2);
|
||||
double e = CaveScalerMixin_scarpetMixin.invokeScaleTunnels(d);
|
||||
return sample(this.spaghetti3dFirstNoise, x, y, z, e);
|
||||
double d = this.spaghetti3DRarityModulator.getValue(x * 2, y, z * 2);
|
||||
double e = CaveScalerMixin_scarpetMixin.invokeGetSpaghettiRarity3D(d);
|
||||
return sampleWithRarity(this.spaghetti3DNoiseSource1, x, y, z, e);
|
||||
}
|
||||
case "spaghetti3dSecond" -> {
|
||||
double d = this.spaghetti3dRarityNoise.sample(x * 2, y, z * 2);
|
||||
double e = CaveScalerMixin_scarpetMixin.invokeScaleTunnels(d);
|
||||
return sample(this.spaghetti3dSecondNoise, x, y, z, e);
|
||||
double d = this.spaghetti3DRarityModulator.getValue(x * 2, y, z * 2);
|
||||
double e = CaveScalerMixin_scarpetMixin.invokeGetSpaghettiRarity3D(d);
|
||||
return sampleWithRarity(this.spaghetti3DNoiseSource2, x, y, z, e);
|
||||
}
|
||||
case "spaghetti3dRarity" -> {
|
||||
return this.spaghetti3dRarityNoise.sample(x * 2, y, z * 2);
|
||||
return this.spaghetti3DRarityModulator.getValue(x * 2, y, z * 2);
|
||||
}
|
||||
case "spaghetti3dThickness" -> {
|
||||
return NoiseHelper.lerpFromProgress(this.spaghetti3dThicknessNoise, x, y, z, 0.065, 0.088);
|
||||
return NoiseUtils.sampleNoiseAndMapToRange(this.spaghetti3DThicknessModulator, x, y, z, 0.065, 0.088);
|
||||
}
|
||||
case "spaghettiRoughness" -> {
|
||||
return this.sampleSpaghettiRoughnessNoise(x, y, z);
|
||||
return this.spaghettiRoughness(x, y, z);
|
||||
}
|
||||
case "spaghettiRoughnessModulator" -> {
|
||||
return NoiseHelper.lerpFromProgress(this.spaghettiRoughnessModulatorNoise, x, y, z, 0.0, 0.1);
|
||||
return NoiseUtils.sampleNoiseAndMapToRange(this.spaghettiRoughnessModulator, x, y, z, 0.0, 0.1);
|
||||
}
|
||||
case "caveEntrance" -> {
|
||||
return this.sampleCaveEntranceNoise(
|
||||
BiomeCoords.toBlock(x),
|
||||
BiomeCoords.toBlock(y),
|
||||
BiomeCoords.toBlock(z)
|
||||
return this.getBigEntrances(
|
||||
QuartPos.toBlock(x),
|
||||
QuartPos.toBlock(y),
|
||||
QuartPos.toBlock(z)
|
||||
);
|
||||
}
|
||||
case "caveLayer" -> {
|
||||
// scaling them by 4 because it's sampled in normal coords
|
||||
return this.sampleCaveLayerNoise(
|
||||
BiomeCoords.toBlock(x),
|
||||
BiomeCoords.toBlock(y),
|
||||
BiomeCoords.toBlock(z)
|
||||
return this.getLayerizedCaverns(
|
||||
QuartPos.toBlock(x),
|
||||
QuartPos.toBlock(y),
|
||||
QuartPos.toBlock(z)
|
||||
);
|
||||
}
|
||||
case "caveCheese" -> {
|
||||
// same reason as above
|
||||
return this.caveCheeseNoise.sample(
|
||||
BiomeCoords.toBlock(x),
|
||||
BiomeCoords.toBlock(y) / 1.5,
|
||||
BiomeCoords.toBlock(z)
|
||||
return this.cheeseNoiseSource.getValue(
|
||||
QuartPos.toBlock(x),
|
||||
QuartPos.toBlock(y) / 1.5,
|
||||
QuartPos.toBlock(z)
|
||||
);
|
||||
}
|
||||
case "terrainPeaks" -> {
|
||||
return terrainNoisePoint.peaks();
|
||||
return terrainNoisePoint.jaggedness();
|
||||
}
|
||||
case "terrainOffset" -> {
|
||||
return terrainNoisePoint.offset();
|
||||
@@ -251,7 +251,7 @@ public abstract class NoiseColumnSamplerMixin_scarpetMixin implements NoiseColum
|
||||
return terrainNoisePoint.factor();
|
||||
}
|
||||
case "oreGap" -> {
|
||||
return this.oreGapNoise.sample(x, y, z);
|
||||
return this.gapNoise.getValue(x, y, z);
|
||||
}
|
||||
}
|
||||
throw new InternalExpressionException("Unknown noise type: " + name);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.dedicated.command.PerfCommand;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.server.commands.PerfCommand;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -12,10 +12,10 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
public class PerfCommand_permissionMixin
|
||||
{
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Inject(method = "method_37340(Lnet/minecraft/server/command/ServerCommandSource;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private static void canRun(ServerCommandSource source, CallbackInfoReturnable<Boolean> cir)
|
||||
@Inject(method = "lambda$register$0(Lnet/minecraft/commands/CommandSourceStack;)Z", at = @At("HEAD"), cancellable = true)
|
||||
private static void canRun(CommandSourceStack source, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
cir.setReturnValue(source.hasPermissionLevel(CarpetSettings.perfPermissionLevel));
|
||||
cir.setReturnValue(source.hasPermission(CarpetSettings.perfPermissionLevel));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,31 +1,31 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.MiningToolItem;
|
||||
import net.minecraft.item.PickaxeItem;
|
||||
import net.minecraft.item.ToolMaterial;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.world.item.DiggerItem;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.PickaxeItem;
|
||||
import net.minecraft.world.item.Tier;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
//import org.spongepowered.asm.mixin.injection.At;
|
||||
//import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(PickaxeItem.class)
|
||||
public class PickaxeItem_missingToolsMixin extends MiningToolItem
|
||||
public class PickaxeItem_missingToolsMixin extends DiggerItem
|
||||
{
|
||||
|
||||
protected PickaxeItem_missingToolsMixin(float attackDamage, float attackSpeed, ToolMaterial material, Tag<Block> tag, Settings settings) {
|
||||
protected PickaxeItem_missingToolsMixin(float attackDamage, float attackSpeed, Tier material, Tag<Block> tag, Properties settings) {
|
||||
super(attackDamage, attackSpeed, material, tag, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
|
||||
public float getDestroySpeed(ItemStack stack, BlockState state) {
|
||||
Material material = state.getMaterial();
|
||||
if (CarpetSettings.missingTools && material == Material.GLASS)
|
||||
return miningSpeed;
|
||||
return super.getMiningSpeedMultiplier(stack, state);
|
||||
return speed;
|
||||
return super.getDestroySpeed(stack, state);
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -2,33 +2,33 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.PistonBlockEntityInterface;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
|
||||
import net.minecraft.client.render.block.entity.PistonBlockEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.client.renderer.blockentity.PistonHeadRenderer;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(PistonBlockEntityRenderer.class)
|
||||
public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockEntityRenderer<PistonBlockEntity>
|
||||
@Mixin(PistonHeadRenderer.class)
|
||||
public abstract class PistonBlockEntityRenderer_movableBEMixin implements BlockEntityRenderer<PistonMovingBlockEntity>
|
||||
{
|
||||
BlockEntityRenderDispatcher dispatcher;
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void onInitCM(BlockEntityRendererFactory.Context arguments, CallbackInfo ci)
|
||||
private void onInitCM(BlockEntityRendererProvider.Context arguments, CallbackInfo ci)
|
||||
{
|
||||
dispatcher = arguments.getRenderDispatcher();
|
||||
dispatcher = arguments.getBlockEntityRenderDispatcher();
|
||||
}
|
||||
|
||||
@Inject(method = "render", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/render/block/entity/PistonBlockEntityRenderer;renderModel(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;ZI)V", ordinal = 3))
|
||||
private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, float float_1, MatrixStack matrixStack_1, VertexConsumerProvider layeredVertexConsumerStorage_1, int int_1, int int_2, CallbackInfo ci)
|
||||
target = "Lnet/minecraft/client/renderer/blockentity/PistonHeadRenderer;renderBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/level/Level;ZI)V", ordinal = 3))
|
||||
private void updateRenderBool(PistonMovingBlockEntity pistonBlockEntity_1, float float_1, PoseStack matrixStack_1, MultiBufferSource layeredVertexConsumerStorage_1, int int_1, int int_2, CallbackInfo ci)
|
||||
//private void updateRenderBool(PistonBlockEntity pistonBlockEntity_1, double double_1, double double_2, double double_3, float float_1, class_4587 class_4587_1, class_4597 class_4597_1, int int_1, CallbackInfo ci)
|
||||
{
|
||||
if (!((PistonBlockEntityInterface) pistonBlockEntity_1).isRenderModeSet())
|
||||
@@ -37,7 +37,7 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockE
|
||||
|
||||
|
||||
@Inject(method = "render", at = @At("RETURN"), locals = LocalCapture.NO_CAPTURE)
|
||||
private void endMethod3576(PistonBlockEntity pistonBlockEntity_1, float partialTicks, MatrixStack matrixStack_1, VertexConsumerProvider layeredVertexConsumerStorage_1, int int_1, int init_2, CallbackInfo ci)
|
||||
private void endMethod3576(PistonMovingBlockEntity pistonBlockEntity_1, float partialTicks, PoseStack matrixStack_1, MultiBufferSource layeredVertexConsumerStorage_1, int int_1, int init_2, CallbackInfo ci)
|
||||
{
|
||||
if (((PistonBlockEntityInterface) pistonBlockEntity_1).getRenderCarriedBlockEntity())
|
||||
{
|
||||
@@ -47,9 +47,9 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin implements BlockE
|
||||
// maybe ??? carriedBlockEntity.setPos(pistonBlockEntity_1.getPos());
|
||||
//((BlockEntityRenderDispatcherInterface) BlockEntityRenderDispatcher.INSTANCE).renderBlockEntityOffset(carriedBlockEntity, float_1, int_1, BlockRenderLayer.field_20799, bufferBuilder_1, pistonBlockEntity_1.getRenderOffsetX(float_1), pistonBlockEntity_1.getRenderOffsetY(float_1), pistonBlockEntity_1.getRenderOffsetZ(float_1));
|
||||
matrixStack_1.translate(
|
||||
pistonBlockEntity_1.getRenderOffsetX(partialTicks),
|
||||
pistonBlockEntity_1.getRenderOffsetY(partialTicks),
|
||||
pistonBlockEntity_1.getRenderOffsetZ(partialTicks)
|
||||
pistonBlockEntity_1.getXOff(partialTicks),
|
||||
pistonBlockEntity_1.getYOff(partialTicks),
|
||||
pistonBlockEntity_1.getZOff(partialTicks)
|
||||
);
|
||||
dispatcher.render(carriedBlockEntity, partialTicks, matrixStack_1, layeredVertexConsumerStorage_1);
|
||||
|
||||
+43
-43
@@ -4,16 +4,16 @@ import carpet.CarpetSettings;
|
||||
import carpet.fakes.BlockEntityInterface;
|
||||
import carpet.fakes.PistonBlockEntityInterface;
|
||||
import carpet.fakes.WorldInterface;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockEntityProvider;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.EntityBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -22,19 +22,19 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(PistonBlockEntity.class)
|
||||
public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity implements PistonBlockEntityInterface
|
||||
@Mixin(PistonMovingBlockEntity.class)
|
||||
public abstract class PistonBlockEntity_movableBEMixin extends BlockEntity implements PistonBlockEntityInterface
|
||||
{
|
||||
@Shadow
|
||||
private boolean source;
|
||||
private boolean isSourcePiston;
|
||||
@Shadow
|
||||
private BlockState pushedBlock;
|
||||
private BlockState movedState;
|
||||
|
||||
private BlockEntity carriedBlockEntity;
|
||||
private boolean renderCarriedBlockEntity = false;
|
||||
private boolean renderSet = false;
|
||||
|
||||
public PistonBlockEntity_movableTEMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
public PistonBlockEntity_movableBEMixin(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
||||
super(blockEntityType, blockPos, blockState);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorld(World world) {
|
||||
super.setWorld(world);
|
||||
if (carriedBlockEntity != null) carriedBlockEntity.setWorld(world);
|
||||
public void setLevel(Level world) {
|
||||
super.setLevel(world);
|
||||
if (carriedBlockEntity != null) carriedBlockEntity.setLevel(world);
|
||||
}
|
||||
|
||||
public void setCarriedBlockEntity(BlockEntity blockEntity)
|
||||
@@ -58,9 +58,9 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
this.carriedBlockEntity = blockEntity;
|
||||
if (this.carriedBlockEntity != null)
|
||||
{
|
||||
((BlockEntityInterface)carriedBlockEntity).setCMPos(pos);
|
||||
((BlockEntityInterface)carriedBlockEntity).setCMPos(worldPosition);
|
||||
// this might be little dangerous since pos is final for a hashing reason?
|
||||
if (world != null) carriedBlockEntity.setWorld(world);
|
||||
if (level != null) carriedBlockEntity.setLevel(level);
|
||||
}
|
||||
// this.carriedBlockEntity.setPos(this.pos);
|
||||
}
|
||||
@@ -85,23 +85,23 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
* @author 2No2Name
|
||||
*/
|
||||
@Redirect(method = "tick", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
|
||||
target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
|
||||
private static boolean movableTEsetBlockState0(
|
||||
World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1,
|
||||
World world2, BlockPos blockPos, BlockState blockState, PistonBlockEntity pistonBlockEntity)
|
||||
Level world, BlockPos blockPos_1, BlockState blockAState_2, int int_1,
|
||||
Level world2, BlockPos blockPos, BlockState blockState, PistonMovingBlockEntity pistonBlockEntity)
|
||||
{
|
||||
if (!CarpetSettings.movableBlockEntities)
|
||||
return world.setBlockState(blockPos_1, blockAState_2, int_1);
|
||||
return world.setBlock(blockPos_1, blockAState_2, int_1);
|
||||
else
|
||||
return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, ((PistonBlockEntityInterface)pistonBlockEntity).getCarriedBlockEntity(), int_1);
|
||||
}
|
||||
|
||||
@Redirect(method = "finish", at = @At(value = "INVOKE",
|
||||
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)
|
||||
@Redirect(method = "finalTick", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Level;setBlock(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;I)Z"))
|
||||
private boolean movableTEsetBlockState1(Level world, BlockPos blockPos_1, BlockState blockState_2, int int_1)
|
||||
{
|
||||
if (!CarpetSettings.movableBlockEntities)
|
||||
return world.setBlockState(blockPos_1, blockState_2, int_1);
|
||||
return world.setBlock(blockPos_1, blockState_2, int_1);
|
||||
else
|
||||
{
|
||||
boolean ret = ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockState_2, this.carriedBlockEntity, int_1);
|
||||
@@ -110,44 +110,44 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "finish", at = @At(value = "RETURN"))
|
||||
@Inject(method = "finalTick", at = @At(value = "RETURN"))
|
||||
private void finishHandleBroken(CallbackInfo cir)
|
||||
{
|
||||
//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.
|
||||
// This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
|
||||
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
|
||||
if (CarpetSettings.movableBlockEntities && this.carriedBlockEntity != null && !this.level.isClientSide && this.level.getBlockState(this.worldPosition).getBlock() == Blocks.AIR)
|
||||
{
|
||||
BlockState blockState_2;
|
||||
if (this.source)
|
||||
blockState_2 = Blocks.AIR.getDefaultState();
|
||||
if (this.isSourcePiston)
|
||||
blockState_2 = Blocks.AIR.defaultBlockState();
|
||||
else
|
||||
blockState_2 = Block.postProcessState(this.pushedBlock, this.world, this.pos);
|
||||
((WorldInterface) (this.world)).setBlockStateWithBlockEntity(this.pos, blockState_2, this.carriedBlockEntity, 3);
|
||||
this.world.breakBlock(this.pos, false, null);
|
||||
blockState_2 = Block.updateFromNeighbourShapes(this.movedState, this.level, this.worldPosition);
|
||||
((WorldInterface) (this.level)).setBlockStateWithBlockEntity(this.worldPosition, blockState_2, this.carriedBlockEntity, 3);
|
||||
this.level.destroyBlock(this.worldPosition, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "readNbt", at = @At(value = "TAIL"))
|
||||
private void onFromTag(NbtCompound NbtCompound_1, CallbackInfo ci)
|
||||
@Inject(method = "load", at = @At(value = "TAIL"))
|
||||
private void onFromTag(CompoundTag NbtCompound_1, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.movableBlockEntities && NbtCompound_1.contains("carriedTileEntityCM", 10))
|
||||
{
|
||||
if (this.pushedBlock.getBlock() instanceof BlockEntityProvider)
|
||||
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(pos, pushedBlock);// this.world);
|
||||
if (this.movedState.getBlock() instanceof EntityBlock)
|
||||
this.carriedBlockEntity = ((EntityBlock) (this.movedState.getBlock())).newBlockEntity(worldPosition, movedState);// this.world);
|
||||
if (carriedBlockEntity != null) //Can actually be null, as BlockPistonMoving.createNewTileEntity(...) returns null
|
||||
this.carriedBlockEntity.readNbt(NbtCompound_1.getCompound("carriedTileEntityCM"));
|
||||
this.carriedBlockEntity.load(NbtCompound_1.getCompound("carriedTileEntityCM"));
|
||||
setCarriedBlockEntity(carriedBlockEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "writeNbt", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void onToTag(NbtCompound NbtCompound_1, CallbackInfo ci)
|
||||
@Inject(method = "saveAdditional", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
|
||||
private void onToTag(CompoundTag 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.createNbt());
|
||||
NbtCompound_1.put("carriedTileEntityCM", this.carriedBlockEntity.saveWithoutMetadata());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,16 @@ package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.patches.EntityPlayerMPFake;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.PistonBlockEntity;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.piston.PistonMovingBlockEntity;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -19,54 +19,54 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(PistonBlockEntity.class)
|
||||
@Mixin(PistonMovingBlockEntity.class)
|
||||
public abstract class PistonBlockEntity_playerHandlingMixin
|
||||
{
|
||||
@Shadow private BlockState pushedBlock;
|
||||
@Shadow private BlockState movedState;
|
||||
|
||||
@Shadow public abstract Direction getMovementDirection();
|
||||
|
||||
@Inject(method = "moveEntity", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "moveEntityByPiston", at = @At("HEAD"), cancellable = true)
|
||||
private static void dontPushSpectators(Direction direction, Entity entity, double d, Direction direction2, CallbackInfo ci)
|
||||
{
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) ci.cancel();
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof Player && (((Player) entity).isCreative()) && ((Player) entity).getAbilities().flying) ci.cancel();
|
||||
}
|
||||
|
||||
@Redirect(method = "pushEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;setVelocity(DDD)V"))
|
||||
@Redirect(method = "moveCollidedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(DDD)V"))
|
||||
private static void ignoreAccel(Entity entity, double x, double y, double z)
|
||||
{
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof PlayerEntity && (((PlayerEntity) entity).isCreative()) && ((PlayerEntity) entity).getAbilities().flying) return;
|
||||
entity.setVelocity(x,y,z);
|
||||
if (CarpetSettings.creativeNoClip && entity instanceof Player && (((Player) entity).isCreative()) && ((Player) entity).getAbilities().flying) return;
|
||||
entity.setDeltaMovement(x,y,z);
|
||||
}
|
||||
|
||||
@Redirect(method = "pushEntities", at = @At(
|
||||
@Redirect(method = "moveCollidedEntities", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/Entity;getPistonBehavior()Lnet/minecraft/block/piston/PistonBehavior;"
|
||||
target = "Lnet/minecraft/world/entity/Entity;getPistonPushReaction()Lnet/minecraft/world/level/material/PushReaction;"
|
||||
))
|
||||
private static PistonBehavior moveFakePlayers(Entity entity,
|
||||
World world, BlockPos blockPos, float ff, PistonBlockEntity pistonBlockEntity)
|
||||
private static PushReaction moveFakePlayers(Entity entity,
|
||||
Level world, BlockPos blockPos, float ff, PistonMovingBlockEntity pistonBlockEntity)
|
||||
{
|
||||
if (entity instanceof EntityPlayerMPFake && pistonBlockEntity.getPushedBlock().isOf(Blocks.SLIME_BLOCK))
|
||||
if (entity instanceof EntityPlayerMPFake && pistonBlockEntity.getMovedState().is(Blocks.SLIME_BLOCK))
|
||||
{
|
||||
Vec3d vec3d = entity.getVelocity();
|
||||
Vec3 vec3d = entity.getDeltaMovement();
|
||||
double e = vec3d.x;
|
||||
double f = vec3d.y;
|
||||
double g = vec3d.z;
|
||||
Direction direction = pistonBlockEntity.getMovementDirection();
|
||||
switch(direction.getAxis()) {
|
||||
case X:
|
||||
e = (double)direction.getOffsetX();
|
||||
e = (double)direction.getStepX();
|
||||
break;
|
||||
case Y:
|
||||
f = (double)direction.getOffsetY();
|
||||
f = (double)direction.getStepY();
|
||||
break;
|
||||
case Z:
|
||||
g = (double)direction.getOffsetZ();
|
||||
g = (double)direction.getStepZ();
|
||||
}
|
||||
|
||||
entity.setVelocity(e, f, g);
|
||||
entity.setDeltaMovement(e, f, g);
|
||||
}
|
||||
return entity.getPistonBehavior();
|
||||
return entity.getPistonPushReaction();
|
||||
}
|
||||
|
||||
}
|
||||
+39
-33
@@ -3,13 +3,19 @@ package carpet.mixins;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.fakes.PistonBlockEntityInterface;
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.piston.PistonBehavior;
|
||||
import net.minecraft.block.piston.PistonHandler;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.CommandBlock;
|
||||
import net.minecraft.world.level.block.DirectionalBlock;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.piston.MovingPistonBlock;
|
||||
import net.minecraft.world.level.block.piston.PistonBaseBlock;
|
||||
import net.minecraft.world.level.block.piston.PistonStructureResolver;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -20,18 +26,18 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(PistonBlock.class)
|
||||
public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
@Mixin(PistonBaseBlock.class)
|
||||
public abstract class PistonBlock_movableBEMixin extends DirectionalBlock
|
||||
{
|
||||
protected PistonBlock_movableTEMixin(Settings block$Settings_1)
|
||||
protected PistonBlock_movableBEMixin(Properties block$Settings_1)
|
||||
{
|
||||
super(block$Settings_1);
|
||||
}
|
||||
|
||||
private ThreadLocal<List<BlockEntity>> list1_BlockEntities = new ThreadLocal<>(); //Unneccessary ThreadLocal if client and server use different PistonBlock instances
|
||||
|
||||
@Inject(method = "isMovable", cancellable = true, at = @At(value = "RETURN", ordinal = 3, shift = At.Shift.BEFORE))
|
||||
private static void movableCMD(BlockState blockState_1, World world_1, BlockPos blockPos_1,
|
||||
@Inject(method = "isPushable", cancellable = true, at = @At(value = "RETURN", ordinal = 3, shift = At.Shift.BEFORE))
|
||||
private static void movableCMD(BlockState blockState_1, Level world_1, BlockPos blockPos_1,
|
||||
Direction direction_1, boolean boolean_1, Direction direction_2, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
Block block_1 = blockState_1.getBlock();
|
||||
@@ -50,7 +56,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
block != Blocks.SPAWNER;
|
||||
}
|
||||
|
||||
@Redirect(method = "isMovable", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/BlockState;hasBlockEntity()Z"))
|
||||
@Redirect(method = "isPushable", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;hasBlockEntity()Z"))
|
||||
private static boolean ifHasBlockEntity(BlockState blockState)
|
||||
{
|
||||
if (!blockState.hasBlockEntity())
|
||||
@@ -63,20 +69,20 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "isMovable", at = @At(
|
||||
@Redirect(method = "isPushable", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/BlockState;getPistonBehavior()Lnet/minecraft/block/piston/PistonBehavior;"
|
||||
target = "Lnet/minecraft/world/level/block/state/BlockState;getPistonPushReaction()Lnet/minecraft/world/level/material/PushReaction;"
|
||||
))
|
||||
private static PistonBehavior moveGrindstones(BlockState blockState)
|
||||
private static PushReaction moveGrindstones(BlockState blockState)
|
||||
{
|
||||
if (CarpetSettings.movableBlockEntities && blockState.getBlock() == Blocks.GRINDSTONE) return PistonBehavior.NORMAL;
|
||||
return blockState.getPistonBehavior();
|
||||
if (CarpetSettings.movableBlockEntities && blockState.getBlock() == Blocks.GRINDSTONE) return PushReaction.NORMAL;
|
||||
return blockState.getPistonPushReaction();
|
||||
}
|
||||
|
||||
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
@Inject(method = "moveBlocks", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
target = "Ljava/util/List;size()I", ordinal = 4),locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void onMove(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1,
|
||||
private void onMove(Level world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonStructureResolver pistonHandler_1, Map map_1,
|
||||
List<BlockPos> list_1, List<BlockState> list_2, List list_3, BlockState[] blockStates_1,
|
||||
Direction direction_2, int int_2)
|
||||
{
|
||||
@@ -94,37 +100,37 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
|
||||
//hopefully this call won't have any side effects in the future, such as dropping all the BlockEntity's items
|
||||
//we want to place this same(!) BlockEntity object into the world later when the movement stops again
|
||||
world_1.removeBlockEntity(blockpos);
|
||||
blockEntity.markDirty();
|
||||
blockEntity.setChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
target = "Lnet/minecraft/world/World;addBlockEntity(Lnet/minecraft/block/entity/BlockEntity;)V", ordinal = 0),
|
||||
@Inject(method = "moveBlocks", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
|
||||
target = "Lnet/minecraft/world/level/Level;setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V", ordinal = 0),
|
||||
locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void setBlockEntityWithCarried(World world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonHandler pistonHandler_1, Map map_1, List list_1,
|
||||
private void setBlockEntityWithCarried(Level world_1, BlockPos blockPos_1, Direction direction_1, boolean boolean_1,
|
||||
CallbackInfoReturnable<Boolean> cir, BlockPos blockPos_2, PistonStructureResolver pistonHandler_1, Map map_1, List list_1,
|
||||
List list_2, List list_3, BlockState[] blockStates_1, Direction direction_2, int int_2,
|
||||
int int_3, BlockPos blockPos_4, BlockState blockState9, BlockState blockState4)
|
||||
{
|
||||
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston(blockPos_4, blockState4, (BlockState) list_2.get(int_3),
|
||||
BlockEntity blockEntityPiston = MovingPistonBlock.newMovingBlockEntity(blockPos_4, blockState4, (BlockState) list_2.get(int_3),
|
||||
direction_1, boolean_1, false);
|
||||
if (CarpetSettings.movableBlockEntities)
|
||||
((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3));
|
||||
world_1.addBlockEntity(blockEntityPiston);
|
||||
world_1.setBlockEntity(blockEntityPiston);
|
||||
//world_1.setBlockEntity(blockPos_4, blockEntityPiston);
|
||||
}
|
||||
|
||||
@Redirect(method = "move", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;addBlockEntity(Lnet/minecraft/block/entity/BlockEntity;)V",
|
||||
@Redirect(method = "moveBlocks", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Level;setBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;)V",
|
||||
ordinal = 0))
|
||||
private void dontDoAnything(World world, BlockEntity blockEntity)
|
||||
private void dontDoAnything(Level world, BlockEntity blockEntity)
|
||||
{
|
||||
}
|
||||
|
||||
@Redirect(method = "move", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/block/PistonExtensionBlock;createBlockEntityPiston(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/Direction;ZZ)Lnet/minecraft/block/entity/BlockEntity;",
|
||||
@Redirect(method = "moveBlocks", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/piston/MovingPistonBlock;newMovingBlockEntity(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/Direction;ZZ)Lnet/minecraft/world/level/block/entity/BlockEntity;",
|
||||
ordinal = 0))
|
||||
private BlockEntity returnNull(BlockPos blockPos, BlockState blockState, BlockState blockState2, Direction direction, boolean bl, boolean bl2)
|
||||
{
|
||||
Loaded 100 of 346 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user