mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 07:13:28 +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.
|
ALL RIGHTS RESERVED.
|
||||||
|
|
||||||
For more Information, check the README.md file.
|
For more Information, check the README.md file.
|
||||||
|
|
||||||
|
© 2015 Ellpeck
|
|
@ -123,3 +123,10 @@
|
||||||
-Weeping Angel-like Statues
|
-Weeping Angel-like Statues
|
||||||
-Only move when you don't look
|
-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.config.values.ConfigIntValues;
|
||||||
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
import ellpeck.actuallyadditions.tile.IPhantomTile;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlacer;
|
||||||
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomPlayerface;
|
||||||
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
import ellpeck.actuallyadditions.tile.TileEntityPhantomface;
|
||||||
import ellpeck.actuallyadditions.util.*;
|
import ellpeck.actuallyadditions.util.*;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
@ -26,16 +27,19 @@ import java.util.List;
|
||||||
|
|
||||||
public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||||
|
|
||||||
public static final int FACE = 0;
|
public enum Type{
|
||||||
public static final int PLACER = 1;
|
FACE,
|
||||||
public static final int BREAKER = 2;
|
PLACER,
|
||||||
public static final int LIQUIFACE = 3;
|
BREAKER,
|
||||||
public static final int ENERGYFACE = 4;
|
LIQUIFACE,
|
||||||
|
ENERGYFACE,
|
||||||
|
PLAYERFACE
|
||||||
|
}
|
||||||
|
|
||||||
public int type;
|
public Type type;
|
||||||
public int range;
|
public int range;
|
||||||
|
|
||||||
public BlockPhantom(int type){
|
public BlockPhantom(Type type){
|
||||||
super(Material.rock);
|
super(Material.rock);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
this.setHarvestLevel("pickaxe", 0);
|
||||||
|
@ -43,17 +47,17 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||||
this.setResistance(10.0F);
|
this.setResistance(10.0F);
|
||||||
this.setStepSound(soundTypeStone);
|
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();
|
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();
|
this.range = ConfigIntValues.PHANTOM_PLACER_RANGE.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, int x, int y, int z, Block block, int par6){
|
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);
|
super.breakBlock(world, x, y, z, block, par6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +66,13 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntity tile = world.getTileEntity(x, y, z);
|
TileEntity tile = world.getTileEntity(x, y, z);
|
||||||
if(tile != null){
|
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;
|
IPhantomTile phantom = (IPhantomTile)tile;
|
||||||
if(player.isSneaking() || phantom.getGuiID() == -1){
|
if(player.isSneaking() || phantom.getGuiID() == -1){
|
||||||
player.addChatComponentMessage(new ChatComponentText(StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomRange.desc") + ": " + phantom.getRange()));
|
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();
|
return new TileEntityPhantomface.TileEntityPhantomLiquiface();
|
||||||
case ENERGYFACE:
|
case ENERGYFACE:
|
||||||
return new TileEntityPhantomface.TileEntityPhantomEnergyface();
|
return new TileEntityPhantomface.TileEntityPhantomEnergyface();
|
||||||
|
case PLAYERFACE:
|
||||||
|
return new TileEntityPhantomPlayerface();
|
||||||
default:
|
default:
|
||||||
return new TileEntityPhantomface.TileEntityPhantomItemface();
|
return new TileEntityPhantomface.TileEntityPhantomItemface();
|
||||||
}
|
}
|
||||||
|
@ -122,6 +134,8 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||||
return "blockPhantomLiquiface";
|
return "blockPhantomLiquiface";
|
||||||
case ENERGYFACE:
|
case ENERGYFACE:
|
||||||
return "blockPhantomEnergyface";
|
return "blockPhantomEnergyface";
|
||||||
|
case PLAYERFACE:
|
||||||
|
return "blockPhantomPlayerface";
|
||||||
default:
|
default:
|
||||||
return "blockPhantomface";
|
return "blockPhantomface";
|
||||||
}
|
}
|
||||||
|
@ -154,7 +168,7 @@ public class BlockPhantom extends BlockContainerBase implements INameableItem{
|
||||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean isHeld) {
|
||||||
BlockUtil.addInformation(theBlock, list, 2, "");
|
BlockUtil.addInformation(theBlock, list, 2, "");
|
||||||
if(KeyUtil.isShiftPressed()){
|
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.3"));
|
||||||
list.add(StringUtil.ORANGE+StringUtil.localize("tooltip."+ModUtil.MOD_ID_LOWER+".blockPhantomLiquiface.desc.4"));
|
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 blockPhantomBreaker;
|
||||||
public static Block blockPhantomLiquiface;
|
public static Block blockPhantomLiquiface;
|
||||||
public static Block blockPhantomEnergyface;
|
public static Block blockPhantomEnergyface;
|
||||||
|
public static Block blockPhantomPlayerface;
|
||||||
|
|
||||||
public static Block blockFluidPlacer;
|
public static Block blockFluidPlacer;
|
||||||
public static Block blockFluidCollector;
|
public static Block blockFluidCollector;
|
||||||
|
@ -126,21 +127,24 @@ public class InitBlocks{
|
||||||
blockCanolaPress = new BlockCanolaPress();
|
blockCanolaPress = new BlockCanolaPress();
|
||||||
BlockUtil.register(blockCanolaPress, BlockCanolaPress.TheItemBlock.class);
|
BlockUtil.register(blockCanolaPress, BlockCanolaPress.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomface = new BlockPhantom(BlockPhantom.FACE);
|
blockPhantomface = new BlockPhantom(BlockPhantom.Type.FACE);
|
||||||
BlockUtil.register(blockPhantomface, BlockPhantom.TheItemBlock.class);
|
BlockUtil.register(blockPhantomface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomPlacer = new BlockPhantom(BlockPhantom.PLACER);
|
blockPhantomPlacer = new BlockPhantom(BlockPhantom.Type.PLACER);
|
||||||
BlockUtil.register(blockPhantomPlacer, BlockPhantom.TheItemBlock.class);
|
BlockUtil.register(blockPhantomPlacer, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomLiquiface = new BlockPhantom(BlockPhantom.LIQUIFACE);
|
blockPhantomLiquiface = new BlockPhantom(BlockPhantom.Type.LIQUIFACE);
|
||||||
BlockUtil.register(blockPhantomLiquiface, BlockPhantom.TheItemBlock.class);
|
BlockUtil.register(blockPhantomLiquiface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomEnergyface = new BlockPhantom(BlockPhantom.ENERGYFACE);
|
blockPhantomEnergyface = new BlockPhantom(BlockPhantom.Type.ENERGYFACE);
|
||||||
BlockUtil.register(blockPhantomEnergyface, BlockPhantom.TheItemBlock.class);
|
BlockUtil.register(blockPhantomEnergyface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockPhantomBreaker = new BlockPhantom(BlockPhantom.BREAKER);
|
blockPhantomBreaker = new BlockPhantom(BlockPhantom.Type.BREAKER);
|
||||||
BlockUtil.register(blockPhantomBreaker, BlockPhantom.TheItemBlock.class);
|
BlockUtil.register(blockPhantomBreaker, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
|
blockPhantomPlayerface = new BlockPhantom(BlockPhantom.Type.PLAYERFACE);
|
||||||
|
BlockUtil.register(blockPhantomPlayerface, BlockPhantom.TheItemBlock.class);
|
||||||
|
|
||||||
blockCoalGenerator = new BlockCoalGenerator();
|
blockCoalGenerator = new BlockCoalGenerator();
|
||||||
BlockUtil.register(blockCoalGenerator, BlockCoalGenerator.TheItemBlock.class);
|
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 WorldPos boundPosition;
|
||||||
|
|
||||||
public int type;
|
public BlockPhantom.Type type;
|
||||||
|
|
||||||
public final int defaultRange = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
public final int defaultRange = ConfigIntValues.PHANTOMFACE_RANGE.getValue();
|
||||||
public int range;
|
public int range;
|
||||||
|
@ -151,7 +151,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
|
|
||||||
public TileEntityPhantomLiquiface(){
|
public TileEntityPhantomLiquiface(){
|
||||||
super("liquiface");
|
super("liquiface");
|
||||||
this.type = BlockPhantom.LIQUIFACE;
|
this.type = BlockPhantom.Type.LIQUIFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -241,7 +241,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
|
|
||||||
public TileEntityPhantomEnergyface(){
|
public TileEntityPhantomEnergyface(){
|
||||||
super("energyface");
|
super("energyface");
|
||||||
this.type = BlockPhantom.ENERGYFACE;
|
this.type = BlockPhantom.Type.ENERGYFACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -334,7 +334,7 @@ public class TileEntityPhantomface extends TileEntityInventoryBase implements IP
|
||||||
|
|
||||||
public TileEntityPhantomItemface(){
|
public TileEntityPhantomItemface(){
|
||||||
super("phantomface");
|
super("phantomface");
|
||||||
this.type = BlockPhantom.FACE;
|
this.type = BlockPhantom.Type.FACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IInventory getInventory(){
|
public IInventory getInventory(){
|
||||||
|
|
Loading…
Reference in a new issue