Added laser wrench mode switch.

Closes #119
This commit is contained in:
Ellpeck 2016-06-15 17:42:55 +02:00
parent 03215e3b5b
commit 718c999f70
5 changed files with 60 additions and 15 deletions

View file

@ -110,7 +110,7 @@ public class InitBooklet{
//RF Using Blocks
new BookletChapter("fireworkBox", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFireworkBox), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityFireworkBox.USE_PER_SHOT), new PageCrafting(2, BlockCrafting.recipeFireworkBox)).setSpecial();
new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1).addTextReplacement("<range>", TileEntityLaserRelay.MAX_DISTANCE).addTextReplacement("<loss>", ConfigIntValues.LASER_RELAY_LOSS.getValue()), new PagePicture(2, "pageLaserRelay", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLaserRelay).setNoText().setPageStacksWildcard(), new PageCrafting(4, ItemCrafting.recipeLaserWrench).setNoText()).setImportant();
new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1).addTextReplacement("<range>", TileEntityLaserRelay.MAX_DISTANCE).addTextReplacement("<loss>", ConfigIntValues.LASER_RELAY_LOSS.getValue()), new PagePicture(2, "pageLaserRelay", 0).setNoText(), new PageCrafting(3, BlockCrafting.recipeLaserRelay).setNoText().setPageStacksWildcard(), new PageCrafting(4, ItemCrafting.recipeLaserWrench)).setImportant();
new BookletChapter("miner", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockMiner), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityMiner.ENERGY_USE_PER_BLOCK).addTextReplacement("<range>", TileEntityMiner.DEFAULT_RANGE), new PageCrafting(2, BlockCrafting.recipeMiner)).setSpecial();
new BookletChapterCoffee("coffeeMachine", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockCoffeeMachine), new PageTextOnly(1).setStack(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("<rf>", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("<coffee>", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("<water>", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).setStack(new ItemStack(InitItems.itemCoffee)), new PagePicture(3, "pageCoffeeMachine", 115), new PageCrafting(4, BlockCrafting.recipeCoffeeMachine).setNoText().setPageStacksWildcard(), new PageCrafting(5, ItemCrafting.recipeCup).setNoText()).setImportant();
new BookletChapterCrusher("crusher", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockGrinderDouble), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityGrinder.ENERGY_USE), new PageCrafting(2, BlockCrafting.recipeCrusher).setNoText().setPageStacksWildcard(), new PageCrafting(3, BlockCrafting.recipeDoubleCrusher).setNoText().setPageStacksWildcard(), new PageCrusherRecipe(4, CrusherCrafting.recipeIronHorseArmor).setNoText(), new PageCrusherRecipe(5, CrusherCrafting.recipeGoldHorseArmor).setNoText(), new PageCrusherRecipe(6, CrusherCrafting.recipeDiamondHorseArmor).setNoText());

View file

@ -52,7 +52,6 @@ public enum ConfigBoolValues{
BOOKLET_TEXT_TO_FILE("Booklet Text to File", ConfigCategories.OTHER, false, "Should the entire text of the booklet be put into a new file in the Minecraft Folder on startup or resource reload. This is for debug purposes only and shouldn't really ever be needed."),
WATER_BOWL("Water Bowl", ConfigCategories.OTHER, true, "If right-clicking a bowl on water should create a water bowl"),
LASER_WRENCH_HOLDING_PARTICLES("Laser Wrench Holding Particles", ConfigCategories.OTHER, false, "If particles of laser devices should only render when holding a Laser Wrench"),
LESS_SOUND("Less Sound", ConfigCategories.PERFORMANCE, false, "If blocks in Actually Additions should have less sounds"),
LESS_PARTICLES("Less Particles", ConfigCategories.PERFORMANCE, false, "If blocks in Actually Additions should have less particles"),

View file

@ -10,20 +10,26 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.World;
@ -39,12 +45,11 @@ public class ItemLaserWrench extends ItemBase{
this.setMaxStackSize(1);
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing par7, float par8, float par9, float par10){
if(!world.isRemote){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityLaserRelay){
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityLaserRelay){
if(!world.isRemote){
if(ItemPhantomConnector.getStoredPosition(stack) == null){
ItemPhantomConnector.storeConnection(stack, pos.getX(), pos.getY(), pos.getZ(), world);
player.addChatComponentMessage(new TextComponentTranslation("tooltip."+ModUtil.MOD_ID+".laser.stored.desc"));
@ -67,12 +72,35 @@ public class ItemLaserWrench extends ItemBase{
}
}
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.SUCCESS;
}
return EnumActionResult.FAIL;
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){
if(!world.isRemote && player.isSneaking()){
PlayerData.PlayerSave save = PlayerData.getDataFromPlayer(player);
int currMode = save.theCompound.getInteger("LaserWrenchMode");
if(currMode+1 >= WrenchMode.values().length){
currMode = 0;
}
else{
currMode++;
}
save.theCompound.setInteger("LaserWrenchMode", currMode);
if(player instanceof EntityPlayerMP){
PacketHandler.theNetwork.sendTo(new PacketServerToClient(save.theCompound, PacketHandler.PLAYER_DATA_TO_CLIENT_HANDLER), (EntityPlayerMP)player);
}
player.addChatComponentMessage(new TextComponentString("Mode changed to "+WrenchMode.values()[currMode].name+"!"));
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
@Override
public boolean getShareTag(){
return true;
@ -98,9 +126,20 @@ public class ItemLaserWrench extends ItemBase{
}
}
@Override
public EnumRarity getRarity(ItemStack stack){
return EnumRarity.EPIC;
}
public enum WrenchMode{
ALWAYS_PARTICLES("always show particles"),
NO_PARTICLES("never show particles"),
HOLDING_PARTICLES("show particles when holding a Laser Wrench");
public String name;
WrenchMode(String name){
this.name = name;
}
}
}

View file

@ -11,7 +11,9 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench.WrenchMode;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.mod.misc.LaserRelayConnectionHandler.ConnectionPair;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
@ -98,13 +100,17 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
if(Util.RANDOM.nextInt(ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 16 : 8) == 0){
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if(player != null){
ItemStack stack = player.getHeldItemMainhand();
if(!ConfigBoolValues.LASER_WRENCH_HOLDING_PARTICLES.isEnabled() || (stack != null && stack.getItem() instanceof ItemLaserWrench)){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getNetworkFor(this.pos, this.worldObj);
if(network != null){
for(ConnectionPair aPair : network.connections){
if(aPair.contains(this.pos) && PosUtil.areSamePos(this.pos, aPair.positions[0])){
AssetUtil.renderParticlesFromAToB(aPair.positions[0].getX(), aPair.positions[0].getY(), aPair.positions[0].getZ(), aPair.positions[1].getX(), aPair.positions[1].getY(), aPair.positions[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F);
PlayerData.PlayerSave data = PlayerData.getDataFromPlayer(player);
WrenchMode mode = WrenchMode.values()[data.theCompound.getInteger("LaserWrenchMode")];
if(mode != WrenchMode.NO_PARTICLES){
ItemStack stack = player.getHeldItemMainhand();
if(mode == WrenchMode.ALWAYS_PARTICLES || (stack != null && stack.getItem() instanceof ItemLaserWrench)){
LaserRelayConnectionHandler.Network network = LaserRelayConnectionHandler.getNetworkFor(this.pos, this.worldObj);
if(network != null){
for(ConnectionPair aPair : network.connections){
if(aPair.contains(this.pos) && PosUtil.areSamePos(this.pos, aPair.positions[0])){
AssetUtil.renderParticlesFromAToB(aPair.positions[0].getX(), aPair.positions[0].getY(), aPair.positions[0].getZ(), aPair.positions[1].getX(), aPair.positions[1].getY(), aPair.positions[1].getZ(), ConfigBoolValues.LESS_PARTICLES.isEnabled() ? 1 : Util.RANDOM.nextInt(3)+1, 0.8F, this.isItem ? COLOR_ITEM : COLOR, 1F);
}
}
}
}

View file

@ -822,6 +822,7 @@ booklet.actuallyadditions.chapter.hairBalls.text.2=<item>Balls of Fur<r> are an
booklet.actuallyadditions.chapter.laserRelays.name=Laser Relays
booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Laser Relay<r> is a block that can <imp>wirelessly transfer RF<r> just by being connected with a <item>Laser Wrench<r>, generating a network. <n>When placing a Power Generator or Receiver next to the relay, it can receive Power <imp>from any other relay<r> in the network. <n>Two relays can be at most <range> blocks apart. <n>During an energy transfer, they have an <imp>Energy Loss<r> of <loss>%.
booklet.actuallyadditions.chapter.laserRelays.text.4=The <item>Laser Wrench<r>'s mode can be switched by <imp>sneak-right-clicking it<r> anywhere. <n>Possible modes are to <imp>always show lasers<r>, <imp>never show lasers<r> or only show lasers when <imp>holding the wrench<r>.
booklet.actuallyadditions.chapter.blackLotus.name=Black Lotus
booklet.actuallyadditions.chapter.blackLotus.text.1=Think of this: <n>You need to craft <imp>black wool<r>, <imp>black clay<r> or anything else that <imp>needs black dye<r> but you are just guilty about killing so many <imp>innocent squids<r>? <n>Well, the <item>Black Lotus<r> is exactly the thing you need! <n>Just look around <imp>in the wild<r> a bit, and you will find one, then being able to craft some <item>Black Dye<r> that can be used <imp>instead of Ink Sacs<r> so that you don't need to kill poor squids and L any longer.