diff --git a/.gitattributes b/.gitattributes index fb08201822..24e37356d2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,6 @@ src/generated/**/*.json text eol=lf src/generated_test/**/.cache/cache text eol=lf src/generated_test/**/*.json text eol=lf +# We force eclipse to use unix line endings +ide/eclipse/template/.settings/*.prefs text eol=lf + diff --git a/.gitignore b/.gitignore index 1d703c8706..74683483cc 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,9 @@ /classes *.iml +# We however WANT the ide folder as it has tempaltes/configs for developing Forge. +!ide/** + #gradle /build /.gradle diff --git a/build.gradle b/build.gradle index e41dda3e92..943423d187 100644 --- a/build.gradle +++ b/build.gradle @@ -44,10 +44,10 @@ ext { ] } MAPPING_CHANNEL = 'official' - MC_VERSION = '1.20.2-pre3' + MC_VERSION = '1.20.2-pre4' MAPPING_VERSION = MC_VERSION MC_NEXT_VERSION = '1.21' - MCP_VERSION = '20230912.103757' + MCP_VERSION = '20230913.141520' SNAPSHOT = false SPI_VERSION = '7.0.1' @@ -1526,3 +1526,16 @@ if (System.env.TEAMCITY_VERSION) { } } } + +allprojects { prj -> + prj.tasks.eclipse.doFirst { + rootProject.fileTree('ide/eclipse/template/.settings/').matching { include '**/*.prefs' }.each { file -> + def target = project.file('.settings/' + file.name) + def temp = new CleanProperties().load(file) + def exst = new CleanProperties().load(target) + exst.put('eclipse.preferences.version', '1') + temp.forEach(exst::put) + exst.store(target) + } + } +} diff --git a/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CleanProperties.groovy b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CleanProperties.groovy new file mode 100644 index 0000000000..4a33b9edf1 --- /dev/null +++ b/buildSrc/src/main/groovy/net/minecraftforge/forge/tasks/CleanProperties.groovy @@ -0,0 +1,92 @@ +package net.minecraftforge.forge.tasks; + +import java.util.Properties; +import java.util.Enumeration; +import java.util.Map; +import java.util.TreeSet; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.Reader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.OutputStream; +import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Set; + +/** + * Eclipse config files are literally just java properties, with the header cleaned up. + * https://github.com/eclipse/buildship/blob/5b2c7fca7fa86cd74d71b3c099c7b1559eba038e/org.eclipse.buildship.core/src/main/java/org/eclipse/buildship/core/internal/configuration/PreferenceStore.java#L238 + * + * This does the same thing, as well as sorting alphabetically. + * It also ignores all comments. We can add them latter if someone cares. + */ +public class CleanProperties extends Properties { + private static final long serialVersionUID = 1L; + private static final String LINE_SEP = System.getProperty("line.separator"); + private static final String UNIX_LINE_SEP = "\n"; + private static final Charset ENCODING = StandardCharsets.UTF_8; + + public CleanProperties load(File input) throws IOException { + if (input.exists()) { + try (Reader is = new InputStreamReader(new FileInputStream(input), ENCODING)) { + super.load(is); + } + } + return this; + } + + public void store(File out) throws IOException { + if (!out.getParentFile().exists()) + out.getParentFile().mkdirs(); + + try (OutputStream os = new FileOutputStream(out)) { + store(os, null); + } + } + + @Override + public synchronized Enumeration keys() { + Set ret = new TreeSet<>(); + for (Enumeration e = super.keys(); e.hasMoreElements();) + ret.add(e.nextElement()); + return Collections.enumeration(ret); + } + + @Override + public Set> entrySet() { + Set> ret = new TreeSet<>((l, r) -> ((String)l.getKey()).compareTo((String)r.getKey())); + ret.addAll(super.entrySet()); + return ret; + } + + @Override + public void store(OutputStream out, String comments) throws IOException { + out.write(clean().getBytes(ENCODING)); + out.flush(); + } + + @Override + public void store(Writer out, String comments) throws IOException { + out.write(clean()); + out.flush(); + } + + private String clean() throws IOException { + ByteArrayOutputStream tmp = new ByteArrayOutputStream(); + try { + super.store(tmp, null); + } finally { + tmp.close(); + } + + String ret = tmp.toString(ENCODING).replace(LINE_SEP, UNIX_LINE_SEP); + ret = ret.substring(ret.indexOf(UNIX_LINE_SEP) + 1); + return ret; + } +} \ No newline at end of file diff --git a/ide/eclipse/template/.settings/de.loskutov.anyedit.AnyEditTools.prefs b/ide/eclipse/template/.settings/de.loskutov.anyedit.AnyEditTools.prefs new file mode 100644 index 0000000000..0a727fb1f9 --- /dev/null +++ b/ide/eclipse/template/.settings/de.loskutov.anyedit.AnyEditTools.prefs @@ -0,0 +1,19 @@ +activeContentFilterList=*.makefile,makefile,*.Makefile,Makefile,Makefile.*,*.mk,MANIFEST.MF,.project,*.yml +addNewLine=true +convertActionOnSaave=AnyEdit.CnvrtTabToSpaces +eclipse.preferences.version=1 +encoding/=UTF-8 +fixLineDelimiters=false +ignoreBlankLinesWhenTrimming=false +inActiveContentFilterList= +javaTabWidthForJava=true +org.eclipse.jdt.ui.editor.tab.width=2 +projectPropsEnabled=true +removeTrailingSpaces=true +replaceAllSpaces=false +replaceAllTabs=false +saveAndAddLine=false +saveAndConvert=true +saveAndFixLineDelimiters=false +saveAndTrim=true +useModulo4Tabs=false diff --git a/ide/eclipse/template/.settings/org.eclipse.core.resources.prefs b/ide/eclipse/template/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..99f26c0203 --- /dev/null +++ b/ide/eclipse/template/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/ide/eclipse/template/.settings/org.eclipse.core.runtime.prefs b/ide/eclipse/template/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..5a0ad22d2a --- /dev/null +++ b/ide/eclipse/template/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +line.separator=\n diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index dd44d16c1d..36d8c9a4b4 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/Minecraft.java +++ b/net/minecraft/client/Minecraft.java -@@ -251,7 +_,7 @@ +@@ -252,7 +_,7 @@ import org.slf4j.Logger; @OnlyIn(Dist.CLIENT) @@ -9,7 +9,7 @@ static Minecraft instance; private static final Logger LOGGER = LogUtils.getLogger(); public static final boolean ON_OSX = Util.getPlatform() == Util.OS.OSX; -@@ -421,7 +_,6 @@ +@@ -422,7 +_,6 @@ }, Util.ioPool()); this.userApiService = this.createUserApiService(this.authenticationService, p_91084_); LOGGER.info("Setting user: {}", (Object)this.user.getName()); @@ -17,7 +17,7 @@ this.demo = p_91084_.game.demo; this.allowsMultiplayer = !p_91084_.game.disableMultiplayer; this.allowsChat = !p_91084_.game.disableChat; -@@ -457,15 +_,15 @@ +@@ -458,15 +_,15 @@ } this.window.setFramerateLimit(this.options.framerateLimit().get()); @@ -35,7 +35,7 @@ this.resourcePackRepository.reload(); this.options.loadSelectedResourcePacks(this.resourcePackRepository); this.languageManager = new LanguageManager(this.options.languageCode); -@@ -511,10 +_,13 @@ +@@ -512,10 +_,13 @@ this.gameRenderer = new GameRenderer(this, this.entityRenderDispatcher.getItemInHandRenderer(), this.resourceManager, this.renderBuffers); this.resourceManager.registerReloadListener(this.gameRenderer.createReloadListener()); this.levelRenderer = new LevelRenderer(this, this.entityRenderDispatcher, this.blockEntityRenderDispatcher, this.renderBuffers); @@ -50,7 +50,7 @@ this.resourceManager.registerReloadListener(this.particleEngine); this.paintingTextures = new PaintingTextureManager(this.textureManager); this.resourceManager.registerReloadListener(this.paintingTextures); -@@ -525,7 +_,10 @@ +@@ -526,7 +_,10 @@ this.gpuWarnlistManager = new GpuWarnlistManager(); this.resourceManager.registerReloadListener(this.gpuWarnlistManager); this.resourceManager.registerReloadListener(this.regionalCompliancies); @@ -62,7 +62,7 @@ this.debugRenderer = new DebugRenderer(this); RealmsClient realmsclient = RealmsClient.create(this); this.realmsDataFetcher = new RealmsDataFetcher(realmsclient); -@@ -545,6 +_,7 @@ +@@ -546,6 +_,7 @@ TinyFileDialogs.tinyfd_messageBox("Minecraft", stringbuilder.toString(), "ok", "error", false); } @@ -70,7 +70,7 @@ this.window.updateVsync(this.options.enableVsync().get()); this.window.updateRawMouseInput(this.options.rawMouseInput().get()); this.window.setDefaultErrorCallback(); -@@ -564,7 +_,7 @@ +@@ -565,7 +_,7 @@ ReloadInstance reloadinstance = this.resourceManager.createReload(Util.backgroundExecutor(), this, RESOURCE_RELOAD_INITIAL_TASK, list); GameLoadTimesEvent.INSTANCE.beginStep(TelemetryProperty.LOAD_TIME_LOADING_OVERLAY_MS); Minecraft.GameLoadCookie minecraft$gameloadcookie = new Minecraft.GameLoadCookie(realmsclient, p_91084_.quickPlay); @@ -79,7 +79,7 @@ Util.ifElse(p_296164_, (p_296162_) -> { this.rollbackResourcePacks(p_296162_, minecraft$gameloadcookie); }, () -> { -@@ -574,8 +_,10 @@ +@@ -575,8 +_,10 @@ this.reloadStateTracker.finishReload(); this.onResourceLoadFinished(minecraft$gameloadcookie); @@ -91,7 +91,7 @@ this.quickPlayLog = QuickPlayLog.of(p_91084_.quickPlay.path()); } -@@ -673,7 +_,7 @@ +@@ -674,7 +_,7 @@ private String createTitle() { StringBuilder stringbuilder = new StringBuilder("Minecraft"); if (checkModStatus().shouldReportAsModified()) { @@ -100,7 +100,7 @@ } stringbuilder.append(" "); -@@ -698,6 +_,8 @@ +@@ -699,6 +_,8 @@ private UserApiService createUserApiService(YggdrasilAuthenticationService p_193586_, GameConfig p_193587_) { try { @@ -109,7 +109,7 @@ return p_193586_.createUserApiService(p_193587_.user.user.getAccessToken()); } catch (AuthenticationException authenticationexception) { LOGGER.error("Failed to verify authentication", (Throwable)authenticationexception); -@@ -710,7 +_,7 @@ +@@ -711,7 +_,7 @@ } private void rollbackResourcePacks(Throwable p_91240_, @Nullable Minecraft.GameLoadCookie p_299515_) { @@ -118,7 +118,7 @@ this.clearResourcePacksOnError(p_91240_, (Component)null, p_299515_); } else { Util.throwAsRuntime(p_91240_); -@@ -802,7 +_,10 @@ +@@ -803,7 +_,10 @@ } public void createSearchTrees() { @@ -130,7 +130,7 @@ return new FullTextSearchTree<>((p_210797_) -> { return p_210797_.getTooltipLines((Player)null, TooltipFlag.Default.NORMAL.asCreative()).stream().map((p_231455_) -> { return ChatFormatting.stripFormatting(p_231455_.getString()).trim(); -@@ -813,7 +_,8 @@ +@@ -814,7 +_,8 @@ return Stream.of(BuiltInRegistries.ITEM.getKey(p_91317_.getItem())); }, p_231451_); }); @@ -140,7 +140,7 @@ return new IdSearchTree<>((p_231353_) -> { return p_231353_.getTags().map(TagKey::location); }, p_231430_); -@@ -833,9 +_,12 @@ +@@ -834,9 +_,12 @@ }); }, p_301514_); }); @@ -156,7 +156,7 @@ }); } -@@ -1018,10 +_,6 @@ +@@ -1019,10 +_,6 @@ LOGGER.error("setScreen called from non-game thread"); } @@ -167,7 +167,7 @@ if (p_91153_ == null && this.level == null) { p_91153_ = new TitleScreen(); } else if (p_91153_ == null && this.player.isDeadOrDying()) { -@@ -1032,6 +_,19 @@ +@@ -1033,6 +_,19 @@ } } @@ -187,7 +187,7 @@ this.screen = p_91153_; if (this.screen != null) { this.screen.added(); -@@ -1178,9 +_,12 @@ +@@ -1179,9 +_,12 @@ RenderSystem.enableCull(); this.profiler.pop(); if (!this.noRender) { @@ -200,7 +200,7 @@ } if (this.fpsPieResults != null) { -@@ -1301,10 +_,12 @@ +@@ -1302,10 +_,12 @@ this.window.setGuiScale((double)i); if (this.screen != null) { this.screen.resize(this, this.window.getGuiScaledWidth(), this.window.getGuiScaledHeight()); @@ -213,7 +213,7 @@ this.gameRenderer.resize(this.window.getWidth(), this.window.getHeight()); this.mouseHandler.setIgnoreFirstMove(); } -@@ -1578,6 +_,7 @@ +@@ -1579,6 +_,7 @@ } public void stop() { @@ -221,7 +221,7 @@ this.running = false; } -@@ -1607,10 +_,18 @@ +@@ -1608,10 +_,18 @@ if (p_91387_ && this.hitResult != null && this.hitResult.getType() == HitResult.Type.BLOCK) { BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -243,7 +243,7 @@ this.player.swing(InteractionHand.MAIN_HAND); } } -@@ -1639,6 +_,8 @@ +@@ -1640,6 +_,8 @@ return false; } else { boolean flag = false; @@ -252,7 +252,7 @@ switch (this.hitResult.getType()) { case ENTITY: this.gameMode.attack(this.player, ((EntityHitResult)this.hitResult).getEntity()); -@@ -1646,7 +_,7 @@ +@@ -1647,7 +_,7 @@ case BLOCK: BlockHitResult blockhitresult = (BlockHitResult)this.hitResult; BlockPos blockpos = blockhitresult.getBlockPos(); @@ -261,7 +261,7 @@ this.gameMode.startDestroyBlock(blockpos, blockhitresult.getDirection()); if (this.level.getBlockState(blockpos).isAir()) { flag = true; -@@ -1659,8 +_,10 @@ +@@ -1660,8 +_,10 @@ } this.player.resetAttackStrengthTicker(); @@ -272,7 +272,7 @@ this.player.swing(InteractionHand.MAIN_HAND); return flag; } -@@ -1676,6 +_,11 @@ +@@ -1677,6 +_,11 @@ } for(InteractionHand interactionhand : InteractionHand.values()) { @@ -284,7 +284,7 @@ ItemStack itemstack = this.player.getItemInHand(interactionhand); if (!itemstack.isItemEnabled(this.level.enabledFeatures())) { return; -@@ -1696,7 +_,7 @@ +@@ -1697,7 +_,7 @@ } if (interactionresult.consumesAction()) { @@ -293,7 +293,7 @@ this.player.swing(interactionhand); } -@@ -1708,7 +_,7 @@ +@@ -1709,7 +_,7 @@ int i = itemstack.getCount(); InteractionResult interactionresult1 = this.gameMode.useItemOn(this.player, interactionhand, blockhitresult); if (interactionresult1.consumesAction()) { @@ -302,7 +302,7 @@ this.player.swing(interactionhand); if (!itemstack.isEmpty() && (itemstack.getCount() != i || this.gameMode.hasInfiniteItems())) { this.gameRenderer.itemInHandRenderer.itemUsed(interactionhand); -@@ -1724,6 +_,9 @@ +@@ -1725,6 +_,9 @@ } } @@ -312,7 +312,7 @@ if (!itemstack.isEmpty()) { InteractionResult interactionresult2 = this.gameMode.useItem(this.player, interactionhand); if (interactionresult2.consumesAction()) { -@@ -1750,6 +_,8 @@ +@@ -1751,6 +_,8 @@ --this.rightClickDelay; } @@ -321,7 +321,7 @@ this.profiler.push("gui"); this.chatListener.tick(); this.gui.tick(this.pause); -@@ -1838,6 +_,7 @@ +@@ -1839,6 +_,7 @@ this.tutorial.tick(); @@ -329,7 +329,7 @@ try { this.level.tick(() -> { return true; -@@ -1853,6 +_,7 @@ +@@ -1854,6 +_,7 @@ throw new ReportedException(crashreport); } @@ -337,7 +337,7 @@ } this.profiler.popPush("animateTick"); -@@ -1872,6 +_,8 @@ +@@ -1873,6 +_,8 @@ this.profiler.popPush("keyboard"); this.keyboardHandler.tick(); this.profiler.pop(); @@ -346,7 +346,7 @@ } private boolean isMultiplayerServer() { -@@ -2068,6 +_,7 @@ +@@ -2069,6 +_,7 @@ } public void setLevel(ClientLevel p_91157_) { @@ -354,7 +354,7 @@ ProgressScreen progressscreen = new ProgressScreen(true); progressscreen.progressStartNoAbort(Component.translatable("connect.joining")); this.updateScreenAndTick(progressscreen); -@@ -2101,10 +_,12 @@ +@@ -2102,10 +_,12 @@ IntegratedServer integratedserver = this.singleplayerServer; this.singleplayerServer = null; this.gameRenderer.resetData(); @@ -367,7 +367,7 @@ if (integratedserver != null) { this.profiler.push("waitForServer"); -@@ -2118,6 +_,7 @@ +@@ -2119,6 +_,7 @@ this.downloadedPackSource.clearServerPack(); this.gui.onDisconnected(); this.isLocalServer = false; @@ -375,7 +375,7 @@ } this.level = null; -@@ -2242,6 +_,7 @@ +@@ -2243,6 +_,7 @@ private void pickBlock() { if (this.hitResult != null && this.hitResult.getType() != HitResult.Type.MISS) { @@ -383,7 +383,7 @@ boolean flag = this.player.getAbilities().instabuild; BlockEntity blockentity = null; HitResult.Type hitresult$type = this.hitResult.getType(); -@@ -2254,10 +_,7 @@ +@@ -2255,10 +_,7 @@ } Block block = blockstate.getBlock(); @@ -395,7 +395,7 @@ if (flag && Screen.hasControlDown() && blockstate.hasBlockEntity()) { blockentity = this.level.getBlockEntity(blockpos); -@@ -2268,7 +_,7 @@ +@@ -2269,7 +_,7 @@ } Entity entity = ((EntityHitResult)this.hitResult).getEntity(); @@ -404,7 +404,7 @@ if (itemstack == null) { return; } -@@ -2804,6 +_,19 @@ +@@ -2808,6 +_,19 @@ public void updateMaxMipLevel(int p_91313_) { this.modelManager.updateMaxMipLevel(p_91313_); diff --git a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch index a2f335503e..b4ef4467d4 100644 --- a/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch +++ b/patches/minecraft/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java +++ b/net/minecraft/client/gui/screens/worldselection/WorldOpenFlows.java -@@ -165,13 +_,23 @@ +@@ -183,13 +_,23 @@ } private void doLoadLevel(Screen p_233146_, String p_233147_, boolean p_233148_, boolean p_233149_) { @@ -24,7 +24,7 @@ } catch (Exception exception) { LOGGER.warn("Failed to load level data or datapacks, can't proceed with server load", (Throwable)exception); if (!p_233148_) { -@@ -191,7 +_,9 @@ +@@ -209,7 +_,9 @@ WorldData worlddata = worldstem.worldData(); boolean flag = worlddata.worldGenOptions().isOldCustomizedWorld(); boolean flag1 = worlddata.worldGenSettingsLifecycle() != Lifecycle.stable(); @@ -35,7 +35,7 @@ this.minecraft.getDownloadedPackSource().loadBundledResourcePack(levelstoragesource$levelstorageaccess).thenApply((p_233177_) -> { return true; }).exceptionallyComposeAsync((p_233183_) -> { -@@ -213,9 +_,11 @@ +@@ -231,9 +_,11 @@ return null; }); } else { diff --git a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index e2d5c18b5e..84eef80dfb 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -33,20 +_,21 @@ - double d2 = p_123375_.y() + (double)((float)direction.getStepY() * 1.125F); - double d3 = p_123375_.z() + (double)direction.getStepZ() * d0; - BlockPos blockpos = p_123375_.getPos().relative(direction); +@@ -34,20 +_,21 @@ + double d2 = vec3.y() + (double)((float)direction.getStepY() * 1.125F); + double d3 = vec3.z() + (double)direction.getStepZ() * d0; + BlockPos blockpos = p_123375_.pos().relative(direction); + Boat boat = (Boat)(this.isChestBoat ? new ChestBoat(level, d0, d1, d2) : new Boat(level, d0, d1, d2)); + boat.setVariant(this.type); + boat.setYRot(direction.toYRot()); diff --git a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index ac64ecec15..c650799f7f 100644 --- a/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/patches/minecraft/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -352,7 +_,7 @@ +@@ -351,7 +_,7 @@ DispensibleContainerItem dispensiblecontaineritem = (DispensibleContainerItem)p_123562_.getItem(); - BlockPos blockpos = p_123561_.getPos().relative(p_123561_.getBlockState().getValue(DispenserBlock.FACING)); - Level level = p_123561_.getLevel(); + BlockPos blockpos = p_123561_.pos().relative(p_123561_.state().getValue(DispenserBlock.FACING)); + Level level = p_123561_.level(); - if (dispensiblecontaineritem.emptyContents((Player)null, level, blockpos, (BlockHitResult)null)) { + if (dispensiblecontaineritem.emptyContents((Player)null, level, blockpos, (BlockHitResult)null, p_123562_)) { dispensiblecontaineritem.checkExtraContent((Player)null, level, p_123562_, blockpos); return new ItemStack(Items.BUCKET); } else { -@@ -411,9 +_,10 @@ +@@ -410,9 +_,10 @@ level.setBlockAndUpdate(blockpos, BaseFireBlock.getState(level, blockpos)); level.gameEvent((Entity)null, GameEvent.BLOCK_PLACE, blockpos); } else if (!CampfireBlock.canLight(blockstate) && !CandleBlock.canLight(blockstate) && !CandleCakeBlock.canLight(blockstate)) { diff --git a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch index 0201c92a03..6ba0aa85d3 100644 --- a/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch +++ b/patches/minecraft/net/minecraft/world/item/MinecartItem.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/item/MinecartItem.java +++ b/net/minecraft/world/item/MinecartItem.java -@@ -28,7 +_,7 @@ - double d2 = p_42949_.z() + (double)direction.getStepZ() * 1.125D; - BlockPos blockpos = p_42949_.getPos().relative(direction); +@@ -30,7 +_,7 @@ + double d2 = vec3.z() + (double)direction.getStepZ() * 1.125D; + BlockPos blockpos = p_42949_.pos().relative(direction); BlockState blockstate = level.getBlockState(blockpos); - RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock ? blockstate.getValue(((BaseRailBlock)blockstate.getBlock()).getShapeProperty()) : RailShape.NORTH_SOUTH; + RailShape railshape = blockstate.getBlock() instanceof BaseRailBlock ? ((BaseRailBlock)blockstate.getBlock()).getRailDirection(blockstate, level, blockpos, null) : RailShape.NORTH_SOUTH; double d3; if (blockstate.is(BlockTags.RAILS)) { if (railshape.isAscending()) { -@@ -81,7 +_,7 @@ +@@ -83,7 +_,7 @@ } else { ItemStack itemstack = p_42943_.getItemInHand(); if (!level.isClientSide) { diff --git a/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch index f175065d80..440b1d05b8 100644 --- a/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch +++ b/patches/minecraft/net/minecraft/world/level/block/DropperBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/DropperBlock.java +++ b/net/minecraft/world/level/block/DropperBlock.java -@@ -38,7 +_,7 @@ - p_52944_.levelEvent(1001, p_52945_, 0); - } else { - ItemStack itemstack = dispenserblockentity.getItem(i); -- if (!itemstack.isEmpty()) { +@@ -45,7 +_,7 @@ + p_52944_.levelEvent(1001, p_52945_, 0); + } else { + ItemStack itemstack = dispenserblockentity.getItem(i); +- if (!itemstack.isEmpty()) { + if (!itemstack.isEmpty() && net.minecraftforge.items.VanillaInventoryCodeHooks.dropperInsertHook(p_52944_, p_52945_, dispenserblockentity, i, itemstack)) { - Direction direction = p_52944_.getBlockState(p_52945_).getValue(FACING); - Container container = HopperBlockEntity.getContainerAt(p_52944_, p_52945_.relative(direction)); - ItemStack itemstack1; + Direction direction = p_52944_.getBlockState(p_52945_).getValue(FACING); + Container container = HopperBlockEntity.getContainerAt(p_52944_, p_52945_.relative(direction)); + ItemStack itemstack1; diff --git a/src/main/java/net/minecraftforge/network/ForgePacketHandler.java b/src/main/java/net/minecraftforge/network/ForgePacketHandler.java index 6263fd21fd..e5d576ac54 100644 --- a/src/main/java/net/minecraftforge/network/ForgePacketHandler.java +++ b/src/main/java/net/minecraftforge/network/ForgePacketHandler.java @@ -216,7 +216,7 @@ public class ForgePacketHandler { var missing = new HashSet(); for (var id : missingMods) { var key = new ResourceLocation(id, ""); - var container = ModList.get().getModContainerById(id).get(); + var container = ModList.get().getModContainerById(id).orElse(null); if (container != null) mismatched.put(key, new NetworkMismatchData.Version(container.getModInfo().getVersion().toString(), "")); else diff --git a/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java b/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java index 74a8fcb851..4953f17902 100644 --- a/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java +++ b/src/main/java/net/minecraftforge/network/packets/ChannelVersions.java @@ -5,31 +5,25 @@ package net.minecraftforge.network.packets; -import java.util.HashMap; import java.util.Map; + +import org.jetbrains.annotations.NotNull; + +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; -public record ChannelVersions(Map channels) { +public record ChannelVersions(Map channels) { public ChannelVersions() { this(NetworkRegistry.buildChannelVersions()); } public static ChannelVersions decode(FriendlyByteBuf buf) { - Map channels = new HashMap<>(); - int len = buf.readVarInt(); - for (int x = 0; x < len; x++) - channels.put(buf.readResourceLocation(), buf.readVarInt()); - - return new ChannelVersions(channels); + return new ChannelVersions(buf.readMap(Object2IntOpenHashMap::new, FriendlyByteBuf::readResourceLocation, FriendlyByteBuf::readVarInt)); } public void encode(FriendlyByteBuf buf) { - buf.writeVarInt(channels.size()); - channels.forEach((k, v) -> { - buf.writeResourceLocation(k); - buf.writeVarInt(v); - }); + buf.writeMap(channels, FriendlyByteBuf::writeResourceLocation, FriendlyByteBuf::writeVarInt); } } \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/network/packets/ModVersions.java b/src/main/java/net/minecraftforge/network/packets/ModVersions.java index 161b5eaae4..eb1d347d8c 100644 --- a/src/main/java/net/minecraftforge/network/packets/ModVersions.java +++ b/src/main/java/net/minecraftforge/network/packets/ModVersions.java @@ -5,10 +5,11 @@ package net.minecraftforge.network.packets; -import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; import net.minecraft.network.FriendlyByteBuf; import net.minecraftforge.fml.ModList; +import net.minecraftforge.forgespi.language.IModInfo; /** * Prefixes S2CModList by sending additional data about the mods installed on the server to the client @@ -18,25 +19,20 @@ public record ModVersions(Map mods) { private static final int MAX_LENGTH = 0x100; public static ModVersions create() { - Map mods = new HashMap<>(); - ModList.get().getMods().stream().forEach(mod -> - mods.put( - mod.getModId(), - new Info(mod.getDisplayName(), mod.getVersion().toString()) - ) - ); - return new ModVersions(mods); + return new ModVersions(ModList.get().getMods().stream().collect(Collectors.toMap( + IModInfo::getModId, + mod -> new Info(mod.getDisplayName(), mod.getVersion().toString()) + ))); } public static ModVersions decode(FriendlyByteBuf buf) { - var mods = buf.readMap( + return new ModVersions(buf.readMap( o -> o.readUtf(MAX_LENGTH), o -> new Info( o.readUtf(MAX_LENGTH), o.readUtf(MAX_LENGTH) ) - ); - return new ModVersions(mods); + )); } public void encode(FriendlyByteBuf output) { @@ -49,5 +45,5 @@ public record ModVersions(Map mods) { ); } - public record Info(String name, String version) {} + public record Info(String name, String version) { } } \ No newline at end of file