-
-
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.
- Loading branch information
1 parent
9687054
commit e0c6a7c
Showing
20 changed files
with
436 additions
and
8 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
common/src/generated/resources/.cache/630af4bded938901e0e1fd57c58a2ac245292828
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
2 changes: 1 addition & 1 deletion
2
common/src/generated/resources/.cache/816056b233c115f7af92c9ed2c207f096721f5cf
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// 1.20.1 2024-08-07T20:38:49.189381552 Create: Numismatics/Numismatics EMI excluded tags | ||
// 1.20.1 2024-08-07T23:05:34.248846149 Create: Numismatics/Numismatics EMI excluded tags | ||
b57edab6f7e7a6e1b1211daa4c3b217ffd09ce62 assets/emi/tag/exclusions/numismatics.json |
2 changes: 1 addition & 1 deletion
2
common/src/generated/resources/.cache/c6e4c19894bc5aece2976a0277ba8e1dbf023865
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 |
---|---|---|
@@ -1 +1 @@ | ||
// 1.20.1 2024-08-07T20:38:49.19624371 Create: Numismatics/Numismatics' Sequenced Assembly Recipes | ||
// 1.20.1 2024-08-07T23:05:34.252881766 Create: Numismatics/Numismatics' Sequenced Assembly Recipes |
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
35 changes: 35 additions & 0 deletions
35
...rc/generated/resources/data/numismatics/advancements/recipes/misc/crafting/salepoint.json
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,35 @@ | ||
{ | ||
"parent": "minecraft:recipes/root", | ||
"criteria": { | ||
"has_item": { | ||
"conditions": { | ||
"items": [ | ||
{ | ||
"items": [ | ||
"numismatics:vendor" | ||
] | ||
} | ||
] | ||
}, | ||
"trigger": "minecraft:inventory_changed" | ||
}, | ||
"has_the_recipe": { | ||
"conditions": { | ||
"recipe": "numismatics:crafting///salepoint" | ||
}, | ||
"trigger": "minecraft:recipe_unlocked" | ||
} | ||
}, | ||
"requirements": [ | ||
[ | ||
"has_item", | ||
"has_the_recipe" | ||
] | ||
], | ||
"rewards": { | ||
"recipes": [ | ||
"numismatics:crafting///salepoint" | ||
] | ||
}, | ||
"sends_telemetry_event": false | ||
} |
27 changes: 27 additions & 0 deletions
27
common/src/generated/resources/data/numismatics/recipes/crafting/salepoint.json
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,27 @@ | ||
{ | ||
"type": "minecraft:crafting_shaped", | ||
"category": "misc", | ||
"key": { | ||
"@": { | ||
"item": "create:precision_mechanism" | ||
}, | ||
"I": { | ||
"item": "create:electron_tube" | ||
}, | ||
"p": { | ||
"item": "create:placard" | ||
}, | ||
"v": { | ||
"item": "numismatics:vendor" | ||
} | ||
}, | ||
"pattern": [ | ||
" p ", | ||
"IvI", | ||
" @ " | ||
], | ||
"result": { | ||
"item": "numismatics:salepoint" | ||
}, | ||
"show_notification": 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
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
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
37 changes: 37 additions & 0 deletions
37
...main/java/dev/ithundxr/createnumismatics/compat/computercraft/implementation/Details.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,37 @@ | ||
/* | ||
* 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.compat.computercraft.implementation; | ||
|
||
import dev.architectury.injectables.annotations.ExpectPlatform; | ||
import dev.ithundxr.createnumismatics.multiloader.fluid.MultiloaderFluidStack; | ||
import net.minecraft.world.item.ItemStack; | ||
|
||
import java.util.Map; | ||
|
||
public class Details { | ||
@ExpectPlatform | ||
public static Map<String, Object> getItemDetail(ItemStack stack) { | ||
throw new AssertionError(); | ||
} | ||
|
||
@ExpectPlatform | ||
public static Map<String, Object> getFluidDetail(MultiloaderFluidStack stack) { | ||
throw new AssertionError(); | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
...reatenumismatics/compat/computercraft/implementation/peripherals/SalepointPeripheral.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,139 @@ | ||
/* | ||
* 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.compat.computercraft.implementation.peripherals; | ||
|
||
import com.simibubi.create.compat.computercraft.implementation.peripherals.SyncedPeripheral; | ||
import com.simibubi.create.foundation.utility.Components; | ||
import dan200.computercraft.api.lua.LuaException; | ||
import dan200.computercraft.api.lua.LuaFunction; | ||
import dev.ithundxr.createnumismatics.Numismatics; | ||
import dev.ithundxr.createnumismatics.content.backend.*; | ||
import dev.ithundxr.createnumismatics.content.backend.sub_authorization.Authorization; | ||
import dev.ithundxr.createnumismatics.content.backend.sub_authorization.SubAccount; | ||
import dev.ithundxr.createnumismatics.content.salepoint.SalepointBlockEntity; | ||
import dev.ithundxr.createnumismatics.content.salepoint.Transaction; | ||
import dev.ithundxr.createnumismatics.content.salepoint.states.ISalepointState; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
import static dev.ithundxr.createnumismatics.content.backend.Coin.getCoinFromName; | ||
import static dev.ithundxr.createnumismatics.content.backend.Coin.getCoinsFromSpurAmount; | ||
|
||
public class SalepointPeripheral extends SyncedPeripheral<SalepointBlockEntity> { | ||
public SalepointPeripheral(SalepointBlockEntity blockEntity) { | ||
super(blockEntity); | ||
} | ||
|
||
@LuaFunction(mainThread = true) | ||
public final void setCoinAmount(String coinName, int amount) throws LuaException { | ||
Coin coin = getCoinFromName(coinName); | ||
if(coin == null) throw new LuaException("incorrect coin name"); | ||
blockEntity.setPrice(coin, amount); | ||
blockEntity.notifyUpdate(); | ||
} | ||
|
||
@LuaFunction(mainThread = true) | ||
public final void setTotalPrice(int spurAmount) { | ||
List<Map.Entry<Coin, Integer>> coins = getCoinsFromSpurAmount(spurAmount); | ||
for (Map.Entry<Coin, Integer> coin : coins) { | ||
blockEntity.setPrice(coin.getKey(), coin.getValue()); | ||
} | ||
blockEntity.notifyUpdate(); | ||
} | ||
|
||
@LuaFunction | ||
public final int getTotalPrice() { | ||
return blockEntity.getTotalPrice(); | ||
} | ||
|
||
@LuaFunction | ||
public final int getPrice(String coinName) throws LuaException { | ||
Coin coin = getCoinFromName(coinName); | ||
if(coin == null) throw new LuaException("incorrect coin name"); | ||
return blockEntity.getPrice(coin); | ||
} | ||
|
||
@LuaFunction | ||
public final Map<String, Object> getSaleObject() throws LuaException { | ||
ISalepointState<?> state = blockEntity.getSalepointState(); | ||
if (state == null) | ||
throw new LuaException("Salepoint is not initialized"); | ||
return state.writeForComputerCraft(); | ||
} | ||
|
||
@LuaFunction(mainThread = true) | ||
public final Map<String, Object> getTransaction() throws LuaException { | ||
Transaction<?> transaction = blockEntity.getTransaction(); | ||
if (transaction == null) | ||
throw new LuaException("No transaction is currently active"); | ||
return Map.of( | ||
"object", blockEntity.getSalepointState().writeForComputerCraft(), | ||
"totalPrice", transaction.totalPrice(), | ||
"targetCount", transaction.multiplier(), | ||
"currentCount", transaction.progress() | ||
); | ||
} | ||
|
||
@LuaFunction(mainThread = true) | ||
public final void startTransaction(String accountID, String authorizationID, int count) throws LuaException { | ||
if (count <= 0) | ||
throw new LuaException("Count must be at least 1"); | ||
|
||
UUID account$, authorization$; | ||
try { | ||
account$ = UUID.fromString(accountID); | ||
authorization$ = UUID.fromString(authorizationID); | ||
} catch (IllegalArgumentException e) { | ||
throw new LuaException("Invalid UUID"); | ||
} | ||
|
||
Authorization authorization = new Authorization.Anonymous(authorization$); | ||
BankAccount account = Numismatics.BANK.getAccount(account$); | ||
if (account == null) { | ||
throw new LuaException("Account not found"); | ||
} | ||
|
||
ReasonHolder reasonHolder = new ReasonHolder(); | ||
SubAccount subAccount = account.getSubAccount(authorization, reasonHolder); | ||
|
||
if (subAccount == null) { | ||
Component errorMessage = reasonHolder.getMessageOrDefault(Components.translatable("error.numismatics.authorized_card.account_not_found")); | ||
throw new LuaException(errorMessage.getString()); | ||
} | ||
|
||
IDeductable deductable = subAccount.getDeductor(authorization); | ||
|
||
if (deductable == null) { | ||
throw new LuaException("Deductor not found"); | ||
} | ||
|
||
IAuthorizationCheckingDeductable authorizationCheckingDeductable = IAuthorizationCheckingDeductable.of(deductable, authorization, subAccount); | ||
|
||
if (!blockEntity.startTransaction(authorizationCheckingDeductable, count)) | ||
throw new LuaException("Failed to start transaction"); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return "Numismatics_Salepoint"; | ||
} | ||
} |
Oops, something went wrong.