mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-28 11:39:07 +00:00
Better
This commit is contained in:
@@ -34,6 +34,7 @@ import com.volmit.iris.engine.object.carve.IrisCaveFluid;
|
||||
import com.volmit.iris.engine.object.carve.IrisCaveLayer;
|
||||
import com.volmit.iris.engine.object.carve.IrisCaverns;
|
||||
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
|
||||
import com.volmit.iris.engine.object.entity.IrisEntityVillagerOverride;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
|
||||
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure;
|
||||
@@ -330,6 +331,9 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@Desc("Define biome mutations for this dimension")
|
||||
private KList<IrisBiomeMutation> mutations = new KList<>();
|
||||
|
||||
@Desc("Cartographer map trade overrides")
|
||||
private IrisEntityVillagerOverride villagerTrade = new IrisEntityVillagerOverride().setDisableTrade(false);
|
||||
|
||||
private final transient AtomicCache<Position2> parallaxSize = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> fluidLayerGenerator = new AtomicCache<>();
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.volmit.iris.engine.object.entity;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.DependsOn;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@Desc("Override cartographer map trades with others or disable the trade altogether")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisEntityVillagerOverride {
|
||||
@Desc("""
|
||||
Disable the trade altogether.
|
||||
If a cartographer villager gets a new explorer map trade:
|
||||
If this is enabled -> the trade is removed
|
||||
If this is disabled -> the trade is replaced with the "override" setting below
|
||||
Default is true, so if you omit this, trades will be removed.""")
|
||||
private boolean disableTrade = true;
|
||||
|
||||
@DependsOn("disableTrade")
|
||||
@Required
|
||||
@Desc("""
|
||||
The items to override the cartographer trade with.
|
||||
By default, this is 3 emeralds + 3 glass blocks -> 1 spyglass.
|
||||
Can trade 3 to 5 times""")
|
||||
private IrisEntityVillagerOverrideItems items = new IrisEntityVillagerOverrideItems()
|
||||
.setIngredient1(new ItemStack(Material.EMERALD, 3))
|
||||
.setIngredient2(new ItemStack(Material.GLASS, 3))
|
||||
.setResult(new ItemStack(Material.SPYGLASS))
|
||||
.setMinTrades(3)
|
||||
.setMaxTrades(5);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.volmit.iris.engine.object.entity;
|
||||
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
@Desc("Override cartographer map trades with these items. ")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisEntityVillagerOverrideItems {
|
||||
|
||||
@Required
|
||||
@RegistryListItemType
|
||||
@Desc("The first, required, ingredient for the trade.\nNote: this MUST be an item, and may not be a non-obtainable block!")
|
||||
private ItemStack ingredient1;
|
||||
|
||||
@RegistryListItemType
|
||||
@Desc("The second, optional, ingredient for the trade.\nNote: this MUST be an item, and may not be a non-obtainable block!")
|
||||
private ItemStack ingredient2 = null;
|
||||
|
||||
@Required
|
||||
@RegistryListItemType
|
||||
@Desc("The result of the trade.\nNote: this MUST be an item, and may not be a non-obtainable block!")
|
||||
private ItemStack result;
|
||||
|
||||
@Desc("The min amount of times this trade can be done. Default 3")
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
private int minTrades = 3;
|
||||
|
||||
@Desc("The max amount of times this trade can be done. Default 5")
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
private int maxTrades = 5;
|
||||
|
||||
/**
|
||||
* @return true if:<br>
|
||||
* ingredient 1 & result are non-null,<br>
|
||||
* mintrades > 0, maxtrades > 0, maxtrades > mintrades, and<br>
|
||||
* ingredient 1, (if defined ingredient 2) and the result are valid items
|
||||
*/
|
||||
public boolean isValidItems(){
|
||||
if (ingredient1 == null || result == null || minTrades <= 0 || maxTrades <= 0 || maxTrades < minTrades){
|
||||
return false;
|
||||
}
|
||||
return ingredient1.getType().isItem() && (ingredient2 == null || ingredient2.getType().isItem()) && result.getType().isItem();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ingredients
|
||||
* @return The list of 1 or 2 ingredients (depending on if ing2 is null)
|
||||
*/
|
||||
public List<ItemStack> getIngredients() {
|
||||
if (!isValidItems()){
|
||||
return null;
|
||||
}
|
||||
return ingredient2 == null ? new KList<>(ingredient1) : new KList<>(ingredient1, ingredient2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount of trades (RNG.r.i(min, max))
|
||||
*/
|
||||
public int getAmount() {
|
||||
return RNG.r.i(minTrades, maxTrades);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user