mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 11:29:23 +01:00
Started work on Playerfaces, might kind of work a bit maybe but I didn't test it yet because I don't want to
This commit is contained in:
parent
cdd101d395
commit
1b3cf54155
6 changed files with 160 additions and 22 deletions
2
LICENSE
2
LICENSE
|
@ -1,3 +1,5 @@
|
|||
ALL RIGHTS RESERVED.
|
||||
|
||||
For more Information, check the README.md file.
|
||||
|
||||
© 2015 Ellpeck
|
|
@ -122,4 +122,11 @@
|
|||
|
||||
-Weeping Angel-like Statues
|
||||
-Only move when you don't look
|
||||
-Teleport you away
|
||||
-Teleport you away
|
||||
|
||||
-ME Phantomface
|
||||
|
||||
-Redstone Phantomface
|
||||
|
||||
-Player Phantomface
|
||||
-Boosters make it work across dimensions
|
|
@ -6,6 +6,7 @@ import ellpeck.actuallyadditions.ActuallyAdditions;
|
|||
import ellpeck.actuallyadditions.config.values.ConfigIntValues;
|
||||
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlayerface;
|
||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
||||
import ellpeck.actuallyadditions.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -26,16 +27,19 @@ import java.util.List;
|
|||
|
||||
public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||
|
||||
public static final int FACE = 0;
|
||||
public static final int PLACER = 1;
|
||||
public static final int BREAKER = 2;
|
||||
public static final int LIQUIFACE = 3;
|
||||
public static final int ENERGYFACE = 4;
|
||||
public enum Type{
|
||||
FACE,
|
||||
PLACER,
|
||||
BREAKER,
|
||||
LIQUIFACE,
|
||||
ENERGYFACE,
|
||||
PLAYERFACE
|
||||
}
|
||||
|
||||
public int type;
|
||||
public Type type;
|
||||
public int range;
|
||||
|
||||
public BlockPhantom(int type){
|
||||
public BlockPhantom(Type type){
|
||||
super(Material.rock);
|
||||
this.type = type;
|
||||
this.setHarvestLevel("pickaxe", 0);
|
||||
|
@ -43,17 +47,17 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
|||
this.setResistance(10.0F);
|
||||
this.setStepSound(soundTypeStone);
|
||||
|
||||
if(type == FACE || type == LIQUIFACE || type == ENERGYFACE){
|
||||
if(type == Type.FACE || type == Type.LIQUIFACE || type == Type.ENERGYFACE){
|
||||
this.range = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
||||
}
|
||||
else if(type == BREAKER || type == PLACER){
|
||||
else if(type == Type.BREAKER || type == Type.PLACER){
|
||||
this.range = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
||||
if(this.type == PLACER || this.type == BREAKER) this.dropInventory(world, x, y, z);
|
||||
if(this.type == Type.PLACER || this.type == Type.BREAKER) this.dropInventory(world, x, y, z);
|
||||
super.breakBlock(world, x, y, z, block, par6);
|
||||
}
|
||||
|
||||
|
@ -62,7 +66,13 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
|||
if(!world.isRemote){
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null){
|
||||
if(tile instanceof IPhantomTile){
|
||||
if(tile instanceof TileEntityPhantomPlayerface){
|
||||
TileEntityPhantomPlayerface phantom = (TileEntityPhantomPlayerface)tile;
|
||||
if(player.isSneaking()){
|
||||
phantom.boundPlayerUUID = player.getUniqueID().toString();
|
||||
}
|
||||
}
|
||||
else if(tile instanceof IPhantomTile){
|
||||
IPhantomTile phantom = (IPhantomTile)tile;
|
||||
if(player.isSneaking() || phantom.getGuiID() == -1){
|
||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.getRange()));
|
||||
|
@ -95,6 +105,8 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
|||
return new TileEntityPhantomface.TileEntityPhantomLiquiface();
|
||||
case ENERGYFACE:
|
||||
return new TileEntityPhantomface.TileEntityPhantomEnergyface();
|
||||
case PLAYERFACE:
|
||||
return new TileEntityPhantomPlayerface();
|
||||
default:
|
||||
return new TileEntityPhantomface.TileEntityPhantomItemface();
|
||||
}
|
||||
|
@ -122,6 +134,8 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
|||
return "blockPhantomLiquiface";
|
||||
case ENERGYFACE:
|
||||
return "blockPhantomEnergyface";
|
||||
case PLAYERFACE:
|
||||
return "blockPhantomPlayerface";
|
||||
default:
|
||||
return "blockPhantomface";
|
||||
}
|
||||
|
@ -154,7 +168,7 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
|||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||
BlockUtil.addInformation(theBlock, list, 2, "");
|
||||
if(KeyUtil.isShiftPressed()){
|
||||
if(((BlockPhantom)this.theBlock).type == LIQUIFACE){
|
||||
if(((BlockPhantom)this.theBlock).type == Type.LIQUIFACE){
|
||||
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.3"));
|
||||
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.4"));
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ public class InitBlocks{
|
|||
public static Block blockPhantomBreaker;
|
||||
public static Block blockPhantomLiquiface;
|
||||
public static Block blockPhantomEnergyface;
|
||||
public static Block blockPhantomPlayerface;
|
||||
|
||||
public static Block blockFluidPlacer;
|
||||
public static Block blockFluidCollector;
|
||||
|
@ -126,21 +127,24 @@ public class InitBlocks{
|
|||
blockCanolaPress = new BlockCanolaPress();
|
||||
BlockUtil.register(blockCanolaPress, BlockCanolaPress.TheItemBlock.class);
|
||||
|
||||
blockPhantomface = new BlockPhantom(BlockPhantom.FACE);
|
||||
blockPhantomface = new BlockPhantom(BlockPhantom.Type.FACE);
|
||||
BlockUtil.register(blockPhantomface, BlockPhantom.TheItemBlock.class);
|
||||
|
||||
blockPhantomPlacer = new BlockPhantom(BlockPhantom.PLACER);
|
||||
blockPhantomPlacer = new BlockPhantom(BlockPhantom.Type.PLACER);
|
||||
BlockUtil.register(blockPhantomPlacer, BlockPhantom.TheItemBlock.class);
|
||||
|
||||
blockPhantomLiquiface = new BlockPhantom(BlockPhantom.LIQUIFACE);
|
||||
blockPhantomLiquiface = new BlockPhantom(BlockPhantom.Type.LIQUIFACE);
|
||||
BlockUtil.register(blockPhantomLiquiface, BlockPhantom.TheItemBlock.class);
|
||||
|
||||
blockPhantomEnergyface = new BlockPhantom(BlockPhantom.ENERGYFACE);
|
||||
blockPhantomEnergyface = new BlockPhantom(BlockPhantom.Type.ENERGYFACE);
|
||||
BlockUtil.register(blockPhantomEnergyface, BlockPhantom.TheItemBlock.class);
|
||||
|
||||
blockPhantomBreaker = new BlockPhantom(BlockPhantom.BREAKER);
|
||||
blockPhantomBreaker = new BlockPhantom(BlockPhantom.Type.BREAKER);
|
||||
BlockUtil.register(blockPhantomBreaker, BlockPhantom.TheItemBlock.class);
|
||||
|
||||
blockPhantomPlayerface = new BlockPhantom(BlockPhantom.Type.PLAYERFACE);
|
||||
BlockUtil.register(blockPhantomPlayerface, BlockPhantom.TheItemBlock.class);
|
||||
|
||||
blockCoalGenerator = new BlockCoalGenerator();
|
||||
BlockUtil.register(blockCoalGenerator, BlockCoalGenerator.TheItemBlock.class);
|
||||
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package ellpeck.actuallyadditions.tile;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityPhantomPlayerface extends TileEntityInventoryBase{
|
||||
|
||||
public String boundPlayerUUID;
|
||||
private String boundPlayerBefore;
|
||||
|
||||
public TileEntityPhantomPlayerface(){
|
||||
super(0, "phantomPlayerface");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity(){
|
||||
if(!this.boundPlayerBefore.equals(this.boundPlayerUUID)){
|
||||
this.boundPlayerBefore = this.boundPlayerUUID;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public InventoryPlayer getInventory(){
|
||||
if(!worldObj.isRemote && this.boundPlayerUUID != null){
|
||||
List<EntityPlayer> list = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
|
||||
for(EntityPlayer player : list){
|
||||
if(!player.getUniqueID().toString().equals(this.boundPlayerUUID)){
|
||||
return player.inventory;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasInventory(){
|
||||
return this.getInventory() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit(){
|
||||
return this.hasInventory() ? this.getInventory().getInventoryStackLimit() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
||||
return this.hasInventory() && this.getInventory().isItemValidForSlot(i, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i){
|
||||
return this.hasInventory() ? this.getInventory().getStackInSlotOnClosing(i) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack stack){
|
||||
if(this.hasInventory()) this.getInventory().setInventorySlotContents(i, stack);
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory(){
|
||||
return this.hasInventory() ? this.getInventory().getSizeInventory() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i){
|
||||
return this.hasInventory() ? this.getInventory().getStackInSlot(i) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j){
|
||||
return this.hasInventory() ? this.getInventory().decrStackSize(i, j) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName(){
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side){
|
||||
if(this.hasInventory()){
|
||||
int[] theInt = new int[this.getSizeInventory()];
|
||||
for(int i = 0; i < theInt.length; i++){
|
||||
theInt[i] = i;
|
||||
}
|
||||
return theInt;
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slot, ItemStack stack, int side){
|
||||
return this.hasInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slot, ItemStack stack, int side){
|
||||
return this.hasInventory();
|
||||
}
|
||||
|
||||
}
|
|
@ -27,7 +27,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
public WorldPos boundPosition;
|
||||
|
||||
public int type;
|
||||
public BlockPhantom.Type type;
|
||||
|
||||
public final int defaultRange = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
||||
public int range;
|
||||
|
@ -151,7 +151,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
public TileEntityPhantomLiquiface(){
|
||||
super("liquiface");
|
||||
this.type = BlockPhantom.LIQUIFACE;
|
||||
this.type = BlockPhantom.Type.LIQUIFACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,7 +241,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
public TileEntityPhantomEnergyface(){
|
||||
super("energyface");
|
||||
this.type = BlockPhantom.ENERGYFACE;
|
||||
this.type = BlockPhantom.Type.ENERGYFACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -334,7 +334,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
|||
|
||||
public TileEntityPhantomItemface(){
|
||||
super("phantomface");
|
||||
this.type = BlockPhantom.FACE;
|
||||
this.type = BlockPhantom.Type.FACE;
|
||||
}
|
||||
|
||||
public IInventory getInventory(){
|
||||
|
|
Loading…
Reference in a new issue