Skip to content

Commit

Permalink
Advanced infusion provider (#72)
Browse files Browse the repository at this point in the history
* Add block,tile,texture,lang

* make new provider can provide essentia

* Code Optimization

* if fail to bind matrix will clear old XYZ for matrix

* spotless

* mark dirty after unbind

* add research, recipe and change texture

* Update en_US.lang

Co-authored-by: Alexander Anishin <[email protected]>

* Update zh_CN.lang

* fix and add comments, fix en_US.lang

---------

Co-authored-by: Alexander Anishin <[email protected]>
  • Loading branch information
MCTBL and OneEyeMaker authored Sep 4, 2024
1 parent d96e256 commit 81e5cea
Show file tree
Hide file tree
Showing 20 changed files with 489 additions and 5 deletions.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.25'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
}


6 changes: 6 additions & 0 deletions src/main/java/thaumicenergistics/api/IThEBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ public abstract class IThEBlocks {
@Nonnull
public IThEItemDescription InfusionProvider;

/**
* Advanced Infusion Provider.
*/
@Nonnull
public IThEItemDescription AdvancedInfusionProvider;

/**
* Iron Gearbox.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package thaumicenergistics.client.render;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumicenergistics.client.textures.BlockTextureManager;
import thaumicenergistics.common.registries.Renderers;
import thaumicenergistics.common.tiles.TileInfusionProvider;

/**
* Renders the {@link TileInfusionProvider}
*
* @author MCTBL
*
*/
@SideOnly(Side.CLIENT)
public class RenderBlockAdvancedInfusionProvider extends RenderBlockProviderBase {

public RenderBlockAdvancedInfusionProvider() {
super(BlockTextureManager.ADVANCED_INFUSION_PROVIDER);
}

@Override
public int getRenderId() {
return Renderers.AdvancedInfusionProviderRenderID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public enum BlockTextureManager {

INFUSION_PROVIDER(TextureTypes.Block, new String[] { "infusion.provider", "infusion.provider.overlay" }),

ADVANCED_INFUSION_PROVIDER(TextureTypes.Block,
new String[] { "advanced.infusion.provider", "infusion.provider.overlay" }),

ARCANE_CRAFTING_TERMINAL(TextureTypes.Part,
new String[] { "arcane.crafting.overlay1", "arcane.crafting.overlay2", "arcane.crafting.overlay3",
"arcane.crafting.side", "arcane.crafting.overlay4" }),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package thaumicenergistics.common.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumicenergistics.client.textures.BlockTextureManager;
import thaumicenergistics.common.registries.Renderers;
import thaumicenergistics.common.tiles.TileAdvancedInfusionProvider;

/**
* {@link TileAdvancedInfusionProvider} block.
*
* @author MCTBL
*
*/
public class BlockAdvancedInfusionProvider extends AbstractBlockProviderBase {

public BlockAdvancedInfusionProvider() {
// Call super with material machine (iron)
super(Material.iron);

// Basic hardness
this.setHardness(1.0f);

// Sound of metal
this.setStepSound(Block.soundTypeMetal);
}

/**
* Called when the provider is right-clicked
*
* @param world
* @param x
* @param y
* @param z
* @param player
* @return
*/
@Override
protected boolean onBlockActivated(final World world, final int x, final int y, final int z,
final EntityPlayer player) {
if (world.getTileEntity(x, y, z) instanceof TileAdvancedInfusionProvider taip && taip.isActive()) {
if (taip.matrix != null) {
taip.unbindMatrix();
}
taip.searchMatrix();
return true;
} else {
return false;
}
}

@Override
public TileEntity createNewTileEntity(final World world, final int metaData) {
// Create a new provider tile, passing the side to attach to
TileAdvancedInfusionProvider tile = new TileAdvancedInfusionProvider();

tile.setupProvider(metaData);

tile.searchMatrix();

// Return the tile
return tile;
}

@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(final int side, final int metaData) {
return BlockTextureManager.ADVANCED_INFUSION_PROVIDER.getTextures()[1];
}

@SideOnly(Side.CLIENT)
@Override
public int getRenderType() {
// Provide our custom ID
return Renderers.AdvancedInfusionProviderRenderID;
}

@Override
public String getUnlocalizedName() {
return BlockEnum.ADVANCED_INFUSION_PROVIDER.getUnlocalizedName();
}

@Override
public void onNeighborBlockChange(final World world, final int x, final int y, final int z, final Block neighbor) {
// Get tile entity
TileEntity tileProvider = world.getTileEntity(x, y, z);
if (tileProvider instanceof TileAdvancedInfusionProvider tP) {
// Inform our tile entity a neighbor has changed
tP.checkGridConnectionColor();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum BlockEnum {

ESSENTIA_PROVIDER(ThEStrings.Block_EssentiaProvider, new BlockEssentiaProvider()),
INFUSION_PROVIDER(ThEStrings.Block_InfusionProvider, new BlockInfusionProvider()),
ADVANCED_INFUSION_PROVIDER(ThEStrings.Block_AdvancedInfusionProvider, new BlockAdvancedInfusionProvider()),
IRON_GEAR_BOX(ThEStrings.Block_IronGearbox, new BlockGearBox()),
THAUMIUM_GEAR_BOX(ThEStrings.Block_ThaumiumGearbox, new BlockGolemGearBox()),
ESSENTIA_CELL_WORKBENCH(ThEStrings.Block_EssentiaCellWorkbench, new BlockEssentiaCellWorkbench()),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package thaumicenergistics.common.features;

import net.minecraft.item.ItemStack;

import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.api.research.ResearchPage;
import thaumicenergistics.api.IThEConfig;
import thaumicenergistics.api.ThEApi;
import thaumicenergistics.common.blocks.BlockEnum;
import thaumicenergistics.common.registries.FeatureRegistry;
import thaumicenergistics.common.registries.RecipeRegistry;
import thaumicenergistics.common.registries.ResearchRegistry;
import thaumicenergistics.common.registries.ResearchRegistry.ResearchTypes;

/**
* {@link TileAdvancedInfusionProvider} feature.
*
* @author MCTBL
*
*/
public class FeatureAdvancedInfusionProvider extends ThEThaumcraftResearchFeature {

public FeatureAdvancedInfusionProvider() {
super(ResearchTypes.ADVANCED_INFUSION_PROVIDER.getKey());
}

@Override
protected ThEThaumcraftResearchFeature getParentFeature() {
return FeatureRegistry.instance().featureInfusionProvider;
}

@Override
protected void registerPseudoParents() {}

@Override
protected void registerResearch() {
// What aspects does research note have
AspectList advancedInfusionProviderList = new AspectList();
advancedInfusionProviderList.add(Aspect.MECHANISM, 1);
advancedInfusionProviderList.add(Aspect.MAGIC, 1);
advancedInfusionProviderList.add(Aspect.EXCHANGE, 1);
advancedInfusionProviderList.add(Aspect.MOTION, 1);
advancedInfusionProviderList.add(Aspect.TOOL, 1);
advancedInfusionProviderList.add(Aspect.MIND, 1);
advancedInfusionProviderList.add(Aspect.SENSES, 1);

// Research icon
ItemStack advancedInfusionProviderIcon = new ItemStack(BlockEnum.ADVANCED_INFUSION_PROVIDER.getBlock(), 1);

// Research Page
ResearchPage[] advancedInfusionProviderPages = new ResearchPage[] {
new ResearchPage(ResearchTypes.ADVANCED_INFUSION_PROVIDER.getPageName(1)),
new ResearchPage(RecipeRegistry.BLOCK_ADVANCED_INFUSION_PROVIDER) };

// Create the advanced infusion provider research
ResearchTypes.ADVANCED_INFUSION_PROVIDER.createResearchItem(
advancedInfusionProviderList,
ResearchRegistry.COMPLEXITY_LARGE,
advancedInfusionProviderIcon,
advancedInfusionProviderPages);

ResearchTypes.ADVANCED_INFUSION_PROVIDER.researchItem.setParents(ResearchTypes.INFUSION_PROVIDER.getKey());
ResearchTypes.ADVANCED_INFUSION_PROVIDER.researchItem.setConcealed().setSpecial();
ResearchTypes.ADVANCED_INFUSION_PROVIDER.researchItem.registerResearchItem();
}

@Override
protected boolean checkConfigs(IThEConfig theConfig) {
return true;
}

@Override
protected Object[] getItemReqs(CommonDependantItems cdi) {
return null;
}

@Override
protected void registerCrafting(CommonDependantItems cdi) {

ItemStack DiffusionCore = ThEApi.instance().items().DiffusionCore.getStack();
ItemStack InfusionProvider = ThEApi.instance().blocks().InfusionProvider.getStack();
ItemStack AdvancedInfusionProvider = ThEApi.instance().blocks().AdvancedInfusionProvider.getStack();

// Set required aspects for infusion provider
AspectList advancedInfusionProviderList = new AspectList();
advancedInfusionProviderList.add(Aspect.MECHANISM, 64);
advancedInfusionProviderList.add(Aspect.MAGIC, 64);
advancedInfusionProviderList.add(Aspect.EXCHANGE, 64);
advancedInfusionProviderList.add(Aspect.MIND, 64);
advancedInfusionProviderList.add(Aspect.GREED, 64);

ItemStack[] advancedInfusionProviderRecipeItems = { cdi.PrimalCharm, cdi.BallanceShard, DiffusionCore,
cdi.BallanceShard, cdi.PrimalCharm, cdi.BallanceShard, DiffusionCore, cdi.BallanceShard };
RecipeRegistry.BLOCK_ADVANCED_INFUSION_PROVIDER = ThaumcraftApi.addInfusionCraftingRecipe(
this.researchKey,
AdvancedInfusionProvider,
10,
advancedInfusionProviderList,
InfusionProvider,
advancedInfusionProviderRecipeItems);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import thaumicenergistics.common.features.CommonDependantItems;
import thaumicenergistics.common.features.FeatureACT;
import thaumicenergistics.common.features.FeatureAdvancedInfusionProvider;
import thaumicenergistics.common.features.FeatureAutocrafting_Arcane;
import thaumicenergistics.common.features.FeatureAutocrafting_Essentia;
import thaumicenergistics.common.features.FeatureCellMicroscope;
Expand Down Expand Up @@ -92,6 +93,11 @@ public class FeatureRegistry {
*/
public final FeatureInfusionProvider featureInfusionProvider;

/**
* Advanced Infusion provider.
*/
public final FeatureAdvancedInfusionProvider featureAdvancedInfusionProvider;

/**
* Essentia Provider.
*/
Expand Down Expand Up @@ -176,6 +182,9 @@ private FeatureRegistry() {
// Build infusion provider
this.featuresList.add(this.featureInfusionProvider = new FeatureInfusionProvider());

// Build infusion provider
this.featuresList.add(this.featureAdvancedInfusionProvider = new FeatureAdvancedInfusionProvider());

// Build essentia provider
this.featuresList.add(this.featureEssentiaProvider = new FeatureEssentiaProvider());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@ public class RecipeRegistry {
public static InfusionRecipe BLOCK_INFUSION_PROVIDER;
public static InfusionRecipe BLOCK_ESSENTIA_PROVIDER;
public static InfusionRecipe BLOCK_ARCANE_ASSEMBLER;
public static InfusionRecipe BLOCK_ADVANCED_INFUSION_PROVIDER;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import thaumicenergistics.api.ThEApi;
import thaumicenergistics.client.render.RenderBlockAdvancedInfusionProvider;
import thaumicenergistics.client.render.RenderBlockEssentiaProvider;
import thaumicenergistics.client.render.RenderBlockInfusionProvider;
import thaumicenergistics.client.render.RenderTileArcaneAssembler;
Expand All @@ -31,7 +32,7 @@ public class Renderers {

public static int currentRenderPass = 0;

public static int EssentiaProviderRenderID, InfusionProviderRenderID;
public static int EssentiaProviderRenderID, InfusionProviderRenderID, AdvancedInfusionProviderRenderID;

public static void registerRenderers() {
// Get the next render ID
Expand All @@ -42,9 +43,15 @@ public static void registerRenderers() {
// Get the next render ID
Renderers.InfusionProviderRenderID = RenderingRegistry.getNextAvailableRenderId();

// Get the next render ID
Renderers.AdvancedInfusionProviderRenderID = RenderingRegistry.getNextAvailableRenderId();

// Register the infusion provider renderer
RenderingRegistry.registerBlockHandler(new RenderBlockInfusionProvider());

// Register the advanced infusion provider renderer
RenderingRegistry.registerBlockHandler(new RenderBlockAdvancedInfusionProvider());

// Are gearbox models enabled?
if (!ThEApi.instance().config().disableGearboxModel()) {
// Register the gearbox renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public static enum ResearchTypes {
ESSENTIA_TERMINAL("ESSTERM", -1, -4),
ESSENTIA_PROVIDER("ESSPROV", -2, -4),
INFUSION_PROVIDER("INFPROV", -5, -2),
ADVANCED_INFUSION_PROVIDER("ADVINFPROV", -7, -2),
IRON_GEARBOX("IRONGEARBOX", 4, -5),
THAUMIUM_GEARBOX("THAUMGBOX", 4, -6),
CERTUS_DUPE("CERTUSDUPE", -5, -5),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum ThEStrings {
// Blocks
Block_EssentiaProvider("block.essentia.provider", true),
Block_InfusionProvider("block.infusion.provider", true),
Block_AdvancedInfusionProvider("block.advanced.infusion.provider", true),
Block_IronGearbox("block.gear.box", true),
Block_ThaumiumGearbox("block.golem.gear.box", true),
Block_EssentiaCellWorkbench("block.essentia.cell.workbench", true),
Expand Down Expand Up @@ -75,6 +76,10 @@ public enum ThEStrings {
Tooltip_CellTypes("tooltip.essentia.cell.types", false),
Tooltip_CellContains("tooltip.essentia.cell.contains", false),
Tooltip_ArcaneAssemblerHasVis("tooltip.arcane.assembler.hasVis", false),
Tooltip_AdvancedInfusionProviderWorkingMode("tooltip.advanced.infusion.provider.working.on", false),
Tooltip_AdvancedInfusionProviderNormalMode("tooltip.advanced.infusion.provider.normal", false),
Tooltip_AdvancedInfusionProviderAdvancedMode("tooltip.advanced.infusion.provider.advanced", false),
Tooltip_AdvancedInfusionProviderBindTo("tooltip.advanced.infusion.provider.bindto", false),

// Button Tooltips
TooltipButton_VoidHeader("tooltip.button.void", false),
Expand Down
Loading

0 comments on commit 81e5cea

Please sign in to comment.