diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-29 22:47:18 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-29 22:47:18 -0800 |
commit | 960bbb3537d7c8c552050b5826de58bc8d798f04 (patch) | |
tree | 8006e73e99cc48c8b401cf9b34388f9b293dd43e /src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java | |
parent | 1e0349649cf45764435b993bc87339742a025078 (diff) | |
download | GT5-Unofficial-960bbb3537d7c8c552050b5826de58bc8d798f04.tar.gz GT5-Unofficial-960bbb3537d7c8c552050b5826de58bc8d798f04.tar.bz2 GT5-Unofficial-960bbb3537d7c8c552050b5826de58bc8d798f04.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java')
-rw-r--r-- | src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java | 181 |
1 files changed, 88 insertions, 93 deletions
diff --git a/src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java b/src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java index 948a4e52a5..f40aef3101 100644 --- a/src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java +++ b/src/main/java/bloodasp/galacticgreg/schematics/SpaceSchematicWrapper.java @@ -1,5 +1,11 @@ package bloodasp.galacticgreg.schematics; +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.util.Vec3; + import bloodasp.galacticgreg.GalacticGreg; import bloodasp.galacticgreg.api.BlockMetaComb; import bloodasp.galacticgreg.api.Enums.SpaceObjectType; @@ -8,102 +14,91 @@ import bloodasp.galacticgreg.api.ISpaceObjectGenerator; import bloodasp.galacticgreg.api.StructureInformation; import bloodasp.galacticgreg.schematics.SpaceSchematic.BaseStructureInfo; import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.block.Block; -import net.minecraft.util.Vec3; - -import java.util.ArrayList; -import java.util.List; /** - * Class for XML Structure files. You only should edit/use this file/class if you want to add/fix stuff with - * GalacticGreg itself, and never if you're a mod developer and want to add support for GGreg to your mod. - * However, feel free to copy this code to your own mod to implement structures. If you have questions, find me on github - * and ask + * Class for XML Structure files. You only should edit/use this file/class if you want to add/fix stuff with + * GalacticGreg itself, and never if you're a mod developer and want to add support for GGreg to your mod. However, feel + * free to copy this code to your own mod to implement structures. If you have questions, find me on github and ask */ public class SpaceSchematicWrapper implements ISpaceObjectGenerator { - private SpaceSchematic _mSchematic; - private Vec3 _mCenter = Vec3.createVectorHelper(0, 0, 0); - private List<StructureInformation> _mFinalizedStructure; - - public SpaceSchematicWrapper(SpaceSchematic pSchematic) - { - _mSchematic = pSchematic; - } - - public boolean isCalculated() - { - return _mFinalizedStructure != null && _mFinalizedStructure.size() > 0; - } - - /** - * Recalculate the Structures position, center it around _mCenter - */ - private void RecalculatePosition() - { - _mFinalizedStructure = new ArrayList<>(); - - for (BaseStructureInfo bsi: _mSchematic.coordInfo()) - { - try - { - String tModID = bsi.blockName.split(":")[0]; - String tBlockName = bsi.blockName.split(":")[1]; - - Block tBlock = GameRegistry.findBlock(tModID, tBlockName); - if (tBlock != null) - { - BlockMetaComb bmc = new BlockMetaComb(tBlock, bsi.blockMeta); - Vec3 tCenteredPos = _mCenter.addVector(bsi.posX, bsi.posY, bsi.posZ); - StructureInformation tnewSI = new StructureInformation(tCenteredPos, TargetBlockPosition.StructureBlock, bmc); - _mFinalizedStructure.add(tnewSI); - } - else - GalacticGreg.Logger.warn("Block %s:%s could not be found. Schematic will be incomplete!", tModID, tBlockName); - } - catch (Exception e) - { - e.printStackTrace(); - GalacticGreg.Logger.error("Error while recalculating blocks position"); - } - } - } - - @Override - public Vec3 getCenterPoint() { - return _mCenter; - } - - @Override - public void setCenterPoint(int pX, int pY, int pZ) { - _mCenter = Vec3.createVectorHelper(pX, pY, pZ); - } - - @Override - public void setCenterPoint(Vec3 pCenter) { - _mCenter = pCenter; - } - - @Override - public List<StructureInformation> getStructure() { - return _mFinalizedStructure; - } - - @Override - public void calculate() { - RecalculatePosition(); - } - - @Override - public void randomize(int pSizeMin, int pSizeMax) {} - - @Override - public SpaceObjectType getType() { - return SpaceObjectType.NonOreSchematic; - } - - @Override - public void reset() { - - } + + private SpaceSchematic _mSchematic; + private Vec3 _mCenter = Vec3.createVectorHelper(0, 0, 0); + private List<StructureInformation> _mFinalizedStructure; + + public SpaceSchematicWrapper(SpaceSchematic pSchematic) { + _mSchematic = pSchematic; + } + + public boolean isCalculated() { + return _mFinalizedStructure != null && _mFinalizedStructure.size() > 0; + } + + /** + * Recalculate the Structures position, center it around _mCenter + */ + private void RecalculatePosition() { + _mFinalizedStructure = new ArrayList<>(); + + for (BaseStructureInfo bsi : _mSchematic.coordInfo()) { + try { + String tModID = bsi.blockName.split(":")[0]; + String tBlockName = bsi.blockName.split(":")[1]; + + Block tBlock = GameRegistry.findBlock(tModID, tBlockName); + if (tBlock != null) { + BlockMetaComb bmc = new BlockMetaComb(tBlock, bsi.blockMeta); + Vec3 tCenteredPos = _mCenter.addVector(bsi.posX, bsi.posY, bsi.posZ); + StructureInformation tnewSI = new StructureInformation( + tCenteredPos, + TargetBlockPosition.StructureBlock, + bmc); + _mFinalizedStructure.add(tnewSI); + } else GalacticGreg.Logger + .warn("Block %s:%s could not be found. Schematic will be incomplete!", tModID, tBlockName); + } catch (Exception e) { + e.printStackTrace(); + GalacticGreg.Logger.error("Error while recalculating blocks position"); + } + } + } + + @Override + public Vec3 getCenterPoint() { + return _mCenter; + } + + @Override + public void setCenterPoint(int pX, int pY, int pZ) { + _mCenter = Vec3.createVectorHelper(pX, pY, pZ); + } + + @Override + public void setCenterPoint(Vec3 pCenter) { + _mCenter = pCenter; + } + + @Override + public List<StructureInformation> getStructure() { + return _mFinalizedStructure; + } + + @Override + public void calculate() { + RecalculatePosition(); + } + + @Override + public void randomize(int pSizeMin, int pSizeMax) {} + + @Override + public SpaceObjectType getType() { + return SpaceObjectType.NonOreSchematic; + } + + @Override + public void reset() { + + } } |