use of org.spongepowered.asm.mixin.Unique in project nbt-crafting by Siphalor.
the class MixinIngredient method loadIngredientEntryCondition.
@Unique
private static IngredientEntryCondition loadIngredientEntryCondition(JsonObject jsonObject) {
if (jsonObject.has("data")) {
if (JsonHelper.hasString(jsonObject, "data")) {
try {
CompoundTag compoundTag = new StringNbtReader(new StringReader(jsonObject.get("data").getAsString())).parseCompoundTag();
IngredientEntryCondition condition = new IngredientEntryCondition();
if (compoundTag.contains("require") || compoundTag.contains("deny")) {
if (compoundTag.contains("require"))
condition.requiredElements = compoundTag.getCompound("require");
if (compoundTag.contains("deny"))
condition.deniedElements = compoundTag.getCompound("deny");
} else {
condition.requiredElements = compoundTag;
}
return condition;
} catch (CommandSyntaxException e) {
e.printStackTrace();
}
} else if (jsonObject.get("data").isJsonObject()) {
return IngredientEntryCondition.fromJson((JsonObject) JsonPreprocessor.process(jsonObject.get("data").getAsJsonObject()));
}
}
return new IngredientEntryCondition();
}
use of org.spongepowered.asm.mixin.Unique in project nbt-crafting by Siphalor.
the class MixinIngredient method ofAdvancedEntries.
@Unique
private static Ingredient ofAdvancedEntries(Stream<? extends IngredientEntry> entries) {
if (entries == null)
NbtCrafting.logError("Internal error: can't construct ingredient from null entry stream!");
try {
Ingredient ingredient;
// noinspection ConstantConditions
ingredient = (Ingredient) ((ICloneable) (Object) Ingredient.EMPTY).clone();
((IIngredient) (Object) ingredient).nbtCrafting$setAdvancedEntries(entries);
return ingredient;
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
return Ingredient.EMPTY;
}
use of org.spongepowered.asm.mixin.Unique in project nbt-crafting by Siphalor.
the class MixinIngredient method advancedEntryFromJson.
@Unique
private static IngredientEntry advancedEntryFromJson(JsonObject jsonObject) {
if (jsonObject.has("item") && jsonObject.has("tag")) {
throw new JsonParseException("An ingredient entry is either a tag or an item or a potion, not both");
}
if (jsonObject.has("item")) {
final Identifier identifier = new Identifier(JsonHelper.getString(jsonObject, "item"));
try {
final Item item = Registry.ITEM.getOrEmpty(identifier).orElseThrow(() -> {
throw new JsonSyntaxException("Unknown item '" + identifier.toString() + "'");
});
IngredientStackEntry entry = new IngredientStackEntry(Registry.ITEM.getRawId(item), loadIngredientEntryCondition(jsonObject));
if (jsonObject.has("remainder")) {
entry.setRecipeRemainder(ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject, "remainder")));
}
return entry;
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
if (jsonObject.has("potion")) {
final Identifier identifier = new Identifier(JsonHelper.getString(jsonObject, "potion"));
try {
Registry.POTION.getOrEmpty(identifier).orElseThrow(() -> {
throw new JsonSyntaxException("Unknown potion '" + identifier.toString() + "'");
});
IngredientEntryCondition condition = loadIngredientEntryCondition(jsonObject);
if (condition.requiredElements == NbtUtil.EMPTY_COMPOUND)
condition.requiredElements = new CompoundTag();
condition.requiredElements.putString("Potion", identifier.toString());
IngredientStackEntry entry = new IngredientStackEntry(Registry.ITEM.getRawId(Items.POTION), condition);
if (jsonObject.has("remainder")) {
entry.setRecipeRemainder(ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject, "remainder")));
}
return entry;
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
if (!jsonObject.has("tag")) {
throw new JsonParseException("An ingredient entry needs either a tag or an item");
}
final Identifier identifier2 = new Identifier(JsonHelper.getString(jsonObject, "tag"));
final Tag<Item> tag = ItemTags.getContainer().get(identifier2);
if (tag == null) {
throw new JsonSyntaxException("Unknown item tag '" + identifier2 + "'");
}
IngredientMultiStackEntry entry = new IngredientMultiStackEntry(tag.values().stream().map(Registry.ITEM::getRawId).collect(Collectors.toList()), loadIngredientEntryCondition(jsonObject));
entry.setTag(identifier2.toString());
if (jsonObject.has("remainder")) {
entry.setRecipeRemainder(ShapedRecipe.getItemStack(JsonHelper.getObject(jsonObject, "remainder")));
}
return entry;
}
use of org.spongepowered.asm.mixin.Unique in project Botania by VazkiiMods.
the class FabricMixinEnderMan method checkForVincs.
@Unique
private void checkForVincs(Args args) {
double x = args.get(0);
double y = args.get(1);
double z = args.get(2);
Vec3 vincPos = SubTileVinculotus.onEndermanTeleport((EnderMan) (Object) this, x, y, z);
if (vincPos != null) {
args.set(0, vincPos.x());
args.set(1, vincPos.y());
args.set(2, vincPos.z());
}
}
use of org.spongepowered.asm.mixin.Unique in project beebuddy by queenofthebees.
the class BeeEntityMixin method beebuddy$initTamedGoals.
@Unique
private void beebuddy$initTamedGoals() {
BeeEntity us = (BeeEntity) (Object) this;
this.goalSelector.add(0, new BeeSitGoal(us));
this.goalSelector.add(1, StingGoalInvoker.beebuddy$make(us, us, 1.399999976158142D, true));
this.goalSelector.add(2, new FollowParentGoal(us, 1.25D));
this.goalSelector.add(3, new FollowFriendGoal(us));
this.goalSelector.add(4, new AnimalMateGoal(us, 1.0D));
if (pollinateGoal == null) {
// we can be called before initGoals's body
pollinateGoal = PollinateGoalInvoker.beebuddy$make(us);
}
this.goalSelector.add(5, pollinateGoal);
if (moveToFlowerGoal == null) {
moveToFlowerGoal = MoveToFlowerGoalInvoker.beebuddy$make(us);
}
this.goalSelector.add(6, moveToFlowerGoal);
this.goalSelector.add(7, new SitOnHeadGoal(us));
this.goalSelector.add(7, BeeWanderAroundGoalInvoker.beebuddy$make(us));
this.goalSelector.add(8, new LookAtEntityGoal(us, PlayerEntity.class, 4.0F));
this.goalSelector.add(8, new SwimGoal(us));
BeeEntityMixin mix = this;
this.targetSelector.add(1, (new RevengeGoal(this) {
@Override
public boolean canStart() {
if (!super.canStart()) {
return false;
}
if (us.getAttacker() != null) {
UUID u = us.getAttacker().getUuid();
return !u.equals(mix.beebuddy$getFriend());
} else {
return true;
}
}
@Override
public boolean shouldContinue() {
return us.hasAngerTime() && super.shouldContinue();
}
}).setGroupRevenge(new Class[0]));
}
Aggregations