use of moriyashiine.bewitchment.api.registry.Contract in project bewitchment by MoriyaShiine.
the class BaphometEntity method getOffers.
@Override
public List<DemonEntity.DemonTradeOffer> getOffers() {
if (offers.isEmpty()) {
List<Contract> availableContracts = BWRegistries.CONTRACTS.stream().collect(Collectors.toList());
for (int i = 0; i < 5; i++) {
Contract contract = availableContracts.get(random.nextInt(availableContracts.size()));
offers.add(new DemonEntity.DemonTradeOffer(contract, 72000, 2 + random.nextInt(2) * 2));
availableContracts.remove(contract);
}
}
return offers;
}
use of moriyashiine.bewitchment.api.registry.Contract in project bewitchment by MoriyaShiine.
the class DemonEntity method getOffers.
@Override
public List<DemonEntity.DemonTradeOffer> getOffers() {
if (offers.isEmpty()) {
List<Contract> availableContracts = BWRegistries.CONTRACTS.stream().collect(Collectors.toList());
for (int i = 0; i < 3; i++) {
Contract contract = availableContracts.get(random.nextInt(availableContracts.size()));
offers.add(new DemonTradeOffer(contract, 168000, MathHelper.nextInt(random, 3, 6)));
availableContracts.remove(contract);
}
}
return offers;
}
use of moriyashiine.bewitchment.api.registry.Contract in project bewitchment by MoriyaShiine.
the class ContractsComponent method readFromNbt.
@Override
public void readFromNbt(NbtCompound tag) {
NbtList contractsList = tag.getList("Contracts", NbtType.COMPOUND);
for (int i = 0; i < contractsList.size(); i++) {
NbtCompound contractCompound = contractsList.getCompound(i);
addContract(new Contract.Instance(BWRegistries.CONTRACTS.get(new Identifier(contractCompound.getString("Contract"))), contractCompound.getInt("Duration"), contractCompound.getInt("Cost")));
}
}
use of moriyashiine.bewitchment.api.registry.Contract in project bewitchment by MoriyaShiine.
the class ContractsComponent method toNbtContract.
@SuppressWarnings("ConstantConditions")
public NbtList toNbtContract() {
NbtList contractsTag = new NbtList();
for (Contract.Instance instance : getContracts()) {
NbtCompound contractCompound = new NbtCompound();
contractCompound.putString("Contract", BWRegistries.CONTRACTS.getId(instance.contract).toString());
contractCompound.putInt("Duration", instance.duration);
contractCompound.putInt("Cost", instance.cost);
contractsTag.add(contractCompound);
}
return contractsTag;
}
use of moriyashiine.bewitchment.api.registry.Contract in project bewitchment by MoriyaShiine.
the class SyncContractsPacket method handle.
public static void handle(MinecraftClient client, ClientPlayNetworkHandler network, PacketByteBuf buf, PacketSender sender) {
NbtCompound contractsCompound = buf.readNbt();
client.execute(new Runnable() {
@Override
public void run() {
if (client.player != null) {
BWComponents.CONTRACTS_COMPONENT.maybeGet(client.player).ifPresent(contractsComponent -> {
contractsComponent.getContracts().clear();
NbtList contractsList = contractsCompound.getList("Contracts", NbtType.COMPOUND);
for (int i = 0; i < contractsList.size(); i++) {
NbtCompound contractCompound = contractsList.getCompound(i);
contractsComponent.addContract(new Contract.Instance(BWRegistries.CONTRACTS.get(new Identifier(contractCompound.getString("Contract"))), contractCompound.getInt("Duration"), contractCompound.getInt("Cost")));
}
});
}
}
});
}
Aggregations