Compare commits
3 Commits
60429c35b2
...
af0cc383e5
Author | SHA1 | Date | |
---|---|---|---|
af0cc383e5 | |||
5af896e476 | |||
0446e5adb3 |
@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.capability.fluid
|
||||
|
||||
import net.minecraft.world.item.ItemStack
|
||||
import net.neoforged.neoforge.fluids.FluidStack
|
||||
import net.neoforged.neoforge.fluids.SimpleFluidContent
|
||||
import net.neoforged.neoforge.fluids.capability.IFluidHandler
|
||||
import net.neoforged.neoforge.fluids.capability.IFluidHandlerItem
|
||||
import ru.dbotthepony.mc.otm.registry.MDataComponentTypes
|
||||
@ -12,8 +13,8 @@ import java.util.function.IntSupplier
|
||||
*/
|
||||
open class ItemMatteryFluidHandler(val itemStack: ItemStack, private val _capacity: IntSupplier) : AbstractMatteryFluidHandler(), IFluidHandlerItem {
|
||||
override var fluid: FluidStack
|
||||
get() = itemStack[MDataComponentTypes.FLUID_STACK] ?: FluidStack.EMPTY
|
||||
set(value) { itemStack[MDataComponentTypes.FLUID_STACK] = value }
|
||||
get() = (itemStack[MDataComponentTypes.FLUID_STACK] ?: SimpleFluidContent.EMPTY).copy()
|
||||
set(value) { itemStack[MDataComponentTypes.FLUID_STACK] = SimpleFluidContent.copyOf(value) }
|
||||
|
||||
final override val capacity: Int
|
||||
get() = _capacity.asInt
|
||||
|
@ -312,7 +312,7 @@ class QuantumBatteryItem(val savedataID: String, val balanceValues: EnergyBalanc
|
||||
components.add(TranslatableComponent("otm.item.quantum_battery.creative2").withStyle(ChatFormatting.DARK_GRAY))
|
||||
}
|
||||
|
||||
components.add(TranslatableComponent("otm.item.quantum_link_id", power.values.uuid).withStyle(ChatFormatting.DARK_GRAY))
|
||||
components.add(TranslatableComponent("otm.item.quantum_link_id", power.values.uuid.toString()).withStyle(ChatFormatting.DARK_GRAY))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.item.matter
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import net.minecraft.ChatFormatting
|
||||
import net.minecraft.network.chat.Component
|
||||
import net.minecraft.world.item.Item
|
||||
@ -119,7 +120,7 @@ class PatternStorageItem : Item, CapabilitiesRegisterListener {
|
||||
}
|
||||
|
||||
patterns[i] = pattern
|
||||
stack[MDataComponentTypes.PATTERNS] = patterns
|
||||
stack[MDataComponentTypes.PATTERNS] = ImmutableList.copyOf(patterns)
|
||||
return PatternInsertUpdated(pattern, ePattern)
|
||||
}
|
||||
}
|
||||
@ -129,7 +130,7 @@ class PatternStorageItem : Item, CapabilitiesRegisterListener {
|
||||
|
||||
if (!simulate) {
|
||||
patterns.add(pattern)
|
||||
stack[MDataComponentTypes.PATTERNS] = patterns
|
||||
stack[MDataComponentTypes.PATTERNS] = ImmutableList.copyOf(patterns)
|
||||
}
|
||||
|
||||
return PatternInsertInserted(pattern)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ru.dbotthepony.mc.otm.registry
|
||||
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.mojang.serialization.Codec
|
||||
import net.minecraft.core.UUIDUtil
|
||||
import net.minecraft.core.component.DataComponentType
|
||||
@ -8,6 +9,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf
|
||||
import net.minecraft.network.codec.StreamCodec
|
||||
import net.neoforged.bus.api.IEventBus
|
||||
import net.neoforged.neoforge.fluids.FluidStack
|
||||
import net.neoforged.neoforge.fluids.SimpleFluidContent
|
||||
import ru.dbotthepony.mc.otm.capability.matter.PatternState
|
||||
import ru.dbotthepony.mc.otm.container.ItemFilter
|
||||
import ru.dbotthepony.mc.otm.core.math.Decimal
|
||||
@ -30,13 +32,13 @@ object MDataComponentTypes {
|
||||
}
|
||||
|
||||
val FLUID_STACK by registry.register("fluid_stack") {
|
||||
object : DataComponentType<FluidStack> {
|
||||
override fun codec(): Codec<FluidStack> {
|
||||
return FluidStack.OPTIONAL_CODEC
|
||||
object : DataComponentType<SimpleFluidContent> {
|
||||
override fun codec(): Codec<SimpleFluidContent> {
|
||||
return SimpleFluidContent.CODEC
|
||||
}
|
||||
|
||||
override fun streamCodec(): StreamCodec<in RegistryFriendlyByteBuf, FluidStack> {
|
||||
return FluidStack.OPTIONAL_STREAM_CODEC
|
||||
override fun streamCodec(): StreamCodec<in RegistryFriendlyByteBuf, SimpleFluidContent> {
|
||||
return SimpleFluidContent.STREAM_CODEC
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,7 +55,10 @@ object MDataComponentTypes {
|
||||
val EXOPACK_UPGRADE_ID: DataComponentType<UUID> by registry.register("exopack_upgrade_id") { uuid() }
|
||||
val QUANTUM_LINK_ID: DataComponentType<UUID> by registry.register("quantum_link_id") { uuid() }
|
||||
val CONDENSATION_DRIVE_UUID: DataComponentType<UUID> by registry.register("condensation_drive_uuid") { uuid() }
|
||||
val PATTERNS: DataComponentType<List<PatternState>> by registry.register("patterns") { DataComponentType.builder<List<PatternState>>().persistent(Codec.list(PatternState.CODEC)).build() }
|
||||
val PATTERNS: DataComponentType<ImmutableList<PatternState>> by registry.register("patterns") {
|
||||
DataComponentType.builder<ImmutableList<PatternState>>().persistent(Codec.list(PatternState.CODEC).xmap({ ImmutableList.copyOf(it) }, { it })).build()
|
||||
}
|
||||
|
||||
val ITEM_FILTER: DataComponentType<ItemFilter> by registry.register("item_filter") { DataComponentType.builder<ItemFilter>().persistent(ItemFilter.CODEC).build() }
|
||||
|
||||
val EXPERIENCE: DataComponentType<Long> by registry.register("experience") { DataComponentType.builder<Long>().persistent(Codec.LONG).networkSynchronized(StreamCodecs.LONG).build() }
|
||||
|
@ -23,13 +23,10 @@ var isOwnPatches = [
|
||||
|
||||
function patchMethod(node) {
|
||||
if (node.desc.endsWith('AbstractContainerMenu;')) {
|
||||
var threeRows = ASMAPI.mapMethod('m_39237_')
|
||||
var sixRows = ASMAPI.mapMethod('m_39246_')
|
||||
|
||||
for (var i = 0; i < node.instructions.size(); i++) {
|
||||
var instr = node.instructions.get(i)
|
||||
|
||||
if (instr.getOpcode() == Opcodes.INVOKESTATIC && instr.name == threeRows && instr.owner == 'net/minecraft/world/inventory/ChestMenu') {
|
||||
if (instr.getOpcode() == Opcodes.INVOKESTATIC && instr.name == 'threeRows' && instr.owner == 'net/minecraft/world/inventory/ChestMenu') {
|
||||
node.instructions.set(instr, new MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu',
|
||||
@ -38,7 +35,7 @@ function patchMethod(node) {
|
||||
))
|
||||
|
||||
break
|
||||
} else if (instr.getOpcode() == Opcodes.INVOKESTATIC && instr.name == sixRows && instr.owner == 'net/minecraft/world/inventory/ChestMenu') {
|
||||
} else if (instr.getOpcode() == Opcodes.INVOKESTATIC && instr.name == 'sixRows' && instr.owner == 'net/minecraft/world/inventory/ChestMenu') {
|
||||
node.instructions.set(instr, new MethodInsnNode(
|
||||
Opcodes.INVOKESTATIC,
|
||||
'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu',
|
||||
@ -80,7 +77,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': clazz,
|
||||
'methodName': ASMAPI.mapMethod('m_142718_'),
|
||||
'methodName': 'isOwnContainer',
|
||||
'methodDesc': '(Lnet/minecraft/world/entity/player/Player;)Z'
|
||||
},
|
||||
'transformer': function(node) {
|
||||
@ -89,7 +86,7 @@ function initializeCoreMod() {
|
||||
|
||||
if ((instr.getOpcode() == Opcodes.INSTANCEOF || instr.getOpcode() == Opcodes.CHECKCAST) && instr.desc == 'net/minecraft/world/inventory/ChestMenu') {
|
||||
instr.desc = 'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu'
|
||||
} else if (instr.getOpcode() == Opcodes.INVOKEVIRTUAL && instr.owner == 'net/minecraft/world/inventory/ChestMenu' && instr.name == ASMAPI.mapMethod('m_39261_')) {
|
||||
} else if (instr.getOpcode() == Opcodes.INVOKEVIRTUAL && instr.owner == 'net/minecraft/world/inventory/ChestMenu' && instr.name == 'getContainer') {
|
||||
instr.owner = 'ru/dbotthepony/mc/otm/compat/vanilla/MatteryChestMenu'
|
||||
instr.name = 'getContainer'
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'com.mojang.blaze3d.systems.RenderSystem',
|
||||
'methodName': ASMAPI.mapMethod('m_69478_'), // enableBlend
|
||||
'methodName': 'enableBlend',
|
||||
'methodDesc': '()V'
|
||||
},
|
||||
'transformer': patchBlendFunc
|
||||
@ -636,7 +636,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'com.mojang.blaze3d.systems.RenderSystem',
|
||||
'methodName': ASMAPI.mapMethod('m_69461_'), // disableBlend
|
||||
'methodName': 'disableBlend',
|
||||
'methodDesc': '()V'
|
||||
},
|
||||
'transformer': patchBlendFunc
|
||||
@ -646,7 +646,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'com.mojang.blaze3d.systems.RenderSystem',
|
||||
'methodName': ASMAPI.mapMethod('m_69405_'), // blendFunc
|
||||
'methodName': 'blendFunc',
|
||||
'methodDesc': '(II)V'
|
||||
},
|
||||
'transformer': patchBlendFunc
|
||||
@ -656,7 +656,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'com.mojang.blaze3d.systems.RenderSystem',
|
||||
'methodName': ASMAPI.mapMethod('m_69411_'), // blendFuncSeparate
|
||||
'methodName': 'blendFuncSeparate',
|
||||
'methodDesc': '(IIII)V'
|
||||
},
|
||||
'transformer': patchBlendFunc
|
||||
@ -666,7 +666,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'com.mojang.blaze3d.systems.RenderSystem',
|
||||
'methodName': ASMAPI.mapMethod('m_69416_'), // blendFuncSeparate
|
||||
'methodName': 'blendFuncSeparate',
|
||||
'methodDesc': '(Lcom/mojang/blaze3d/platform/GlStateManager$SourceFactor;Lcom/mojang/blaze3d/platform/GlStateManager$DestFactor;Lcom/mojang/blaze3d/platform/GlStateManager$SourceFactor;Lcom/mojang/blaze3d/platform/GlStateManager$DestFactor;)V'
|
||||
},
|
||||
'transformer': patchBlendFunc
|
||||
@ -676,7 +676,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
'type': 'METHOD',
|
||||
'class': 'com.mojang.blaze3d.systems.RenderSystem',
|
||||
'methodName': ASMAPI.mapMethod('m_69408_'), // blendFunc
|
||||
'methodName': 'blendFunc',
|
||||
'methodDesc': '(Lcom/mojang/blaze3d/platform/GlStateManager$SourceFactor;Lcom/mojang/blaze3d/platform/GlStateManager$DestFactor;)V'
|
||||
},
|
||||
'transformer': patchBlendFunc
|
||||
|
@ -8,7 +8,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
"type":"METHOD",
|
||||
"class":"net.minecraft.world.item.BrushItem",
|
||||
"methodName":"m_5929_",
|
||||
"methodName":"onUseTick",
|
||||
"methodDesc":"(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;I)V"
|
||||
},
|
||||
'transformer': function(node) {
|
||||
@ -49,7 +49,7 @@ function initializeCoreMod() {
|
||||
'target': {
|
||||
"type":"METHOD",
|
||||
"class":"net.minecraft.world.level.block.entity.BrushableBlockEntity",
|
||||
"methodName":"m_276923_",
|
||||
"methodName":"brush",
|
||||
"methodDesc":"(JLnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/Direction;)Z"
|
||||
},
|
||||
'transformer': function(node) {
|
||||
@ -73,4 +73,4 @@ function initializeCoreMod() {
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user