mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
parent
9337a6e6aa
commit
1a9a69a4bd
5 changed files with 11 additions and 65 deletions
|
@ -14,17 +14,10 @@ package de.ellpeck.actuallyadditions.mod.blocks.render;
|
|||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||
import de.ellpeck.actuallyadditions.api.laser.IConnectionPair;
|
||||
import de.ellpeck.actuallyadditions.api.laser.LaserType;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData.PlayerSave;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench;
|
||||
import de.ellpeck.actuallyadditions.mod.items.ItemLaserWrench.WrenchMode;
|
||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityLaserRelay;
|
||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
|
@ -38,26 +31,15 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer{
|
|||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float par5, int par6){
|
||||
if(tile instanceof TileEntityLaserRelay){
|
||||
TileEntityLaserRelay relay = (TileEntityLaserRelay)tile;
|
||||
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());
|
||||
if(connections != null && !connections.isEmpty()){
|
||||
for(IConnectionPair pair : connections){
|
||||
if(!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])){
|
||||
BlockPos first = tile.getPos();
|
||||
BlockPos second = pair.getPositions()[1];
|
||||
float[] color = relay.type == LaserType.ITEM ? COLOR_ITEM : (relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if(player != null){
|
||||
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)){
|
||||
ConcurrentSet<IConnectionPair> connections = ActuallyAdditionsAPI.connectionHandler.getConnectionsFor(tile.getPos(), tile.getWorld());
|
||||
if(connections != null && !connections.isEmpty()){
|
||||
for(IConnectionPair pair : connections){
|
||||
if(!pair.doesSuppressRender() && tile.getPos().equals(pair.getPositions()[0])){
|
||||
BlockPos first = tile.getPos();
|
||||
BlockPos second = pair.getPositions()[1];
|
||||
float[] color = relay.type == LaserType.ITEM ? COLOR_ITEM : (relay.type == LaserType.FLUID ? COLOR_FLUIDS : COLOR);
|
||||
|
||||
AssetUtil.renderLaser(first.getX()+0.5, first.getY()+0.5, first.getZ()+0.5, second.getX()+0.5, second.getY()+0.5, second.getZ()+0.5, 120, 0.5F, 0.05, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
AssetUtil.renderLaser(first.getX()+0.5, first.getY()+0.5, first.getZ()+0.5, second.getX()+0.5, second.getY()+0.5, second.getZ()+0.5, 120, 0.5F, 0.05, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ public final class InitBooklet{
|
|||
//RF Using Blocks
|
||||
new BookletChapter("farmer", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockFarmer), new PageTextOnly(1).addTextReplacement("<energy>", TileEntityFarmer.USE_PER_OPERATION), new PageCrafting(2, BlockCrafting.recipeFarmer).setNoText().setPageStacksWildcard()).setImportant();
|
||||
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), new PageTextOnly(2).addTextReplacement("<cap1>", TileEntityLaserRelayEnergy.CAP).addTextReplacement("<cap2>", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("<cap3>", TileEntityLaserRelayEnergyExtreme.CAP), new PagePicture(3, "pageLaserRelay", 0).setNoText(), new PageCrafting(4, BlockCrafting.recipeLaserRelay).setNoText().setPageStacksWildcard(), new PageCrafting(5, BlockCrafting.recipeLaserRelayAdvanced).setNoText().setPageStacksWildcard(), new PageCrafting(6, BlockCrafting.recipeLaserRelayExtreme).setNoText().setPageStacksWildcard(), new PageCrafting(7, ItemCrafting.recipeLaserWrench)).setImportant();
|
||||
new BookletChapter("laserRelays", ActuallyAdditionsAPI.entryFunctionalRF, new ItemStack(InitBlocks.blockLaserRelay), new PageTextOnly(1).addTextReplacement("<range>", TileEntityLaserRelay.MAX_DISTANCE), new PageTextOnly(2).addTextReplacement("<cap1>", TileEntityLaserRelayEnergy.CAP).addTextReplacement("<cap2>", TileEntityLaserRelayEnergyAdvanced.CAP).addTextReplacement("<cap3>", TileEntityLaserRelayEnergyExtreme.CAP), new PagePicture(3, "pageLaserRelay", 0).setNoText(), new PageCrafting(4, BlockCrafting.recipeLaserRelay).setNoText().setPageStacksWildcard(), new PageCrafting(5, BlockCrafting.recipeLaserRelayAdvanced).setNoText().setPageStacksWildcard(), new PageCrafting(6, BlockCrafting.recipeLaserRelayExtreme).setNoText().setPageStacksWildcard(), new PageCrafting(7, ItemCrafting.recipeLaserWrench).setNoText()).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).setStacks(new ItemStack(InitItems.itemCoffeeBean)).addTextReplacement("<rf>", TileEntityCoffeeMachine.ENERGY_USED).addTextReplacement("<coffee>", TileEntityCoffeeMachine.CACHE_USE).addTextReplacement("<water>", TileEntityCoffeeMachine.WATER_USE), new PageTextOnly(2).setStacks(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());
|
||||
|
|
|
@ -78,29 +78,6 @@ public class ItemLaserWrench extends ItemBase{
|
|||
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){
|
||||
PacketHandlerHelper.sendPlayerDataToClientPacket(player, save.theCompound, false);
|
||||
}
|
||||
|
||||
player.addChatComponentMessage(new TextComponentString("Mode changed to "+WrenchMode.values()[currMode].name+"!"));
|
||||
}
|
||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getShareTag(){
|
||||
return true;
|
||||
|
@ -123,16 +100,4 @@ public class ItemLaserWrench extends ItemBase{
|
|||
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 final String name;
|
||||
|
||||
WrenchMode(String name){
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ public final class AssetUtil{
|
|||
//Thanks to feldim2425 for this.
|
||||
//I can't do rendering code. Ever.
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static void renderLaser(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, int rotationTime, float alpha, double beamWidth, float[] color){
|
||||
public static void renderLaser(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, double rotationTime, float alpha, double beamWidth, float[] color){
|
||||
Tessellator tessy = Tessellator.getInstance();
|
||||
VertexBuffer render = tessy.getBuffer();
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
|
@ -222,7 +222,7 @@ public final class AssetUtil{
|
|||
Vec3d vec2 = new Vec3d(secondX, secondY, secondZ);
|
||||
Vec3d combinedVec = vec2.subtract(vec1);
|
||||
|
||||
double rot = rotationTime > 0 ? (360F*(((float)world.getTotalWorldTime()%(float)rotationTime)/(float)rotationTime)) : 0;
|
||||
double rot = rotationTime > 0 ? (360D*((world.getTotalWorldTime()%rotationTime)/rotationTime)) : 0;
|
||||
double pitch = Math.atan2(combinedVec.yCoord, Math.sqrt(combinedVec.xCoord*combinedVec.xCoord+combinedVec.zCoord*combinedVec.zCoord));
|
||||
double yaw = Math.atan2(-combinedVec.zCoord, combinedVec.xCoord);
|
||||
|
||||
|
|
|
@ -918,7 +918,6 @@ booklet.actuallyadditions.chapter.hairBalls.text.2=<item>Balls of Fur<r> are an
|
|||
booklet.actuallyadditions.chapter.laserRelays.name=Energy Laser Relays
|
||||
booklet.actuallyadditions.chapter.laserRelays.text.1=The <item>Energy Laser Relay<r> is a block that can <imp>wirelessly transfer RF (or Tesla)<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. This system always works in both directions simultaneously. <n>Two relays can be at most <range> blocks apart. <n>During an energy transfer, they have a light <imp>Energy Loss<r>, but nothing to worry about.
|
||||
booklet.actuallyadditions.chapter.laserRelays.text.2=There are <imp>three tiers<r> of Energy Laser Relay. They have different maximum amounts of energy to be transferred through them in one tick. The <imp>energy caps<r> are, in order, <cap1>, <cap2>, and <cap3>. <n>Additionally, the energy loss is a bit higher every tier. <n><n><imp>Interconnecting<r> different tiers is possible, however the <imp>lowest cap<r> and <imp>highest loss<r> of the two relays connected to the blocks involved in the transfer is considered.
|
||||
booklet.actuallyadditions.chapter.laserRelays.text.7=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.
|
||||
|
|
Loading…
Reference in a new issue