-
Notifications
You must be signed in to change notification settings - Fork 214
Primitive Water Pump #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
105b2fd
most initial work on Water Pump
serenibyss 9a8d6ac
change pump hatch default texture
serenibyss 4627c24
create pump hatch UI
serenibyss ab21e82
fix front overlay on controller
serenibyss 48fc5b3
fix pump hatch texture issue
serenibyss c3ad283
finish water pump logic and allowed hatches
serenibyss 59e672d
JEI page, lang
serenibyss cf13904
last cleanups
serenibyss 723ff1e
remove unnecessary changes
serenibyss fe79c3b
address requested changes
serenibyss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
src/main/java/gregtech/common/metatileentities/multi/MetaTileEntityPrimitiveWaterPump.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| package gregtech.common.metatileentities.multi; | ||
|
|
||
| import codechicken.lib.render.CCRenderState; | ||
| import codechicken.lib.render.pipeline.IVertexOperation; | ||
| import codechicken.lib.vec.Matrix4; | ||
| import gregtech.api.gui.ModularUI; | ||
| import gregtech.api.metatileentity.MetaTileEntity; | ||
| import gregtech.api.metatileentity.MetaTileEntityHolder; | ||
| import gregtech.api.metatileentity.multiblock.IMultiblockAbilityPart; | ||
| import gregtech.api.metatileentity.multiblock.IMultiblockPart; | ||
| import gregtech.api.metatileentity.multiblock.MultiblockAbility; | ||
| import gregtech.api.metatileentity.multiblock.MultiblockControllerBase; | ||
| import gregtech.api.multiblock.BlockPattern; | ||
| import gregtech.api.multiblock.BlockWorldState; | ||
| import gregtech.api.multiblock.FactoryBlockPattern; | ||
| import gregtech.api.multiblock.PatternMatchContext; | ||
| import gregtech.api.render.ICubeRenderer; | ||
| import gregtech.api.render.OrientedOverlayRenderer; | ||
| import gregtech.api.render.Textures; | ||
| import gregtech.api.unification.material.Materials; | ||
| import gregtech.common.blocks.BlockSteamCasing; | ||
| import gregtech.common.blocks.MetaBlocks; | ||
| import gregtech.common.metatileentities.electric.multiblockpart.MetaTileEntityFluidHatch; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.util.ResourceLocation; | ||
| import net.minecraft.world.biome.*; | ||
| import net.minecraftforge.fluids.FluidTank; | ||
| import net.minecraftforge.fluids.IFluidTank; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
| import java.util.List; | ||
| import java.util.function.Predicate; | ||
|
|
||
| public class MetaTileEntityPrimitiveWaterPump extends MultiblockControllerBase { | ||
|
|
||
| private IFluidTank waterTank; | ||
| private int biomeModifier = 0; | ||
| private int hatchModifier = 0; | ||
|
|
||
| public MetaTileEntityPrimitiveWaterPump(ResourceLocation metaTileEntityId) { | ||
| super(metaTileEntityId); | ||
| resetTileAbilities(); | ||
| } | ||
|
|
||
| @Override | ||
| public MetaTileEntity createMetaTileEntity(MetaTileEntityHolder holder) { | ||
| return new MetaTileEntityPrimitiveWaterPump(metaTileEntityId); | ||
| } | ||
|
|
||
| @Override | ||
| public void update() { | ||
| super.update(); | ||
| if (getOffsetTimer() % 20 == 0 && !getWorld().isRemote && isStructureFormed()) { | ||
| if (biomeModifier == 0) { | ||
| biomeModifier = getAmountForBiome(getWorld().getBiome(getPos())); | ||
| } | ||
| waterTank.fill(Materials.Water.getFluid(biomeModifier * hatchModifier), true); | ||
| } | ||
| } | ||
|
|
||
| private static int getAmountForBiome(Biome biome) { | ||
| Class<? extends Biome> biomeClass = biome.getBiomeClass(); | ||
| if (biomeClass == BiomeOcean.class || biomeClass == BiomeRiver.class) { | ||
| return 1000; | ||
| } else if (biomeClass == BiomeSwamp.class) { | ||
| return 800; | ||
| } else if (biomeClass == BiomeJungle.class) { | ||
| return 350; | ||
| } else if (biomeClass == BiomeSnow.class) { | ||
| return 300; | ||
| } else if (biomeClass == BiomePlains.class || biomeClass == BiomeForest.class) { | ||
| return 250; | ||
| } else if (biomeClass == BiomeTaiga.class) { | ||
| return 175; | ||
| } else if (biomeClass == BiomeBeach.class) { | ||
| return 170; | ||
| } else { | ||
| return 100; | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible to do this based off of Biome Temperature? This would give it more compat with other biome mods that utilize the biome temperature system, like Arid or Temperate, etc. |
||
|
|
||
| @Override | ||
| protected ModularUI createUI(EntityPlayer entityPlayer) { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean openGUIOnRightClick() { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected void updateFormedValid() { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| protected void formStructure(PatternMatchContext context) { | ||
| super.formStructure(context); | ||
| initializeAbilities(); | ||
| } | ||
|
|
||
| @Override | ||
| public void invalidateStructure() { | ||
| super.invalidateStructure(); | ||
| resetTileAbilities(); | ||
| } | ||
|
|
||
| private void initializeAbilities() { | ||
| List<IFluidTank> tanks = getAbilities(MultiblockAbility.PUMP_FLUID_HATCH); | ||
| if (tanks == null || tanks.size() == 0) { | ||
| tanks = getAbilities(MultiblockAbility.EXPORT_FLUIDS); | ||
| this.hatchModifier = tanks.get(0).getCapacity() == 8000 ? 2 : 4; | ||
| } else { | ||
| this.hatchModifier = 1; | ||
| } | ||
| this.waterTank = tanks.get(0); | ||
| } | ||
|
|
||
| private void resetTileAbilities() { | ||
| this.waterTank = new FluidTank(0); | ||
| } | ||
|
|
||
| @Override | ||
| protected BlockPattern createStructurePattern() { | ||
| return FactoryBlockPattern.start() | ||
| .aisle("XXXX", "**F*", "**F*") | ||
| .aisle("XXHX", "F**F", "FFFF") | ||
| .aisle("SXXX", "**F*", "**F*") | ||
| .where('S', selfPredicate()) | ||
| .where('X', statePredicate(MetaBlocks.STEAM_CASING.getState(BlockSteamCasing.SteamCasingType.PUMP_DECK))) | ||
| .where('F', statePredicate(MetaBlocks.FRAMES.get(Materials.Wood).getBlockState().getBaseState())) | ||
| .where('H', hatchPredicate()) | ||
| .where('*', (x) -> true) | ||
| .build(); | ||
| } | ||
|
|
||
| private static Predicate<BlockWorldState> hatchPredicate() { | ||
| return tilePredicate((state, tile) -> { | ||
| if (tile instanceof IMultiblockAbilityPart<?>) { | ||
| IMultiblockAbilityPart<?> abilityPart = (IMultiblockAbilityPart<?>) tile; | ||
| if (abilityPart.getAbility() == MultiblockAbility.PUMP_FLUID_HATCH) return true; | ||
| if (abilityPart.getAbility() == MultiblockAbility.EXPORT_FLUIDS) { | ||
| return ((MetaTileEntityFluidHatch) tile).getTier() <= 1; | ||
| } | ||
| } | ||
| return false; | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public ICubeRenderer getBaseTexture(IMultiblockPart sourcePart) { | ||
| return Textures.PRIMITIVE_PUMP; | ||
| } | ||
|
|
||
| @Nonnull | ||
| @Override | ||
| protected OrientedOverlayRenderer getFrontOverlay() { | ||
| return Textures.PRIMITIVE_PUMP_OVERLAY; | ||
| } | ||
|
|
||
| @Override | ||
| public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { | ||
| super.renderMetaTileEntity(renderState, translation, pipeline); | ||
| this.getFrontOverlay().render(renderState, translation, pipeline, getFrontFacing(), true); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.