forked from xsun2001/Applied-Energistics-2-Unofficial
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reference issue: xsun2001#7
- Loading branch information
Showing
13 changed files
with
181 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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 appeng.block.legacy; | ||
|
||
import java.util.EnumSet; | ||
|
||
import appeng.api.AEApi; | ||
import appeng.api.storage.ICellHandler; | ||
import appeng.block.AEBaseBlock; | ||
import appeng.block.AEBaseTileBlock; | ||
import appeng.client.render.BaseBlockRender; | ||
import appeng.client.render.blocks.RenderBlockLegacyChest; | ||
import appeng.core.features.AEFeature; | ||
import appeng.core.localization.PlayerMessages; | ||
import appeng.core.sync.GuiBridge; | ||
import appeng.tile.AEBaseTile; | ||
import appeng.tile.legacy.TileLegacyChest; | ||
import appeng.tile.storage.TileChest; | ||
import appeng.util.Platform; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
|
||
public class BlockLegacyChest extends AEBaseTileBlock { | ||
|
||
public BlockLegacyChest() { | ||
super(Material.iron); | ||
this.isFullSize = this.isOpaque = false; | ||
this.setTileEntity(TileChest.class); | ||
this.setFeature(EnumSet.of(AEFeature.Legacy)); | ||
} | ||
|
||
@Override | ||
protected BaseBlockRender<? extends AEBaseBlock, ? extends AEBaseTile> getRenderer() { | ||
return new RenderBlockLegacyChest(); | ||
} | ||
|
||
@Override | ||
public boolean onActivated( | ||
final World w, | ||
final int x, | ||
final int y, | ||
final int z, | ||
final EntityPlayer p, | ||
final int side, | ||
final float hitX, | ||
final float hitY, | ||
final float hitZ | ||
) { | ||
final TileChest tg = this.getTileEntity(w, x, y, z); | ||
if (tg != null && !p.isSneaking()) { | ||
if (Platform.isClient()) { | ||
return true; | ||
} | ||
|
||
if (side != tg.getUp().ordinal()) { | ||
Platform.openGUI( | ||
p, tg, ForgeDirection.getOrientation(side), GuiBridge.GUI_CHEST | ||
); | ||
} else { | ||
final ItemStack cell = tg.getStackInSlot(1); | ||
if (cell != null) { | ||
final ICellHandler ch | ||
= AEApi.instance().registries().cell().getHandler(cell); | ||
|
||
tg.openGui(p, ch, cell, side); | ||
} else { | ||
p.addChatMessage(PlayerMessages.ChestCannotReadStorageCell.get()); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/appeng/client/render/blocks/RenderBlockLegacyChest.java
This file contains 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,20 @@ | ||
package appeng.client.render.blocks; | ||
|
||
import appeng.block.legacy.BlockLegacyChest; | ||
import appeng.client.render.BaseBlockRender; | ||
import appeng.tile.legacy.TileLegacyChest; | ||
import net.minecraft.client.renderer.RenderBlocks; | ||
import net.minecraft.world.IBlockAccess; | ||
|
||
public class RenderBlockLegacyChest extends BaseBlockRender<BlockLegacyChest, TileLegacyChest> { | ||
|
||
@Override | ||
public boolean renderInWorld(BlockLegacyChest block, IBlockAccess world, int x, int y, int z, RenderBlocks renderer) { | ||
renderer.setRenderBounds(0.02, 0.0, 0.02, 0.98, 0.98, 0.98); | ||
renderer.renderAllFaces = true; | ||
renderer.renderStandardBlock(block, x, y, z); | ||
renderer.renderAllFaces = false; | ||
return true; | ||
} | ||
|
||
} |
This file contains 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 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,45 @@ | ||
package appeng.tile.legacy; | ||
|
||
import java.util.EnumSet; | ||
|
||
import appeng.api.storage.StorageChannel; | ||
import appeng.tile.storage.TileChest; | ||
import net.minecraftforge.common.util.ForgeDirection; | ||
|
||
public class TileLegacyChest extends TileChest { | ||
|
||
public TileLegacyChest() { | ||
super(); | ||
this.getProxy().setIdlePowerUsage(0.5); | ||
this.getProxy().setValidSides(EnumSet.allOf(ForgeDirection.class)); | ||
} | ||
|
||
@Override | ||
public void | ||
setOrientation(final ForgeDirection inForward, final ForgeDirection inUp) { | ||
ForgeDirection forward = inForward; | ||
ForgeDirection up = inUp; | ||
if (up == ForgeDirection.DOWN) { | ||
up = ForgeDirection.UP; | ||
} else if (up != ForgeDirection.UP) { | ||
forward = up.getOpposite(); | ||
up = ForgeDirection.UP; | ||
} | ||
super.setOrientation(forward, up); | ||
} | ||
|
||
@Override | ||
public int[] getAccessibleSlotsBySide(ForgeDirection whichSide) { | ||
if (this.isPowered()) { | ||
try { | ||
if (this.getHandler(StorageChannel.ITEMS) != null) { | ||
return SIDES; | ||
} | ||
} catch (final ChestNoHandler e) { | ||
// nope! | ||
} | ||
} | ||
return NO_SLOTS; | ||
} | ||
|
||
} |
This file contains 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 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 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
Binary file added
BIN
+426 Bytes
src/main/resources/assets/appliedenergistics2/textures/blocks/BlockHDChestTop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+391 Bytes
...n/resources/assets/appliedenergistics2/textures/blocks/BlockHDChestTopParts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+434 Bytes
src/main/resources/assets/appliedenergistics2/textures/blocks/BlockLegacyChest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+398 Bytes
...resources/assets/appliedenergistics2/textures/blocks/BlockLegacyChestBottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+447 Bytes
.../resources/assets/appliedenergistics2/textures/blocks/BlockLegacyChestFront.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+427 Bytes
...n/resources/assets/appliedenergistics2/textures/blocks/BlockLegacyChestSide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.