-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
798 additions
and
44 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
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
50 changes: 50 additions & 0 deletions
50
...va/sunsetsatellite/signalindustries/api/impl/btwaila/tooltip/StorageContainerTooltip.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,50 @@ | ||
package sunsetsatellite.signalindustries.api.impl.btwaila.tooltip; | ||
|
||
import net.minecraft.core.block.Block; | ||
import sunsetsatellite.signalindustries.SignalIndustries; | ||
import sunsetsatellite.signalindustries.inventories.TileEntitySIFluidTank; | ||
import sunsetsatellite.signalindustries.inventories.TileEntityStorageContainer; | ||
import sunsetsatellite.signalindustries.inventories.base.TileEntityTieredMachineBase; | ||
import toufoumaster.btwaila.gui.components.AdvancedInfoComponent; | ||
import toufoumaster.btwaila.util.ProgressBarOptions; | ||
import toufoumaster.btwaila.util.TextureOptions; | ||
|
||
public class StorageContainerTooltip extends SIBaseTooltip<TileEntityStorageContainer> { | ||
@Override | ||
public void initTooltip() { | ||
this.addClass(TileEntityStorageContainer.class); | ||
} | ||
|
||
@Override | ||
public void drawAdvancedTooltip(TileEntityStorageContainer tile, AdvancedInfoComponent c) { | ||
if(tile.contents != null){ | ||
int color = 0x00FF00; | ||
float ratio = (float) tile.contents.stackSize / tile.capacity; | ||
if(ratio >= 0.5f && ratio < 0.8f){ | ||
color = 0xFFFF00; | ||
} else if (ratio >= 0.8f) { | ||
color = 0xFF0000; | ||
} | ||
if(tile.locked){ | ||
c.drawStringWithShadow("Locked",0,0xFFFF00); | ||
} | ||
c.drawStringWithShadow("Holding: "+tile.contents.stackSize+"x "+tile.contents.getDisplayName(),0); | ||
ProgressBarOptions options = new ProgressBarOptions() | ||
.setForegroundOptions(new TextureOptions(color, Block.sand.atlasIndices[0])) | ||
.setBackgroundOptions(new TextureOptions(0, SignalIndustries.realityFabric.atlasIndices[0])) | ||
.setText("Capacity: "); | ||
c.drawProgressBarTextureWithText(tile.contents.stackSize,tile.capacity,options,0); | ||
} else { | ||
if(tile.locked){ | ||
c.drawStringWithShadow("Locked",0,0xFFFF00); | ||
} | ||
c.drawStringWithShadow("Empty",0); | ||
ProgressBarOptions options = new ProgressBarOptions() | ||
.setForegroundOptions(new TextureOptions(0x00FF00, Block.sand.atlasIndices[0])) | ||
.setBackgroundOptions(new TextureOptions(0, SignalIndustries.realityFabric.atlasIndices[0])) | ||
.setText("Capacity: "); | ||
c.drawProgressBarTextureWithText(0,tile.capacity,options,0); | ||
} | ||
|
||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
src/main/java/sunsetsatellite/signalindustries/blocks/BlockStorageContainer.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,122 @@ | ||
package sunsetsatellite.signalindustries.blocks; | ||
|
||
|
||
import net.minecraft.core.block.entity.TileEntity; | ||
import net.minecraft.core.block.material.Material; | ||
import net.minecraft.core.entity.EntityItem; | ||
import net.minecraft.core.entity.player.EntityPlayer; | ||
import net.minecraft.core.item.ItemStack; | ||
import net.minecraft.core.item.tool.ItemTool; | ||
import net.minecraft.core.player.gamemode.Gamemode; | ||
import net.minecraft.core.util.helper.Side; | ||
import net.minecraft.core.util.helper.Sides; | ||
import net.minecraft.core.world.World; | ||
import net.minecraft.core.world.WorldSource; | ||
import sunsetsatellite.catalyst.core.util.Direction; | ||
import sunsetsatellite.catalyst.core.util.Vec3f; | ||
import sunsetsatellite.signalindustries.SignalIndustries; | ||
import sunsetsatellite.signalindustries.blocks.base.BlockContainerTiered; | ||
import sunsetsatellite.signalindustries.inventories.TileEntityStorageContainer; | ||
import sunsetsatellite.signalindustries.util.Tier; | ||
|
||
import java.util.Random; | ||
|
||
public class BlockStorageContainer extends BlockContainerTiered { | ||
public BlockStorageContainer(String key, int i, Tier tier, Material material) { | ||
super(key, i, tier, material); | ||
withTags(SignalIndustries.ITEM_CONDUITS_CONNECT); | ||
} | ||
|
||
@Override | ||
protected TileEntity getNewBlockEntity() { | ||
return new TileEntityStorageContainer(); | ||
} | ||
|
||
@Override | ||
public void onBlockRemoved(World world, int i, int j, int k, int data) { | ||
TileEntityStorageContainer tile = (TileEntityStorageContainer) world.getBlockTileEntity(i, j, k); | ||
if (tile != null && tile.contents != null && tier != Tier.INFINITE) { | ||
Random random = new Random(); | ||
float f = random.nextFloat() * 0.8F + 0.1F; | ||
float f1 = random.nextFloat() * 0.8F + 0.1F; | ||
float f2 = random.nextFloat() * 0.8F + 0.1F; | ||
EntityItem entityitem = new EntityItem(world, (float) i + f, (float) j + f1, (float) k + f2, tile.contents.copy()); | ||
float f3 = 0.05F; | ||
entityitem.xd = (float) random.nextGaussian() * f3; | ||
entityitem.yd = (float) random.nextGaussian() * f3 + 0.2F; | ||
entityitem.zd = (float) random.nextGaussian() * f3; | ||
world.entityJoinedWorld(entityitem); | ||
} | ||
super.onBlockRemoved(world, i, j, k, data); | ||
} | ||
|
||
@Override | ||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { | ||
super.onBlockClicked(world, x, y, z, player); | ||
TileEntityStorageContainer tile = (TileEntityStorageContainer) world.getBlockTileEntity(x, y, z); | ||
if (tile != null) { | ||
if(player.getCurrentEquippedItem() == null || !(player.getCurrentEquippedItem().getItem() instanceof ItemTool)){ | ||
ItemStack stack; | ||
if(!player.isSneaking()){ | ||
stack = tile.extractStack(1); | ||
} else { | ||
stack = tile.extractStack(); | ||
} | ||
if(stack != null){ | ||
Vec3f vec = new Vec3f(x,y,z).add(Direction.getDirectionFromSide(world.getBlockMetadata(x,y,z)).getVecF()).add(0.5f); | ||
EntityItem entityitem = new EntityItem(world, vec.x, vec.y, vec.z, stack); | ||
world.entityJoinedWorld(entityitem); | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public boolean blockActivated(World world, int i, int j, int k, EntityPlayer player) | ||
{ | ||
TileEntityStorageContainer tile = (TileEntityStorageContainer) world.getBlockTileEntity(i, j, k); | ||
if (tile != null) { | ||
if(player.getCurrentEquippedItem() != null) { | ||
if (player.getCurrentEquippedItem().animationsToGo <= 0) { | ||
ItemStack stack = player.getCurrentEquippedItem().copy(); | ||
stack.stackSize = 1; | ||
if(tile.insertStack(stack)){ | ||
player.getCurrentEquippedItem().stackSize--; | ||
if(player.getCurrentEquippedItem().stackSize <= 0){ | ||
player.destroyCurrentEquippedItem(); | ||
} else { | ||
player.getCurrentEquippedItem().animationsToGo = 5; | ||
} | ||
} | ||
} else { | ||
tile.insertStack(player.getCurrentEquippedItem()); | ||
if(player.getCurrentEquippedItem().stackSize <= 0){ | ||
player.destroyCurrentEquippedItem(); | ||
} else { | ||
player.getCurrentEquippedItem().animationsToGo = 5; | ||
} | ||
} | ||
return true; | ||
} else { | ||
if(tile.infinite && player.gamemode == Gamemode.creative){ | ||
tile.contents = null; | ||
} else { | ||
tile.locked = !tile.locked; | ||
if(tile.locked){ | ||
player.addChatMessage("event.signalindustries.containerLocked"); | ||
} else { | ||
player.addChatMessage("event.signalindustries.containerUnlocked"); | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int getBlockTexture(WorldSource blockAccess, int x, int y, int z, Side side) { | ||
int meta = blockAccess.getBlockMetadata(x,y,z); | ||
int index = Sides.orientationLookUpHorizontal[6 * meta + side.getId()]; | ||
return this.atlasIndices[index]; | ||
} | ||
} |
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
Oops, something went wrong.