Add mixins, move getter methodhandles to them

Remove libobfuscation getMethod usages

Libobfuscation is gone 🦀

Combine mixins into one package

Port all accesstransformers possible to Mixins
This commit is contained in:
Vincent Lee committed 2020-07-17 20:19:50 -05:00
1 parent e4ba90b5bb
commit 2a928124c3
89 files changed
+824 -344

No files matched your search

+11 -1
View File
@@ -5,9 +5,11 @@ buildscript {
name "forge"
url "https://files.minecraftforge.net/maven"
}
maven { url = 'https://dist.creeper.host/Sponge/maven' }
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.0.+'
classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
}
}
@@ -20,6 +22,11 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'pmd'
apply plugin: 'org.spongepowered.mixin'
mixin {
add sourceSets.main, "botania.refmap.json"
}
ext.configFile = file('build.properties')
ext.config = parseConfig(configFile)
@@ -102,6 +109,7 @@ test {
dependencies {
minecraft "net.minecraftforge:forge:${mc_version}-32.0.66"
compile 'org.spongepowered:mixin:0.8'
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.16-39:api")
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.16-39")
@@ -144,7 +152,9 @@ jar {
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor": "botania",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],)
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConnector": "vazkii.botania.common.MixinConnector"
])
}
exclude "**/*.bat"
@@ -57,11 +57,11 @@ public final class ColorHandler {
return -1;
}
int color = DyeColor.WHITE.colorValue;
int color = DyeColor.WHITE.getColorValue();
if (world != null && pos != null) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TilePool) {
color = ((TilePool) te).color.colorValue;
color = ((TilePool) te).color.getColorValue();
}
}
if (((BlockPool) state.getBlock()).variant == BlockPool.Variant.FABULOUS) {
@@ -84,7 +84,7 @@ public final class ColorHandler {
);
// Petal Block
blocks.register((state, world, pos, tintIndex) -> tintIndex == 0 ? ((BlockPetalBlock) state.getBlock()).color.colorValue : -1,
blocks.register((state, world, pos, tintIndex) -> tintIndex == 0 ? ((BlockPetalBlock) state.getBlock()).color.getColorValue() : -1,
ModBlocks.petalBlockWhite, ModBlocks.petalBlockOrange, ModBlocks.petalBlockMagenta, ModBlocks.petalBlockLightBlue,
ModBlocks.petalBlockYellow, ModBlocks.petalBlockLime, ModBlocks.petalBlockPink, ModBlocks.petalBlockGray,
ModBlocks.petalBlockSilver, ModBlocks.petalBlockCyan, ModBlocks.petalBlockPurple, ModBlocks.petalBlockBlue,
@@ -114,12 +114,12 @@ public final class ColorHandler {
items.register((s, t) -> t == 0 ? MathHelper.hsvToRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F) : -1,
ModItems.lifeEssence, ModItems.gaiaIngot);
items.register((s, t) -> t == 1 ? DyeColor.byId(ItemTwigWand.getColor1(s)).colorValue
: t == 2 ? DyeColor.byId(ItemTwigWand.getColor2(s)).colorValue
items.register((s, t) -> t == 1 ? DyeColor.byId(ItemTwigWand.getColor1(s)).getColorValue()
: t == 2 ? DyeColor.byId(ItemTwigWand.getColor2(s)).getColorValue()
: -1,
ModItems.twigWand);
IItemColor petalHandler = (s, t) -> t == 0 ? ((ItemPetal) s.getItem()).color.colorValue : -1;
IItemColor petalHandler = (s, t) -> t == 0 ? ((ItemPetal) s.getItem()).color.getColorValue() : -1;
for (DyeColor color : DyeColor.values()) {
items.register(petalHandler, ModItems.getPetal(color));
}
@@ -18,14 +18,13 @@ import net.minecraft.client.gui.screen.inventory.InventoryScreen;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import vazkii.botania.client.core.proxy.ClientProxy;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.common.network.PacketIndexKeybindRequest;
import vazkii.botania.mixin.MixinRecipeBookGui;
import vazkii.botania.mixin.MixinRecipeBookPage;
import java.util.function.Predicate;
import java.util.function.Supplier;
@@ -83,14 +82,10 @@ public class CorporeaInputHandler {
if (screen instanceof InventoryScreen && ((InventoryScreen) screen).getRecipeGui().isVisible()) {
RecipeBookGui recipeBook = ((InventoryScreen) screen).getRecipeGui();
try {
RecipeBookPage page = ObfuscationReflectionHelper.getPrivateValue(RecipeBookGui.class, recipeBook, LibObfuscation.RECIPE_BOOK_PAGE);
RecipeWidget widget = ObfuscationReflectionHelper.getPrivateValue(RecipeBookPage.class, page, LibObfuscation.HOVERED_BUTTON);
if (widget != null) {
return widget.getRecipe().getRecipeOutput();
}
} catch (Exception e) {
Botania.LOGGER.error("Failed to get hovered recipe gui button", e);
RecipeBookPage page = ((MixinRecipeBookGui) recipeBook).getRecipeBookPage();
RecipeWidget widget = ((MixinRecipeBookPage) page).getHoveredButton();
if (widget != null) {
return widget.getRecipe().getRecipeOutput();
}
}
@@ -10,7 +10,7 @@ package vazkii.botania.client.core.handler;
import net.minecraft.client.renderer.Atlases;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ItemOverride;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.model.RenderMaterial;
import net.minecraft.client.renderer.texture.AtlasTexture;
@@ -30,15 +30,15 @@ import vazkii.botania.common.Botania;
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
import vazkii.botania.common.item.relic.ItemKingKey;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.mixin.MixinItemOverrideList;
import vazkii.botania.mixin.MixinModelBakery;
import java.lang.invoke.MethodHandle;
import java.util.List;
import java.util.Set;
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
public class MiscellaneousIcons {
private static final MethodHandle MATERIALS = LibObfuscation.getGetter(ModelBakery.class, "field_177602_b");
public static final MiscellaneousIcons INSTANCE = new MiscellaneousIcons();
public TextureAtlasSprite alfPortalTex,
@@ -86,12 +86,7 @@ public class MiscellaneousIcons {
public final IBakedModel[] kingKeyWeaponModels = new IBakedModel[ItemKingKey.WEAPON_TYPES];
public void onModelRegister(ModelRegistryEvent evt) {
Set<RenderMaterial> materials;
try {
materials = (Set<RenderMaterial>) MATERIALS.invokeExact();
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
Set<RenderMaterial> materials = MixinModelBakery.getMaterials();
materials.add(RenderLexicon.TEXTURE);
materials.add(RenderLexicon.ELVEN_TEXTURE);
@@ -147,8 +142,9 @@ public class MiscellaneousIcons {
new LexiconModel(original));
// models referenced using json overrides aren't put in the model registry, so just go through all override models and wrap them there
for (int i = 0; i < original.getOverrides().overrideBakedModels.size(); i++) {
original.getOverrides().overrideBakedModels.set(i, new LexiconModel(original.getOverrides().overrideBakedModels.get(i)));
List<IBakedModel> overrides = ((MixinItemOverrideList) original.getOverrides()).getOverrideBakedModels();
for (int i = 0; i < overrides.size(); i++) {
overrides.set(i, new LexiconModel(overrides.get(i)));
}
// Mana Blaster
@@ -14,7 +14,6 @@ import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.FirstPersonRenderer;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.model.BookModel;
@@ -39,16 +38,13 @@ import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.item.ItemLexicon;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.mixin.MixinFirstPersonRenderer;
import java.lang.invoke.MethodHandle;
import java.util.ArrayList;
import java.util.List;
// Hacky way to render 3D lexicon, will be reevaluated in the future.
public class RenderLexicon {
private static final MethodHandle APPLY_EQUIP_OFFSET = LibObfuscation.getMethod(FirstPersonRenderer.class, "func_228406_b_", MatrixStack.class, HandSide.class, float.class);
private static final MethodHandle APPLY_SWING_OFFSET = LibObfuscation.getMethod(FirstPersonRenderer.class, "func_228399_a_", MatrixStack.class, HandSide.class, float.class);
private static final BookModel model = new BookModel();
private static final boolean SHOULD_MISSPELL = Math.random() < 0.0004;
public static final RenderMaterial TEXTURE = new RenderMaterial(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(LibResources.MODEL_LEXICA_DEFAULT));
@@ -101,12 +97,8 @@ public class RenderLexicon {
float f10 = -0.2F * MathHelper.sin(swingProgress * (float) Math.PI);
int l = flag3 ? 1 : -1;
ms.translate((double) ((float) l * f5), (double) f6, (double) f10);
try {
APPLY_EQUIP_OFFSET.invokeExact(Minecraft.getInstance().getFirstPersonRenderer(), ms, handside, equipProgress);
APPLY_SWING_OFFSET.invokeExact(Minecraft.getInstance().getFirstPersonRenderer(), ms, handside, swingProgress);
} catch (Throwable ex) {
Botania.LOGGER.catching(ex);
}
((MixinFirstPersonRenderer) Minecraft.getInstance().getFirstPersonRenderer()).callTransformSideFirstPerson(ms, handside, equipProgress);
((MixinFirstPersonRenderer) Minecraft.getInstance().getFirstPersonRenderer()).callTransformFirstPerson(ms, handside, swingProgress);
}
doRender(stack, handside, ms, buffers, light, partialTicks);
@@ -41,11 +41,9 @@ import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.client.render.tile.RenderTilePylon;
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
import vazkii.botania.common.lib.LibObfuscation;
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
import java.util.Arrays;
import java.util.List;
import java.util.OptionalDouble;
@@ -392,8 +390,6 @@ public final class RenderHelper {
}
private static final MethodHandle RENDER_BAKED_ITEM_MODEL = LibObfuscation.getMethod(ItemRenderer.class, "func_229114_a_", IBakedModel.class, ItemStack.class, int.class, int.class, MatrixStack.class, IVertexBuilder.class);
// [VanillaCopy] Portions of ItemRenderer.renderItem
// Does not support TEISRs
public static void renderItemModelGold(@Nullable LivingEntity entity, ItemStack stack, ItemCameraTransforms.TransformType transform, MatrixStack ms, IRenderTypeBuffer buffers, @Nullable World world, int light, int overlay) {
@@ -411,11 +407,7 @@ public final class RenderHelper {
ms.translate(-0.5D, -0.5D, -0.5D);
if (!ibakedmodel.isBuiltInRenderer() && (stack.getItem() != Items.TRIDENT || flag1)) {
IVertexBuilder ivertexbuilder = ItemRenderer.getBuffer(buffers, ENTITY_TRANSLUCENT_GOLD, true, stack.hasEffect());
try {
RENDER_BAKED_ITEM_MODEL.invokeExact(ir, ibakedmodel, stack, light, overlay, ms, ivertexbuilder);
} catch (Throwable ex) {
throw new RuntimeException("Error calling renderBakedItemModel", ex);
}
ir.renderModel(ibakedmodel, stack, light, overlay, ms, ivertexbuilder);
}
ms.pop();
@@ -12,7 +12,6 @@ import net.minecraft.block.Block;
import net.minecraft.block.FlowerBlock;
import net.minecraft.block.TallFlowerBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeBuffers;
@@ -75,16 +74,14 @@ import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
import vazkii.botania.common.item.relic.ItemInfiniteFruit;
import vazkii.botania.common.item.rod.ItemTornadoRod;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.mixin.MixinBiomeGeneratorTypeScreens;
import vazkii.patchouli.api.IMultiblock;
import vazkii.patchouli.api.PatchouliAPI;
import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandle;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.SortedMap;
@@ -95,7 +92,6 @@ public class ClientProxy implements IProxy {
public static boolean jingleTheBells = false;
public static boolean dootDoot = false;
private static final MethodHandle REGISTER_PROPERTY_GETTER = LibObfuscation.getMethod(ItemModelsProperties.class, "func_239418_a_", Item.class, ResourceLocation.class, IItemPropertyGetter.class);
public static KeyBinding CORPOREA_REQUEST;
@@ -160,14 +156,7 @@ public class ClientProxy implements IProxy {
registerRenderTypes();
DeferredWorkQueue.runLater(() -> {
MethodHandle worldTypesGetter = LibObfuscation.getGetter(BiomeGeneratorTypeScreens.class, "field_239068_c_");
try {
@SuppressWarnings("unchecked")
List<BiomeGeneratorTypeScreens> worldTypes = (List<BiomeGeneratorTypeScreens>) worldTypesGetter.invokeExact();
worldTypes.add(WorldTypeSkyblock.INSTANCE);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
MixinBiomeGeneratorTypeScreens.getAllTypes().add(WorldTypeSkyblock.INSTANCE);
CORPOREA_REQUEST = new KeyBinding("key.botania_corporea_request", KeyConflictContext.GUI, InputMappings.getInputByCode(GLFW.GLFW_KEY_C, 0), LibMisc.MOD_NAME);
ClientRegistry.registerKeyBinding(ClientProxy.CORPOREA_REQUEST);
@@ -177,11 +166,7 @@ public class ClientProxy implements IProxy {
}
private static void registerPropertyGetter(IItemProvider item, ResourceLocation id, IItemPropertyGetter propGetter) {
try {
REGISTER_PROPERTY_GETTER.invokeExact(item.asItem(), id, propGetter);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
ItemModelsProperties.func_239418_a_(item.asItem(), id, propGetter);
}
private static void registerPropertyGetters() {
@@ -27,6 +27,7 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.mana.IManaItem;
@@ -120,12 +121,13 @@ public class JEIBotaniaPlugin implements IModPlugin {
@Override
public void registerRecipes(@Nonnull IRecipeRegistration registry) {
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.BREW_TYPE).values(), BreweryRecipeCategory.UID);
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PURE_DAISY_TYPE).values(), PureDaisyRecipeCategory.UID);
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PETAL_TYPE).values(), PetalApothecaryRecipeCategory.UID);
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values(), ElvenTradeRecipeCategory.UID);
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.RUNE_TYPE).values(), RunicAltarRecipeCategory.UID);
registry.addRecipes(TilePool.manaInfusionRecipes(Minecraft.getInstance().world.getRecipeManager()), ManaPoolRecipeCategory.UID);
World world = Minecraft.getInstance().world;
registry.addRecipes(ModRecipeTypes.getRecipes(world, ModRecipeTypes.BREW_TYPE).values(), BreweryRecipeCategory.UID);
registry.addRecipes(ModRecipeTypes.getRecipes(world, ModRecipeTypes.PURE_DAISY_TYPE).values(), PureDaisyRecipeCategory.UID);
registry.addRecipes(ModRecipeTypes.getRecipes(world, ModRecipeTypes.PETAL_TYPE).values(), PetalApothecaryRecipeCategory.UID);
registry.addRecipes(ModRecipeTypes.getRecipes(world, ModRecipeTypes.ELVEN_TRADE_TYPE).values(), ElvenTradeRecipeCategory.UID);
registry.addRecipes(ModRecipeTypes.getRecipes(world, ModRecipeTypes.RUNE_TYPE).values(), RunicAltarRecipeCategory.UID);
registry.addRecipes(TilePool.manaInfusionRecipes(Minecraft.getInstance().world), ManaPoolRecipeCategory.UID);
registry.addRecipes(
BotaniaAPI.instance().getOreWeights().entrySet().stream()
@@ -187,7 +189,7 @@ public class JEIBotaniaPlugin implements IModPlugin {
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager();
// Hide the return recipes (iron ingot/diamond/ender pearl returns, not lexicon)
for (IElvenTradeRecipe recipe : TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().world.getRecipeManager())) {
for (IElvenTradeRecipe recipe : TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().world)) {
if (recipe instanceof LexiconElvenTradeRecipe) {
continue;
}
@@ -14,6 +14,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import vazkii.botania.common.crafting.ModRecipeTypes;
import vazkii.patchouli.api.IVariable;
@@ -34,11 +35,12 @@ public class RotatingRecipeComponent extends RotatingItemListComponentBase {
@Override
protected List<Ingredient> makeIngredients() {
World world = Minecraft.getInstance().world;
Map<ResourceLocation, ? extends IRecipe<?>> map;
if ("runic_altar".equals(recipeType)) {
map = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.RUNE_TYPE);
map = ModRecipeTypes.getRecipes(world, ModRecipeTypes.RUNE_TYPE);
} else if ("petal_apothecary".equals(recipeType)) {
map = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PETAL_TYPE);
map = ModRecipeTypes.getRecipes(world, ModRecipeTypes.PETAL_TYPE);
} else {
throw new IllegalArgumentException("Type must be 'runic_altar' or 'petal_apothecary'!");
}
@@ -33,7 +33,7 @@ public class BrewRecipeProcessor implements IComponentProcessor {
@Override
public void setup(IVariableProvider variables) {
ResourceLocation id = new ResourceLocation(variables.get("recipe").asString());
IRecipe<?> recipe = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.BREW_TYPE).get(id);
IRecipe<?> recipe = ModRecipeTypes.getRecipes(Minecraft.getInstance().world, ModRecipeTypes.BREW_TYPE).get(id);
if (recipe instanceof IBrewRecipe) {
this.recipe = (IBrewRecipe) recipe;
} else {
@@ -35,7 +35,7 @@ public class ElvenTradeProcessor implements IComponentProcessor {
public void setup(IVariableProvider variables) {
ImmutableList.Builder<IElvenTradeRecipe> builder = ImmutableList.builder();
for (IVariable s : variables.get("recipes").asListOrSingleton()) {
IRecipe<?> recipe = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).get(new ResourceLocation(s.asString()));
IRecipe<?> recipe = ModRecipeTypes.getRecipes(Minecraft.getInstance().world, ModRecipeTypes.ELVEN_TRADE_TYPE).get(new ResourceLocation(s.asString()));
if (recipe instanceof IElvenTradeRecipe) {
builder.add((IElvenTradeRecipe) recipe);
} else {
@@ -42,12 +42,12 @@ public class ManaInfusionProcessor implements IComponentProcessor {
ImmutableList.Builder<IManaInfusionRecipe> builder = ImmutableList.builder();
if (variables.has("group")) {
String group = variables.get("group").asString();
TilePool.manaInfusionRecipes(Minecraft.getInstance().world.getRecipeManager()).stream()
TilePool.manaInfusionRecipes(Minecraft.getInstance().world).stream()
.filter(r -> r.getGroup().equals(group))
.forEach(builder::add);
} else {
for (IVariable s : variables.get("recipes").asListOrSingleton()) {
IRecipe<?> recipe = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.MANA_INFUSION_TYPE).get(new ResourceLocation(s.asString()));
IRecipe<?> recipe = ModRecipeTypes.getRecipes(Minecraft.getInstance().world, ModRecipeTypes.MANA_INFUSION_TYPE).get(new ResourceLocation(s.asString()));
if (recipe instanceof IManaInfusionRecipe) {
builder.add((IManaInfusionRecipe) recipe);
} else {
@@ -20,6 +20,7 @@ import net.minecraftforge.common.crafting.IShapedRecipe;
import vazkii.botania.client.patchouli.PatchouliUtils;
import vazkii.botania.common.Botania;
import vazkii.botania.common.crafting.ModRecipeTypes;
import vazkii.patchouli.api.IComponentProcessor;
import vazkii.patchouli.api.IVariable;
import vazkii.patchouli.api.IVariableProvider;
@@ -38,7 +39,7 @@ public class MultiCraftingProcessor implements IComponentProcessor {
@Override
public void setup(IVariableProvider variables) {
Map<ResourceLocation, IRecipe<CraftingInventory>> recipeMap = Minecraft.getInstance().world.getRecipeManager().getRecipes(IRecipeType.CRAFTING);
Map<ResourceLocation, IRecipe<CraftingInventory>> recipeMap = ModRecipeTypes.getRecipes(Minecraft.getInstance().world, IRecipeType.CRAFTING);
List<String> names = variables.get("recipes").asStream().map(IVariable::asString).collect(Collectors.toList());
this.recipes = new ArrayList<>();
for (String name : names) {
@@ -24,7 +24,7 @@ public class PetalApothecaryProcessor implements IComponentProcessor {
@Override
public void setup(IVariableProvider variables) {
ResourceLocation id = new ResourceLocation(variables.get("recipe").asString());
this.recipe = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PETAL_TYPE).get(id);
this.recipe = ModRecipeTypes.getRecipes(Minecraft.getInstance().world, ModRecipeTypes.PETAL_TYPE).get(id);
if (recipe == null) {
Botania.LOGGER.warn("Missing apothecary recipe " + id);
}
@@ -21,7 +21,7 @@ public class RunicAltarProcessor extends PetalApothecaryProcessor {
@Override
public void setup(IVariableProvider variables) {
ResourceLocation id = new ResourceLocation(variables.get("recipe").asString());
this.recipe = Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.RUNE_TYPE).get(id);
this.recipe = ModRecipeTypes.getRecipes(Minecraft.getInstance().world, ModRecipeTypes.RUNE_TYPE).get(id);
if (recipe == null) {
Botania.LOGGER.warn("Missing rune altar recipe " + id);
}
@@ -60,7 +60,7 @@ public abstract class RenderSparkBase<T extends EntitySparkBase> extends EntityR
ms.push();
ms.translate(-0.02F + (float) Math.sin(time / 20) * 0.2F, 0.24F + (float) Math.cos(time / 20) * 0.2F, 0.005F);
ms.scale(0.2F, 0.2F, 0.2F);
int starColor = tEntity.getNetwork().colorValue | ((int) (a * 255.0F) << 24);
int starColor = tEntity.getNetwork().getColorValue() | ((int) (a * 255.0F) << 24);
renderIcon(ms, buffer, MiscellaneousIcons.INSTANCE.corporeaIconStar, starColor);
ms.pop();
@@ -26,6 +26,7 @@ import net.minecraft.util.math.vector.Vector3f;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.common.block.tile.corporea.TileCorporeaCrystalCube;
import vazkii.botania.mixin.MixinItemEntity;
import javax.annotation.Nullable;
@@ -56,7 +57,7 @@ public class RenderTileCorporeaCrystalCube extends TileEntityRenderer<TileCorpor
};
}
entity.age = ClientTickHandler.ticksInGame;
((MixinItemEntity) entity).setAge(ClientTickHandler.ticksInGame);
stack = cube.getRequestTarget();
entity.setItem(stack);
}
@@ -23,6 +23,7 @@ import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.common.block.tile.TileEnchanter;
import vazkii.botania.mixin.MixinItemEntity;
import javax.annotation.Nonnull;
@@ -52,7 +53,7 @@ public class RenderTileEnchanter extends TileEntityRenderer<TileEnchanter> {
item = new ItemEntity(enchanter.getWorld(), enchanter.getPos().getX(), enchanter.getPos().getY() + 1, enchanter.getPos().getZ(), enchanter.itemToEnchant);
}
item.age = ClientTickHandler.ticksInGame;
((MixinItemEntity) item).setAge(ClientTickHandler.ticksInGame);
item.setItem(enchanter.itemToEnchant);
ms.translate(0.5F, 1.25F, 0.5F);
@@ -54,7 +54,7 @@ public class RenderTilePool extends TileEntityRenderer<TilePool> {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
time += new Random(pool.getPos().getX() ^ pool.getPos().getY() ^ pool.getPos().getZ()).nextInt(100000);
time *= 0.005F;
int color = vazkii.botania.common.core.helper.MathHelper.multiplyColor(MathHelper.hsvToRGB(time - (int) time, 0.6F, 1F), pool.color.colorValue);
int color = vazkii.botania.common.core.helper.MathHelper.multiplyColor(MathHelper.hsvToRGB(time - (int) time, 0.6F, 1F), pool.color.getColorValue());
int red = (color & 0xFF0000) >> 16;
int green = (color & 0xFF00) >> 8;
@@ -32,6 +32,7 @@ import org.lwjgl.opengl.GL11;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.mixin.MixinWorldRenderer;
import java.util.Random;
@@ -54,8 +55,8 @@ public class SkyblockSkyRenderer implements SkyRenderHandler {
@Override
public void render(int ticks, float partialTicks, MatrixStack matrixStackIn, ClientWorld world, Minecraft mc) {
// Environment setup
VertexBuffer skyVBO = mc.worldRenderer.skyVBO;
VertexFormat skyVertexFormat = mc.worldRenderer.skyVertexFormat;
VertexBuffer skyVBO = ((MixinWorldRenderer) mc.worldRenderer).getSkyVBO();
VertexFormat skyVertexFormat = ((MixinWorldRenderer) mc.worldRenderer).getSkyVertexFormat();
RenderSystem.disableTexture();
Vector3d Vector3d = world.getSkyColor(mc.gameRenderer.getActiveRenderInfo().getBlockPos(), partialTicks);
@@ -377,7 +378,7 @@ public class SkyblockSkyRenderer implements SkyRenderHandler {
}
private void renderStars(VertexFormat format, MatrixStack ms, Minecraft mc, float alpha, float partialTicks) {
net.minecraft.client.renderer.vertex.VertexBuffer starVBO = mc.worldRenderer.starVBO;
net.minecraft.client.renderer.vertex.VertexBuffer starVBO = ((MixinWorldRenderer) mc.worldRenderer).getStarVBO();
float t = (ClientTickHandler.ticksInGame + partialTicks + 2000) * 0.005F;
ms.push();
@@ -0,0 +1,19 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.common;
import org.spongepowered.asm.mixin.Mixins;
import org.spongepowered.asm.mixin.connect.IMixinConnector;
public class MixinConnector implements IMixinConnector {
@Override
public void connect() {
Mixins.addConfigurations("assets/botania/botania.mixins.json");
}
}
@@ -23,6 +23,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.mixin.MixinMobEntity;
public class BlockFelPumpkin extends BlockMod {
private static final ResourceLocation LOOT_TABLE = new ResourceLocation(LibMisc.MOD_ID, "fel_blaze");
@@ -48,7 +49,7 @@ public class BlockFelPumpkin extends BlockMod {
world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState());
BlazeEntity blaze = EntityType.BLAZE.create(world);
blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F);
blaze.deathLootTable = LOOT_TABLE;
((MixinMobEntity) blaze).setDeathLootTable(LOOT_TABLE);
blaze.onInitialSpawn(world, world.getDifficultyForLocation(pos), SpawnReason.EVENT, null, null);
world.addEntity(blaze);
}
@@ -55,7 +55,7 @@ public class BlockModDoubleFlower extends TallFlowerBlock {
@Override
@OnlyIn(Dist.CLIENT)
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
int hex = color.colorValue;
int hex = color.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -76,7 +76,7 @@ public class BlockModFlower extends FlowerBlock implements IGrowable {
@OnlyIn(Dist.CLIENT)
@Override
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
int hex = this.color.colorValue;
int hex = this.color.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -17,6 +17,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.server.ServerWorld;
import vazkii.botania.mixin.MixinFireBlock;
import javax.annotation.Nonnull;
import java.util.Random;
@@ -25,7 +27,7 @@ public class BlockSolidVines extends VineBlock {
public BlockSolidVines(Properties builder) {
super(builder);
((FireBlock) Blocks.FIRE).setFireInfo(this, 15, 100);
((MixinFireBlock) Blocks.FIRE).callSetFireInfo(this, 15, 100);
}
@Override
@@ -46,7 +46,7 @@ public class BlockBuriedPetals extends BushBlock implements IGrowable {
@OnlyIn(Dist.CLIENT)
@Override
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
int hex = color.colorValue;
int hex = color.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -66,7 +66,7 @@ public class BlockFloatingFlower extends BlockModWaterloggable implements ITileE
@OnlyIn(Dist.CLIENT)
@Override
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
int hex = color.colorValue;
int hex = color.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -66,7 +66,7 @@ public class BlockModMushroom extends MushroomBlock implements IHornHarvestable,
@OnlyIn(Dist.CLIENT)
@Override
public void animateTick(BlockState state, World world, BlockPos pos, Random rand) {
int hex = color.colorValue;
int hex = color.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -92,6 +92,6 @@ public class BlockModMushroom extends MushroomBlock implements IHornHarvestable,
@Override
public int getParticleColor(ItemStack stack) {
return color.colorValue;
return color.getColorValue();
}
}
@@ -119,7 +119,7 @@ public class SubTilePureDaisy extends TileEntitySpecialFlower {
private IPureDaisyRecipe findRecipe(BlockPos coords) {
BlockState state = getWorld().getBlockState(coords);
for (IRecipe<?> recipe : world.getRecipeManager().getRecipes(ModRecipeTypes.PURE_DAISY_TYPE).values()) {
for (IRecipe<?> recipe : ModRecipeTypes.getRecipes(world, ModRecipeTypes.PURE_DAISY_TYPE).values()) {
if (recipe instanceof IPureDaisyRecipe && ((IPureDaisyRecipe) recipe).matches(getWorld(), coords, this, state)) {
return ((IPureDaisyRecipe) recipe);
}
@@ -27,6 +27,7 @@ import vazkii.botania.client.fx.WispParticleData;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.common.network.PacketItemAge;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.List;
@@ -62,7 +63,7 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower {
List<ItemEntity> items = getWorld().getEntitiesWithinAABB(ItemEntity.class, axis);
int slowdown = getSlowdownFactor();
for (ItemEntity item : items) {
if (item.isAlive() && item.age >= slowdown) {
if (item.isAlive() && ((MixinItemEntity) item).getAge() >= slowdown) {
item.setMotion(
item.getMotion().getX() + orientation.getXOffset() * 0.05,
item.getMotion().getY() + orientation.getYOffset() * 0.05,
@@ -171,7 +172,7 @@ public class SubTileDaffomill extends TileEntityFunctionalFlower {
public static void onItemTrack(PlayerEvent.StartTracking evt) {
if (evt.getTarget() instanceof ItemEntity) {
int entityId = evt.getTarget().getEntityId();
int age = ((ItemEntity) evt.getTarget()).age;
int age = ((MixinItemEntity) evt.getTarget()).getAge();
PacketHandler.sendTo((ServerPlayerEntity) evt.getPlayer(), new PacketItemAge(entityId, age));
}
}
@@ -21,6 +21,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.mixin.MixinGoalSelector;
import java.util.List;
@@ -71,7 +72,7 @@ public class SubTileHeiseiDream extends TileEntityFunctionalFlower {
entity.setAttackTarget(null);
// Move any EntityAIHurtByTarget to highest priority
for (PrioritizedGoal entry : entity.targetSelector.goals) {
for (PrioritizedGoal entry : ((MixinGoalSelector) entity.targetSelector).getGoals()) {
if (entry.getGoal() instanceof HurtByTargetGoal) {
// Concurrent modification OK since we break out of the loop
entity.targetSelector.removeGoal(entry.getGoal());
@@ -37,6 +37,7 @@ import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.common.core.helper.InventoryHelper;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.ArrayList;
import java.util.List;
@@ -76,7 +77,8 @@ public class SubTileHopperhock extends TileEntityFunctionalFlower {
int slowdown = getSlowdownFactor();
for (ItemEntity item : items) {
if (item.age < 60 + slowdown || item.age >= 105 && item.age < 110 || !item.isAlive() || item.getItem().isEmpty()) {
int age = ((MixinItemEntity) item).getAge();
if (age < 60 + slowdown || age >= 105 && age < 110 || !item.isAlive() || item.getItem().isEmpty()) {
continue;
}
@@ -16,6 +16,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.List;
@@ -44,7 +45,8 @@ public class SubTilePollidisiac extends TileEntityFunctionalFlower {
if (animal.getGrowingAge() == 0 && !animal.isInLove()) {
for (ItemEntity item : items) {
if (item.age < 60 + slowdown || !item.isAlive()) {
int age = ((MixinItemEntity) item).getAge();
if (age < 60 + slowdown || !item.isAlive()) {
continue;
}
@@ -36,6 +36,7 @@ import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.mixin.MixinItemEntity;
import javax.annotation.Nonnull;
@@ -77,7 +78,8 @@ public class SubTileRannuncarpus extends TileEntityFunctionalFlower {
int slowdown = getSlowdownFactor();
for (ItemEntity item : items) {
if (item.age < 60 + slowdown || !item.isAlive() || item.getItem().isEmpty()) {
int age = ((MixinItemEntity) item).getAge();
if (age < 60 + slowdown || !item.isAlive() || item.getItem().isEmpty()) {
continue;
}
@@ -28,6 +28,7 @@ import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.List;
@@ -61,7 +62,8 @@ public class SubTileSpectranthemum extends TileEntityFunctionalFlower {
int slowdown = getSlowdownFactor();
for (ItemEntity item : items) {
if (item.age < 60 + slowdown || !item.isAlive() || item.getPersistentData().getBoolean(TAG_TELEPORTED)) {
int age = ((MixinItemEntity) item).getAge();
if (age < 60 + slowdown || !item.isAlive() || item.getPersistentData().getBoolean(TAG_TELEPORTED)) {
continue;
}
@@ -21,6 +21,10 @@ import net.minecraft.util.math.AxisAlignedBB;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityFunctionalFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.mixin.MixinAvoidEntityGoal;
import vazkii.botania.mixin.MixinCreeperEntity;
import vazkii.botania.mixin.MixinGoalSelector;
import vazkii.botania.mixin.MixinNearestAttackableTarget;
import java.util.ArrayList;
import java.util.List;
@@ -48,8 +52,8 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
List<MobEntity> entities = getWorld().getEntitiesWithinAABB(MobEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE_Y, -RANGE), getEffectivePos().add(RANGE + 1, RANGE_Y + 1, RANGE + 1)));
for (MobEntity entity : entities) {
List<PrioritizedGoal> entries = new ArrayList<>(entity.goalSelector.goals);
entries.addAll(entity.targetSelector.goals);
List<PrioritizedGoal> entries = new ArrayList<>(((MixinGoalSelector) entity.goalSelector).getGoals());
entries.addAll(((MixinGoalSelector) entity.targetSelector).getGoals());
boolean avoidsOcelots = false;
if (shouldAfffect) {
@@ -65,7 +69,7 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
}
if (entity instanceof CreeperEntity) {
((CreeperEntity) entity).timeSinceIgnited = 2;
((MixinCreeperEntity) entity).setTimeSinceIgnited(2);
entity.setAttackTarget(null);
}
@@ -80,8 +84,9 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
// TODO replace this kludge
@SuppressWarnings({ "unchecked", "rawtypes" })
private boolean messWithRunAwayAI(AvoidEntityGoal aiEntry) {
if (aiEntry.classToAvoid == OcelotEntity.class) {
aiEntry.classToAvoid = PlayerEntity.class;
MixinAvoidEntityGoal mEntry = (MixinAvoidEntityGoal) aiEntry;
if (mEntry.getClassToAvoid() == OcelotEntity.class) {
mEntry.setClassToAvoid(PlayerEntity.class);
return true;
}
return false;
@@ -89,8 +94,9 @@ public class SubTileTigerseye extends TileEntityFunctionalFlower {
@SuppressWarnings({ "unchecked", "rawtypes" })
private void messWithGetTargetAI(NearestAttackableTargetGoal aiEntry) {
if (aiEntry.targetClass == PlayerEntity.class) {
aiEntry.targetClass = EnderCrystalEntity.class; // Something random that won't be around
MixinNearestAttackableTarget mEntry = (MixinNearestAttackableTarget) aiEntry;
if (mEntry.getTargetClass() == PlayerEntity.class) {
mEntry.setTargetClass(EnderCrystalEntity.class); // Something random that won't be around
}
}
@@ -24,6 +24,7 @@ import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.common.block.mana.BlockSpreader;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.mixin.MixinItemEntity;
public class SubTileEndoflame extends TileEntityGeneratingFlower {
private static final String TAG_BURN_TIME = "burnTime";
@@ -59,7 +60,8 @@ public class SubTileEndoflame extends TileEntityGeneratingFlower {
int slowdown = getSlowdownFactor();
for (ItemEntity item : getWorld().getEntitiesWithinAABB(ItemEntity.class, new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1)))) {
if (item.age >= 59 + slowdown && !item.removed) {
int age = ((MixinItemEntity) item).getAge();
if (age >= 59 + slowdown && item.isAlive()) {
ItemStack stack = item.getItem();
if (stack.isEmpty() || stack.getItem().hasContainerItem(stack)) {
continue;
@@ -24,6 +24,7 @@ import net.minecraftforge.common.util.Constants;
import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.LinkedList;
import java.util.List;
@@ -123,7 +124,8 @@ public class SubTileGourmaryllis extends TileEntityGeneratingFlower {
for (ItemEntity item : items) {
ItemStack stack = item.getItem();
if (!stack.isEmpty() && stack.getItem().isFood() && !item.removed && item.age >= slowdown) {
int age = ((MixinItemEntity) item).getAge();
if (!stack.isEmpty() && stack.getItem().isFood() && item.isAlive() && age >= slowdown) {
if (cooldown <= 0) {
streakLength = Math.min(streakLength + 1, processFood(stack));
@@ -34,6 +34,7 @@ import vazkii.botania.api.subtile.RadiusDescriptor;
import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
import vazkii.botania.common.block.ModSubtiles;
import vazkii.botania.common.core.helper.ColorHelper;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.List;
import java.util.function.Predicate;
@@ -65,7 +66,7 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower {
AxisAlignedBB itemAABB = new AxisAlignedBB(getEffectivePos().add(-RANGE, -RANGE, -RANGE), getEffectivePos().add(RANGE + 1, RANGE + 1, RANGE + 1));
int slowdown = getSlowdownFactor();
Predicate<Entity> selector = e -> (e instanceof ItemEntity && e.isAlive() && ((ItemEntity) e).age >= slowdown);
Predicate<Entity> selector = e -> (e instanceof ItemEntity && e.isAlive() && ((MixinItemEntity) e).getAge() >= slowdown);
targets.addAll(getWorld().getEntitiesWithinAABB(Entity.class, itemAABB, selector));
for (Entity target : targets) {
@@ -24,6 +24,7 @@ import net.minecraft.util.Rotation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import vazkii.botania.api.recipe.ElvenPortalUpdateEvent;
@@ -167,7 +168,7 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
private boolean validateItemUsage(ItemEntity entity) {
ItemStack inputStack = entity.getItem();
for (IRecipe<?> recipe : world.getRecipeManager().getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values()) {
for (IRecipe<?> recipe : ModRecipeTypes.getRecipes(world, ModRecipeTypes.ELVEN_TRADE_TYPE).values()) {
if (recipe instanceof IElvenTradeRecipe && ((IElvenTradeRecipe) recipe).containsItem(inputStack)) {
return true;
}
@@ -263,16 +264,16 @@ public class TileAlfPortal extends TileMod implements ITickableTileEntity {
}
@SuppressWarnings("unchecked")
public static Collection<IElvenTradeRecipe> elvenTradeRecipes(RecipeManager rm) {
public static Collection<IElvenTradeRecipe> elvenTradeRecipes(World world) {
// By virtue of IRecipeType's type parameter,
// we know all the recipes in the map must be AbstractElvenTradeRecipe.
// we know all the recipes in the map must be IElvenTradeRecipe.
// However, vanilla's signature on this method is dumb (should be Map<ResourceLocation, T>)
return (Collection<IElvenTradeRecipe>) (Collection<?>) rm.getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values();
return (Collection<IElvenTradeRecipe>) (Collection<?>) ModRecipeTypes.getRecipes(world, ModRecipeTypes.ELVEN_TRADE_TYPE).values();
}
private void resolveRecipes() {
List<BlockPos> pylons = locatePylons();
for (IRecipe<?> r : world.getRecipeManager().getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values()) {
for (IRecipe<?> r : ModRecipeTypes.getRecipes(world, ModRecipeTypes.ELVEN_TRADE_TYPE).values()) {
if (!(r instanceof IElvenTradeRecipe)) {
continue;
}
@@ -20,6 +20,8 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.world.World;
import vazkii.botania.mixin.MixinItemEntity;
public class TileOpenCrate extends TileExposedSimpleInventory implements ITickableTileEntity {
public TileOpenCrate() {
this(ModTiles.OPEN_CRATE);
@@ -71,7 +73,7 @@ public class TileOpenCrate extends TileExposedSimpleInventory implements ITickab
ItemEntity item = new ItemEntity(world, pos.getX() + 0.5, pos.getY() - 0.5, pos.getZ() + 0.5, stack);
item.setMotion(Vector3d.ZERO);
if (redstone) {
item.age = -200;
((MixinItemEntity) item).setAge(-200);
}
getItemHandler().setInventorySlotContents(0, ItemStack.EMPTY);
@@ -82,7 +82,7 @@ public class TilePylon extends TileEntity implements ITickableTileEntity {
Block block = world.getBlockState(pos.down()).getBlock();
if (block instanceof BlockModFlower) {
int hex = ((BlockModFlower) block).color.colorValue;
int hex = ((BlockModFlower) block).color.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -21,6 +21,7 @@ import net.minecraft.world.spawner.AbstractSpawner;
import vazkii.botania.api.mana.IManaReceiver;
import vazkii.botania.client.fx.WispParticleData;
import vazkii.botania.mixin.MixinAbstractSpawner;
import java.util.Optional;
@@ -39,10 +40,12 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
if (mana >= 5 && tileBelow instanceof MobSpawnerTileEntity) {
MobSpawnerTileEntity spawner = (MobSpawnerTileEntity) tileBelow;
AbstractSpawner logic = spawner.getSpawnerBaseLogic();
MixinAbstractSpawner mLogic = (MixinAbstractSpawner) logic;
// [VanillaCopy] AbstractSpawner.tick, edits noted
if (!logic.isActivated()) {
logic.prevMobRotation = logic.mobRotation;
// todo 1.16 investigate instead mixing into AbstractSpawner instead of duplicating logic here
if (!mLogic.callIsActivated()) {
mLogic.setPrevMobRotation(mLogic.getMobRotation());
} else {
World world = this.getWorld();
BlockPos blockpos = logic.getSpawnerPosition();
@@ -52,53 +55,53 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, 0.6F - (float) Math.random() * 0.3F, 0.1F, 0.6F - (float) Math.random() * 0.3F, 2F);
world.addParticle(data, getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() - 0.3 + Math.random() * 0.25, getPos().getZ() + Math.random(), 0, -(-0.025F - 0.005F * (float) Math.random()), 0);
}
if (logic.spawnDelay > 0) {
--logic.spawnDelay;
if (mLogic.getSpawnDelay() > 0) {
mLogic.setSpawnDelay(mLogic.getSpawnDelay() - 1);
}
logic.prevMobRotation = logic.mobRotation;
logic.mobRotation = (logic.mobRotation + (double) (1000.0F / ((float) logic.spawnDelay + 200.0F))) % 360.0D;
mLogic.setPrevMobRotation(mLogic.getMobRotation());
mLogic.setMobRotation((mLogic.getMobRotation() + (double) (1000.0F / ((float) mLogic.getSpawnDelay() + 200.0F))) % 360.0D);
} else {
// Botania - consume mana
this.mana -= 6;
if (logic.spawnDelay == -1) {
logic.resetTimer();
if (mLogic.getSpawnDelay() == -1) {
mLogic.callResetTimer();
}
if (logic.spawnDelay > 0) {
--logic.spawnDelay;
if (mLogic.getSpawnDelay() > 0) {
mLogic.setSpawnDelay(mLogic.getSpawnDelay() - 1);
return;
}
boolean flag = false;
for (int i = 0; i < logic.spawnCount; ++i) {
CompoundNBT compoundnbt = logic.spawnData.getNbt();
for (int i = 0; i < mLogic.getSpawnCount(); ++i) {
CompoundNBT compoundnbt = mLogic.getSpawnData().getNbt();
Optional<EntityType<?>> optional = EntityType.readEntityType(compoundnbt);
if (!optional.isPresent()) {
logic.resetTimer();
mLogic.callResetTimer();
return;
}
ListNBT listnbt = compoundnbt.getList("Pos", 6);
int j = listnbt.size();
double d0 = j >= 1 ? listnbt.getDouble(0) : (double) blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D;
double d0 = j >= 1 ? listnbt.getDouble(0) : (double) blockpos.getX() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) mLogic.getSpawnRange() + 0.5D;
double d1 = j >= 2 ? listnbt.getDouble(1) : (double) (blockpos.getY() + world.rand.nextInt(3) - 1);
double d2 = j >= 3 ? listnbt.getDouble(2) : (double) blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) logic.spawnRange + 0.5D;
double d2 = j >= 3 ? listnbt.getDouble(2) : (double) blockpos.getZ() + (world.rand.nextDouble() - world.rand.nextDouble()) * (double) mLogic.getSpawnRange() + 0.5D;
if (world.hasNoCollisions(optional.get().func_220328_a(d0, d1, d2))) {
Entity entity = EntityType.func_220335_a(compoundnbt, world, (p_221408_6_) -> {
p_221408_6_.setLocationAndAngles(d0, d1, d2, p_221408_6_.rotationYaw, p_221408_6_.rotationPitch);
return p_221408_6_;
});
if (entity == null) {
logic.resetTimer();
mLogic.callResetTimer();
return;
}
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) logic.spawnRange)).size();
if (k >= logic.maxNearbyEntities) {
logic.resetTimer();
int k = world.getEntitiesWithinAABB(entity.getClass(), (new AxisAlignedBB((double) blockpos.getX(), (double) blockpos.getY(), (double) blockpos.getZ(), (double) (blockpos.getX() + 1), (double) (blockpos.getY() + 1), (double) (blockpos.getZ() + 1))).grow((double) mLogic.getSpawnRange())).size();
if (k >= mLogic.getMaxNearbyEntities()) {
mLogic.callResetTimer();
return;
}
@@ -109,12 +112,14 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
continue;
}
if (logic.spawnData.getNbt().size() == 1 && logic.spawnData.getNbt().contains("id", 8)) {
((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(entity.func_233580_cy_()), SpawnReason.SPAWNER, (ILivingEntityData) null, (CompoundNBT) null);
if (mLogic.getSpawnData().getNbt().size() == 1 && mLogic.getSpawnData().getNbt().contains("id", 8)) {
if (!net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(mobentity, world, (float) entity.getPosX(), (float) entity.getPosY(), (float) entity.getPosZ(), logic, SpawnReason.SPAWNER)) {
((MobEntity) entity).onInitialSpawn(world, world.getDifficultyForLocation(entity.func_233580_cy_()), SpawnReason.SPAWNER, (ILivingEntityData) null, (CompoundNBT) null);
}
}
}
func_221409_a(entity);
mLogic.callSpawnEntity(entity);
world.playEvent(2004, blockpos, 0);
if (entity instanceof MobEntity) {
((MobEntity) entity).spawnExplosionParticle();
@@ -125,23 +130,13 @@ public class TileSpawnerClaw extends TileMod implements IManaReceiver, ITickable
}
if (flag) {
logic.resetTimer();
mLogic.callResetTimer();
}
}
}
}
}
// [VanillaCopy] AbstractSpawner
private void func_221409_a(Entity p_221409_1_) {
if (this.getWorld().addEntity(p_221409_1_)) {
for (Entity entity : p_221409_1_.getPassengers()) {
this.func_221409_a(entity);
}
}
}
@Override
public void writePacketNBT(CompoundNBT cmp) {
cmp.putInt(TAG_MANA, mana);
@@ -29,6 +29,7 @@ import vazkii.botania.common.block.tile.ModTiles;
import vazkii.botania.common.block.tile.TileMod;
import vazkii.botania.common.core.handler.ExoflameFurnaceHandler;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.mixin.MixinAbstractFurnaceTileEntity;
import javax.annotation.Nullable;
@@ -81,8 +82,9 @@ public class TileBellows extends TileMod implements ITickableTileEntity {
AbstractCookingRecipe recipe = p.getFirst();
boolean canSmelt = p.getSecond();
if (canSmelt) {
furnace.cookTime = Math.min(recipe.getCookTime() - 1, furnace.cookTime + 20);
furnace.burnTime = Math.max(0, furnace.burnTime - 10);
MixinAbstractFurnaceTileEntity mFurnace = (MixinAbstractFurnaceTileEntity) furnace;
mFurnace.setCookTime(Math.min(recipe.getCookTime() - 1, mFurnace.getCookTime() + 20));
mFurnace.setBurnTime(Math.max(0, mFurnace.getBurnTime() - 10));
}
if (furnace instanceof FurnaceTileEntity
@@ -150,21 +152,11 @@ public class TileBellows extends TileMod implements ITickableTileEntity {
}
}
@Nullable
@SuppressWarnings("unchecked")
public static Pair<AbstractCookingRecipe, Boolean> canSmelt(AbstractFurnaceTileEntity furnace) {
IRecipeType<AbstractCookingRecipe> rt;
AbstractCookingRecipe recipe;
boolean canSmelt;
try {
rt = (IRecipeType<AbstractCookingRecipe>) ExoflameFurnaceHandler.getRecipeType(furnace);
recipe = furnace.getWorld().getRecipeManager().getRecipe(rt, furnace, furnace.getWorld()).orElse(null);
canSmelt = ExoflameFurnaceHandler.canSmelt(furnace, recipe);
return Pair.of(recipe, canSmelt);
} catch (Throwable e) {
Botania.LOGGER.error("Failed to reflect furnace", e);
return null;
}
IRecipeType<? extends AbstractCookingRecipe> rt = ExoflameFurnaceHandler.getRecipeType(furnace);
AbstractCookingRecipe recipe = furnace.getWorld().getRecipeManager().getRecipe(rt, furnace, furnace.getWorld()).orElse(null);
boolean canSmelt = ExoflameFurnaceHandler.canSmelt(furnace, recipe);
return Pair.of(recipe, canSmelt);
}
}
@@ -27,6 +27,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -55,6 +56,7 @@ import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.crafting.ModRecipeTypes;
import vazkii.botania.common.item.ItemManaTablet;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.mixin.MixinItemEntity;
import javax.annotation.Nonnull;
@@ -138,8 +140,8 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
return val;
}
public static List<IManaInfusionRecipe> manaInfusionRecipes(RecipeManager rm) {
return rm.getRecipes(ModRecipeTypes.MANA_INFUSION_TYPE).values().stream()
public static List<IManaInfusionRecipe> manaInfusionRecipes(World world) {
return ModRecipeTypes.getRecipes(world, ModRecipeTypes.MANA_INFUSION_TYPE).values().stream()
.filter(r -> r instanceof IManaInfusionRecipe)
.map(r -> (IManaInfusionRecipe) r)
.collect(Collectors.toList());
@@ -149,7 +151,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
List<IManaInfusionRecipe> matchingNonCatRecipes = new ArrayList<>();
List<IManaInfusionRecipe> matchingCatRecipes = new ArrayList<>();
for (IManaInfusionRecipe recipe : manaInfusionRecipes(world.getRecipeManager())) {
for (IManaInfusionRecipe recipe : manaInfusionRecipes(world)) {
if (recipe.matches(stack)) {
if (recipe.getCatalyst() == null) {
matchingNonCatRecipes.add(recipe);
@@ -174,7 +176,8 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
((IManaDissolvable) stack.getItem()).onDissolveTick(this, stack, item);
}
if (item.age > 100 && item.age < 130) {
int age = ((MixinItemEntity) item).getAge();
if (age > 100 && age < 130) {
return false;
}
@@ -190,7 +193,7 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
ItemStack output = recipe.getRecipeOutput().copy();
ItemEntity outputItem = new ItemEntity(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, output);
outputItem.age = 105;
((MixinItemEntity) outputItem).setAge(105);
world.addEntity(outputItem);
craftingFanciness();
@@ -49,6 +49,7 @@ import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.entity.EntityManaBurst;
import vazkii.botania.common.entity.EntityManaBurst.PositionProperties;
import vazkii.botania.common.item.ItemLexicon;
import javax.annotation.Nullable;
@@ -386,7 +387,7 @@ public class TileSpreader extends TileExposedSimpleInventory implements IManaCol
if (!player.isSneaking()) {
VanillaPacketDispatcher.dispatchTEToNearbyPlayers(this);
} else {
BlockRayTraceResult bpos = Item.rayTrace(world, player, RayTraceContext.FluidMode.ANY);
BlockRayTraceResult bpos = ItemLexicon.doRayTrace(world, player, RayTraceContext.FluidMode.NONE);
if (!world.isRemote) {
double x = bpos.getHitVec().x - getPos().getX() - 0.5;
double y = bpos.getHitVec().y - getPos().getY() - 0.5;
@@ -20,9 +20,8 @@ import net.minecraftforge.registries.RegistryBuilder;
import vazkii.botania.api.brew.Brew;
import vazkii.botania.common.lib.LibBrewNames;
import vazkii.botania.common.lib.LibObfuscation;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.Method;
import java.util.Arrays;
import static vazkii.botania.common.block.ModBlocks.register;
@@ -58,10 +57,11 @@ public class ModBrews {
public static void registerRegistry(RegistryEvent.NewRegistry evt) {
// Some sneaky hacks to get Forge to create the registry with a vanilla wrapper attached
MethodHandle makeBuilder = LibObfuscation.getMethod(GameData.class, "makeRegistry", ResourceLocation.class, Class.class, ResourceLocation.class);
try {
Method makeBuilder = GameData.class.getDeclaredMethod("makeRegistry", ResourceLocation.class, Class.class, ResourceLocation.class);
makeBuilder.setAccessible(true);
@SuppressWarnings("unchecked")
RegistryBuilder<Brew> builder = (RegistryBuilder<Brew>) makeBuilder.invokeExact(prefix("brews"), Brew.class, prefix("fallback"));
RegistryBuilder<Brew> builder = (RegistryBuilder<Brew>) makeBuilder.invoke(null, prefix("brews"), Brew.class, prefix("fallback"));
builder.disableSaving().create();
// grab the vanilla wrapper for use
registry = GameData.getWrapperDefaulted(Brew.class);
@@ -13,6 +13,7 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.AbstractFurnaceTileEntity;
import net.minecraft.tileentity.SmokerTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
@@ -25,9 +26,7 @@ import vazkii.botania.api.item.IExoflameHeatable;
import vazkii.botania.common.Botania;
import vazkii.botania.common.capability.SimpleCapProvider;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.lib.LibObfuscation;
import java.lang.invoke.MethodHandle;
import vazkii.botania.mixin.MixinAbstractFurnaceTileEntity;
public class ExoflameFurnaceHandler {
@@ -35,9 +34,6 @@ public class ExoflameFurnaceHandler {
public static Capability<IExoflameHeatable> CAPABILITY;
public static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "exoflame_heatable");
private static final MethodHandle CAN_SMELT = LibObfuscation.getMethod(AbstractFurnaceTileEntity.class, "func_214008_b", IRecipe.class);
private static final MethodHandle RECIPE_TYPE = LibObfuscation.getGetter(AbstractFurnaceTileEntity.class, "field_214014_c");
public static void attachFurnaceCapability(AttachCapabilitiesEvent<TileEntity> event) {
TileEntity te = event.getObject();
if (te instanceof AbstractFurnaceTileEntity) {
@@ -46,13 +42,12 @@ public class ExoflameFurnaceHandler {
}
}
public static boolean canSmelt(AbstractFurnaceTileEntity furnace, IRecipe<?> recipe) throws Throwable {
return (boolean) CAN_SMELT.invokeExact(furnace, recipe);
public static boolean canSmelt(AbstractFurnaceTileEntity furnace, IRecipe<?> recipe) {
return ((MixinAbstractFurnaceTileEntity) furnace).invokeCanSmelt(recipe);
}
@SuppressWarnings("unchecked")
public static IRecipeType<? extends AbstractCookingRecipe> getRecipeType(AbstractFurnaceTileEntity furnace) throws Throwable {
return (IRecipeType<? extends AbstractCookingRecipe>) RECIPE_TYPE.invokeExact(furnace);
public static IRecipeType<? extends AbstractCookingRecipe> getRecipeType(AbstractFurnaceTileEntity furnace) {
return ((MixinAbstractFurnaceTileEntity) furnace).getRecipeType();
}
private static class FurnaceExoflameHeatable implements IExoflameHeatable {
@@ -90,7 +85,7 @@ public class ExoflameFurnaceHandler {
@Override
public int getBurnTime() {
return furnace.burnTime;
return ((MixinAbstractFurnaceTileEntity) furnace).getBurnTime();
}
@Override
@@ -100,12 +95,14 @@ public class ExoflameFurnaceHandler {
BlockPos pos = furnace.getPos();
world.setBlockState(pos, world.getBlockState(pos).with(BlockStateProperties.LIT, true));
}
furnace.burnTime += 200;
int burnTime = ((MixinAbstractFurnaceTileEntity) furnace).getBurnTime();
((MixinAbstractFurnaceTileEntity) furnace).setBurnTime(burnTime + 200);
}
@Override
public void boostCookTime() {
furnace.cookTime = Math.min(currentRecipe.getCookTime() - 1, furnace.cookTime + 1);
int cookTime = ((MixinAbstractFurnaceTileEntity) furnace).getCookTime();
((MixinAbstractFurnaceTileEntity) furnace).setCookTime(Math.min(currentRecipe.getCookTime() - 1, cookTime + 1));
}
}
}
@@ -8,16 +8,21 @@
*/
package vazkii.botania.common.crafting;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.SpecialRecipeSerializer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import net.minecraftforge.event.RegistryEvent;
import vazkii.botania.api.recipe.*;
import vazkii.botania.common.crafting.recipe.HeadRecipe;
import vazkii.botania.mixin.MixinRecipeManager;
import java.util.Map;
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
@@ -76,4 +81,8 @@ public class ModRecipeTypes {
return Registry.RECIPE_TYPE.getKey(this).toString();
}
}
public static <C extends IInventory, T extends IRecipe<C>> Map<ResourceLocation, IRecipe<C>> getRecipes(World world, IRecipeType<T> type) {
return ((MixinRecipeManager) world.getRecipeManager()).callGetRecipes(type);
}
}
@@ -23,17 +23,24 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import vazkii.botania.mixin.MixinGoalSelector;
import javax.annotation.Nonnull;
public class EntityPinkWither extends WitherEntity {
public EntityPinkWither(EntityType<EntityPinkWither> type, World world) {
super(type, world);
}
@Override
protected void registerGoals() {
super.registerGoals();
// Remove firing wither skulls
goalSelector.goals.removeIf(entry -> entry.getGoal() instanceof RangedAttackGoal);
((MixinGoalSelector) goalSelector).getGoals().removeIf(entry -> entry.getGoal() instanceof RangedAttackGoal);
// Remove revenge and aggro
targetSelector.goals.removeIf(entry -> entry.getGoal() instanceof HurtByTargetGoal
((MixinGoalSelector) targetSelector).getGoals().removeIf(entry -> entry.getGoal() instanceof HurtByTargetGoal
|| entry.getGoal() instanceof NearestAttackableTargetGoal);
}
@@ -59,7 +59,7 @@ public class EntitySignalFlare extends Entity {
int color = getColor();
if (color < 16 && color >= 0) {
int hex = DyeColor.byId(color).colorValue;
int hex = DyeColor.byId(color).getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -21,6 +21,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.mixin.MixinItemEntity;
import javax.annotation.Nonnull;
@@ -35,7 +36,7 @@ public class EntityThrownItem extends ItemEntity {
public EntityThrownItem(World world, double x,
double y, double z, ItemEntity item) {
super(world, x, y, z, item.getItem());
setPickupDelay(item.pickupDelay);
setPickupDelay(((MixinItemEntity) item).getPickupDelay());
setMotion(item.getMotion());
setInvulnerable(true);
}
@@ -65,6 +66,7 @@ public class EntityThrownItem extends ItemEntity {
Entity entity = null;
List<Entity> list = world.getEntitiesWithinAABBExcludingEntity(this, getBoundingBox().offset(getMotion().scale(2)).grow(2));
double d0 = 0.0D;
int pickupDelay = ((MixinItemEntity) this).getPickupDelay();
for (Entity entity1 : list) {
if (entity1.canBeCollidedWith() && (!(entity1 instanceof PlayerEntity) || pickupDelay == 0)) {
@@ -29,24 +29,21 @@ import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.TileCacophonium;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.mixin.MixinMobEntity;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.lang.invoke.MethodHandle;
import java.util.List;
public class ItemCacophonium extends Item {
private static final String TAG_SOUND = "sound";
private static final String TAG_SOUND_NAME = "soundName";
private static final MethodHandle GET_AMBIENT_SOUND = LibObfuscation.getMethod(MobEntity.class, LibObfuscation.GET_LIVING_SOUND);
public ItemCacophonium(Properties props) {
super(props);
@@ -63,11 +60,7 @@ public class ItemCacophonium extends Item {
} else if (living instanceof SlimeEntity) {
sound = ((SlimeEntity) living).isSmallSlime() ? SoundEvents.ENTITY_SLIME_SQUISH_SMALL : SoundEvents.ENTITY_SLIME_SQUISH;
} else {
try {
sound = (SoundEvent) GET_AMBIENT_SOUND.invokeExact(living);
} catch (Throwable ex) {
Botania.LOGGER.debug("Couldn't get living sound", ex);
}
sound = ((MixinMobEntity) living).callGetAmbientSound();
}
if (sound != null) {
@@ -61,6 +61,7 @@ import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.crafting.ModRecipeTypes;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
@@ -268,7 +269,7 @@ public class ItemCraftingHalo extends Item {
if (position <= 0 || position >= SEGMENTS || id == null) {
return null;
} else {
return world.getRecipeManager().getRecipes(IRecipeType.CRAFTING).get(id);
return ModRecipeTypes.getRecipes(world, IRecipeType.CRAFTING).get(id);
}
}
@@ -323,7 +324,7 @@ public class ItemCraftingHalo extends Item {
String savedId = ItemNBTHelper.getString(halo, TAG_LAST_CRAFTING, "");
ResourceLocation id = savedId.isEmpty() ? null : ResourceLocation.tryCreate(savedId);
return world.getRecipeManager().getRecipes(IRecipeType.CRAFTING).get(id);
return ModRecipeTypes.getRecipes(world, IRecipeType.CRAFTING).get(id);
}
private static boolean wasEquipped(ItemStack stack) {
@@ -18,6 +18,8 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -102,4 +104,9 @@ public class ItemLexicon extends Item implements IElvenItem {
public boolean isElvenItem(ItemStack stack) {
return stack.hasTag() && stack.getTag().getBoolean(TAG_ELVEN_UNLOCK);
}
// Random item to expose this as public
public static BlockRayTraceResult doRayTrace(World world, PlayerEntity player, RayTraceContext.FluidMode fluidMode) {
return Item.rayTrace(world, player, fluidMode);
}
}
@@ -41,6 +41,7 @@ import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.mixin.MixinCreeperEntity;
import java.util.List;
@@ -74,7 +75,7 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem {
target.heal(target.getMaxHealth());
target.revive();
if (target instanceof CreeperEntity) {
((CreeperEntity) event.getEntityLiving()).timeSinceIgnited = 2;
((MixinCreeperEntity) event.getEntityLiving()).setTimeSinceIgnited(2);
}
ManaItemHandler.instance().requestManaExact(amulet, player, cost, true);
@@ -26,6 +26,7 @@ import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.core.helper.MathHelper;
import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.lib.ModTags;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.List;
@@ -102,7 +103,8 @@ public class ItemMagnetRing extends ItemBauble {
}
private boolean canPullItem(ItemEntity item) {
if (!item.isAlive() || item.pickupDelay >= 40 || BotaniaAPI.instance().hasSolegnoliaAround(item) || item.getPersistentData().getBoolean("PreventRemoteMovement")) {
int pickupDelay = ((MixinItemEntity) item).getPickupDelay();
if (!item.isAlive() || pickupDelay >= 40 || BotaniaAPI.instance().hasSolegnoliaAround(item) || item.getPersistentData().getBoolean("PreventRemoteMovement")) {
return false;
}
@@ -22,23 +22,20 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.UseHoeEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.item.ISortableTool;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.common.lib.LibObfuscation;
import vazkii.botania.mixin.MixinHoeItem;
import javax.annotation.Nonnull;
import java.util.Map;
import java.util.function.Consumer;
public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, ISortableTool {
protected static final Map<Block, BlockState> HOE_LOOKUP = ObfuscationReflectionHelper.getPrivateValue(HoeItem.class, null, LibObfuscation.HOE_LOOKUP);
private static final int MANA_PER_DAMAGE = 60;
public ItemManasteelShovel(Properties props) {
@@ -91,7 +88,7 @@ public class ItemManasteelShovel extends ShovelItem implements IManaUsingItem, I
}
Block block = world.getBlockState(pos).getBlock();
BlockState converted = HOE_LOOKUP.get(block);
BlockState converted = MixinHoeItem.getConversions().get(block);
if (converted == null) {
return ActionResultType.PASS;
}
@@ -134,7 +134,7 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I
return MathHelper.hsvToRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F);
}
return DyeColor.byId(storedColor).colorValue;
return DyeColor.byId(storedColor).getColorValue();
}
public static int getStoredColor(ItemStack stack) {
@@ -52,7 +52,7 @@ public class LensFlare extends Lens {
if (storedColor == 16) {
hex = MathHelper.hsvToRGB(tile.getWorld().getGameTime() * 2 % 360 / 360F, 1F, 1F);
} else if (storedColor >= 0) {
hex = DyeColor.byId(storedColor).colorValue;
hex = DyeColor.byId(storedColor).getColorValue();
}
float r = ((hex & 0xFF0000) >> 16) / 255F;
@@ -34,6 +34,6 @@ public class ItemPetal extends BlockItem implements ICustomApothecaryColor {
@Override
public int getParticleColor(ItemStack stack) {
return color.colorValue;
return color.getColorValue();
}
}
@@ -20,6 +20,7 @@ import net.minecraft.world.World;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.mixin.MixinLivingEntity;
import javax.annotation.Nonnull;
@@ -66,7 +67,7 @@ public class ItemInfiniteFruit extends ItemRelic implements IManaUsingItem {
if (count == 5) {
if (player.canEat(false)) {
player.activeItemStackUseCount = 20;
((MixinLivingEntity) player).setActiveItemStackUseCount(20);
}
}
}
@@ -1,50 +0,0 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.common.lib;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import cpw.mods.modlauncher.api.INameMappingService;
public final class LibObfuscation {
// EntityLiving
public static final String GET_LIVING_SOUND = "func_184639_G";
// RecipeBookGui
public static final String RECIPE_BOOK_PAGE = "field_193022_s";
// RecipeBookPage
public static final String HOVERED_BUTTON = "field_194201_b";
// HoeItem
public static final String HOE_LOOKUP = "field_195973_b";
public static MethodHandle getGetter(Class<?> clazz, String srg) {
try {
// From ObfuscationReflectionHelper.findField, because it has weird generics that fail when called alone
Field f = clazz.getDeclaredField(ObfuscationReflectionHelper.remapName(INameMappingService.Domain.FIELD, srg));
f.setAccessible(true);
return MethodHandles.publicLookup().unreflectGetter(f);
} catch (IllegalAccessException | NoSuchFieldException e) {
throw new IllegalStateException("Can't find " + srg, e);
}
}
public static MethodHandle getMethod(Class<?> clazz, String srg, Class<?>... paramTypes) {
try {
return MethodHandles.publicLookup().unreflect(ObfuscationReflectionHelper.findMethod(clazz, srg, paramTypes));
} catch (IllegalAccessException e) {
throw new IllegalStateException("Can't find " + srg, e);
}
}
}
@@ -87,7 +87,7 @@ public class PacketBotaniaEffect {
switch (message.type) {
case PAINT_LENS: {
DyeColor placeColor = DyeColor.byId(message.args[0]);
int hex = placeColor.colorValue;
int hex = placeColor.getColorValue();
int r = (hex & 0xFF0000) >> 16;
int g = (hex & 0xFF00) >> 8;
int b = hex & 0xFF;
@@ -14,6 +14,8 @@ import net.minecraft.entity.item.ItemEntity;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.network.NetworkEvent;
import vazkii.botania.mixin.MixinItemEntity;
import java.util.function.Supplier;
public class PacketItemAge {
@@ -39,7 +41,7 @@ public class PacketItemAge {
ctx.get().enqueueWork(() -> {
Entity e = Minecraft.getInstance().world.getEntityByID(message.entityId);
if (e instanceof ItemEntity) {
((ItemEntity) e).age = message.age;
((MixinItemEntity) e).setAge(message.age);
}
});
}
@@ -12,7 +12,6 @@ import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.Blockreader;
import net.minecraft.world.IBlockReader;
@@ -24,16 +23,10 @@ import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.structure.StructureManager;
import net.minecraft.world.gen.settings.DimensionStructuresSettings;
import net.minecraft.world.gen.settings.NoiseSettings;
import net.minecraft.world.gen.settings.ScalingSettings;
import net.minecraft.world.gen.settings.SlideSettings;
import net.minecraft.world.server.ServerChunkProvider;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.lib.LibObfuscation;
import java.lang.invoke.MethodHandle;
import java.util.Optional;
import vazkii.botania.mixin.MixinDimensionSettingsPreset;
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
@@ -47,15 +40,8 @@ public class SkyblockChunkGenerator extends ChunkGenerator {
public static void init() {
Registry.register(Registry.field_239690_aB_, prefix("skyblock"), SkyblockChunkGenerator.CODEC);
MethodHandle createOverWorldPreset = LibObfuscation.getMethod(DimensionSettings.Preset.class, "func_236135_a_", DimensionStructuresSettings.class, boolean.class, DimensionSettings.Preset.class);
dimSettingsPreset = new DimensionSettings.Preset(LibResources.PREFIX_MOD + "skyblock", preset -> {
// [VanillaCopy] overworld preset creation
try {
return (DimensionSettings) createOverWorldPreset.invokeExact(new DimensionStructuresSettings(true), false, preset);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
});
dimSettingsPreset = new DimensionSettings.Preset(LibResources.PREFIX_MOD + "skyblock",
preset -> MixinDimensionSettingsPreset.createOverworldSettings(new DimensionStructuresSettings(true), false, preset));
}
private final long seed;
@@ -0,0 +1,41 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.item.crafting.AbstractCookingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.tileentity.AbstractFurnaceTileEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import javax.annotation.Nullable;
@Mixin(AbstractFurnaceTileEntity.class)
public interface MixinAbstractFurnaceTileEntity {
@Invoker
boolean invokeCanSmelt(@Nullable IRecipe<?> recipe);
@Accessor
IRecipeType<? extends AbstractCookingRecipe> getRecipeType();
@Accessor
int getBurnTime();
@Accessor
void setBurnTime(int burnTime);
@Accessor
int getCookTime();
@Accessor
void setCookTime(int cookTime);
}
@@ -0,0 +1,56 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.util.WeightedSpawnerEntity;
import net.minecraft.world.spawner.AbstractSpawner;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(AbstractSpawner.class)
public interface MixinAbstractSpawner {
@Invoker("func_221409_a")
void callSpawnEntity(Entity e);
@Invoker
boolean callIsActivated();
@Invoker
void callResetTimer();
@Accessor
int getSpawnCount();
@Accessor
int getSpawnRange();
@Accessor
WeightedSpawnerEntity getSpawnData();
@Accessor
int getMaxNearbyEntities();
@Accessor
double getMobRotation();
@Accessor
void setMobRotation(double rot);
@Accessor
void setPrevMobRotation(double rot);
@Accessor
int getSpawnDelay();
@Accessor
void setSpawnDelay(int delay);
}
@@ -0,0 +1,24 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.AvoidEntityGoal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(AvoidEntityGoal.class)
public interface MixinAvoidEntityGoal {
@Accessor
Class<?> getClassToAvoid();
@Accessor
void setClassToAvoid(Class<? extends LivingEntity> clazz);
}
@@ -0,0 +1,24 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
@Mixin(BiomeGeneratorTypeScreens.class)
public interface MixinBiomeGeneratorTypeScreens {
@Accessor("field_239068_c_")
static List<BiomeGeneratorTypeScreens> getAllTypes() {
throw new IllegalStateException();
}
}
@@ -0,0 +1,20 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.monster.CreeperEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(CreeperEntity.class)
public interface MixinCreeperEntity {
@Accessor
void setTimeSinceIgnited(int time);
}
@@ -0,0 +1,23 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.world.gen.DimensionSettings;
import net.minecraft.world.gen.settings.DimensionStructuresSettings;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(DimensionSettings.Preset.class)
public interface MixinDimensionSettingsPreset {
@Invoker("func_236135_a_")
static DimensionSettings createOverworldSettings(DimensionStructuresSettings structureSettings, boolean amplified, DimensionSettings.Preset preset) {
throw new IllegalStateException();
}
}
@@ -0,0 +1,21 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.block.Block;
import net.minecraft.block.FireBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(FireBlock.class)
public interface MixinFireBlock {
@Invoker
void callSetFireInfo(Block block, int encouragement, int flammability);
}
@@ -0,0 +1,26 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.FirstPersonRenderer;
import net.minecraft.util.HandSide;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(FirstPersonRenderer.class)
public interface MixinFirstPersonRenderer {
@Invoker
void callTransformSideFirstPerson(MatrixStack ms, HandSide side, float equip);
@Invoker
void callTransformFirstPerson(MatrixStack ms, HandSide side, float swing);
}
@@ -0,0 +1,23 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.ai.goal.GoalSelector;
import net.minecraft.entity.ai.goal.PrioritizedGoal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Set;
@Mixin(GoalSelector.class)
public interface MixinGoalSelector {
@Accessor
Set<PrioritizedGoal> getGoals();
}
@@ -0,0 +1,26 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.item.HoeItem;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Map;
@Mixin(HoeItem.class)
public interface MixinHoeItem {
@Accessor("HOE_LOOKUP")
static Map<Block, BlockState> getConversions() {
throw new IllegalStateException();
}
}
@@ -0,0 +1,26 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.item.ItemEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(ItemEntity.class)
public interface MixinItemEntity {
@Accessor
int getAge();
@Accessor
void setAge(int age);
@Accessor
int getPickupDelay();
}
@@ -0,0 +1,23 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemOverrideList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
@Mixin(ItemOverrideList.class)
public interface MixinItemOverrideList {
@Accessor
List<IBakedModel> getOverrideBakedModels();
}
@@ -0,0 +1,20 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(LivingEntity.class)
public interface MixinLivingEntity {
@Accessor
void setActiveItemStackUseCount(int ticks);
}
@@ -0,0 +1,29 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.MobEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.gen.Invoker;
import javax.annotation.Nullable;
@Mixin(MobEntity.class)
public interface MixinMobEntity {
@Nullable
@Invoker
SoundEvent callGetAmbientSound();
@Accessor
void setDeathLootTable(ResourceLocation id);
}
@@ -0,0 +1,25 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.RenderMaterial;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Set;
@Mixin(ModelBakery.class)
public interface MixinModelBakery {
@Accessor("LOCATIONS_BUILTIN_TEXTURES")
static Set<RenderMaterial> getMaterials() {
throw new IllegalStateException();
}
}
@@ -0,0 +1,24 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.goal.NearestAttackableTargetGoal;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(NearestAttackableTargetGoal.class)
public interface MixinNearestAttackableTarget {
@Accessor
Class<?> getTargetClass();
@Accessor
void setTargetClass(Class<?> clazz);
}
@@ -0,0 +1,21 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.client.gui.recipebook.RecipeBookGui;
import net.minecraft.client.gui.recipebook.RecipeBookPage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(RecipeBookGui.class)
public interface MixinRecipeBookGui {
@Accessor
RecipeBookPage getRecipeBookPage();
}
@@ -0,0 +1,21 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.client.gui.recipebook.RecipeBookPage;
import net.minecraft.client.gui.recipebook.RecipeWidget;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(RecipeBookPage.class)
public interface MixinRecipeBookPage {
@Accessor
RecipeWidget getHoveredButton();
}
@@ -0,0 +1,26 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.RecipeManager;
import net.minecraft.util.ResourceLocation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import java.util.Map;
@Mixin(RecipeManager.class)
public interface MixinRecipeManager {
@Invoker
<C extends IInventory, T extends IRecipe<C>> Map<ResourceLocation, IRecipe<C>> callGetRecipes(IRecipeType<T> type);
}
@@ -0,0 +1,28 @@
/*
* This class is distributed as part of the Botania Mod.
* Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.mixin;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.vertex.VertexBuffer;
import net.minecraft.client.renderer.vertex.VertexFormat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(WorldRenderer.class)
public interface MixinWorldRenderer {
@Accessor
VertexFormat getSkyVertexFormat();
@Accessor
VertexBuffer getSkyVBO();
@Accessor
VertexBuffer getStarVBO();
}
+1
View File
@@ -0,0 +1 @@
MixinConnector: vazkii.botania.common.MixinConnector
@@ -1,59 +1,7 @@
public net.minecraft.client.renderer.WorldRenderer field_175013_s # starVBO
public net.minecraft.client.renderer.WorldRenderer field_175012_t # skyVBO
public net.minecraft.client.renderer.WorldRenderer field_175014_r # skyVertexFormat
public net.minecraft.entity.item.ItemEntity field_70292_b # age
public net.minecraft.entity.item.ItemEntity field_145804_b # delayBeforeCanPickup
public-f net.minecraft.entity.ai.goal.NearestAttackableTargetGoal field_75307_b # targetClass
public-f net.minecraft.entity.ai.goal.AvoidEntityGoal field_181064_i # classToAvoid
public net.minecraft.entity.monster.CreeperEntity field_70833_d # timeSinceIgnited
public net.minecraft.entity.LivingEntity field_184628_bn # activeItemStackUseCount
public net.minecraft.entity.passive.horse.AbstractHorseEntity field_110271_bv # JUMP_STRENGTH
public net.minecraft.world.spawner.AbstractSpawner func_98279_f()Z # isActivated
public net.minecraft.world.spawner.AbstractSpawner func_98273_j()V # resetTimer
public net.minecraft.world.spawner.AbstractSpawner field_98290_m # spawnRange
public net.minecraft.world.spawner.AbstractSpawner field_98294_i # spawnCount
public net.minecraft.world.spawner.AbstractSpawner field_98292_k # maxNearbyEntities
public net.minecraft.world.spawner.AbstractSpawner field_98293_h # maxSpawnDelay
public net.minecraft.world.spawner.AbstractSpawner field_98283_g # minSpawnDelay
public net.minecraft.world.spawner.AbstractSpawner field_98285_e # potentialSpawns
public net.minecraft.world.spawner.AbstractSpawner field_98286_b # spawnDelay
public net.minecraft.world.spawner.AbstractSpawner field_98284_d # prevMobRotation
public net.minecraft.world.spawner.AbstractSpawner field_98287_c # mobRotation
public net.minecraft.world.spawner.AbstractSpawner field_98282_f # spawnData
public net.minecraft.advancements.CriteriaTriggers func_192118_a(Lnet/minecraft/advancements/ICriterionTrigger;)Lnet/minecraft/advancements/ICriterionTrigger; # register
public net.minecraft.item.DyeColor field_193351_w # colorValue
public net.minecraft.entity.MobEntity field_184659_bA # deathLootTable
public net.minecraft.item.ItemUseContext <init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/math/BlockRayTraceResult;)V
public net.minecraft.item.BlockItemUseContext <init>(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/Hand;Lnet/minecraft/item/ItemStack;Lnet/minecraft/util/math/BlockRayTraceResult;)V
public net.minecraft.client.renderer.model.ItemOverrideList field_209582_c # overrideBakedModels
public net.minecraft.item.Item func_219968_a(Lnet/minecraft/world/World;Lnet/minecraft/entity/player/PlayerEntity;Lnet/minecraft/util/math/RayTraceContext$FluidMode;)Lnet/minecraft/util/math/BlockRayTraceResult; # rayTrace
public net.minecraft.entity.ai.goal.GoalSelector field_220892_d # goals
public net.minecraft.tileentity.AbstractFurnaceTileEntity field_214018_j # burnTime
public net.minecraft.tileentity.AbstractFurnaceTileEntity field_214020_l # cookTime
public net.minecraft.item.crafting.RecipeManager func_215366_a(Lnet/minecraft/item/crafting/IRecipeType;)Ljava/util/Map; # getRecipes
public net.minecraft.client.renderer.BlockModelRenderer func_178264_a(FFFFLjava/util/List;)V # renderModelBrightnessColorQuads
public net.minecraft.client.gui.screen.BiomeGeneratorTypeScreens <init>(Ljava/lang/String;)V
public net.minecraft.entity.projectile.ProjectileEntity <init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V
public net.minecraft.block.FireBlock func_180686_a(Lnet/minecraft/block/Block;II)V # setFireInfo
@@ -0,0 +1,34 @@
{
"required": true,
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"package": "vazkii.botania.mixin",
"refmap": "botania.refmap.json",
"mixins": [
"MixinAbstractFurnaceTileEntity",
"MixinAbstractSpawner",
"MixinAvoidEntityGoal",
"MixinCreeperEntity",
"MixinDimensionSettingsPreset",
"MixinFireBlock",
"MixinGoalSelector",
"MixinHoeItem",
"MixinItemEntity",
"MixinLivingEntity",
"MixinMobEntity",
"MixinNearestAttackableTarget",
"MixinRecipeManager"
],
"client": [
"MixinBiomeGeneratorTypeScreens",
"MixinFirstPersonRenderer",
"MixinItemOverrideList",
"MixinModelBakery",
"MixinRecipeBookGui",
"MixinRecipeBookPage",
"MixinWorldRenderer"
],
"injectors": {
"defaultRequire": 1
}
}