This commit is contained in:
rjnasers committed 2026-01-24 01:17:44 +01:00
1 parent 1c035f6110
commit 761a5631fe
4 files changed
+78 -14

No files matched your search

@@ -0,0 +1,50 @@
/*
* EndlessIDs
*
* Copyright (C) 2022-2025 FalsePattern, The MEGA Team
* All Rights Reserved
*
* The above copyright notice, this permission notice and the word "MEGA"
* shall be included in all copies or substantial portions of the Software.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, only version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.endlessids.mixin.mixins.common.blockitem.thermos;
import com.falsepattern.endlessids.config.GeneralConfig;
import lombok.var;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@Mixin(ExtendedBlockStorage.class)
public class ExtendedBlockStorageMixin
{
@Redirect(method = "removeInvalidBlocks",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"),
require = 1)
private Block removeInvalidBlocks(ExtendedBlockStorage instance, int x, int y, int z) {
var block = instance.getBlockByExtId(x, y, z);
if (block == null && GeneralConfig.removeInvalidBlocks) {
instance.func_150818_a(x, y, z, Blocks.air);
block = Blocks.air;
}
return block;
}
}
@@ -189,19 +189,6 @@ public abstract class ExtendedBlockStorageMixin implements SubChunkBlockHook {
setExtBlockMetadata(x, y, z, id);
}
@Redirect(method = "removeInvalidBlocks",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;getBlockByExtId(III)Lnet/minecraft/block/Block;"),
require = 1)
private Block removeInvalidBlocks(ExtendedBlockStorage instance, int x, int y, int z) {
var block = instance.getBlockByExtId(x, y, z);
if (block == null && GeneralConfig.removeInvalidBlocks) {
instance.func_150818_a(x, y, z, Blocks.air);
block = Blocks.air;
}
return block;
}
private UnsupportedOperationException emergencyCrash() {
val crashMSG = "A mod that is incompatible with " + Tags.MODNAME + " has tried to access the block array of a" +
" chunk like in vanilla! Crashing in fear of potential world corruption!\n" +
@@ -418,7 +418,11 @@ public enum Mixin implements IMixins {
// endregion Biome
// region BlockItem
BlockItem_Thermos(Phase.EARLY,
() -> { return Ext.BlockItem.getAsBoolean() && !hasThermos(); },
common("blockitem.thermos.ExtendedBlockStorageMixin")),
BlockItem_Vanilla(Phase.EARLY,
Ext.BlockItem,
common("blockitem.vanilla.BlockFireMixin",
@@ -607,4 +611,16 @@ public enum Mixin implements IMixins {
public static final BooleanSupplier Potion = () -> GeneralConfig.extendPotion;
public static final BooleanSupplier Entity = () -> GeneralConfig.extendEntity;
}
static boolean hasThermos()
{
try
{
Class.forName("thermos.Thermos");
return true;
}
catch(ClassNotFoundException ignored) {
return false;
}
}
}