Skip to content

Commit f64b714

Browse files
committed
chore: started update to 1.21.8
this doesn't even compile yet!
2 parents 086edcc + 02b445f commit f64b714

File tree

12 files changed

+139
-120
lines changed

12 files changed

+139
-120
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
3+
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
44
id "me.modmuss50.mod-publish-plugin" version "0.5.1"
55
}
66

common/src/main/java/dev/ftb/mods/ftbchunks/EntityTypeBoolMapValue.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.minecraft.resources.ResourceKey;
1818
import net.minecraft.resources.ResourceLocation;
1919
import net.minecraft.world.entity.EntityType;
20+
import org.apache.commons.lang3.mutable.MutableInt;
2021
import org.jetbrains.annotations.Nullable;
2122
import org.slf4j.Logger;
2223

@@ -48,15 +49,16 @@ public void write(SNBTCompoundTag tag) {
4849
public void read(SNBTCompoundTag tag) {
4950
Map<ResourceKey<EntityType<?>>, Boolean> map = new HashMap<>();
5051

51-
SNBTCompoundTag compound = tag.getCompound(key);
52-
for (String key : compound.getAllKeys()) {
53-
try {
54-
ResourceLocation parse = ResourceLocation.parse(key);
55-
map.put(ResourceKey.create(Registries.ENTITY_TYPE, parse), compound.getBoolean(key));
56-
} catch (ResourceLocationException e) {
57-
LOGGER.error("Failed to parse {} skipping", key, e);
52+
tag.getCompound(key).ifPresent(compound -> {
53+
for (String key : compound.keySet()) {
54+
try {
55+
ResourceLocation parse = ResourceLocation.parse(key);
56+
compound.getBoolean(key).ifPresent(c -> map.put(ResourceKey.create(Registries.ENTITY_TYPE, parse), c));
57+
} catch (ResourceLocationException e) {
58+
LOGGER.error("Failed to parse {} skipping", key, e);
59+
}
5860
}
59-
}
61+
});
6062

6163
set(map);
6264
}
@@ -79,19 +81,18 @@ public Component getStringForGUI(@Nullable Map<ResourceKey<EntityType<?>>, Boole
7981
if (v == null) {
8082
return super.getStringForGUI(null);
8183
}
82-
int enabled = 0;
83-
int disabled = 0;
84+
MutableInt enabled = new MutableInt();
85+
MutableInt disabled = new MutableInt();
8486
for (ResourceKey<EntityType<?>> entityTypeResourceKey : v.keySet()) {
85-
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(entityTypeResourceKey);
86-
if (entityType != null) {
87+
BuiltInRegistries.ENTITY_TYPE.get(entityTypeResourceKey).ifPresent(holder -> {
8788
if (v.get(entityTypeResourceKey)) {
88-
enabled++;
89+
enabled.increment();
8990
} else {
90-
disabled++;
91+
disabled.increment();
9192
}
92-
}
93+
});
9394
}
94-
return Component.translatable("ftbchunks.gui.enabled_disabled_count", enabled, disabled);
95+
return Component.translatable("ftbchunks.gui.enabled_disabled_count", enabled.getValue(), disabled.getValue());
9596
}
9697
}
9798

common/src/main/java/dev/ftb/mods/ftbchunks/FTBCUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static boolean isRail(Block block) {
2424
public static void forceHeldItemSync(ServerPlayer sp, InteractionHand hand) {
2525
if (sp.connection != null) {
2626
switch (hand) {
27-
case MAIN_HAND -> sp.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, sp.getInventory().selected, sp.getItemInHand(hand)));
27+
case MAIN_HAND -> sp.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, sp.getInventory().getSelectedSlot(), sp.getItemInHand(hand)));
2828
case OFF_HAND -> sp.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, Inventory.SLOT_OFFHAND, sp.getItemInHand(hand)));
2929
}
3030
}

common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
5-
import dev.architectury.event.CompoundEventResult;
65
import dev.architectury.event.EventResult;
76
import dev.architectury.event.events.common.*;
87
import dev.architectury.hooks.level.entity.PlayerHooks;
@@ -13,12 +12,14 @@
1312
import dev.architectury.utils.Env;
1413
import dev.architectury.utils.EnvExecutor;
1514
import dev.architectury.utils.value.IntValue;
16-
import dev.ftb.mods.ftbchunks.api.*;
15+
import dev.ftb.mods.ftbchunks.api.ClaimedChunk;
16+
import dev.ftb.mods.ftbchunks.api.FTBChunksAPI;
17+
import dev.ftb.mods.ftbchunks.api.FTBChunksProperties;
18+
import dev.ftb.mods.ftbchunks.api.Protection;
1719
import dev.ftb.mods.ftbchunks.client.FTBChunksClient;
1820
import dev.ftb.mods.ftbchunks.client.FTBChunksClientConfig;
1921
import dev.ftb.mods.ftbchunks.data.*;
2022
import dev.ftb.mods.ftbchunks.net.*;
21-
import dev.ftb.mods.ftbchunks.data.ChunkSyncInfo;
2223
import dev.ftb.mods.ftblibrary.config.manager.ConfigManager;
2324
import dev.ftb.mods.ftblibrary.integration.stages.StageHelper;
2425
import dev.ftb.mods.ftblibrary.math.ChunkDimPos;
@@ -39,17 +40,15 @@
3940
import net.minecraft.server.level.ServerPlayer;
4041
import net.minecraft.stats.Stats;
4142
import net.minecraft.world.InteractionHand;
43+
import net.minecraft.world.InteractionResult;
4244
import net.minecraft.world.damagesource.DamageSource;
4345
import net.minecraft.world.entity.Entity;
46+
import net.minecraft.world.entity.EntitySpawnReason;
4447
import net.minecraft.world.entity.LivingEntity;
45-
import net.minecraft.world.entity.MobSpawnType;
4648
import net.minecraft.world.entity.player.Player;
4749
import net.minecraft.world.item.BlockItem;
4850
import net.minecraft.world.item.ItemStack;
49-
import net.minecraft.world.level.BaseSpawner;
50-
import net.minecraft.world.level.Explosion;
51-
import net.minecraft.world.level.Level;
52-
import net.minecraft.world.level.LevelAccessor;
51+
import net.minecraft.world.level.*;
5352
import net.minecraft.world.level.block.Block;
5453
import net.minecraft.world.level.block.state.BlockState;
5554
import net.minecraft.world.phys.BlockHitResult;
@@ -268,17 +267,17 @@ private void teamSaved(TeamEvent teamEvent) {
268267
ClaimedChunkManagerImpl.getInstance().getOrCreateData(teamEvent.getTeam()).saveNow();
269268
}
270269

271-
public EventResult blockLeftClick(Player player, InteractionHand hand, BlockPos pos, Direction face) {
270+
public InteractionResult blockLeftClick(Player player, InteractionHand hand, BlockPos pos, Direction face) {
272271
// calling architectury stub method
273272
//noinspection ConstantConditions
274273
if (player instanceof ServerPlayer && ClaimedChunkManagerImpl.getInstance().shouldPreventInteraction(player, hand, pos, FTBChunksExpected.getBlockBreakProtection(), null)) {
275-
return EventResult.interruptFalse();
274+
return InteractionResult.FAIL;
276275
}
277276

278-
return EventResult.pass();
277+
return InteractionResult.PASS;
279278
}
280279

281-
public EventResult blockRightClick(Player player, InteractionHand hand, BlockPos pos, Direction face) {
280+
public InteractionResult blockRightClick(Player player, InteractionHand hand, BlockPos pos, Direction face) {
282281
// calling architectury stub method
283282
//noinspection ConstantConditions
284283
if (player instanceof ServerPlayer sp) {
@@ -290,20 +289,20 @@ public EventResult blockRightClick(Player player, InteractionHand hand, BlockPos
290289
|| blockItem && mgr.shouldPreventInteraction(player, hand, pos, FTBChunksExpected.getBlockPlaceProtection(), null))
291290
{
292291
FTBCUtils.forceHeldItemSync(sp, hand);
293-
return EventResult.interruptFalse();
292+
return InteractionResult.FAIL;
294293
}
295294
}
296295

297-
return EventResult.pass();
296+
return InteractionResult.PASS;
298297
}
299298

300-
public CompoundEventResult<ItemStack> itemRightClick(Player player, InteractionHand hand) {
299+
public InteractionResult itemRightClick(Player player, InteractionHand hand) {
301300
if (player instanceof ServerPlayer sp && ClaimedChunkManagerImpl.getInstance().shouldPreventInteraction(player, hand, BlockPos.containing(player.getEyePosition(1F)), Protection.RIGHT_CLICK_ITEM, null)) {
302301
FTBCUtils.forceHeldItemSync(sp, hand);
303-
return CompoundEventResult.interruptFalse(player.getItemInHand(hand));
302+
return InteractionResult.FAIL;
304303
}
305304

306-
return CompoundEventResult.pass();
305+
return InteractionResult.PASS;
307306
}
308307

309308

@@ -334,23 +333,23 @@ public EventResult blockPlace(Level level, BlockPos pos, BlockState blockState,
334333
return EventResult.pass();
335334
}
336335

337-
public CompoundEventResult<ItemStack> fillBucket(Player player, Level level, ItemStack emptyBucket, @Nullable HitResult target) {
336+
public InteractionResult fillBucket(Player player, Level level, ItemStack emptyBucket, @Nullable HitResult target) {
338337
if (player instanceof ServerPlayer && target instanceof BlockHitResult hitResult) {
339338
InteractionHand hand = player.getUsedItemHand();
340339
if (ClaimedChunkManagerImpl.getInstance().shouldPreventInteraction(player, hand, hitResult.getBlockPos(), Protection.EDIT_FLUID, null)) {
341-
return CompoundEventResult.interrupt(false, player.getItemInHand(hand));
340+
return InteractionResult.FAIL;
342341
}
343342
}
344343

345-
return CompoundEventResult.pass();
344+
return InteractionResult.PASS;
346345
}
347346

348-
public EventResult farmlandTrample(Level world, BlockPos pos, BlockState blockState, float distance, Entity entity) {
347+
public InteractionResult farmlandTrample(Level world, BlockPos pos, BlockState blockState, double distance, Entity entity) {
349348
if (entity instanceof ServerPlayer && ClaimedChunkManagerImpl.getInstance().shouldPreventInteraction(entity, InteractionHand.MAIN_HAND, pos, Protection.EDIT_BLOCK, null)) {
350-
return EventResult.interrupt(false);
349+
return InteractionResult.FAIL;
351350
}
352351

353-
return EventResult.pass();
352+
return InteractionResult.PASS;
354353
}
355354

356355
// This event is a nightmare, gets fired before login
@@ -367,7 +366,7 @@ public void enterSection(Entity entity, int chunkX, int chunkY, int chunkZ, int
367366
});
368367
}
369368

370-
public EventResult checkSpawn(LivingEntity entity, LevelAccessor levelAccessor, double x, double y, double z, MobSpawnType type, @Nullable BaseSpawner spawner) {
369+
public EventResult checkSpawn(LivingEntity entity, LevelAccessor levelAccessor, double x, double y, double z, EntitySpawnReason type, @Nullable BaseSpawner spawner) {
371370
if (!levelAccessor.isClientSide() && !(entity instanceof Player) && levelAccessor instanceof Level level) {
372371
switch (type) {
373372
case NATURAL, CHUNK_GENERATION, SPAWNER, STRUCTURE, JOCKEY, PATROL -> {

common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ private static int viewLoadedChunks(CommandSourceStack source, ServerLevel level
560560
}
561561
}
562562

563-
for (long pos : level.getForcedChunks()) {
563+
for (long pos : level.getForceLoadedChunks()) {
564564
if (chunks.get(pos) == LoadedChunkViewPacket.LOADED) {
565565
chunks.put(pos, LoadedChunkViewPacket.FORCE_LOADED);
566566
}

common/src/main/java/dev/ftb/mods/ftbchunks/client/FTBChunksClient.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ public void init() {
171171

172172
registerKeys();
173173

174-
// ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new EntityIcons());
175-
ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new ColorMapLoader());
174+
ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new ColorMapLoader(), FTBChunksAPI.rl("colormap"));
176175
ClientPlayerEvent.CLIENT_PLAYER_QUIT.register(this::loggedOut);
177176
CustomClickEvent.EVENT.register(this::customClick);
178177
ClientRawInputEvent.KEY_PRESSED.register(this::keyPressed);
@@ -183,7 +182,7 @@ public void init() {
183182
TeamEvent.CLIENT_PROPERTIES_CHANGED.register(this::teamPropertiesChanged);
184183
MapIconEvent.LARGE_MAP.register(this::mapIcons);
185184
MapIconEvent.MINIMAP.register(this::mapIcons);
186-
ClientReloadShadersEvent.EVENT.register(this::reloadShaders);
185+
// ClientReloadShadersEvent.EVENT.register(this::reloadShaders);
187186
registerPlatform();
188187

189188
if (ModUtils.isDevMode()) {
@@ -348,15 +347,15 @@ public void handleBlockColorRequest() {
348347
if (mc.hitResult instanceof BlockHitResult hitResult && mc.level != null && mc.player != null) {
349348
ResourceLocation id = FTBChunks.BLOCK_REGISTRY.getId(mc.level.getBlockState(hitResult.getBlockPos()).getBlock());
350349
Window window = mc.getWindow();
351-
try (NativeImage image = Screenshot.takeScreenshot(mc.getMainRenderTarget())) {
352-
int col = image.getPixelRGBA(image.getWidth() / 2 - (int) (2D * window.getGuiScale()), image.getHeight() / 2 - (int) (2D * window.getGuiScale()));
350+
Screenshot.takeScreenshot(mc.getMainRenderTarget(), image -> {
351+
int col = image.getPixel(image.getWidth() / 2 - (int) (2D * window.getGuiScale()), image.getHeight() / 2 - (int) (2D * window.getGuiScale()));
353352
String s = String.format("\"%s\": \"#%06X\"", id.getPath(), ColorUtils.convertFromNative(col) & 0xFFFFFF);
354353
mc.player.displayClientMessage(Component.literal(id.getNamespace() + " - " + s)
355354
.withStyle(Style.EMPTY.applyFormat(ChatFormatting.GOLD)
356-
.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, s))
357-
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Click to copy")))
355+
.withClickEvent(new ClickEvent.CopyToClipboard(s))
356+
.withHoverEvent(new HoverEvent.ShowText(Component.literal("Click to copy")))
358357
), false);
359-
}
358+
});
360359
}
361360
});
362361
}, "Color getter").start();

common/src/main/java/dev/ftb/mods/ftbchunks/client/gui/LargeMapScreen.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package dev.ftb.mods.ftbchunks.client.gui;
22

33
import com.mojang.blaze3d.platform.InputConstants;
4-
import com.mojang.blaze3d.vertex.PoseStack;
54
import dev.architectury.networking.NetworkManager;
65
import dev.architectury.platform.Platform;
76
import dev.ftb.mods.ftbchunks.FTBChunks;
@@ -239,7 +238,7 @@ public boolean mousePressed(MouseButton button) {
239238
prevMouseY = getMouseY();
240239
return true;
241240
} else if (button.isRight()) {
242-
int fixedY = Math.max(regionPanel.blockY, Minecraft.getInstance().level.getMinBuildHeight());
241+
int fixedY = Math.max(regionPanel.blockY, Minecraft.getInstance().level.getMinY());
243242
final BlockPos pos = new BlockPos(regionPanel.blockX, fixedY, regionPanel.blockZ);
244243
GlobalPos globalPos = GlobalPos.of(dimension.dimension, pos);
245244
List<ContextMenuItem> list = new ArrayList<>();
@@ -395,12 +394,12 @@ public void drawForeground(GuiGraphics graphics, Theme theme, int x, int y, int
395394
int coordsw = theme.getStringWidth(coords) / 2;
396395

397396
BACKGROUND_COLOR.withAlpha(150).draw(graphics, x + (w - coordsw) / 2, y + h - 6, coordsw + 4, 6);
398-
PoseStack poseStack = graphics.pose();
399-
poseStack.pushPose();
400-
poseStack.translate(x + (w - coordsw) / 2F + 2F, y + h - 5, 0F);
401-
poseStack.scale(0.5F, 0.5F, 1F);
397+
var poseStack = graphics.pose();
398+
poseStack.pushMatrix();
399+
poseStack.translate(x + (w - coordsw) / 2F + 2F, y + h - 5);
400+
poseStack.scale(0.5F, 0.5F);
402401
theme.drawString(graphics, coords, 0, 0, Theme.SHADOW);
403-
poseStack.popPose();
402+
poseStack.popMatrix();
404403

405404
if (FTBChunksClientConfig.DEBUG_INFO.get()) {
406405
long memory = MapManager.getInstance().map(MapManager::estimateMemoryUsage).orElse(0L);
@@ -410,20 +409,20 @@ public void drawForeground(GuiGraphics graphics, Theme theme, int x, int y, int
410409

411410
BACKGROUND_COLOR.withAlpha(150).draw(graphics, x + (w - memoryUsagew) - 2, y, memoryUsagew + 4, 6);
412411

413-
poseStack.pushPose();
414-
poseStack.translate(x + (w - memoryUsagew) - 1F, y + 1, 0F);
415-
poseStack.scale(0.5F, 0.5F, 1F);
412+
poseStack.pushMatrix();
413+
poseStack.translate(x + (w - memoryUsagew) - 1F, y + 1);
414+
poseStack.scale(0.5F, 0.5F);
416415
theme.drawString(graphics, memoryUsage, 0, 0, Theme.SHADOW);
417-
poseStack.popPose();
416+
poseStack.popMatrix();
418417
}
419418

420419
if (zoom == minZoom && zoom > 1) {
421420
Component zoomWarn = Component.translatable("ftbchunks.zoom_warning");
422-
poseStack.pushPose();
423-
poseStack.translate(x + w / 2F, y + 1, 0F);
424-
poseStack.scale(0.5F, 0.5F, 1F);
421+
poseStack.pushMatrix();
422+
poseStack.translate(x + w / 2F, y + 1);
423+
poseStack.scale(0.5F, 0.5F);
425424
theme.drawString(graphics, zoomWarn, 0, 0, Color4I.rgb(0xF0C000), Theme.CENTERED);
426-
poseStack.popPose();
425+
poseStack.popMatrix();
427426
}
428427
}
429428

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
package dev.ftb.mods.ftbchunks.client.gui;
22

3-
import com.mojang.blaze3d.systems.RenderSystem;
43
import dev.ftb.mods.ftbchunks.client.map.MapRegion;
5-
import dev.ftb.mods.ftblibrary.icon.Color4I;
6-
import dev.ftb.mods.ftblibrary.ui.GuiHelper;
74
import dev.ftb.mods.ftblibrary.ui.Theme;
85
import dev.ftb.mods.ftblibrary.ui.Widget;
9-
import net.minecraft.client.Minecraft;
106
import net.minecraft.client.gui.GuiGraphics;
11-
import org.lwjgl.opengl.GL11;
127

138
public class MapTileWidget extends Widget {
149
public final MapRegion region;
@@ -20,16 +15,20 @@ public MapTileWidget(RegionMapPanel panel, MapRegion region) {
2015

2116
@Override
2217
public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) {
23-
int id = region.getRenderedMapImageTextureId();
24-
2518
if (region.isMapImageLoaded()) {
26-
RenderSystem.bindTextureForSetup(id);
27-
int filter = w * Minecraft.getInstance().getWindow().getGuiScale() < 512D ? GL11.GL_LINEAR : GL11.GL_NEAREST;
28-
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
29-
RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
30-
31-
RenderSystem.setShaderTexture(0, id);
32-
GuiHelper.drawTexturedRect(graphics, x, y, w, h, Color4I.WHITE, 0F, 0F, 1F, 1F);
19+
graphics.blit(region.getRenderedTextureId(), x, y, x + w, x + h, 0f, 0f, 1f, 1f);
3320
}
21+
22+
// int id = region.getRenderedMapImageTextureId();
23+
//
24+
// if (region.isMapImageLoaded()) {
25+
// RenderSystem.bindTextureForSetup(id);
26+
// int filter = w * Minecraft.getInstance().getWindow().getGuiScale() < 512D ? GL11.GL_LINEAR : GL11.GL_NEAREST;
27+
// RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filter);
28+
// RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filter);
29+
//
30+
// RenderSystem.setShaderTexture(0, id);
31+
// GuiHelper.drawTexturedRect(graphics, x, y, w, h, Color4I.WHITE, 0F, 0F, 1F, 1F);
32+
// }
3433
}
3534
}

0 commit comments

Comments
 (0)