forked from SpitefulFox/Avaritia
-
Notifications
You must be signed in to change notification settings - Fork 28
Add Matter Cluster Decompressor #70
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
Open
RecursivePineapple
wants to merge
6
commits into
master
Choose a base branch
from
matter-decompressor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d5526e6
Add the Matter Cluster Decompressor
RecursivePineapple 2fb0357
Fix hardness
RecursivePineapple 3ad952d
Address review comments
RecursivePineapple ee345c5
New recipe + fix
RecursivePineapple fee5251
Fix rebase errors
RecursivePineapple 3018753
Trim Mods + fix compilation error
RecursivePineapple 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package fox.spiteful.avaritia; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| import net.minecraft.util.ResourceLocation; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import com.gtnewhorizon.gtnhlib.util.data.IMod; | ||
| import com.gtnewhorizon.gtnhmixins.builders.ITargetMod; | ||
| import com.gtnewhorizon.gtnhmixins.builders.TargetModBuilder; | ||
|
|
||
| import cpw.mods.fml.common.Loader; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public enum Mods implements IMod, ITargetMod { | ||
|
|
||
| AE2FluidCraft(Names.A_E2_FLUID_CRAFT), | ||
| ModularUI2(Names.MODULAR_U_I_2), | ||
|
|
||
| ; | ||
|
|
||
| public static class Names { | ||
|
|
||
| // spotless:off | ||
|
|
||
| public static final String A_E2_FLUID_CRAFT = "ae2fc"; | ||
| public static final String MODULAR_U_I_2 = "modularui2"; | ||
|
|
||
| // spotless:on | ||
| } | ||
|
|
||
| public final String ID; | ||
| public final String resourceDomain; | ||
| protected boolean checkedMod, modLoaded; | ||
| protected final TargetModBuilder builder; | ||
|
|
||
| Mods(String ID) { | ||
| this.ID = ID; | ||
| this.resourceDomain = ID.toLowerCase(Locale.ENGLISH); | ||
| this.builder = new TargetModBuilder().setModId(getEffectiveModID()); | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull TargetModBuilder getBuilder() { | ||
| return builder; | ||
| } | ||
|
|
||
| @Override | ||
| public String getID() { | ||
| return ID; | ||
| } | ||
|
|
||
| protected String getEffectiveModID() { | ||
| return ID; | ||
| } | ||
|
|
||
| public boolean isModLoaded() { | ||
| if (!checkedMod) { | ||
| this.modLoaded = Loader.isModLoaded(getEffectiveModID()); | ||
| checkedMod = true; | ||
| } | ||
| return this.modLoaded; | ||
| } | ||
|
|
||
| @Override | ||
| public String getResourceLocation() { | ||
| return resourceDomain; | ||
| } | ||
|
|
||
| public String getResourcePath(String... path) { | ||
| return this.getResourceLocation(path).toString(); | ||
| } | ||
|
|
||
| public ResourceLocation getResourceLocation(String... path) { | ||
| return new ResourceLocation(this.resourceDomain, String.join("/", path)); | ||
| } | ||
| } | ||
115 changes: 115 additions & 0 deletions
115
src/main/java/fox/spiteful/avaritia/blocks/BlockMatterClusterOpener.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,115 @@ | ||
| package fox.spiteful.avaritia.blocks; | ||
|
|
||
| import net.minecraft.block.BlockContainer; | ||
| import net.minecraft.block.material.Material; | ||
| import net.minecraft.client.renderer.texture.IIconRegister; | ||
| import net.minecraft.entity.EntityLivingBase; | ||
| import net.minecraft.entity.player.EntityPlayer; | ||
| import net.minecraft.entity.player.EntityPlayerMP; | ||
| import net.minecraft.item.ItemStack; | ||
| import net.minecraft.tileentity.TileEntity; | ||
| import net.minecraft.util.IIcon; | ||
| import net.minecraft.util.MathHelper; | ||
| import net.minecraft.world.IBlockAccess; | ||
| import net.minecraft.world.World; | ||
| import net.minecraftforge.common.util.ForgeDirection; | ||
|
|
||
| import com.cleanroommc.modularui.factory.GuiManager; | ||
| import com.cleanroommc.modularui.factory.PosGuiData; | ||
| import com.cleanroommc.modularui.factory.TileEntityGuiFactory; | ||
|
|
||
| import cpw.mods.fml.common.registry.GameRegistry; | ||
| import cpw.mods.fml.relauncher.Side; | ||
| import cpw.mods.fml.relauncher.SideOnly; | ||
| import fox.spiteful.avaritia.items.ItemMatterClusterOpener; | ||
| import fox.spiteful.avaritia.tile.TileMatterClusterOpener; | ||
|
|
||
| public class BlockMatterClusterOpener extends BlockContainer { | ||
|
|
||
| public BlockMatterClusterOpener() { | ||
| super(Material.iron); | ||
|
|
||
| setBlockName("cluster_opener"); | ||
| setHardness(2f); | ||
| setResistance(2f); | ||
| } | ||
|
|
||
| public static void register() { | ||
| LudicrousBlocks.clusterOpener = new BlockMatterClusterOpener(); | ||
| GameRegistry.registerBlock(LudicrousBlocks.clusterOpener, ItemMatterClusterOpener.class, "cluster_opener"); | ||
| GameRegistry.registerTileEntity(TileMatterClusterOpener.class, "cluster_opener"); | ||
| } | ||
|
|
||
| @Override | ||
| public TileEntity createNewTileEntity(World worldIn, int meta) { | ||
| return new TileMatterClusterOpener(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, | ||
| float subY, float subZ) { | ||
| if (!worldIn.isRemote) { | ||
| PosGuiData data = new PosGuiData(player, x, y, z); | ||
| GuiManager.open(TileEntityGuiFactory.INSTANCE, data, (EntityPlayerMP) player); | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { | ||
| int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; | ||
|
|
||
| world.setBlockMetadataWithNotify(x, y, z, l, 2); | ||
| } | ||
|
|
||
| @Override | ||
| public void onBlockPreDestroy(World worldIn, int x, int y, int z, int meta) { | ||
| super.onBlockPreDestroy(worldIn, x, y, z, meta); | ||
|
|
||
| ((TileMatterClusterOpener) worldIn.getTileEntity(x, y, z)).dropContents(); | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| private IIcon top, side, front; | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| @Override | ||
| public void registerBlockIcons(IIconRegister reg) { | ||
| top = reg.registerIcon("avaritia:cluster_opener/top"); | ||
| side = reg.registerIcon("avaritia:cluster_opener/side"); | ||
| front = reg.registerIcon("avaritia:cluster_opener/front"); | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| @Override | ||
| public IIcon getIcon(IBlockAccess worldIn, int x, int y, int z, int side) { | ||
| // In-world rendering | ||
| ForgeDirection dir = ForgeDirection.getOrientation(side); | ||
|
|
||
| if (dir == ForgeDirection.UP) return top; | ||
| if (dir == ForgeDirection.DOWN) return top; | ||
|
|
||
| ForgeDirection front = switch (worldIn.getBlockMetadata(x, y, z)) { | ||
| case 0 -> ForgeDirection.NORTH; | ||
| case 1 -> ForgeDirection.EAST; | ||
| case 2 -> ForgeDirection.SOUTH; | ||
| case 3 -> ForgeDirection.WEST; | ||
| default -> ForgeDirection.UNKNOWN; | ||
| }; | ||
|
|
||
| return dir == front ? this.front : this.side; | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| @Override | ||
| public IIcon getIcon(int side, int meta) { | ||
| // In-hand rendering | ||
| ForgeDirection dir = ForgeDirection.getOrientation(side); | ||
|
|
||
| if (dir == ForgeDirection.UP) return top; | ||
| if (dir == ForgeDirection.DOWN) return top; | ||
|
|
||
| return dir == ForgeDirection.SOUTH ? this.front : this.side; | ||
| } | ||
| } |
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
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.