Skip to content

Commit

Permalink
23w17a
Browse files Browse the repository at this point in the history
  • Loading branch information
gnembon committed Apr 26, 2023
1 parent 15b120f commit 07033af
Show file tree
Hide file tree
Showing 44 changed files with 309 additions and 265 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check https://fabricmc.net/develop/
minecraft_version=23w16a
minecraft_version=23w17a
loader_version=0.14.19
jsr305_version=3.0.2
fabric_version=0.78.0+1.20
fabric_version=0.79.1+1.20

# Mod Properties
mod_version = 1.4.105
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ public static void applyLightBatchSizes(MinecraftServer server, int maxBatchSize
{
for (ServerLevel world : server.getAllLevels())
{
world.getChunkSource().getLightEngine().setTaskPerBatch(maxBatchSize);
//world.getChunkSource().getLightEngine().setTaskPerBatch(maxBatchSize);
}
}
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/carpet/fakes/LightStorageInterface.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package carpet.fakes;

import net.minecraft.world.level.lighting.LayerLightEngine;
import net.minecraft.world.level.lighting.LightEngine;

public interface LightStorageInterface extends Lighting_scarpetChunkCreationInterface
{
void processRemoveLightData(long pos);

void processRelight(LayerLightEngine<?, ?> lightProvider, long pos);
void processRelight(LightEngine<?, ?> lightProvider, long pos);

int getLightLevelByLong(long blockPos);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ public interface Lighting_scarpetChunkCreationInterface
void removeLightData(long pos);

void relight(long pos);

default void clearQueuedSectionBlocksPublicAccess(long sectionPos) {};
}
38 changes: 19 additions & 19 deletions src/main/java/carpet/helpers/EntityPlayerActionPack.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ public EntityPlayerActionPack mount(boolean onlyRideables)
List<Entity> entities;
if (onlyRideables)
{
entities = player.level.getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D),
entities = player.level().getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D),
e -> e instanceof Minecart || e instanceof Boat || e instanceof AbstractHorse);
}
else
{
entities = player.level.getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D));
entities = player.level().getEntities(player, player.getBoundingBox().inflate(3.0D, 1.0D, 3.0D));
}
if (entities.size()==0)
return this;
Expand Down Expand Up @@ -310,11 +310,11 @@ boolean execute(ServerPlayer player, Action action)
case BLOCK:
{
player.resetLastActionTime();
ServerLevel world = player.getLevel();
ServerLevel world = player.serverLevel();
BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getDirection();
if (pos.getY() < player.getLevel().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
if (pos.getY() < player.level().getMaxBuildHeight() - (side == Direction.UP ? 1 : 0) && world.mayInteract(player, pos))
{
InteractionResult result = player.gameMode.useItemOn(player, world, player.getItemInHand(hand), hand, blockHit);
if (result.consumesAction())
Expand Down Expand Up @@ -349,7 +349,7 @@ boolean execute(ServerPlayer player, Action action)
}
}
ItemStack handItem = player.getItemInHand(hand);
if (player.gameMode.useItem(player, player.getLevel(), handItem, hand).consumesAction())
if (player.gameMode.useItem(player, player.level(), handItem, hand).consumesAction())
{
ap.itemUseCooldown = 3;
return true;
Expand Down Expand Up @@ -392,33 +392,33 @@ boolean execute(ServerPlayer player, Action action) {
BlockHitResult blockHit = (BlockHitResult) hit;
BlockPos pos = blockHit.getBlockPos();
Direction side = blockHit.getDirection();
if (player.blockActionRestricted(player.level, pos, player.gameMode.getGameModeForPlayer())) return false;
if (ap.currentBlock != null && player.level.getBlockState(ap.currentBlock).isAir())
if (player.blockActionRestricted(player.level(), pos, player.gameMode.getGameModeForPlayer())) return false;
if (ap.currentBlock != null && player.level().getBlockState(ap.currentBlock).isAir())
{
ap.currentBlock = null;
return false;
}
BlockState state = player.level.getBlockState(pos);
BlockState state = player.level().getBlockState(pos);
boolean blockBroken = false;
if (player.gameMode.getGameModeForPlayer().isCreative())
{
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
ap.blockHitDelay = 5;
blockBroken = true;
}
else if (ap.currentBlock == null || !ap.currentBlock.equals(pos))
{
if (ap.currentBlock != null)
{
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
}
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
boolean notAir = !state.isAir();
if (notAir && ap.curBlockDamageMP == 0)
{
state.attack(player.level, pos, player);
state.attack(player.level(), pos, player);
}
if (notAir && state.getDestroyProgress(player, player.level, pos) >= 1)
if (notAir && state.getDestroyProgress(player, player.level(), pos) >= 1)
{
ap.currentBlock = null;
//instamine??
Expand All @@ -432,15 +432,15 @@ else if (ap.currentBlock == null || !ap.currentBlock.equals(pos))
}
else
{
ap.curBlockDamageMP += state.getDestroyProgress(player, player.level, pos);
ap.curBlockDamageMP += state.getDestroyProgress(player, player.level(), pos);
if (ap.curBlockDamageMP >= 1)
{
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.getLevel().getMaxBuildHeight(), -1);
player.gameMode.handleBlockBreakAction(pos, ServerboundPlayerActionPacket.Action.STOP_DESTROY_BLOCK, side, player.level().getMaxBuildHeight(), -1);
ap.currentBlock = null;
ap.blockHitDelay = 5;
blockBroken = true;
}
player.level.destroyBlockProgress(-1, pos, (int) (ap.curBlockDamageMP * 10));
player.level().destroyBlockProgress(-1, pos, (int) (ap.curBlockDamageMP * 10));

}
player.resetLastActionTime();
Expand All @@ -456,8 +456,8 @@ void inactiveTick(ServerPlayer player, Action action)
{
EntityPlayerActionPack ap = ((ServerPlayerInterface) player).getActionPack();
if (ap.currentBlock == null) return;
player.level.destroyBlockProgress(-1, ap.currentBlock, -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.getLevel().getMaxBuildHeight(), -1);
player.level().destroyBlockProgress(-1, ap.currentBlock, -1);
player.gameMode.handleBlockBreakAction(ap.currentBlock, ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK, Direction.DOWN, player.level().getMaxBuildHeight(), -1);
ap.currentBlock = null;
}
},
Expand All @@ -468,7 +468,7 @@ boolean execute(ServerPlayer player, Action action)
{
if (action.limit == 1)
{
if (player.isOnGround()) player.jumpFromGround(); // onGround
if (player.onGround()) player.jumpFromGround(); // onGround
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/carpet/helpers/FertilizableCoral.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
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 net.minecraft.world.level.material.MapColor;

/**
* Deduplicates logic for the different behaviors of the {@code renewableCoral} rule
Expand Down Expand Up @@ -56,7 +56,7 @@ public default void performBonemeal(ServerLevel worldIn, RandomSource random, Bl
default -> new CoralMushroomFeature(NoneFeatureConfiguration.CODEC);
};

MaterialColor color = blockUnder.getMapColor(worldIn, pos);
MapColor color = blockUnder.getMapColor(worldIn, pos);
BlockState properBlock = blockUnder;
HolderSet.Named<Block> coralBlocks = worldIn.registryAccess().registryOrThrow(Registries.BLOCK).getTag(BlockTags.CORAL_BLOCKS).orElseThrow();
for (Holder<Block> block: coralBlocks)
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/carpet/helpers/HopperCounter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
import net.minecraft.world.level.block.BeaconBeamBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraft.world.level.material.MapColor;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -100,7 +101,7 @@ private HopperCounter(DyeColor color)
{
startTick = -1;
this.color = color;
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMaterialColor(),"w ") + color.getName();
this.prettyColour = WoolTool.Material2DyeName.getOrDefault(color.getMapColor(),"w ") + color.getName();
}

/**
Expand Down Expand Up @@ -229,7 +230,7 @@ public List<Component> format(MinecraftServer server, boolean realTime, boolean
*/
public static int appropriateColor(int color)
{
if (color == 0) return MaterialColor.SNOW.col;
if (color == 0) return MapColor.SNOW.col;
int r = (color >> 16 & 255);
int g = (color >> 8 & 255);
int b = (color & 255);
Expand All @@ -241,7 +242,7 @@ public static int appropriateColor(int color)

/**
* Maps items that don't get a good block to reference for colour, or those that colour is wrong to a number of blocks, so we can get their colours easily with the
* {@link Block#defaultMaterialColor()} method as these items have those same colours.
* {@link Block#defaultMapColor()} method as these items have those same colours.
*/
private static final Map<Item, Block> DEFAULTS = Map.ofEntries(
entry(Items.DANDELION, Blocks.YELLOW_WOOL),
Expand Down Expand Up @@ -334,8 +335,8 @@ public static int appropriateColor(int color)
*/
public static TextColor fromItem(Item item, RegistryAccess registryAccess)
{
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMaterialColor().col));
if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMaterialColor().col));
if (DEFAULTS.containsKey(item)) return TextColor.fromRgb(appropriateColor(DEFAULTS.get(item).defaultMapColor().col));
if (item instanceof DyeItem dye) return TextColor.fromRgb(appropriateColor(dye.getDyeColor().getMapColor().col));
Block block = null;
final Registry<Item> itemRegistry = registryAccess.registryOrThrow(Registries.ITEM);
final Registry<Block> blockRegistry = registryAccess.registryOrThrow(Registries.BLOCK);
Expand All @@ -350,9 +351,9 @@ else if (blockRegistry.getOptional(id).isPresent())
}
if (block != null)
{
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMaterialColor().col));
if (block instanceof BeaconBeamBlock) return TextColor.fromRgb(appropriateColor( ((BeaconBeamBlock) block).getColor().getMaterialColor().col));
return TextColor.fromRgb(appropriateColor( block.defaultMaterialColor().col));
if (block instanceof AbstractBannerBlock) return TextColor.fromRgb(appropriateColor(((AbstractBannerBlock) block).getColor().getMapColor().col));
if (block instanceof BeaconBeamBlock) return TextColor.fromRgb(appropriateColor( ((BeaconBeamBlock) block).getColor().getMapColor().col));
return TextColor.fromRgb(appropriateColor( block.defaultMapColor().col));
}
return null;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/carpet/helpers/ParticleDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public class ParticleDisplay
{
public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, String main, String accent, int count, double spread)
{
HolderLookup<ParticleType<?>> lookup = player.getLevel().holderLookup(Registries.PARTICLE_TYPE);
HolderLookup<ParticleType<?>> lookup = player.level().holderLookup(Registries.PARTICLE_TYPE);
ParticleOptions accentParticle = ParticleParser.getEffect(accent, lookup);
ParticleOptions mainParticle = ParticleParser.getEffect(main, lookup);

if (accentParticle != null) player.getLevel().sendParticles(
if (accentParticle != null) player.serverLevel().sendParticles(
player,
accentParticle,
true,
Expand All @@ -29,9 +29,9 @@ public static void drawParticleLine(ServerPlayer player, Vec3 from, Vec3 to, Str
Vec3 incvec = to.subtract(from).normalize();// multiply(50/sqrt(lineLengthSq));
for (Vec3 delta = new Vec3(0.0,0.0,0.0);
delta.lengthSqr() < lineLengthSq;
delta = delta.add(incvec.scale(player.level.random.nextFloat())))
delta = delta.add(incvec.scale(player.level().random.nextFloat())))
{
player.getLevel().sendParticles(
player.serverLevel().sendParticles(
player,
mainParticle,
true,
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/carpet/logging/HUDController.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void update_hud(MinecraftServer server, List<ServerPlayer> force)
case "overworld" -> Level.OVERWORLD;
case "nether" -> Level.NETHER;
case "end" -> Level.END;
default -> player.level.dimension();
default -> player.level().dimension();
};
return new Component[]{SpawnReporter.printMobcapsForDimension(server.getLevel(dim), false).get(0)};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected ArmorStand_scarpetMarkerMixin(EntityType<? extends LivingEntity> entit
@Inject(method = "readAdditionalSaveData", at = @At("HEAD"))
private void checkScarpetMarkerUnloaded(CallbackInfo ci)
{
if (!level.isClientSide)
if (!level().isClientSide)
{
if (getTags().contains(Auxiliary.MARKER_STRING))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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.LightEngine;
import net.minecraft.world.level.lighting.LayerLightSectionStorage;

@Mixin(BlockLightSectionStorage.class)
Expand All @@ -24,7 +24,7 @@ private BlockLightSectionStorage_scarpetChunkCreationMixin(final LightLayer ligh
}

@Override
public void processRelight(final LayerLightEngine<?, ?> lightProvider, final long cPos)
public void processRelight(final LightEngine<?, ?> lightProvider, final long cPos)
{
final DynamicGraphMinFixedPoint_resetChunkInterface levelPropagator = (DynamicGraphMinFixedPoint_resetChunkInterface) lightProvider;

Expand Down Expand Up @@ -62,4 +62,10 @@ public void processRelight(final LayerLightEngine<?, ?> lightProvider, final lon
}
}
}

@Override
public int getLightLevelByLong(long blockPos)
{
return getLightValue(blockPos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ExperienceOrb_xpNoCooldownMixin(EntityType<?> type, Level world)

@Inject(method = "playerTouch", at = @At("HEAD"))
private void addXP(Player player, CallbackInfo ci) {
if (CarpetSettings.xpNoCooldown && !level.isClientSide) {
if (CarpetSettings.xpNoCooldown && !level().isClientSide) {
player.takeXpDelay = 0;
// reducing the count to 1 and leaving vanilla to deal with it
while (this.count > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ protected Guardian_renewableSpongesMixin(EntityType<? extends Monster> entityTyp
@Override
public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity)
{ // isRemoved()
if (!this.level.isClientSide && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian))
if (!this.level().isClientSide && !this.isRemoved() && CarpetSettings.renewableSponges && !((Object)this instanceof ElderGuardian))
{
ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level);
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.finalizeSpawn(serverWorld ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), MobSpawnType.CONVERSION, (SpawnGroupData)null, (CompoundTag)null);
elderGuardian.setNoAi(this.isNoAi());

if (this.hasCustomName())
Expand All @@ -37,7 +37,7 @@ public void thunderHit(ServerLevel serverWorld, LightningBolt lightningEntity)
elderGuardian.setCustomNameVisible(this.isCustomNameVisible());
}

this.level.addFreshEntity(elderGuardian);
this.level().addFreshEntity(elderGuardian);
this.discard(); // discard remove();
}
else
Expand Down
Loading

0 comments on commit 07033af

Please sign in to comment.