-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forge fluid salepoint implementation
- Loading branch information
1 parent
8ff160c
commit 13a853f
Showing
9 changed files
with
512 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...va/dev/ithundxr/createnumismatics/fabric/mixin/MixinAllFluids$CreateAttributeHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Numismatics | ||
* Copyright (c) 2024 The Railways Team | ||
* | ||
* 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, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* 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 dev.ithundxr.createnumismatics.fabric.mixin; | ||
|
||
import dev.ithundxr.createnumismatics.annotation.mixin.DevMixin; | ||
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.contents.TranslatableContents; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@DevMixin | ||
@Mixin(targets = "com.simibubi.create.AllFluids$CreateAttributeHandler") | ||
@SuppressWarnings("UnstableApiUsage") | ||
public class MixinAllFluids$CreateAttributeHandler { | ||
@Shadow @Final private Component name; | ||
|
||
// Make tea lighter than air to test salepoint rendering | ||
@Inject(method = "isLighterThanAir", at = @At("HEAD"), cancellable = true, remap = false) | ||
private void teaFloats(FluidVariant variant, CallbackInfoReturnable<Boolean> cir) { | ||
if (this.name.getContents() instanceof TranslatableContents translatableContents && translatableContents.getKey().equals("fluid.create.tea")) { | ||
cir.setReturnValue(true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
...enumismatics/content/salepoint/containers/forge/InvalidatableWrappingFluidBufferTank.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* | ||
* Numismatics | ||
* Copyright (c) 2024 The Railways Team | ||
* | ||
* 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, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* 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 dev.ithundxr.createnumismatics.content.salepoint.containers.forge; | ||
|
||
import dev.ithundxr.createnumismatics.content.salepoint.containers.InvalidatableAbstractBuffer; | ||
import dev.ithundxr.createnumismatics.multiloader.fluid.MultiloaderFluidStack; | ||
import dev.ithundxr.createnumismatics.multiloader.fluid.forge.MultiloaderFluidStackImpl; | ||
import net.minecraftforge.fluids.FluidStack; | ||
import net.minecraftforge.fluids.capability.IFluidHandler; | ||
import net.minecraftforge.fluids.capability.templates.FluidTank; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class InvalidatableWrappingFluidBufferTank extends InvalidatableAbstractBuffer<MultiloaderFluidStack> implements IFluidHandler { | ||
|
||
protected FluidTank buffer; | ||
|
||
public InvalidatableWrappingFluidBufferTank(FluidTank buffer) { | ||
this.buffer = buffer; | ||
} | ||
|
||
@Override | ||
protected void afterInvalidate() { | ||
super.afterInvalidate(); | ||
buffer = null; | ||
} | ||
|
||
@Override | ||
protected int copyToBufferInternal(MultiloaderFluidStack source, boolean simulate) { | ||
return buffer.fill(((MultiloaderFluidStackImpl) source).getWrapped(), simulate ? FluidAction.SIMULATE : FluidAction.EXECUTE); | ||
} | ||
|
||
@Override | ||
protected int removeFromBufferInternal(MultiloaderFluidStack source, boolean simulate, int maxAmount) { | ||
return buffer.drain(((MultiloaderFluidStackImpl) source).getWrapped(), simulate ? FluidAction.SIMULATE : FluidAction.EXECUTE).getAmount(); | ||
} | ||
|
||
@Override | ||
public int getTanks() { | ||
if (!isValid()) | ||
return 0; | ||
|
||
return buffer.getTanks(); | ||
} | ||
|
||
@Override | ||
public @NotNull FluidStack getFluidInTank(int tank) { | ||
if (!isValid()) | ||
return FluidStack.EMPTY; | ||
|
||
return buffer.getFluidInTank(tank); | ||
} | ||
|
||
@Override | ||
public int getTankCapacity(int tank) { | ||
if (!isValid()) | ||
return 0; | ||
|
||
return buffer.getTankCapacity(tank); | ||
} | ||
|
||
@Override | ||
public boolean isFluidValid(int tank, @NotNull FluidStack stack) { | ||
if (!isValid()) | ||
return false; | ||
|
||
return buffer.isFluidValid(tank, stack); | ||
} | ||
|
||
@Override | ||
public int fill(FluidStack resource, FluidAction action) { | ||
if (!isValid()) | ||
return 0; | ||
|
||
return buffer.fill(resource, action); | ||
} | ||
|
||
@Override | ||
public @NotNull FluidStack drain(FluidStack resource, FluidAction action) { | ||
if (!isValid()) | ||
return FluidStack.EMPTY; | ||
|
||
return buffer.drain(resource, action); | ||
} | ||
|
||
@Override | ||
public @NotNull FluidStack drain(int tank, FluidAction action) { | ||
if (!isValid()) | ||
return FluidStack.EMPTY; | ||
|
||
return buffer.drain(tank, action); | ||
} | ||
|
||
/* @Override | ||
public long insert(FluidVariant resource, long maxAmount, TransactionContext transaction) { | ||
if (!isValid()) | ||
return 0; | ||
return buffer.insert(resource, maxAmount, transaction); | ||
} | ||
@Override | ||
public long extract(FluidVariant resource, long maxAmount, TransactionContext transaction) { | ||
if (!isValid()) | ||
return 0; | ||
return buffer.extract(resource, maxAmount, transaction); | ||
} | ||
@Override | ||
public @NotNull Iterator<StorageView<FluidVariant>> iterator() { | ||
if (!isValid()) | ||
return Collections.emptyListIterator(); | ||
return buffer.iterator(); | ||
}*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.