use of net.minecraftforge.common.util.FakePlayer in project TecTech by Technus.
the class ConstructableTriggerItem method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
return aPlayer instanceof EntityPlayerMP;
}
if (aPlayer instanceof EntityPlayerMP) {
// struct gen
if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) {
if (tTileEntity instanceof IGregTechTileEntity) {
IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
if (metaTE instanceof IConstructable) {
((IConstructable) metaTE).construct(aStack.stackSize, false);
} else if (multiblockMap.containsKey(metaTE.getClass().getCanonicalName())) {
multiblockMap.get(metaTE.getClass().getCanonicalName()).construct(aStack.stackSize, false, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing());
}
} else if (tTileEntity instanceof IConstructable) {
((IConstructable) tTileEntity).construct(aStack.stackSize, false);
} else if (multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())) {
multiblockMap.get(tTileEntity.getClass().getCanonicalName()).construct(aStack.stackSize, false, tTileEntity, aSide);
}
}
return true;
} else if (aPlayer instanceof EntityClientPlayerMP) {
// if ((!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode)) {
if (tTileEntity instanceof IGregTechTileEntity) {
IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
if (metaTE instanceof IConstructable) {
((IConstructable) metaTE).construct(aStack.stackSize, true);
TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize));
return false;
} else if (multiblockMap.containsKey(metaTE.getClass().getCanonicalName())) {
multiblockMap.get(metaTE.getClass().getCanonicalName()).construct(aStack.stackSize, true, tTileEntity, ((IGregTechTileEntity) tTileEntity).getFrontFacing());
TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize));
return false;
}
} else if (tTileEntity instanceof IConstructable) {
((IConstructable) tTileEntity).construct(aStack.stackSize, true);
TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize));
return false;
} else if (multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())) {
multiblockMap.get(tTileEntity.getClass().getCanonicalName()).construct(aStack.stackSize, true, tTileEntity, aSide);
TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize));
return false;
}
// } else {
// if(tTileEntity instanceof IGregTechTileEntity) {
// IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
// if (metaTE instanceof IConstructable) {
// TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize));
// return false;
// } else if(multiblockMap.containsKey(metaTE.getClass().getCanonicalName())){
// TecTech.proxy.printInchat(multiblockMap.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize));
// return false;
// }
// } else if(tTileEntity instanceof IConstructable){
// TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize));
// return false;
// } else if(multiblockMap.containsKey(tTileEntity.getClass().getCanonicalName())){
// TecTech.proxy.printInchat(multiblockMap.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize));
// return false;
// }
// }
}
return false;
}
use of net.minecraftforge.common.util.FakePlayer in project TecTech by Technus.
the class EuMeterGT method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
return aPlayer instanceof EntityPlayerMP;
}
if (aPlayer instanceof EntityPlayerMP && !aPlayer.isSneaking() && tTileEntity instanceof IGregTechTileEntity) {
if (tTileEntity instanceof BaseMetaTileEntity) {
GT_Utility.sendChatToPlayer(aPlayer, EnumChatFormatting.AQUA + "----- X:" + aX + " Y:" + aY + " Z:" + aZ + " D:" + aWorld.provider.dimensionId + " S:" + aSide + " -----");
GT_Utility.sendChatToPlayer(aPlayer, "Stored energy: " + EnumChatFormatting.YELLOW + (((BaseMetaTileEntity) tTileEntity).getUniversalEnergyStored()) + EnumChatFormatting.RESET + '/' + EnumChatFormatting.GREEN + (((BaseMetaTileEntity) tTileEntity).getUniversalEnergyCapacity()));
GT_Utility.sendChatToPlayer(aPlayer, "Stored EU: " + EnumChatFormatting.YELLOW + (((BaseMetaTileEntity) tTileEntity).getStoredEU()) + EnumChatFormatting.RESET + '/' + EnumChatFormatting.GREEN + (((BaseMetaTileEntity) tTileEntity).getEUCapacity()));
GT_Utility.sendChatToPlayer(aPlayer, "Average I/O: " + EnumChatFormatting.YELLOW + (((BaseMetaTileEntity) tTileEntity).getAverageElectricInput()) + EnumChatFormatting.RESET + '/' + EnumChatFormatting.YELLOW + (((BaseMetaTileEntity) tTileEntity).getAverageElectricOutput()));
GT_Utility.sendChatToPlayer(aPlayer, "Voltage I/O (max): " + EnumChatFormatting.GOLD + (((BaseMetaTileEntity) tTileEntity).getInputVoltage()) + EnumChatFormatting.RESET + '/' + EnumChatFormatting.GOLD + (((BaseMetaTileEntity) tTileEntity).getOutputVoltage()));
GT_Utility.sendChatToPlayer(aPlayer, "Voltage I/O max: " + EnumChatFormatting.RED + (((BaseMetaTileEntity) tTileEntity).getMaxSafeInput()) + EnumChatFormatting.RESET + '/' + EnumChatFormatting.RED + (((BaseMetaTileEntity) tTileEntity).getMaxEnergyOutput()));
GT_Utility.sendChatToPlayer(aPlayer, "Amperage I/O (max): " + EnumChatFormatting.GOLD + (((BaseMetaTileEntity) tTileEntity).getInputAmperage()) + EnumChatFormatting.RESET + '/' + EnumChatFormatting.GOLD + (((BaseMetaTileEntity) tTileEntity).getOutputAmperage()));
GT_Utility.sendChatToPlayer(aPlayer, "Side capabilities: " + (((BaseMetaTileEntity) tTileEntity).inputEnergyFrom((byte) aSide) ? "input " : "") + (((BaseMetaTileEntity) tTileEntity).outputsEnergyTo((byte) aSide) ? "output " : ""));
return true;
} else if (tTileEntity instanceof BaseMetaPipeEntity) {
if (((BaseMetaPipeEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable) {
ArrayList<String> tList = new ArrayList<>();
GT_Utility.getCoordinateScan(tList, aPlayer, aWorld, 1, aX, aY, aZ, aSide, hitX, hitY, hitZ);
for (String str : tList) {
GT_Utility.sendChatToPlayer(aPlayer, str);
}
}
return true;
}
}
if (!(aPlayer instanceof EntityPlayerMP)) {
GT_Utility.doSoundAtClient(Reference.MODID + ":fx_scan", 1, 1.0F, (double) aX, (double) aY, (double) aZ);
}
return false;
}
use of net.minecraftforge.common.util.FakePlayer in project TecTech by Technus.
the class FrontRotationTriggerItem method onItemUseFirst.
@Override
public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (tTileEntity == null || aPlayer instanceof FakePlayer) {
return aPlayer instanceof EntityPlayerMP;
}
if (aPlayer instanceof EntityPlayerMP) {
if (tTileEntity instanceof IGregTechTileEntity) {
IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();
if (metaTE instanceof IFrontRotation) {
((IFrontRotation) metaTE).rotateAroundFrontPlane(!aPlayer.isSneaking());
System.out.println("DID SHIT");
return true;
}
} else if (tTileEntity instanceof IFrontRotation) {
((IFrontRotation) tTileEntity).rotateAroundFrontPlane(!aPlayer.isSneaking());
return true;
}
}
return false;
}
use of net.minecraftforge.common.util.FakePlayer in project Wizardry by TeamWizardry.
the class BlockUtils method breakBlock.
/**
* Tries breaking a block safely and fires an event for it.
*
* @return Whether the block was successfully broken
*/
public static boolean breakBlock(@Nonnull World world, @Nonnull BlockPos pos, @Nullable IBlockState oldState, @Nullable EntityPlayerMP player, boolean drop) {
if (!world.isBlockLoaded(pos))
return false;
EntityPlayerMP playerMP;
if (player == null) {
playerMP = new FakePlayer((WorldServer) world, breaker);
playerMP.setPosition(pos.getX(), pos.getY(), pos.getZ());
} else
playerMP = player;
if (player != null && !(player instanceof FakePlayer))
if (!hasBreakPermission(world, pos, playerMP))
return false;
if (oldState == null)
oldState = world.getBlockState(pos);
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(world, pos, oldState, playerMP);
MinecraftForge.EVENT_BUS.post(event);
return !event.isCanceled() && (drop ? world.destroyBlock(pos, true) : world.setBlockToAir(pos));
}
use of net.minecraftforge.common.util.FakePlayer in project BuildCraft by BuildCraft.
the class TileQuarry method forceChunkLoading.
public void forceChunkLoading(Ticket ticket) {
if (chunkTicket == null) {
chunkTicket = ticket;
}
Set<ChunkPos> chunks = Sets.newHashSet();
ChunkPos quarryChunk = new ChunkPos(pos.getX() >> 4, pos.getZ() >> 4);
chunks.add(quarryChunk);
ForgeChunkManager.forceChunk(ticket, quarryChunk);
if (box.isInitialized()) {
for (int chunkX = box.min().getX() >> 4; chunkX <= box.max().getX() >> 4; chunkX++) {
for (int chunkZ = box.min().getZ() >> 4; chunkZ <= box.max().getZ() >> 4; chunkZ++) {
ChunkPos chunk = new ChunkPos(chunkX, chunkZ);
ForgeChunkManager.forceChunk(ticket, chunk);
chunks.add(chunk);
}
}
}
if (placedBy != null && !(placedBy instanceof FakePlayer)) {
placedBy.addChatMessage(new TextComponentTranslation("chat.buildcraft.quarry.chunkloadInfo", getPos().getX(), getPos().getY(), getPos().getZ(), chunks.size()));
}
}
Aggregations